PrevNextUpHome SophiaFramework UNIVERSE 5.3

20.7. Event Class

20.7.1. SFXEvent Class

The SFXEvent class manages to encapsulate the event information, which consists of three elements: event type( BREW API AEEEvent type), P16 value(UInt16 type), and P32 value(UInt32 type).

The event type corresponds to BREW API AEEEvent. The P16 parameter and the P32 parameter correspond to the wParam parameter and the dwParam parameter passed to an event handler of BREW respectively, which is additional information on the event type and whose meaning differs in each event type.

Example 20.28. How to use the SFXEvent class (1)

// event for destrying responder
SFXEvent event(SREVT_RESPONDER_TERMINATE, SRP16_TERMINATE_INVOKE, true);

// send event to responder and destroy it
responder->Invoke(event);

Example 20.29. How to use the SFXEvent class (2)

SFXEvent event;

// when setting user defined event
event.Set(SFEVT_USER + 0x01, 0, 0);

SFBShellSmp shell = SFBShell::GetInstance();

// send user defined event to itself
shell->PostEvent(GetClassID(), event);

20.7.2. SFXEventRange Class

The SFXEventRange class represents an event range necessary to register an event handler or a tracer which is used in SFY GUI framework.

The event range is specified with the event type( BREW API AEEEvent type) and the P16 parameter(UInt16 type) for each of the starting event and the ending event.

For instance, SFXEventRange(sEventType,eEventType, sP16, eP16) represents events in the range between the (sEventType, sP16, *) event and (eEventType, eP16, *) event.

Example 20.30. Method to use the SFXEventRange class (1): registering an event handler

// constructor
HelloWorld::HelloWorld(Void) static_throws
{
    if (static_try()) {
        static_throw(RegisterHandler(
            SFXEventRange(SFEVT_RESPONDER_RENDER, SFEVT_RESPONDER_RENDER,
            SFP16_RENDER_REQUEST, SFP16_RENDER_REQUEST),
            XANDLER_INTERNAL(OnRenderRequest)
        ));
    }
    if (static_try()) {
        static_throw(RegisterHandler(
            SFXEventRange(SFEVT_KEY, SFEVT_KEY, SFP16_BEGIN, SFP16_END),
            XANDLER_INTERNAL(OnKey)
        ));
    }
}

Example 20.31. Method to use the SFXEventRange class (2): registering an event handler

static SFXEventRange::AtomRecConst range[] = {
    {             SFEVT_KEY,              SFEVT_KEY,          SFP16_BEGIN,            SFP16_END},
    {       SFEVT_KEY_PRESS,        SFEVT_KEY_PRESS,          SFP16_BEGIN,            SFP16_END},
    {     SFEVT_KEY_RELEASE,      SFEVT_KEY_RELEASE,          SFP16_BEGIN,            SFP16_END}
};
SFYHandler::RuleRec rule[lengthof(range)];
SFCError error;

rule[0].spp = XANDLER_FUNCTION(OnKey);
rule[0].reference = this;
rule[1].spp = XANDLER_FUNCTION(OnKeyPress);
rule[1].reference = this;
rule[2].spp = XANDLER_FUNCTION(OnKeyRelease);
rule[2].reference = this;

error = RegisterHandler(atomic_cast(range), rule, lengthof(range));

Example 20.32. Method to use the SFXEventRange class (3): registering a tracer

static SFXEventRange::AtomRecConst range[] = {
    {            SFEVT_APP_START,           SFEVT_APP_START, SFP16_BEGIN, SFP16_END},
    {             SFEVT_APP_STOP,            SFEVT_APP_STOP, SFP16_BEGIN, SFP16_END},
    {           SFEVT_APP_RESUME,          SFEVT_APP_RESUME, SFP16_BEGIN, SFP16_END},
    {          SFEVT_APP_SUSPEND,         SFEVT_APP_SUSPEND, SFP16_BEGIN, SFP16_END}
};
static SFYTracer::RuleRecConst rule[lengthof(range)] = {
    {  SFYTracer::ORDER_BACKWARD,      SFYTracer::STATE_ALL,        true},
    {   SFYTracer::ORDER_FORWARD,      SFYTracer::STATE_ALL,        true},
    {  SFYTracer::ORDER_BACKWARD,      SFYTracer::STATE_ALL,        true},
    {   SFYTracer::ORDER_FORWARD,      SFYTracer::STATE_ALL,        true}
};
SFCError error;

error = RegisterTracer(atomic_cast(range), rule, lengthof(range));