Class XbpSpinButton() Foundation

Class function of the XbpSpinButton class.


The XbpSpinButton class provides spinbutton objects. These are dialog elements that can increment or decrement an integer value. A spinbutton consists of an entry field with two arrows displayed on pushbuttons at the right edge. This type of entry field allows direct input of numeric values. The arrows increment and decrement the value in the entry field when they are clicked with the mouse. Alternatively, the numeric value can be changed using the Up and Down arrow keys. The range of valid values for the spinbutton is set to 0 to 99999 by default but can be redefined to fit specific situations.

When incrementing, the numeric value in the entry field is reset to the smallest valid value after the largest value has been reached. Similarly, when decrementing the value is set to the largest valid value after the smallest value has been reached.

The height of the entry field of the spin button is automatically adjusted to the selected font by OS/2. The height cannot be set by the user because the presentation manager does not support this.

Class methods
Creates an instance of the XbpSpinButton class.

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.

Determines whether fast increment and decrement is turned on.
Specifies the increment for the value of the spin button.
Defines another spinbutton as master.
Fills (or left pads) the numeric value in the entry field of the spinbutton with zeros.
Controls the internal composition of the spin button object.
Runtime Data
Defines whether a number format-specific prefix is displayed.
Selects the number format for display.
Life cycle
Requests system resources for the XbpSpinButton object.
Reconfigures the XbpSpinButton object after :create() has been executed.
Releases the system resources of the XbpSpinButton object.
Decrements the numeric value by a specific amount.
Increments the numeric value by a specific amount.
Returns the value in the edit buffer of the spinbutton.
Returns the numeric value in the edit buffer of the spinbutton.
Sets the value of the edit buffer of the spinbutton.
Defines the range of valid values for the spinbutton.
The numeric value of the spinbutton has been decremented.
Incrementing or decrementing the spinbutton has terminated.
The numeric value of the spinbutton has been incremented.
Set RGB colors using spinbuttons

// This example shows a typical use for spinbuttons. 
// The RGB color values are set using three spinbuttons. 
// The color values set using these spinbuttons are 
// assigned to LOCAL variables. For the first spinbutton, 
// this is done without using a code block for :dataLink. 
// The other two spinbuttons have a data code block 
// assigned to :dataLink. The current RGB color is displayed 
// using the procedure RGB(). 

#include "" 
#include "" 

   LOCAL nEvent, mp1, mp2, oXbp 
   LOCAL oSpinRed, oSpinGreen, oSpinBlue, bCallback 
   LOCAL nRed := 0, nGreen := 0, nBlue := 0 


   // Callback code block 
   bCallback := {|mp1, mp2, oXbp| nRed := oXbp:getData(), ; 
                               RGB( nRed, nGreen, nBlue ) } 

   // Create spinbutton for red (without using :dataLink) 
   oSpinRed := XbpSpinButton():new( ,, {100,200}, {100,40} ) 
   oSpinRed:fastSpin := .T. 
   oSpinRed:setNumLimits( 0, 255 ) 
   oSpinRed:endSpin  := bCallback 
   oSpinRed:keyboard := bCallback 

   // Callback code block 
   bCallback := {|mp1, mp2, oXbp| oXbp:getData(), ; 
                       RGB( nRed, nGreen, nBlue ) } 

   // Create spinbutton for green (using :dataLink) 
   oSpinGreen := XbpSpinButton():new( ,, {100,150}, {100,40} ) 
   oSpinGreen:setNumLimits( 0, 255 ) 
   oSpinGreen:dataLink := {|x| IIf( x==NIL, nGreen, nGreen := x ) } 
   oSpinGreen:endSpin  := bCallback 
   oSpinGreen:keyboard := bCallback 

   // Create spinbutton for blue (using :dataLink) 
   // (Master is oSpinGreen) 
   oSpinBlue := XbpSpinButton():new( ,, {100,100}, {100,40} ) 
   oSpinBlue:master := oSpinGreen 
   oSpinBlue:setNumLimits( 0, 255 ) 
   oSpinBlue:dataLink := {|x| IIf( x==NIL, nBlue, nBlue := x ) } 
   oSpinBlue:endSpin  := bCallback 
   oSpinBlue:keyboard := bCallback 

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

PROCEDURE RGB( nRed, nGreen, nBlue ) 
   LOCAL oPS   := SetAppWindow():presSpace() // presentation space 
   LOCAL aAttr := Array(GRA_AA_COUNT)        // area attributes 
   LOCAL nMax  := oPS:maxColorIndex()        // maximum colors 
   LOCAL aOldAttr, aOldRGB 

   // Set new RGB color and draw box 
   aAttr[ GRA_AA_COLOR  ] := nMax 
   aOldAttr := oPS:setAttrArea( aAttr ) 
   aOldRGB  := oPS:setColorIndex( nMax, {nRed,nGreen,nBlue} ) 
   GraBox( oPS, {300,100}, {550,240}, GRA_FILL ) 
   oPS:setAttrArea( aOldAttr ) 
   oPS:setColorIndex( nMax, aOldRGB ) 

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.