![]() ![]() ![]()
|
SophiaFramework UNIVERSE 5.1 |
Here the code of the HelloWorld applet including processings such as suspend or resume, which is automatically generated by Application Wizard of SophiaFramework UNIVERSE is described.
The maximum code of the application class of the HelloWorld applet, which is automatically generated by Application Wizard of SophiaFramework UNIVERSE, is as follows:
Example 9.38. Declaration
// // USRApplication.hpp // // This source code was automatically // generated by SophiaFramework UNIVERSE 5.1 // #ifndef __USRAPPLICATION_HPP #define __USRAPPLICATION_HPP #define TARGET_BUILD_DEBUG #include <SophiaFramework.hpp> #include "USRApplication.bid" SFMTYPEDEFCLASS(USRApplication) class USRApplication: public SFYApplication { SFMSEALCOPY(USRApplication) public: static SFCInvokerPtr Factory(Void); private: explicit USRApplication(Void) static_throws; virtual ~USRApplication(Void); XANDLER_DECLARE_VOIDRENDER(OnRenderRequest) XANDLER_DECLARE_VOIDSTART(OnAppStart) XANDLER_DECLARE_VOIDSTOP(OnAppStop) XANDLER_DECLARE_VOIDRESUME(OnAppResume) XANDLER_DECLARE_VOIDSUSPEND(OnAppSuspend) XANDLER_DECLARE_BOOLVOID(OnAppNoClose) XANDLER_DECLARE_BOOLVOID(OnAppNoSleep) XANDLER_DECLARE_BOOLEVENT(OnKey) XANDLER_DECLARE_BOOLEVENT(OnKeyPress) XANDLER_DECLARE_BOOLEVENT(OnKeyRelease) }; #endif // __USRAPPLICATION_HPP //
Example 9.39. Implementation
// // USRApplication.cpp // // This source code was automatically // generated by SophiaFramework UNIVERSE 5.1 // #include "USRApplication.hpp" // boot loader SFCApplet::FactorySPP SFCApplet::Boot(AEECLSID id, SFXAnsiStringPtr license) { // here place the license code *license = "heap://"; return (id == AEECLSID_USRAPPLICATION) ? (&USRApplication::Factory): (null); } // factory function to create the instance of the user-defined application class SFCInvokerPtr USRApplication::Factory(Void) { return::new USRApplication; } // constructor USRApplication::USRApplication(Void) static_throws { // here register the various handlers if (static_try()) { // register the drawing handler static_throw(RegisterHandler( SFXEventRange(SFEVT_RESPONDER_RENDER, SFEVT_RESPONDER_RENDER, SFP16_RENDER_REQUEST, SFP16_RENDER_REQUEST), XANDLER_INTERNAL(OnRenderRequest) )); } if (static_try()) { // register the applet-bootup handler static_throw(RegisterHandler( SFXEventRange(SFEVT_APP_START, SFEVT_APP_START, SFP16_BEGIN, SFP16_END), XANDLER_INTERNAL(OnAppStart) )); } if (static_try()) { // register the applet-termination handler static_throw(RegisterHandler( SFXEventRange(SFEVT_APP_STOP, SFEVT_APP_STOP, SFP16_BEGIN, SFP16_END), XANDLER_INTERNAL(OnAppStop) )); } if (static_try()) { // register the applet-resume handler static_throw(RegisterHandler( SFXEventRange(SFEVT_APP_RESUME, SFEVT_APP_RESUME, SFP16_BEGIN, SFP16_END), XANDLER_INTERNAL(OnAppResume) )); } if (static_try()) { // register the applet-suspend handler static_throw(RegisterHandler( SFXEventRange(SFEVT_APP_SUSPEND, SFEVT_APP_SUSPEND, SFP16_BEGIN, SFP16_END), XANDLER_INTERNAL(OnAppSuspend) )); } if (static_try()) { // register the applet-termination confirmation handler static_throw(RegisterHandler( SFXEventRange(SFEVT_APP_NO_CLOSE, SFEVT_APP_NO_CLOSE, SFP16_BEGIN, SFP16_END), XANDLER_INTERNAL(OnAppNoClose) )); } if (static_try()) { // register the applet-sleep-confirmation handler static_throw(RegisterHandler( SFXEventRange(SFEVT_APP_NO_SLEEP, SFEVT_APP_NO_SLEEP, SFP16_BEGIN, SFP16_END), XANDLER_INTERNAL(OnAppNoSleep) )); } if (static_try()) { // register the key handler static_throw(RegisterHandler( SFXEventRange(SFEVT_KEY, SFEVT_KEY, SFP16_BEGIN, SFP16_END), XANDLER_INTERNAL(OnKey) )); } if (static_try()) { // register the key-press handler static_throw(RegisterHandler( SFXEventRange(SFEVT_KEY_PRESS, SFEVT_KEY_PRESS, SFP16_BEGIN, SFP16_END), XANDLER_INTERNAL(OnKeyPress) )); } if (static_try()) { // register the key-release handler static_throw(RegisterHandler( SFXEventRange(SFEVT_KEY_RELEASE, SFEVT_KEY_RELEASE, SFP16_BEGIN, SFP16_END), XANDLER_INTERNAL(OnKeyRelease) )); } } // destructor USRApplication::~USRApplication(Void) { } // drawing handler XANDLER_IMPLEMENT_VOIDRENDER(USRApplication, OnRenderRequest, invoker, reason, graphics) { // avoid outputting warning messagess for unsed variable unused(invoker); unused(reason); // here describe the drawing processing when the SFEVT_RESPONDER_RENDER event is received // draw on the device screen graphics->DrawSingleText("Hello World", GetLocalBound(), SFXRGBColor(0x00, 0x00, 0x00, 0x00)); return; } // applet-bootup handler XANDLER_IMPLEMENT_VOIDSTART(USRApplication, OnAppStart, invoker, environment) { // avoid outputting warning messages for unsed variable unused(invoker); unused(environment); // here describe the applet-bootup processing when the SFEVT_APP_START event is received return; } // applet-termination handler XANDLER_IMPLEMENT_VOIDSTOP(USRApplication, OnAppStop, invoker, quitable) { // avoid outputting warning messages for unsed variable unused(invoker); unused(quitable); // here describe the applet-termination processing when the SFEVT_APP_STOP event is received return; } // applet-resume handler XANDLER_IMPLEMENT_VOIDRESUME(USRApplication, OnAppResume, invoker, environment) { // avoid outputting warning messages for unsed variable unused(invoker); unused(environment); // here describe the applet-resume processing when the SFEVT_APP_RESUME event is received return; } // applet-suspend handler XANDLER_IMPLEMENT_VOIDSUSPEND(USRApplication, OnAppSuspend, invoker, reason, info) { // avoid outputting warning messages for unsed variable unused(invoker); unused(reason); unused(info); // here describe the applet-suspend processing when the SFEVT_APP_SUSPEND event is received return; } // applet-terminate-confirmation handler XANDLER_IMPLEMENT_BOOLVOID(USRApplication, OnAppNoClose, invoker) { // avoid outputting warning messages for unsed variable unused(invoker); // return true if you refuse to terminate the applet return false; } // applet-sleep-confirmation handler XANDLER_IMPLEMENT_BOOLVOID(USRApplication, OnAppNoSleep, invoker) { // avoid outputting warning messages for unsed variable unused(invoker); // return true if you refuse to sleep the applet return false; } // key handler XANDLER_IMPLEMENT_BOOLEVENT(USRApplication, OnKey, invoker, event) { // avoid outputting warning messages for unsed variable unused(invoker); // here describe processing when the SFEVT_KEY event is received // terminate the applet if the SFEVT_KEY event of the SELECT key is recieved switch (event.GetP16()) { case AVK_SELECT: Terminate(); return true; } return false; } // key-press handler XANDLER_IMPLEMENT_BOOLEVENT(USRApplication, OnKeyPress, invoker, event) { // avoid outputting warning messages for unsed variable unused(invoker); unused(event); // here describe processing when the SFEVT_KEY_PRESS event is received return false; } // key release handler XANDLER_IMPLEMENT_BOOLEVENT(USRApplication, OnKeyRelease, invoker, event) { // avoid outputting warning messages for unsed variable unused(invoker); unused(event); // here describe processing when the SFEVT_KEY_RELEASE event is received return false; }
The minimum code of the application class of the applet, which is automatically generated by Application Wizard of SophiaFramework UNIVERSE, is as follows:
Example 9.40. Declaration
// // USRApplication.hpp // // This source code was automatically // generated by SophiaFramework UNIVERSE 5.1 // #ifndef __USRAPPLICATION_HPP #define __USRAPPLICATION_HPP #define TARGET_BUILD_DEBUG #include <SophiaFramework.hpp> #include "USRApplication.bid" SFMTYPEDEFCLASS(USRApplication) class USRApplication: public SFYApplication { SFMSEALCOPY(USRApplication) public: static SFCInvokerPtr Factory(Void); private: explicit USRApplication(Void) static_throws; virtual ~USRApplication(Void); }; #endif // __USRAPPLICATION_HPP //
Example 9.41. Implementation
// // USRApplication.cpp // // This source code was automatically // generated by SophiaFramework UNIVERSE 5.1 // #include "USRApplication.hpp" // boot loader SFCApplet::FactorySPP SFCApplet::Boot(AEECLSID id, SFXAnsiStringPtr license) { // here place the license code *license = "heap://"; return (id == AEECLSID_USRAPPLICATION) ? (&USRApplication::Factory): (null); } // factory function to create the instance of the user-defined application class SFCInvokerPtr USRApplication::Factory(Void) { return::new USRApplication; } // constructor USRApplication::USRApplication(Void) static_throws { // here register various handlers } // destructor USRApplication::~USRApplication(Void) { }
|
Copyright(c) 2002 - 2010 Sophia Cradle Incorporated All Rights Reserved. |
![]() ![]() ![]()
|