Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

DrawScreen function

The C Application Wizard creates a default DrawScreen function for the application, as shown in the following example:

static void MyApp_DrawScreen(MyApp * pMe)
{
    AEERect rc;
    AECHAR szBuf[64] = {0};
    RGBVAL oldTextColor;

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

    // Draw a rectangle on the screen to put the text in:
    SETAEERECT( &rc, 0, pMe->nHeight/2-2, pMe->nWidth, 2);
    IDisplay_DrawRect(pMe->piDisplay, &rc, 0, 1, IDF_RECT_FILL);

    // Set user-text color to black, and save the old color:
    oldTextColor = IDisplay_SetColor(pMe->piDisplay, CLR_USER_TEXT, RGB_BLACK);

    // Load the first string resource into a buffer:
    if (0 <  (ISHELL_LoadResString(pMe->piShell, 
                                   C_BASICAPP_RES_FILE,
                                   IDS_STRING_1001, szBuf, sizeof(szBuf)))) {
        // If the text was successfully loaded from resource file into buffer,
        // draw the text to the screen:
        IDisplay_DrawText(pMe->piDisplay,// Display instance.
                     AEE_FONT_NORMAL,   // Use Normal font.
                     szBuf,             // String buffer containing text.
                     -1,                // Automatically compute string length.
                     0,                 // Ignored since we are centering text.
                     pMe->nHeight/8,     // y-coordinate of text.
                     0,                 // No clipping.
                     IDF_ALIGN_CENTER); // Center-align horizontally.
    }

    // Load the second string resource into the buffer:
    if (0 <  (ISHELL_LoadResString(pMe->piShell, 
                         C_BASICAPP_RES_FILE, 
                         IDS_STRING_1002, szBuf, sizeof(szBuf)))) {
        // If the text was successfully loaded from resource file into buffer,
        // draw the text to the screen:
        IDisplay_DrawText(pMe->piDisplay,// Display instance.
                     AEE_FONT_NORMAL,   // Use Normal font.
                     szBuf,             // String buffer containing text.
                     -1,                // Automatically compute string length.
                     0,                 // Ignored since we are centering text.
                     pMe->nHeight/5,     // y-coordinate of text.
                     0,                 // No clipping.
                     IDF_ALIGN_CENTER); // Center-align horizontally.
    }
    
    // Verify the image pointer is valid, before drawing:
    if (pMe->piImage != NULL) {
       IImage_Draw (pMe->piImage, pMe->nCursorX, pMe->nCursorY);
    }

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

    // Update the display:
    IDisplay_Update (pMe->piDisplay);
}