void RecvData(ExNet *pMe,byte *pbData,int32 nRecvSize) { int nResult; while(nRecvSize > 0) { nResult = ISOCKET_Read(pMe->m_pSocket, pbData, nRecvSize); if(nResult == AEE_NET_WOULDBLOCK) { ISOCKET_Readable(pMe->m_pSocket, (PFNNOTIFY)CBRecv, (void*)pMe); return; } else if(nResult == AEE_NET_ERROR) { return; } else if(nResult > 0) { pMe->m_nRecvSize += nResult; nRecvSize -= nResult; pbData += nResult; } else { return; } } if(nRecvSize == 0) { pMe->m_nRecvSize = 0; pMe->m_bRecvBuf = TRUE; IDISPLAY_DrawText(pMe->pIDisplay,AEE_FONT_NORMAL,pMe->m_bRecvBuffer,-1,0,0,NULL,IDF_TEXT_TRANSPARENT); IDISPLAY_Update(pMe->a.m_pIDisplay); } }
/*=========================================================================== ===========================================================================*/ static void xDisplay( AEEApplet *pMe, int nLine, int nCol, AEEFont fnt, uint32 dwFlags, const char *psz) { AEEDeviceInfo di; AEERect rc; int nMaxLines; ISHELL_GetDeviceInfo(pMe->m_pIShell,&di); nMaxLines = (di.cyScreen / LINEHEIGHT) - 2; if (nMaxLines < 1) nMaxLines = 1; rc.x = nCol; rc.dx = di.cxScreen - nCol; rc.y = nLine * LINEHEIGHT; if( dwFlags & IDF_ALIGNVERT_MASK ) { rc.dy = di.cyScreen - rc.y; } else { rc.dy = LINEHEIGHT; } xDrawTextA(pMe->m_pIDisplay, fnt, psz, -1, rc.x, rc.y, &rc, dwFlags); IDISPLAY_Update(pMe->m_pIDisplay); }
//============================================================================= //Perform rendering //============================================================================= void GLApp::Render() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); AECHAR m_BlendingStr[10] = {'B','l','e','n','d','i','n','g',':','\0'}; AECHAR m_LightingStr[10] = {'L','i','g','h','t','i','n','g',':','\0'}; AECHAR m_TextureStr[9] = {'T','e','x','t','u','r','e',':','\0'}; AECHAR m_FogStr[5] = {'F','o','g',':','\0'}; AECHAR m_OnStr[3] = {'O','n','\0'}; AECHAR m_OffStr[4] = {'O','f','f','\0'}; IDISPLAY_SetColor(m_pIDisplay, CLR_USER_TEXT, MAKE_RGB(0xFF,0xFF,0xFF)); IDISPLAY_SetColor(m_pIDisplay, CLR_USER_BACKGROUND, MAKE_RGB(0,0,0)); IDISPLAY_DrawText(m_pIDisplay, AEE_FONT_NORMAL, m_BlendingStr, -1, 1, 0, 0, IDF_ALIGN_LEFT); IDISPLAY_DrawText(m_pIDisplay, AEE_FONT_NORMAL, (m_Cube.IsBlendEnabled)?m_OnStr:m_OffStr, -1, 1, 0, 0, IDF_ALIGN_RIGHT); IDISPLAY_DrawText(m_pIDisplay, AEE_FONT_NORMAL, m_LightingStr, -1, 1, 12, 0, IDF_ALIGN_LEFT); IDISPLAY_DrawText(m_pIDisplay, AEE_FONT_NORMAL, (m_Cube.IsLightEnabled)?m_OnStr:m_OffStr, -1, 1, 12, 0, IDF_ALIGN_RIGHT); IDISPLAY_DrawText(m_pIDisplay, AEE_FONT_NORMAL, m_TextureStr, -1, 1, 24, 0, IDF_ALIGN_LEFT); IDISPLAY_DrawText(m_pIDisplay, AEE_FONT_NORMAL, (m_Cube.IsTextureEnabled)?m_OnStr:m_OffStr, -1, 1, 24, 0, IDF_ALIGN_RIGHT); IDISPLAY_DrawText(m_pIDisplay, AEE_FONT_NORMAL, m_FogStr, -1, 1, 36, 0, IDF_ALIGN_LEFT); IDISPLAY_DrawText(m_pIDisplay, AEE_FONT_NORMAL, (m_Cube.IsFogEnabled)?m_OnStr:m_OffStr, -1, 1, 36, 0, IDF_ALIGN_RIGHT); IDISPLAY_Update(m_pIDisplay); m_Cube.Render(); eglSwapBuffers(m_eglDisplay, m_eglSurface); }
void test_sn_scene_draw(Bff *bff, Bff_Scene *scene) { /*clear screen*/ IDisplay *display = BFF_DISPLAY_OF(bff); AECHAR IMSI[50]; ITAPI* tapi = NULL; TestSceneData* data; data = (TestSceneData*)scene->getData(scene); IDISPLAY_SetColor(display, CLR_USER_BACKGROUND, MAKE_RGB(0xdd,0xdd,0xdd)); IDISPLAY_ClearScreen(display); if(ISHELL_CreateInstance(BFF_SHELL(), AEECLSID_TAPI, (void **)&tapi)==SUCCESS) { TAPIStatus status; if(ITAPI_GetStatus(tapi,&status)==SUCCESS) { STRTOWSTR(status.szMobileID,IMSI,sizeof(IMSI)*sizeof(AECHAR)); } ITAPI_Release(tapi); } drawString(IMSI,20,20,MAKE_RGB(0xFF,0xFF,0xFF),MAKE_RGB(0x00,0x00,0x00),AEE_FONT_NORMAL,IDS_LEFT|IDS_TOP); //TODO IDISPLAY_Update(BFF_DISPLAY_OF(bff)); }
static void Thread2Main( SThreadCtx *pMe ) { AECHAR wsz[ 16 ]; while( pMe->n < 256 ) { AEECircle circle; pMe->n++; //circle.cx = 176/2; circle.cx = 128/2; circle.cy = 120; circle.r = pMe->n % 20; WSPRINTF( wsz, sizeof( wsz ), L"t2=%d", pMe->n ); IDISPLAY_DrawText(pMe->pid, // Display instance AEE_FONT_NORMAL, // Use BOLD font wsz, // Text - Normally comes from resource -1, // -1 = Use full string length 0, // Ignored - IDF_ALIGN_CENTER 0, // Ignored - IDF_ALIGN_MIDDLE NULL, // No clipping IDF_ALIGN_CENTER | IDF_ALIGN_BOTTOM); IDISPLAY_EraseRgn( pMe->pid, 0, 70, 128, 90 ); IGRAPHICS_DrawCircle( pMe->pig, &circle ); IDISPLAY_Update (pMe->pid); ISHELL_Resume( pMe->pis, ITHREAD_GetResumeCBK( pMe->pit ) ); ITHREAD_Suspend( pMe->pit ); } ITHREAD_Exit( pMe->pit, SUCCESS ); }
/*=========================================================================== This function displays the specified error message and disables the current window. ===========================================================================*/ void TS_ErrorDlg(CTopSoupApp * pme, uint16 wResErrID) { AEEPromptInfo pi; uint16 wButtonIDs[] = {IDS_OK, 0}; if (pme->m_pWin) CTopSoupApp_DisableWin(pme); pi.pszRes = NAVIGATE_RES_FILE; pi.pTitle = NULL; pi.pText = NULL; pi.wTitleID = 0; //IDS_ERR_BASE; pi.wTextID = wResErrID; pi.wDefBtn = IDS_OK; pi.pBtnIDs = wButtonIDs; pi.dwProps = ST_MIDDLETEXT | ST_CENTERTITLE; pi.fntTitle = AEE_FONT_BOLD; pi.fntText = AEE_FONT_NORMAL; pi.dwTimeout = 10000; if (ISHELL_Prompt(pme->a.m_pIShell, &pi) == FALSE ) return; //TS_DrawImage(pme->m_pHdrImage, &pme->m_rectHdr, TRUE); IDISPLAY_Update(pme->a.m_pIDisplay); }
static boolean task_resume(Bff *bff, uint16 flags, AEEAppStart *appStart, boolean *consumed) { if(GetMainAppData()->pScreenBackup) { IDISPLAY_ClearScreen(BFF_DISPLAY()); IDISPLAY_BitBlt(BFF_DISPLAY(),0,0,getDeviceWidth(),getDeviceHeight(),GetMainAppData()->pScreenBackup,0,0,AEE_RO_COPY); IDISPLAY_Update(BFF_DISPLAY()); IBITMAP_Release(GetMainAppData()->pScreenBackup); GetMainAppData()->pScreenBackup = NULL; } return (*consumed = TRUE); }
static boolean HelloWorld_HandleEvent(AEEApplet * p, AEEEvent eCode, uint16 wParam, uint32 dwParam) { AECHAR szText[] = {'H','e','l','l','o',' ','W','o', 'r', 'l', 'd', '\0'}; HelloThreadApp *pMe = (HelloThreadApp *)p; switch (eCode) { case EVT_APP_START: { int r; r = ISHELL_CreateInstance( p->m_pIShell, AEECLSID_THREAD, (void **)&pMe->stc1.pit ); r = ISHELL_CreateInstance( p->m_pIShell, AEECLSID_THREAD, (void **)&pMe->stc2.pit ); r = ISHELL_CreateInstance( p->m_pIShell, AEECLSID_GRAPHICS, (void **)&pMe->stc2.pig ); pMe->stc1.pis = p->m_pIShell; pMe->stc1.pid = p->m_pIDisplay; pMe->stc2.pis = p->m_pIShell; pMe->stc2.pid = p->m_pIDisplay; CALLBACK_Init( &pMe->cbThread2Done, (PFNNOTIFY)Thread2Done, (void *)pMe ); ITHREAD_HoldRsc( pMe->stc2.pit, (IBase *)pMe->stc2.pig ); ITHREAD_Join( pMe->stc2.pit, &pMe->cbThread2Done, &pMe->nThread2Result ); ITHREAD_Start( pMe->stc1.pit, 128, (PFNTHREAD)Thread1Start, (void *)&pMe->stc1 ); ITHREAD_Start( pMe->stc2.pit, 128, (PFNTHREAD)Thread2Start, (void *)&pMe->stc2 ); IDISPLAY_DrawText(p->m_pIDisplay, // Display instance AEE_FONT_BOLD, // Use BOLD font szText, // Text - Normally comes from resource -1, // -1 = Use full string length 0, // Ignored - IDF_ALIGN_CENTER 0, // Ignored - IDF_ALIGN_MIDDLE NULL, // No clipping IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE); IDISPLAY_Update (p->m_pIDisplay); } return(TRUE); case EVT_APP_STOP: { IGRAPHICS_Release( pMe->stc2.pig ); ITHREAD_Release( pMe->stc1.pit ); ITHREAD_Release( pMe->stc2.pit ); } return(TRUE); default: break; } return(FALSE); }
void COMMON_Draw(Common* common) { IDisplay* d = common->display; int i = 0; int j = 0; int len = WSTRLEN(common->message); IDISPLAY_ClearScreen(d); common->lines = 0; while ((i < len - 1) && ((common->lines - common->start_line) * common->font_height < common->height)) { AECHAR t; int l; IDISPLAY_MeasureTextEx(d, AEE_FONT_NORMAL, common->message + i, len - i, common->width, &j); for (l = 0; l < j; l++) { if (common->message[i + l] == 0x0D || common->message[i + l] == '\n') { j = l; break; } } t = common->message[i + j]; common->message[i + j] = 0; if (common->start_line <= common->lines) { IDISPLAY_DrawText(d, AEE_FONT_NORMAL, common->message + i, -1, 0, (common->lines - common->start_line) * common->font_height, NULL, IDF_ALIGN_LEFT); } common->message[i + j] = t; i += j; if (t == 0x0D) { i += 2; } if (t == '\n') { i++; } common->lines++; } IDISPLAY_Update(d); return; }
static void Thread1Main( SThreadCtx *pMe ) { AECHAR wsz[ 16 ]; while( 1 ) { pMe->n++; WSPRINTF( wsz, sizeof( wsz ), L"t1=%d", pMe->n ); IDISPLAY_DrawText(pMe->pid, // Display instance AEE_FONT_NORMAL, // Use BOLD font wsz, // Text - Normally comes from resource -1, // -1 = Use full string length 0, // Ignored - IDF_ALIGN_CENTER 0, // Ignored - IDF_ALIGN_MIDDLE NULL, // No clipping IDF_ALIGN_CENTER | IDF_ALIGN_TOP); IDISPLAY_Update (pMe->pid); ISHELL_Resume( pMe->pis, ITHREAD_GetResumeCBK( pMe->pit ) ); ITHREAD_Suspend( pMe->pit ); } }
/*=========================================================================== This function redraws the main window. ===========================================================================*/ static void CWhereDetailsWin_Redraw(IWindow * po) { CWhereDetailsWin * pme = (CWhereDetailsWin *)po; if (!pme->m_bActive) return; //XXX __begin IDISPLAY_ClearScreen(pme->m_pIDisplay); TS_DrawBackgroud(po); { AECHAR bufRes[MP_MAX_STRLEN]; int a = 0, b = 0; int h = 0, xx = 0, yy = 0, dxx = 0, dyy = 0; AEERect rect; int xMargin = 0; ISHELL_LoadResString(pme->m_pOwner->a.m_pIShell,NAVIGATE_RES_FILE,IDS_STRING_WHERE_DETAILS_0, bufRes, sizeof(bufRes)); h = IDISPLAY_GetFontMetrics(pme->m_pIDisplay, WIN_FONT, &a, &b) + 12; xx = xMargin; yy = 64; dxx = pme->m_pOwner->m_cxWidth - 2; dyy = h; SETAEERECT(&rect, xx, yy, dxx, dyy); TS_DrawText(pme->m_pIDisplay, WIN_FONT, bufRes, &rect); ISHELL_LoadResString(pme->m_pOwner->a.m_pIShell,NAVIGATE_RES_FILE,IDS_STRING_WHERE_DETAILS_1, bufRes, sizeof(bufRes)); h = IDISPLAY_GetFontMetrics(pme->m_pIDisplay, WIN_FONT, &a, &b) + 12; xx = xMargin; yy += h; dxx = pme->m_pOwner->m_cxWidth - 2; dyy = h; SETAEERECT(&rect, xx, yy, dxx, dyy); TS_DrawText(pme->m_pIDisplay, WIN_FONT, bufRes, &rect); ISHELL_LoadResString(pme->m_pOwner->a.m_pIShell,NAVIGATE_RES_FILE,IDS_STRING_WHERE_DETAILS_2, bufRes, sizeof(bufRes)); h = IDISPLAY_GetFontMetrics(pme->m_pIDisplay, WIN_FONT, &a, &b) + 12; xx = xMargin; yy += h; dxx = pme->m_pOwner->m_cxWidth - 2; dyy = h; SETAEERECT(&rect, xx, yy, dxx, dyy); TS_DrawText(pme->m_pIDisplay, WIN_FONT, bufRes, &rect); ISHELL_LoadResString(pme->m_pOwner->a.m_pIShell,NAVIGATE_RES_FILE,IDS_STRING_WHERE_DETAILS_3, bufRes, sizeof(bufRes)); h = IDISPLAY_GetFontMetrics(pme->m_pIDisplay, WIN_FONT, &a, &b) + 12; xx = xMargin; yy += h; dxx = pme->m_pOwner->m_cxWidth - 2; dyy = h; SETAEERECT(&rect, xx, yy, dxx, dyy); TS_DrawText(pme->m_pIDisplay, WIN_FONT, bufRes, &rect); ISHELL_LoadResString(pme->m_pOwner->a.m_pIShell,NAVIGATE_RES_FILE,IDS_STRING_WHERE_DETAILS_4, bufRes, sizeof(bufRes)); h = IDISPLAY_GetFontMetrics(pme->m_pIDisplay, WIN_FONT, &a, &b) + 12; xx = xMargin; yy += h; dxx = pme->m_pOwner->m_cxWidth - 2; dyy = h; SETAEERECT(&rect, xx, yy, dxx, dyy); TS_DrawText(pme->m_pIDisplay, WIN_FONT, bufRes, &rect); ISHELL_LoadResString(pme->m_pOwner->a.m_pIShell,NAVIGATE_RES_FILE,IDS_STRING_WHERE_DETAILS_5, bufRes, sizeof(bufRes)); h = IDISPLAY_GetFontMetrics(pme->m_pIDisplay, WIN_FONT, &a, &b) + 12; xx = xMargin; yy += h; dxx = pme->m_pOwner->m_cxWidth - 2; dyy = h; SETAEERECT(&rect, xx, yy, dxx, dyy); TS_DrawText(pme->m_pIDisplay, WIN_FONT, bufRes, &rect); } IDISPLAY_Update(pme->m_pIDisplay); //XXX _end }
/*=========================================================================== FUNCTION: DisplayOutput DESCRIPTION This function displays an output string at a given line number on the screen. If the nline parameter is a negative value (-1) the string is displayed in the middle of the screen. If the "nline" value is larger than or equal to zero the "nline" value is multiplied by 15 and the resulting value in pixels is set to the y-coordinate of the start of the string display on the screen. If the string does not fit on one line the string wraps around to the next line (spaced rougly 10-15 pixels apart). By default 5 is used as the starting the x-coordinate of a displayed string. How many characters that fit on one line is calculated for each line that is wrapped around to the next line. Note: depending on the phone screen size and the fonts used for characters the output might differ on different handsets (devices). Where some handsets will have a smaller screen and large default fonts which will cause partial overlapping of lines. This function does not try to address these issues (this is meant as a simple display function). PROTOTYPE: int DisplayOutput(IShell *pIShell, IDisplay *pDisplay, int nline, char *pszStr, AECHAR *pszwStr, boolean isWideChar) PARAMETERS: pIShell: [in]: Contains a pointer to the IShell interface. pIDisplay: [in]: Contains a pointer to the IDisplay interface. nline: [in]: Contains the line number to start displaying the text. The line numbers are by default spaced 15 pixels apart along the y-axis. pszStr: [in]: The character string to be displayed on the screen. DEPENDENCIES None RETURN VALUE Number of lines written to the screen. SIDE EFFECTS None ===========================================================================*/ static int DisplayOutput(IShell *pIShell, IDisplay *pIDisplay, int nline, char *pszStr, AECHAR *pszwStr, boolean isWideChar) { AEEDeviceInfo di; // Device Info AECHAR * szBuf; // a buffer that supports 200 char string AECHAR * psz = NULL; int charHeight = 0; // Stores the char height in pixels for given font int pnAscent = 0; // Stores the ascent in number of pixels int pnDescent = 0; // Stores the descent in number of pixels int pixelWidth; AEEFont font = AEE_FONT_NORMAL; int pnFits = 0, dy; int totalCh = 0; int numLinesPrinted = 0; // Make sure the pointers we'll be using are valid if (pIShell == NULL || pIDisplay == NULL) { return 0; } if ((szBuf = (AECHAR *) MALLOC(TEXT_BUFFER_SIZE)) == NULL) { return 0; } // Get device information ISHELL_GetDeviceInfo(pIShell,&di); // Get the font metrics info charHeight = IDISPLAY_GetFontMetrics (pIDisplay, AEE_FONT_NORMAL, &pnAscent, &pnDescent); if(isWideChar) { WSTRCPY(szBuf,pszwStr); } else { // Convert to wide string (unicode) STR_TO_WSTR ((char *)pszStr, szBuf, TEXT_BUFFER_SIZE); } // If nlines is zero then print this string starting around the middle of // the screen. Or else multiply nlines by charheight to decide the y coordinate of // the start of the string. if (nline < 0) { dy = di.cyScreen*2/5; } else{ dy = nline * charHeight + 5; } // psz keeps track of the point from which to write from the string buffer // in case the string does not fit one line and needs to wrap around in the // next line. psz = szBuf; // Need to calculate the lotal string length to decide if any wrapping // around is needed. if(isWideChar) { totalCh = 2*WSTRLEN (pszwStr); } else { totalCh = STRLEN ((char *)pszStr); } // Keep displaying text string on multiple lines if the string can't be displayed // on one single line. Lines are spaced 15 pixels apart. while ((totalCh > 0) && (*psz != NULL)) { // Get information on how many characters will fit in a line. // Give the pointer to the buffer to be displayed, and the number of // pixels along the x axis you want to display the string in (max number) // pnFits will have the max number of chars that will fit in the maxWidth // number of pixels (given string can't fit in one line), or the number of // chars in the string (if it does fit in one line). pnWidth gives the // number of pixels that will be used to display pnFits number of chars. pixelWidth = IDISPLAY_MeasureTextEx(pIDisplay, font, (AECHAR *) psz, // Start of the buffer to display, -1, di.cxScreen - 5, // maxWidth &pnFits); // Number of chars that will fit a line // If pnFits is zero there is something wrong in the input to above function. // Normally this scenario should not occur. But, have the check anyway. if (pnFits == 0) { FREE(szBuf); return 0; } IDISPLAY_DrawText(pIDisplay, AEE_FONT_NORMAL, psz, pnFits, 5 /*start dx*/, dy, 0 /* use default rectangle coordinates */, 0); psz += pnFits; // move pointer to the next segment to be displayed totalCh -= pnFits; // reduce the total number of characters to still display dy += charHeight; // Place next line charHeight pixels below the // previous line. ++numLinesPrinted; IDISPLAY_Update(pIDisplay); //, TRUE); if (totalCh < pnFits) pnFits = totalCh; // if total number is less than pnFits, adjust pnFits } FREE(szBuf); return numLinesPrinted; } // End of DisplayOutput
/*=========================================================================== 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 PocketRocketForBrew_HandleEvent(PocketRocketForBrew* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam) { AECHAR szBuf[] = {'H','e','l','l','o',' ','W','o','r','l','d','\0'}; AECHAR down[] = {'Y','o','u',' ','P','u','s','h','e','d',' ','d','o','w','n','\0'}; AECHAR error[] = {'I','m','a','g','e',' ','l','o','a','d',' ','f','a','i','l','e','d','\0'}; boolean handled = FALSE; AEEApplet * display = (AEEApplet *)pMe; IImage *samplePic = NULL; switch (eCode) { // App is told it is starting up case EVT_APP_START: // Clear the display. IDISPLAY_ClearScreen( display->m_pIDisplay); //IDISPLAY_DrawRect(display->m_pIDisplay, // Display string on the screen IDISPLAY_DrawText( display->m_pIDisplay, // What AEE_FONT_BOLD, // What font szBuf, // How many chars -1, 0, 0, 0, // Where & clip IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE ); // Redraw the display to show the drawn text IDISPLAY_Update (display->m_pIDisplay); //IDISPLAY_DrawFrame // Add your code here... return(TRUE); // App is told it is exiting case EVT_APP_STOP: // Add your code here... return(TRUE); // App is being suspended case EVT_APP_SUSPEND: // Add your code here... return(TRUE); // App is being resumed case EVT_APP_RESUME: // Add your code here... 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); // A key was pressed. Look at the wParam above to see which key was pressed. The key // codes are in AEEVCodes.h. Example "AVK_1" means that the "1" key was pressed. case EVT_KEY: switch (wParam){ case AVK_DOWN: /* IDISPLAY_ClearScreen( display->m_pIDisplay ); IDISPLAY_DrawText (display->m_pIDisplay, AEE_FONT_BOLD, down, -1,0,0,0, IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE); IDISPLAY_Update(display->m_pIDisplay); handled = TRUE; */ //IImage *samplePic = ISHELL_LoadResImage(display->m_pIShell,".\\pics\\xosphere.JPG",5001); samplePic = ISHELL_LoadImage(display->m_pIShell,".\\pics\\xosphere.bmp"); while (!samplePic); if (!samplePic) { IDISPLAY_ClearScreen(display->m_pIDisplay); //IDISPLAY_DrawRect(display->m_pIDisplay, // Display string on the screen IDISPLAY_DrawText( display->m_pIDisplay, // What AEE_FONT_BOLD, // What font error, // How many chars -1, 0, 0, 0, // Where & clip IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE ); // Redraw the display to show the drawn text IDISPLAY_Update (display->m_pIDisplay); } else { IIMAGE_Draw(samplePic, 0,0); IDISPLAY_Update(display->m_pIDisplay); } return(TRUE); } // Add your code here... return(TRUE); // If nothing fits up to this poNumber then we'll just break out default: break; } return FALSE; }
/*=========================================================================== FUNCTION: CGMENUCTL_Redraw DESCRIPTION: Redraws the control on the device screen. If the control currently has focus, the control is drawn with a border. PARAMETERS: pCtl [in] - A pointer to a CGMeuCtl instance DEPENDENCIES: None RETURN VALUE: None SIDE EFFECTS: Updates the device screen. ===========================================================================*/ extern void CGMENUCTL_Redraw(CGMeuCtl* pMe) { AEEApplet* pApp = (AEEApplet*)GETAPPINSTANCE(); AEERect rRect; if (pMe) { int i, j, height, h, a, b; AEEImageInfo infSe, infIc; AEERect rec; int xx, yy, dxx, dyy; RGBVAL oldColor; GMenuItem * pData = NULL; TQueueList * p = pMe->m_pDataList; ZEROAT(&infSe); IDISPLAY_EraseRect(pApp->m_pIDisplay, &pMe->m_Rect); h = IDISPLAY_GetFontMetrics(pApp->m_pIDisplay, AEE_FONT_NORMAL, &a, &b); //绘制背景图 if (pMe->m_pImageBk) { IIMAGE_SetDrawSize(pMe->m_pImageBk, pMe->m_Rect.dx, pMe->m_Rect.dy); IIMAGE_Draw(pMe->m_pImageBk, pMe->m_Rect.x, pMe->m_Rect.y); } //确定菜单高度 if (pMe->m_pImageSe) { IIMAGE_GetInfo(pMe->m_pImageSe, &infSe); IIMAGE_SetDrawSize(pMe->m_pImageSe, pMe->m_Rect.dx, infSe.cy); } else { infSe.cx = pMe->m_Rect.dx; infSe.cy = h; } //绘制菜单项 i = 0; j = 0; height = pMe->m_Rect.y + 5; while (p) { AECHAR iTemText[256]; if (i < pMe->m_startIndex) { p = p->pNext; i++; continue; } if (j >= pMe->m_pageSize) { break; } pData = (GMenuItem*)p->pData; //加载菜单ICON if (pData->pImage == NULL && pData->pszResImage != NULL && pData->wImage != 0) { pData->pImage = ISHELL_LoadResImage(pApp->m_pIShell, pData->pszResImage, pData->wImage); } //加载菜单Text if (pData->pszResText != NULL && pData->wText != 0) { MEMSET(iTemText, 0, sizeof(AECHAR)*256); ISHELL_LoadResString(pApp->m_pIShell, pData->pszResText, pData->wText, iTemText, sizeof(AECHAR)* 256); pData->pText = iTemText; } if (i == pMe->m_Index) { if (pMe->m_pImageSe) IIMAGE_Draw(pMe->m_pImageSe, pMe->m_Rect.x, height + 2); ZEROAT(&infIc); if (pData->pImage) { IIMAGE_GetInfo(pData->pImage, &infIc); IIMAGE_Draw(pData->pImage, pMe->m_Rect.x, height + (infSe.cy - infIc.cy) / 2); } xx = pMe->m_Rect.x + infIc.cx + 2; yy = height + (infSe.cy - h) / 2 + 2; dxx = pMe->m_Rect.x + pMe->m_Rect.dx - xx; dyy = h; SETAEERECT(&rec, xx, yy, dxx, dyy); oldColor = IDISPLAY_SetColor(pApp->m_pIDisplay, CLR_USER_TEXT, pMe->m_Colors.cSelText); if (pMe->m_Properties & 0x02) IDISPLAY_DrawText(pApp->m_pIDisplay, AEE_FONT_NORMAL, pData->pText + pMe->m_textPos, -1, xx + 1, yy, &rec, IDF_TEXT_TRANSPARENT); IDISPLAY_DrawText(pApp->m_pIDisplay, AEE_FONT_NORMAL, pData->pText + pMe->m_textPos, -1, xx, yy, &rec, IDF_TEXT_TRANSPARENT); if (pMe->m_isActive) { if (IDISPLAY_MeasureText(pApp->m_pIDisplay, AEE_FONT_NORMAL, pData->pText) > dxx) { if (IDISPLAY_MeasureText(pApp->m_pIDisplay, AEE_FONT_NORMAL, pData->pText + pMe->m_textPos) > dxx) { pMe->m_textPos++; } else pMe->m_textPos = 0; //单行太长的话,动态显示 ISHELL_SetTimer(pApp->m_pIShell, 300, (PFNNOTIFY)CGMENUCTL_Redraw, (void*)pMe); } } height += infSe.cy; IDISPLAY_SetColor(pApp->m_pIDisplay, CLR_USER_TEXT, oldColor); } else { ZEROAT(&infIc); if (pData->pImage) { IIMAGE_GetInfo(pData->pImage, &infIc); IIMAGE_Draw(pData->pImage, pMe->m_Rect.x, height + (infSe.cy - infIc.cy) / 2); } xx = pMe->m_Rect.x + infIc.cx + 2; yy = height + (infSe.cy - h) / 2 + 2; dxx = pMe->m_Rect.x + pMe->m_Rect.dx - xx; dyy = h; SETAEERECT(&rec, xx, yy, dxx, dyy); oldColor = IDISPLAY_SetColor(pApp->m_pIDisplay, CLR_USER_TEXT, pMe->m_Colors.cText); if (pMe->m_Properties & 0x01) IDISPLAY_DrawText(pApp->m_pIDisplay, AEE_FONT_NORMAL, pData->pText, -1, xx + 1, yy, &rec, IDF_TEXT_TRANSPARENT); IDISPLAY_DrawText(pApp->m_pIDisplay, AEE_FONT_NORMAL, pData->pText, -1, xx, yy, &rec, IDF_TEXT_TRANSPARENT); height += infSe.cy; IDISPLAY_SetColor(pApp->m_pIDisplay, CLR_USER_TEXT, oldColor); } p = p->pNext; i++; j++; } IDISPLAY_Update(pApp->m_pIDisplay); return ; } }
/*============================================================================= FUNCTION c_SampleCameraApp_CameraCBFunc DESCRIPTION This callback notifier function handles all callbacks from ICamera. Depending on how complex your application this function may need to handle several use cases. The most common uses are error handling, state transistion, displaying frames, and monitoring status. PROTOTYPE: static void c_SampleCameraApp_CameraCBFunc(SampleCameraApp* pMe, AEECameraNotify * pcn) PARAMETERS: pMe: Pointer to the applet data stucture pcn: This pointer to a AEECameraNotify structure contains information about the ICamera object. DEPENDENCIES none RETURN VALUE none SIDE EFFECTS none =============================================================================*/ static void c_SampleCameraApp_CameraCBFunc(c_samplecamera* pMe, AEECameraNotify * pcn) { int nErr = AEE_EFAILED; // First validate the callback... if (!pMe || !pcn) { DBGPRINTF("NULL ptr in callback."); return; } c_SampleCameraApp_PrintStatus(pMe); switch (pcn->nStatus) { case CAM_STATUS_FRAME: { // A new frame is available, Get the raw frame, check orientation and blit it to the screen IBitmap * pFrame; AEEBitmapInfo BitmapInfo; ICAMERA_GetFrame( pMe->pICamera, &pFrame ); if (!pFrame) break; //Check to see if the raw frame does not have the same orientation // as what expected. If they are not the same, rotate the preview so // that the final image on the screen is rotated correctly. This // will handle the different mounting possitions of the camera. IBitmap_GetInfo(pFrame, &BitmapInfo, sizeof(AEEBitmapInfo)); if (BitmapInfo.cx == pMe->ImageSize.cy && BitmapInfo.cy == pMe->ImageSize.cx ) { DBGPRINTF("Frame is %d by %d. Expected %d by %d", BitmapInfo.cx, BitmapInfo.cy, pMe->ImageSize.cx, pMe->ImageSize.cy ); if (!pMe->bAdjustedPreviewRotate) { nErr = ICAMERA_SetParm(pMe->pICamera, CAM_PARM_ROTATE_PREVIEW, 90, 0); DBGPRINTF("Rotating the image - nErr is %d", nErr); pMe->bAdjustedPreviewRotate = TRUE; } } IDISPLAY_BitBlt(pMe->Applet.m_pIDisplay, 0, 0, pMe->ImageSize.cx, pMe->ImageSize.cy, pFrame, 0, 0, AEE_RO_COPY); //Display buffer is now updated, need to update the screen IDISPLAY_Update(pMe->Applet.m_pIDisplay); IBITMAP_Release(pFrame); break; } case CAM_STATUS_DONE: { //if there is a command to execute, call the appropriate function if (pMe->bCommandToExecute) { pMe->bCommandToExecute = FALSE; switch (pMe->nCommandToExecute) { case RECORD_SNAPSHOT: { nErr = ICAMERA_RecordSnapshot(pMe->pICamera); DBGPRINTF("ICAMERA_RecordSnapshot %d", nErr); break; } case RECORD_MOVIE: { nErr = ICAMERA_RecordMovie(pMe->pICamera); DBGPRINTF("ICAMERA_RecordMovie %d", nErr); break; } } pMe->nCommandToExecute = NO_COMMAND; } break; } } }