Class XbpWindow() Foundation
Class function of the XbpWindow class.
The XbpWindow class is an abstract class that provides the mechanisms for displaying graphic dialog elements (Xbase Parts) on the screen. All Xbase Parts displayed on the screen are derived from this class (except the system dialogs that are derived from XbpSysWindow()). This includes dialog elements like pushbuttons and checkboxes, as well as complete dialogs. XbpWindow objects manage a window on the screen. They do not actually provide a "window" (dialog) in the sense of the user interface, but handle the display in a defined rectangular section of the screen. An XbpWindow object provides several general methods and instance variables that are needed to display a window and that are required by all dialog elements.
The XbpWindow class is derived from the XbpPartHandler class and inherits the ability to understand and react to events. Another important characteristic of an XbpWindow object is its capability for interaction. It can react to events that occur within the screen area managed by the object. Within the XbpWindow class, a number of default events are handled and reactions to these events occur when the :handleEvent() method is called. For each default event, a method exists that is executed after the event occurs. As an example, clicking the left mouse button generates the event xbeM_LbClick. When this event occurs, the :LbClick() method is executed. This is done automatically within the method :handleEvent(). The following lines illustrate this:
DO WHILE .T. // event loop
nEvent := AppEvent( @mp1, @mp2, @oXbp ) // read event
oXbp:handleEvent( nEvent, mp1, mp2 ) // react
ENDDO
/* Internal in the method :handleEvent()
DO CASE
...
CASE nEvent == xbeM_LbClick
self:LbClick( mp1, mp2 )
ENDCASE
*/
The event is retrieved using AppEvent() and passed to the method :handleEvent() where the reaction occurs. After the event is received, the corresponding method is executed. For this reason, these methods are referred to as "callback methods".
Callback methods can be redefined by programmers when they create new classes that inherit from Xbase Parts. Alternatively, the reaction to an event can be defined using a code block stored in specific instance variables of the XbpWindow object. These instance variables are called "callback slots". Callback slots are instance variables that have the same name as the corresponding callback methods. When a code block is assigned to one of these instance variables, the code block is executed after the execution of the callback method.
Since the XbpWindow class is an abstract class, no instances of it can be created. Its purpose is to provide functionality to other classes that are derived from it. The functionality provided by this class includes screen management and reactions to events. The latter can be defined using code blocks that are assigned to callback slots or by overloading the callback methods. For each callback slot, a method with the same name exists and can be overloaded (redefined) in subclasses. When a callback method is defined in a subclass, it is executed when the corresponding event occurs.
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.
If the :wheel() method is overloaded, the number of rows to scroll can be calculated from the number of rows displayed by the Xbase Part and the second element of <aWheel>:
nResolution := 360 // 240, 480 changes scrolling speed
nRowsToScroll := Int( nRowCount * aWheel[2] / nResolution )
When the first element of <aWheel> is not equal to zero, the $ operator can be used to check which additional keys are pressed while the mouse wheel is rotated. For example:
nEvent := AppEvent( @mp1, @mp2, @oXbp )
IF nEvent == xbeM_Wheel
IF XBP_MK_SHIFT $ mp2[1]
// code for Shift key processing
ENDIF
ENDIF
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.