PrevNextUpHome SophiaFramework UNIVERSE 5.3

25.3. Macro for GUI Framework

25.3.1. Macro for Declaring Event Handler

An event handler is declared using the macro of which name starts with HANDLER_DECLARE_.

Table 25.7. Macro for declaring event handler

Macro Description
HANDLER_DECLARE_VOIDRENDER Drawing handler
HANDLER_DECLARE_VOIDSTART Application start handler
HANDLER_DECLARE_BOOLSTART Application start handler
HANDLER_DECLARE_VOIDSTOP Application stop handler
HANDLER_DECLARE_BOOLSTOP Application stop handler
HANDLER_DECLARE_VOIDRESUME Resume handler
HANDLER_DECLARE_BOOLRESUME Resume handler
HANDLER_DECLARE_VOIDSUSPEND Suspend handler
HANDLER_DECLARE_BOOLSUSPEND Suspend handler
HANDLER_DECLARE_VOIDDIALOG Dialog handler
HANDLER_DECLARE_BOOLDIALOG Dialog handler
HANDLER_DECLARE_VOIDMENU Menu handler
HANDLER_DECLARE_BOOLMENU Menu handler
HANDLER_DECLARE_VOIDCONTROL Control handler
HANDLER_DECLARE_BOOLCONTROL Control handler
HANDLER_DECLARE_VOIDVOID Generic handler
HANDLER_DECLARE_BOOLVOID Generic handler
HANDLER_DECLARE_VOIDEVENT Generic handler
HANDLER_DECLARE_BOOLEVENT Generic handler
[Note] Note
The handler name is specified as an argument

25.3.2. Macro for Implementing Event Handler

An event handler is implemented using the macro of which name starts with HANDLER_IMPLEMENT_.

Table 25.8. Macro for implementing event handler

Macro Description 3rd argument 4th argument 5th argument
HANDLER_IMPLEMENT_VOIDRENDER Drawing handler graphics (graphic object) none none
HANDLER_IMPLEMENT_VOIDSTART Application start handler environment none none
HANDLER_IMPLEMENT_BOOLSTART Application start handler environment none none
HANDLER_IMPLEMENT_VOIDSTOP Application stop handler quitable none none
HANDLER_IMPLEMENT_BOOLSTOP Application stop handler quitable none none
HANDLER_IMPLEMENT_VOIDRESUME Resume handler environment none none
HANDLER_IMPLEMENT_BOOLRESUME Resume handler environment none none
HANDLER_IMPLEMENT_VOIDSUSPEND Suspend handler reason info none
HANDLER_IMPLEMENT_BOOLSUSPEND Suspend handler reason info none
HANDLER_IMPLEMENT_VOIDDIALOG Dialog handler result dialog (pointer) none
HANDLER_IMPLEMENT_BOOLDIALOG Dialog handler result dialog (pointer) none
HANDLER_IMPLEMENT_VOIDMENU Menu handler result menu (pointer) none
HANDLER_IMPLEMENT_BOOLMENU Menu handler result menu (pointer) none
HANDLER_IMPLEMENT_VOIDCONTROL Control handler result control (pointer) none
HANDLER_IMPLEMENT_BOOLCONTROL Control handler result control (pointer) none
HANDLER_IMPLEMENT_VOIDVOID Generic handler none none none
HANDLER_IMPLEMENT_BOOLVOID Generic handler none none none
HANDLER_IMPLEMENT_VOIDEVENT Generic handler event (event object) none none
HANDLER_IMPLEMENT_BOOLEVENT Generic handler event (event object) none none
[Note] Note
Fisrt argument is class name, second argument is handler name, and third argument depends on the type of handler.
[Note] About generic handler

Generic handler is the handler that can be made flexibly to the developer's needs, for example, the handler for the "Select" key only.

Example 25.1. Generic handler

// MyWindow class definition
SFMTYPEDEFCLASS(MyWindow)
class MyWindow : public SFRTitleWindow {
    SFMSEALCOPY(MyWindow)
public:
    MyWindow(Void) static_throws;
    virtual ~MyWindow(Void)
    
   // declare generic handler
   HANDLER_DECLARE_VOIDVOID(OnSelectKey)
};

// register generic handler
// register handler for "Select" key only
RegisterHandler(SFEVT_KEY, AVK_SELECT, HANDLER_AFTER, HANDLER_FUNCTION(OnSelectKey));

// implement generic handler
// since it handles "Select" key only, no need to obtain event parameter
HANDLER_IMPLEMENT_VOIDVOID(MyWindow, OnSelectKey)
{
    // terminate application
    Terminate();
    return;
}

25.3.3. Macro for Registering the Event Handler Function

An event handler function is registered using the macro of which name starts with HANDLER_.

Table 25.9. Macro for registering the event handler function

Macro Description
HANDLER_FUNCTION Pass the pointer to the event handler function pointer and the identification number of handler function(reference value).
HANDLER_NULL Regard the event as being handled though the actual event handler will not be called.
[Note] Note
The handler name is specified as an argument