Class XbpPushButton() Foundation

Class function of the XbpPushButton class.


The XbpPushbutton class provides the pushbutton dialog element. This dialog element causes an action after the button is clicked with the mouse. The action to be performed is defined in a callback code block assigned to the :activate callback slot or is implemented in the :activate() method of a user defined subclass derived from the XbpPushButton class. For more information on the mechanics of callback methods and callback slots see the section "Basics of Xbase Parts" in the chapter "User interface and dialog concepts" in the Xbase++ documentation.

A pushbutton is a rectangular area on the screen where a character string or bitmap can be displayed. Both text and bitmaps appearing on the face of pushbuttons are referred to as pushbutton captions in Xbase++. Since the caption is part of the system resources of the pushbutton, it must be defined before the:create() method is executed.

Class methods
Creates an instance of the XbpPushButton 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.

Automatically fits the size of the pushbutton to the caption.
Determines whether a border is displayed for the pushbutton.
The caption of the pushbutton.
Name of the DLL file containing icons or bitmaps
Indicates whether the pushbutton receives input focus when the mouse is clicked on it.
Determines whether the pushbutton initially has the input focus.
Specifies the visual style to use for display.
Specifies the drawing mode of the pushbutton object.
Specifies the pushbutton to be the default button of the form.
Specifies the XbpPushbutton to be the cancel button of the form.
Life cycle
Requests system resources for the XbpPushButton object.
Reconfigures the XbpPushButton object after :create() has been executed.
Releases the system resources of the XbpPushButton object.
Specifies a new caption.
Executes the method or code block that is linked to the pushbutton.
Informs the application that an owner-drawn pushbutton object needs to be redrawn.
Create pushbutton

// In the example, two pushbuttons are created that 
// output text in an XbpCrt window using QOut() 
// after they are "pressed". 

#include "" 

   LOCAL nEvent, mp1, mp2, oXbp 

   // Create first pushbutton, specify position using :create() 
   oXbp := XbpPushButton():new() 
   oXbp:caption := "A" 
   oXbp:create( , , {10,20}, {100,40} ) 
   oXbp:activate := {|| QOut( "Pushbutton A" ) } 

   // Create second pushbutton, specify position using :new() 
   oXbp := XbpPushButton():new( , , {150,20}, {100,40} ) 
   oXbp:caption := "B" 
   oXbp:activate := {|| QOut( "Pushbutton B" ) } 

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

// The example demonstrates how a user defined 
// class can be defined to perform database 
// operations using default pushbuttons. In the 
// DbPushButton class, the default operations SKIP 
// GO TOP and GO BOTTOM are implemented. 
// Note: The :create() and :configure() methods are 
// not fully implemented in the example. Normally 
// they receive additional parameters like oParent 
// and oOwner. 

#include "" 

#define DB_PB_GOTOP     1 
#define DB_PB_GOBOTTOM  2 
#define DB_PB_SKIPDOWN  3 
#define DB_PB_SKIPUP    4 

   LOCAL nEvent, mp1, mp2, oXbp 

   USE Customer NEW 

   // Create user defined pushbuttons 
   DbPushButton():new( ,, { 10,20}, DB_PB_GOTOP    ):create() 
   DbPushButton():new( ,, {110,20}, DB_PB_SKIPDOWN ):create() 
   DbPushButton():new( ,, {210,20}, DB_PB_SKIPUP   ):create() 
   DbPushButton():new( ,, {310,20}, DB_PB_GOBOTTOM ):create() 

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

      ? "The record is:", Recno() 

   CLOSE Customer 

// User defined pushbutton for database operations 
CLASS DbPushbutton FROM XbpPushbutton 
   VAR    type, dbArea  READONLY 
   METHOD init, create, configure, destroy, activate 

// Initialize superclass and this class 
METHOD DbPushbutton:init( oParent, oOwner, aPos, nType ) 
   LOCAL aCaption := {"First", "Last", "Next", "Previous"} 

   ::XbpPushButton:init( oParent, oOwner, aPos ) 
   ::dbArea   := 0 
   ::type     := nType 
   ::caption  := aCaption[ nType ] 
   ::autoSize := .T. 
RETURN self 

// Request system resources 
METHOD DbPushbutton:create() 
   ::dbArea := Select() 
RETURN self 

// Configure system resources 
METHOD DbPushbutton:configure() 
   ::dbArea := Select() 
RETURN self 

// Destroy system resources 
METHOD DbPushbutton:destroy() 
   ::dbArea := 0 
RETURN self 

// Callback method for the event xbeP_Activate 
METHOD DbPushbutton:activate 
   CASE ::type == DB_PB_GOTOP 
      ( ::dbArea )->( DbGoTop() ) 
   CASE ::type == DB_PB_GOBOTTOM 
      ( ::dbArea )->( DbGoBottom() ) 
   CASE ::type == DB_PB_SKIPDOWN 
      ( ::dbArea )->( DbSkip(1) ) 
   CASE ::type == DB_PB_SKIPUP 
      ( ::dbArea )->( DbSkip(-1) ) 
RETURN self 

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.