$redg45l

Upload: srinisharamaswamy

Post on 14-Apr-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/30/2019 $REDG45L

    1/4

    int AEEClsCreateInstance(AEECLSID ClsId, IShell * piShell, IModule * piModule,void ** ppObj)

    {*ppObj = NULL;

    // Confirm this applet is the one intended to be created (classID matches):if( AEECLSID_APPLICATION1 == ClsId ) {// Create the applet and make room for the applet structure.// NOTE: FreeAppData is called after EVT_APP_STOP is sent to HandleEvent.

    if( TRUE == AEEApplet_New(sizeof(Application1),ClsId,piShell,piModule,(IApplet**)ppObj,(AEEHANDLER)Application1_HandleEvent,(PFNFREEAPPDATA)Application1_FreeAppData) ) {

    // Initialize applet data. This is called before EVT_APP_START is// sent to the HandleEvent function.

    if(TRUE == Application1_InitAppData((Application1*)*ppObj)) {return AEE_SUCCESS; // Data initialized successfully.

    }else {

    // Release the applet. This will free the memory allocated for // the applet when AEEApplet_New was called.IApplet_Release((IApplet*)*ppObj);return AEE_EFAILED;

    }} // End AEEApplet_New}return AEE_EFAILED;

    }

    boolean Application1_InitAppData(Application1 * pMe){

    // Save local copy for easy access:pMe->piDisplay = pMe->applet.m_pIDisplay;pMe->piShell = pMe->applet.m_pIShell;

    // Get the device information for this handset.// Reference all the data by looking at the pMe->deviceInfo structure.// Check the API reference guide for all the handy device info you can get.pMe->deviceInfo.wStructSize = sizeof(pMe->deviceInfo);ISHELL_GetDeviceInfo(pMe->applet.m_pIShell,&pMe->deviceInfo);

  • 7/30/2019 $REDG45L

    2/4

    // Insert your code here for initializing or allocating resources...

    return TRUE;// No failures up to this point, so return success.}

    void Application1_FreeAppData(Application1 * pMe){

    // Insert your code here for freeing any resources you have allocated...

    // Example to use for releasing each interface:// if ( NULL != pMe->piMenuCtl ) { // check for NULL first// IMenuCtl_Release(pMe->piMenuCtl)// release the interface// pMe->piMenuCtl = NULL; // set to NULL so no problems later // }

    //}

    static boolean Application1_HandleEvent(Application1* pMe,AEEEvent eCode, uint16 wParam,

    uint32 dwParam){

    switch (eCode) {// Event to inform app to start, so start-up code is here:case EVT_APP_START:

    Application1_DrawScreen(pMe); // Draw text on display screen.return TRUE;

    // Event to inform app to exit, so shut-down code is here:case EVT_APP_STOP:

    return TRUE;

    // Event to inform app to suspend, so suspend code is here:case EVT_APP_SUSPEND:

    return TRUE;

    // Event to inform app to resume, so resume code is here:case EVT_APP_RESUME:

    Application1_DrawScreen(pMe); // Redraw text on display screen.return TRUE;

    // An SMS message has arrived for this app.// The Message is in the dwParam above as (char *).// sender simply uses this format "//BREW:ClassId:Message",

  • 7/30/2019 $REDG45L

    3/4

    // example //BREW:0x00000001:Hello Worldcase EVT_APP_MESSAGE:

    return TRUE;

    // A key was pressed:

    case EVT_KEY:return FALSE;

    // Clamshell has opened/closed// wParam = TRUE if open, FALSE if closedcase EVT_FLIP:

    return TRUE;

    // Clamtype device is closed and reexposed when opened, and LCD// is blocked, or keys are locked by software.// wParam = TRUE if keygaurd is on

    case EVT_KEYGUARD:return TRUE;

    // If event wasn't handled here, then break out:default:

    break;}return FALSE; // Event wasn't handled.

    }

    static void Application1_DrawScreen(Application1 * pMe){

    AECHAR szBuf[64] = {0};int nStrLen = 0;RGBVAL oldTextColor = RGB_BLACK;

    IDisplay_ClearScreen(pMe->piDisplay); // Erase whole screen.

    // Load the string resource into a buffer:nStrLen = ISHELL_LoadResString(pMe->piShell,

    APPLICATION1_RES_FILE,IDS_STRING_1001, szBuf, sizeof(szBuf));

    // If the text was successfully loaded from resource file into buffer:if (0 < nStrLen) {

    // Set user-text color to black:oldTextColor = IDisplay_SetColor(pMe->piDisplay,

    CLR_USER_TEXT,

  • 7/30/2019 $REDG45L

    4/4

    RGB_BLACK);

    IDisplay_DrawText(pMe->piDisplay, // Display instance.AEE_FONT_BOLD, // Use Bold font.szBuf, // String buffer containing text.

    -1, // Automatically compute string length.0, // x-coordinate ignored since IDF_ALIGN_CENTER.0, // y-coordinate ignored since IDF_ALIGN_MIDDLE.NULL, // No clipping.IDF_ALIGN_CENTER | // Center-align horizontally.IDF_ALIGN_MIDDLE); // Middle-align vertically.

    }

    // Restore previous color:IDisplay_SetColor(pMe->piDisplay, CLR_USER_TEXT, oldTextColor);

    IDisplay_Update (pMe->piDisplay);}