Classes

Class Xbp3State() Foundation

Class function of the Xbp3State class.

Superclass
Description

The Xbp3State class provides a dialog element that is similar to a checkbox but recognizes three states: selected, not selected and undefined. The current state is stored as a numeric value in the edit buffer of the three state button.

A three state button is always displayed on screen in two parts. It consists of a square where the current state of the three state button is visually displayed and a caption to the right next of the square. The character "x" is displayed in the square when a three state button is in the "selected" state. The appearance of the square cannot be altered. The caption displays the specified text which must be defined before the :create() method is called.

Class methods
:new()
Creates an instance of the Xbp3State class.
Configuration

The instance variables in this group configure system resources. If changes are made to these values, they must either be made before the :create() method is executed or the :configure() method must be used to activate the changes.

:autoSize
Automatically fit the size of the three state button to the caption.
:caption
The caption of the three state button.
:pointerFocus
Indicates whether the three state button receives input focus when the mouse is clicked on it.
:selection
The state of the Xbp3State object.
Life cycle
:create()
Requests system resources for the Xbp3State object.
:configure()
Reconfigure Xbp3State object after :create() has been executed.
:destroy()
Releases the system resources of the Xbp3State object.
Manipulation
:editBuffer()
Returns the value in the edit buffer of the three state button.
:getData()
Returns the current state of a three state button.
:setCaption()
Specifies a new caption.
:setData()
Sets the current value or state of a three state button.
Messages
xbeP_Selected
Three state Button is selected.
Examples
Xbp3State()

// In the example, two three state buttons are created that 
// output text in an XbpCrt window using QOut() when they are 
// "selected". Part of the displayed text is stored in an array. 

#include "Appevent.ch" 

PROCEDURE Main 
   LOCAL nEvent, mp1, mp2, oXbp 
   LOCAL aState := {"not selected", "selected", "undefined"} 
   SetColor("N/W") 
   CLS 

   // Create first 3State button, passing the position to :create() 
   oXbp := Xbp3State():new() 
   oXbp:caption := "A" 
   oXbp:create( , , {10,20}, {100,40} ) 

   // Determine current state using mp1 
   oXbp:selected := ; 
      {| mp1, mp2, oBtn| QOut( "3State A", ; 
                         aState[ mp1+1 ] ) } 

   // Create second 3State Button, passing the position to :new() 
   oXbp := Xbp3State():new( , , {150,20}, {100,40} ) 
   oXbp:caption := "B" 
   oXbp:create() 

   // Determine current state using :getData() 
   oXbp:selected := ; 
      {| mp1, mp2, oBtn|  QOut( "3State B", ; 
                        aState[ oBtn:getData()+1 ] ) } 

   // Event loop = Program control 
   nEvent := 0 
   DO WHILE nEvent <> xbeP_Close 
      nEvent := AppEvent( @mp1, @mp2, @oXbp ) 
      oXbp:HandleEvent( nEvent, mp1, mp2 ) 
   ENDDO 
RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.