コード例 #1
0
ファイル: BrewApp.cpp プロジェクト: fmedlin/BrewApp
void BrewApp::DrawScreen() {

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

    IDISPLAY_ClearScreen(this->m_pIDisplay); // Erase whole screen.

    // Load the string resource into a buffer:
    nStrLen = ISHELL_LoadResString(this->m_pIShell, 
                                   BREWAPP_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(this->m_pIDisplay, 
                                         CLR_USER_TEXT, 
                                         RGB_BLACK);

        IDisplay_DrawText(this->m_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(this->m_pIDisplay, CLR_USER_TEXT, oldTextColor);
    IDisplay_Update (this->m_pIDisplay);
}
コード例 #2
0
ファイル: MemChecker.c プロジェクト: virqin/brew_code
/*===========================================================================
FUNCTION SampleAppWizard_HandleEvent

DESCRIPTION
	This is the EventHandler for this app. All events to this app are handled in this
	function. All APPs must supply an Event Handler.

PROTOTYPE:
	boolean SampleAppWizard_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)

PARAMETERS:
	pi: Pointer to the AEEApplet structure. This structure contains information specific
	to this applet. It was initialized during the AEEClsCreateInstance() function.

	ecode: Specifies the Event sent to this applet

   wParam, dwParam: Event specific data.

DEPENDENCIES
  none

RETURN VALUE
  TRUE: If the app has processed the event
  FALSE: If the app did not process the event

SIDE EFFECTS
  none
===========================================================================*/
static boolean MemChecker_HandleEvent(MemChecker* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
#if 1
    // for debugging
    if (EVT_POINTER_DOWN == eCode)
    {
        AEERect rc;
        int x, y;
        AEE_POINTER_GET_XY((char *)dwParam, &x, &y);
        SETAEERECT(&rc, x, y, 2, 2);
        IDisplay_FillRect(pMe->a.m_pIDisplay, &rc, RGB_BLACK);
        IDisplay_Update(pMe->a.m_pIDisplay);
    }
#endif

    if (pMe->m_pIDesktopWindow 
        && IDesktopWindow_HandleEvent(pMe->m_pIDesktopWindow, eCode, wParam, dwParam))
    {
        return TRUE;
    }

    switch (eCode) 
    {
        // App is told it is starting up
    case EVT_APP_START:
        DBGPRINTF("##MemChecker_HandleEvent: EVT_APP_START ##############");

        if (pMe->m_bBackground)
        {
            pMe->m_bBackground = FALSE;
            IContainer_Invalidate((IContainer *)pMe->m_pIDesktopWindow, NULL, NULL);
            return TRUE;
        }

        ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_APPLETCTL, (void **)&pMe->m_pIAppletCtl);
        IniFileParser_LoadFile(pMe->a.m_pIShell, MemChecker_ParseLineCB, pMe);

        // ClassFactory & DestopWindow
        pMe->m_pIClassFactory = XClassFactory_New();
        IClassFactory_CreateInstance(pMe->m_pIClassFactory, XCLSID_DesktopWindow, (void **)&pMe->m_pIDesktopWindow);
        IWidget_SetName((IWidget*)pMe->m_pIDesktopWindow, "DesktopWindow");
        IDesktopWindow_SetDisplay(pMe->m_pIDesktopWindow, pMe->a.m_pIDisplay);
        IWidget_SetRectEx((IWidget*)pMe->m_pIDesktopWindow, 0, 0, pMe->DeviceInfo.cxScreen, pMe->DeviceInfo.cyScreen);

        MemChecker_CreateMainMenu(pMe);

        return(TRUE);


    // App is told it is exiting
    case EVT_APP_STOP:
        DBGPRINTF("##MemChecker_HandleEvent: EVT_APP_STOP ###################");

        if (pMe->m_bBackground)
        {
            *(boolean *)dwParam = FALSE;
            return TRUE;
        }

        CALLBACK_Cancel(&pMe->m_cbModUnload);
        CALLBACK_Cancel(&pMe->m_cbWaitForAppStartup);

        MemHook_Uninstall();

        RELEASEIF(pMe->m_pIClassFactory);
        RELEASEIF(pMe->m_pIDesktopWindow);

        RELEASEIF(pMe->m_pIAppletCtl);

        return(TRUE);


        // App is being suspended 
    case EVT_APP_SUSPEND:
        DBGPRINTF("##MemChecker_HandleEvent: EVT_APP_SUSPEND ################");

        return(TRUE);


        // App is being resumed
    case EVT_APP_RESUME:
        DBGPRINTF("##MemChecker_HandleEvent: EVT_APP_RESUME #################");
        IContainer_Invalidate((IContainer *)pMe->m_pIDesktopWindow, NULL, NULL);

        return(TRUE);


        // An SMS message has arrived for this app. Message is in the dwParam above as (char *)
        // sender simply uses this format "//BREW:ClassId:Message", example //BREW:0x00000001:Hello World
    case EVT_APP_MESSAGE:
        // Add your code here...

        return(TRUE);


        // If nothing fits up to this point then we'll just break out
    default:
        break;
    }

    return FALSE;
}
コード例 #3
0
ファイル: c_samplecamera.c プロジェクト: virqin/brew_code
/*=============================================================================
FUNCTION c_SampleCameraApp_PrintStatus

DESCRIPTION
  This is a helper function that will print to the screen the status for the 
  application as well as the command that the soft keys control.   

PROTOTYPE:
  static void c_SampleCameraApp_PrintStatus(SampleCameraApp* pMe)

PARAMETERS:
   pMe: Pointer to the applet data stucture

DEPENDENCIES
   none

RETURN VALUE
   none

SIDE EFFECTS
   none
=============================================================================*/
static void c_SampleCameraApp_PrintStatus(c_samplecamera* pMe)
{
   int nErr = AEE_EFAILED;
   char *pszBuf = NULL;
   char pszBuf2[100];
   AECHAR wszBuf[100];
   int32 nMode = 0;

   //clear the screen 
   IDisplay_ClearScreen(pMe->Applet.m_pIDisplay);

   //If zoom is supported update the screen with Zoom information
   if (pMe->bSupportZoom)
   {
      AEEParmInfo ZoomInfo;
      int32       nCurrentZoom;

      // retrieve the current setting and the parameter information
      nErr = ICAMERA_GetParm(pMe->pICamera, CAM_PARM_ZOOM, 
                             &nCurrentZoom, (int32 *)&ZoomInfo);
      if (nErr)
         DBGPRINTF("Unable to get CAM_PARM_ZOOM %d", pMe->nPreviewType);

      // create a string with the current value and the range of possible values
      SNPRINTF(pszBuf2, sizeof(pszBuf2), "Zoom %d(%d to %d)", 
               nCurrentZoom, ZoomInfo.nMin, ZoomInfo.nMax);
      STRTOWSTR(pszBuf2, wszBuf, sizeof(wszBuf));
      IDisplay_DrawText(pMe->Applet.m_pIDisplay, AEE_FONT_NORMAL, 
                        wszBuf, -1, pMe->ZoomStatusTextRect.x, 
                        pMe->ZoomStatusTextRect.y, &pMe->ZoomStatusTextRect,
                        IDF_ALIGN_LEFT | IDF_ALIGN_TOP);

      //print our directions on how to control the zoom
      STRTOWSTR("Up/Dn to Zoom", wszBuf, sizeof(wszBuf));
      IDisplay_DrawText(pMe->Applet.m_pIDisplay, AEE_FONT_NORMAL, 
                        wszBuf, -1, pMe->ZoomTextRect.x, pMe->ZoomTextRect.y,
                        &pMe->ZoomTextRect, IDF_ALIGN_CENTER | IDF_ALIGN_TOP);
   }

   //Print out the current camera mode to the screen
   pszBuf = c_SampleCameraApp_GetModeStr(pMe);
   SNPRINTF(pszBuf2, sizeof(pszBuf2), "Mode: %s", pszBuf);
   STRTOWSTR(pszBuf2, wszBuf, sizeof(wszBuf));
   IDisplay_DrawText(pMe->Applet.m_pIDisplay, AEE_FONT_NORMAL, wszBuf, 
                     -1, pMe->Status1TextRect.x, pMe->Status1TextRect.y, 
                     &pMe->Status1TextRect, IDF_ALIGN_LEFT | IDF_ALIGN_TOP);
   // Depending on the preview type display the file name that will store the 
   // output of the camera's snapshot or video
   if (pMe->nPreviewType == CAM_PREVIEW_MOVIE)
      SNPRINTF(pszBuf2, sizeof(pszBuf2), "File Name: %s", MOVIE_FILE_NAME);
   else if (pMe->nPreviewType == CAM_PREVIEW_SNAPSHOT)
      SNPRINTF(pszBuf2, sizeof(pszBuf2), "File Name: %s", SNAPSHOT_FILE_NAME);
   STRTOWSTR(pszBuf2, wszBuf, sizeof(wszBuf));
   IDisplay_DrawText(pMe->Applet.m_pIDisplay, AEE_FONT_NORMAL, wszBuf, 
                     -1, pMe->Status2TextRect.x, pMe->Status2TextRect.y, 
                     &pMe->Status2TextRect, IDF_ALIGN_LEFT | IDF_ALIGN_TOP);

   //Get the current mode of the camera, and update the screen to specify what
   // commands the first soft key controls
   ICAMERA_GetMode(pMe->pICamera, &nMode, NULL);
   if (nMode == CAM_MODE_READY)
   {
      if (pMe->nPreviewType == CAM_PREVIEW_MOVIE)
         pszBuf = "Switch to Snapshot";
      else
         pszBuf = "Switch to Movie";
   }
   else
      pszBuf = "Stop";
   STRTOWSTR(pszBuf, wszBuf, sizeof(wszBuf));
   IDisplay_DrawText(pMe->Applet.m_pIDisplay, AEE_FONT_NORMAL, wszBuf, 
                     -1, pMe->SoftKey1TextRect.x, pMe->SoftKey1TextRect.y, 
                     &pMe->SoftKey1TextRect, IDF_ALIGN_LEFT | IDF_ALIGN_BOTTOM);

   //Update the screen to specify what commands the second soft key controls
   switch (nMode)
   {
   case CAM_MODE_READY:
      pszBuf = "Preview";
      break;
   case CAM_MODE_PREVIEW:
      {
         if (pMe->nPreviewType == CAM_PREVIEW_MOVIE)
            pszBuf = "RecordMovie";
         else
            pszBuf = "RecordSnapshot";
         break;
      }
   case CAM_MODE_MOVIE:
      pszBuf = "";
      break;
   case CAM_MODE_SNAPSHOT:
      pszBuf = "";
      break;
   }
   STRTOWSTR(pszBuf, wszBuf, sizeof(wszBuf));
   IDisplay_DrawText(pMe->Applet.m_pIDisplay, AEE_FONT_NORMAL, wszBuf, 
                     -1, pMe->SoftKey2TextRect.x, pMe->SoftKey2TextRect.y, 
                     &pMe->SoftKey2TextRect, IDF_ALIGN_RIGHT | IDF_ALIGN_BOTTOM);

   // Update the screen with all of the changes
   IDisplay_Update(pMe->Applet.m_pIDisplay);
}