/* * 函数名称: PicBrowser::Draw() * 功能介绍: 该函数为PicBrowser类的显示函数。作用是根据相应的位置信息和颜色信息在屏幕上显示一行字和一副图片。 * 输入参数: N/A * 输出参数: N/A * 返回值: 返回是否初始化成功 * 可能出现的意外: N/A */ void PicBrowser::Draw() { RGBVAL rgb; AEERect rctScreen; AECHAR pwszFailTip[7]= {0x8D44,0x6E90,0x88C5,0x8F7D,0x5931,0x8D25,0}; //资源装载失败 IDISPLAY_ClearScreen(m_pIDisplay); SETAEERECT(&rctScreen,0,0,pApp->lcdW,pApp->lcdH); if(!m_bInitSuccess) //若初始化失败,提示之 { IDISPLAY_DrawText(m_pIDisplay,AEE_FONT_NORMAL,pwszFailTip,-1,0,0,0,0); return; } //以下画彩色文字 rgb=IDISPLAY_SetColor(m_pIDisplay,CLR_USER_TEXT,MAKE_RGB(m_nRed,0,255-m_nRed)); IDISPLAY_DrawText(m_pIDisplay,AEE_FONT_NORMAL,m_pwszTitle,-1,0,0,0,0); IDISPLAY_SetColor(m_pIDisplay,CLR_USER_TEXT,rgb); //以下画图片 IDISPLAY_SetClipRect(m_pIDisplay,&m_rctImage); //设置剪切矩形 IDISPLAY_ClearScreen(m_pIDisplay); IIMAGE_Draw(m_pImage,m_nImageDrawX,m_nImageDrawY); IDISPLAY_DrawRect(m_pIDisplay,&m_rctImage,MAKE_RGB(0,0,0),RGB_NONE,IDF_RECT_FRAME); IDISPLAY_SetClipRect(m_pIDisplay,&rctScreen); //将剪切矩形设回来 }
//============================================================================= //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 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); } }
//绘制文字 void TS_DrawText(IDisplay* pIDisplay, AEEFont nFont, AECHAR* pText, AEERect *rect) { RGBVAL oldColor; oldColor = IDISPLAY_SetColor(pIDisplay, CLR_USER_TEXT, MAKE_RGB(255, 255, 255)); IDISPLAY_DrawText(pIDisplay, nFont, pText, -1, rect->x, rect->y, rect, IDF_TEXT_TRANSPARENT); IDISPLAY_SetColor(pIDisplay, CLR_USER_TEXT, oldColor); }
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 ); }
/*=========================================================================== ===========================================================================*/ static void xDrawTextA(IDisplay * pd,AEEFont fnt, const char * pszText, int nChars, int x,int y,const AEERect * prcBackground,uint32 dwFlags) { AECHAR wcBuf[80]; if (nChars < 0) nChars = STRLEN(pszText); nChars = min(nChars, ARRAYSIZE(wcBuf)); STR_TO_WSTR((char*)pszText, wcBuf, sizeof(wcBuf)); IDISPLAY_DrawText(pd, fnt, wcBuf, nChars, x, y, prcBackground, dwFlags); }
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 Tooltip_Redraw(Tooltip *me) { if (!me->bShown || (0 == WSTRLEN(me->pwsz))) { return; } me->rc.dx = IDISPLAY_MeasureText(me->piDisplay,AEE_FONT_NORMAL,me->pwsz)+4; me->rc.x = me->nX + (((me->nDx-me->rc.dx)*me->nXPercent)/100); me->rc.x = CONSTRAIN(me->rc.x, me->nX, (me->nX + me->nDx) - me->rc.dx); IDISPLAY_DrawText(me->piDisplay,AEE_FONT_NORMAL,me->pwsz,-1, me->rc.x+2,me->rc.y+2, &me->rc,IDF_RECT_FILL|IDF_RECT_FRAME); }
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 ); } }
void StatusBox_Redraw(StatusBox *me) { /* don't draw anything if we're not around */ if (!me->bActive || !me->bStarted) { return; } if ((IImage *)0 != me->piImage) { IIMAGE_DrawFrame(me->piImage,me->nFrame, me->rcImage.x+1,me->rcImage.y+1); /* frame image */ IDISPLAY_DrawRect(me->piDisplay,&me->rcImage,RGB_BLACK,0xbeef, IDF_RECT_FRAME); } if (!me->bTextMeasured) { me->rcText.dx = IDISPLAY_MeasureText(me->piDisplay, AEE_FONT_NORMAL,me->pwsz)+4; me->rcText.dx = MIN(me->rcCenter.dx,me->rcText.dx); if (me->rcText.y == (me->rcImage.y + me->rcImage.dy - 1)) { me->rcText.dx = MAX(me->rcText.dx,me->rcImage.dx); } me->bTextMeasured = TRUE; me->rcText.x = me->rcCenter.x + ((me->rcCenter.dx - me->rcText.dx) / 2); } IDISPLAY_DrawText(me->piDisplay,AEE_FONT_NORMAL, me->pwsz,-1,0,0,&me->rcText, IDF_RECT_FILL|IDF_RECT_FRAME| IDF_ALIGN_CENTER|IDF_ALIGN_MIDDLE); }
/*=========================================================================== FUNCTION: DisplayEvent DESCRIPTION This function prints a heading at the top of the screen to indicate which usage example was selected by the user, It also prints a message on the bottom two lines of the screen instructing the user to press the UP or DOWN key to return to the main menu to execute another example. PROTOTYPE: static void DisplayEvent(CallDemoApp * pMe, uint16 wParam) PARAMETERS: pMe: [in]: Contains a pointer to the usage app data structure. wParam: [in]: Identifier of the selected example (example IDs are specified when the main usage app menu is created). If the value USAGE_ERASE_SCREEN is supplied instead, this function clears the screen. DEPENDENCIES None RETURN VALUE None SIDE EFFECTS None ===========================================================================*/ static void DisplayEvent (CallDemoApp *pMe, uint16 wParam) { AEERect qrc; AEEDeviceInfo di; // Device Info AECHAR * szBuf; AEERect rc; // Make sure the pointers we'll be using are valid if (pMe == NULL || pMe->a.m_pIShell == NULL || pMe->a.m_pIDisplay == NULL) { return; } if ((szBuf = (AECHAR *) MALLOC(TEXT_BUFFER_SIZE)) == NULL) { return; } ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&di); qrc.x = 0; qrc.y = 0; qrc.dx = di.cxScreen; qrc.dy = di.cyScreen; rc.x = 5; rc.y = 5; rc.dx = di.cxScreen - 5; rc.dy = di.cyScreen - 5; // Specify text for heading based on example the user has selected switch (wParam) { case USAGE_ERASE_SCREEN: IDISPLAY_EraseRect(pMe->a.m_pIDisplay,&qrc); //Clear the display FREE(szBuf); return; case USAGE_CALL_ORIG: STR_TO_WSTR("CALL ORIG", szBuf, TEXT_BUFFER_SIZE); break; case USAGE_CALL_OUTGOING_END: STR_TO_WSTR("End OutGoing Call", szBuf, TEXT_BUFFER_SIZE); break; case USAGE_CALL_INCOMING_END: STR_TO_WSTR("End Incoming Call", szBuf, TEXT_BUFFER_SIZE); break; case USAGE_CALL_DTMF: STR_TO_WSTR("Call and DTMF", szBuf, TEXT_BUFFER_SIZE); break; case USAGE_CALL_PARTY3: STR_TO_WSTR("Call Party 3", szBuf, TEXT_BUFFER_SIZE); break; case USAGE_CALL_ANSWER: STR_TO_WSTR("Answer incoming call", szBuf, TEXT_BUFFER_SIZE); break; case USAGE_CALL_REDIRECT: STR_TO_WSTR("Redirect incoming call", szBuf, TEXT_BUFFER_SIZE); break; default: STR_TO_WSTR("Unsupported fn", szBuf, TEXT_BUFFER_SIZE); } // Print the heading at the top of the screen IDISPLAY_DrawText(pMe->a.m_pIDisplay, AEE_FONT_NORMAL, szBuf, -1,10, 5, &rc, IDF_ALIGN_NONE| IDF_TEXT_TRANSPARENT); // Print a message at the bottom of the screen telling the user // how to return to the main app menu STR_TO_WSTR("Press Up/Down", szBuf, TEXT_BUFFER_SIZE); IDISPLAY_DrawText(pMe->a.m_pIDisplay, AEE_FONT_NORMAL, szBuf, -1,10, qrc.dy - 25, &rc, IDF_ALIGN_NONE | IDF_TEXT_TRANSPARENT); STR_TO_WSTR("keys to continue..", szBuf, TEXT_BUFFER_SIZE); IDISPLAY_DrawText(pMe->a.m_pIDisplay, AEE_FONT_NORMAL, szBuf, -1,10, qrc.dy - 15, &rc, IDF_ALIGN_NONE | IDF_TEXT_TRANSPARENT); IDISPLAY_UpdateEx(pMe->a.m_pIDisplay,TRUE); FREE(szBuf); }
/*=========================================================================== 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: DisplayEvent DESCRIPTION This function prints a heading at the top of the screen to indicate which usage example was selected by the user, It also prints a message on the bottom two lines of the screen instructing the user to press the UP or DOWN key to return to the main menu to execute another example. PROTOTYPE: static void DisplayEvent(ISmsApp * pMe, uint16 wParam) PARAMETERS: pMe: [in]: Contains a pointer to the usage app data structure. wParam: [in]: Identifier of the selected example (example IDs are specified when the main usage app menu is created). If the value USAGE_ERASE_SCREEN is supplied instead, this function clears the screen. DEPENDENCIES None RETURN VALUE None SIDE EFFECTS None ===========================================================================*/ static void DisplayEvent (ISmsApp *pMe, uint16 wParam) { AEERect qrc; AEEDeviceInfo di; // Device Info AECHAR * szBuf; AEERect rc; // Make sure the pointers we'll be using are valid if (pMe == NULL || pMe->a.m_pIShell == NULL || pMe->a.m_pIDisplay == NULL) return; if ((szBuf = (AECHAR *) MALLOC(TEXT_BUFFER_SIZE)) == NULL) return; ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&di); qrc.x = 0; qrc.y = 0; qrc.dx = di.cxScreen; qrc.dy = di.cyScreen; rc.x = 5; rc.y = 5; rc.dx = di.cxScreen - 5; rc.dy = di.cyScreen - 5; // Specify text for heading based on example the user has selected switch (wParam) { case USAGE_ERASE_SCREEN: IDISPLAY_EraseRect(pMe->a.m_pIDisplay,&qrc); //Clear the display FREE(szBuf); return; case USAGE_SMS_TX_ASCII: STR_TO_WSTR("SMS TX ASCII", szBuf, TEXT_BUFFER_SIZE); break; case USAGE_SMS_TX_UNICODE: STR_TO_WSTR("SMS TX UNICODE", szBuf, TEXT_BUFFER_SIZE); break; case USAGE_SMS_TX_UTF8: STR_TO_WSTR("SMS TX UTF-8", szBuf, TEXT_BUFFER_SIZE); break; case USAGE_SMS_RX_TAPI_METHOD: STR_TO_WSTR("SMS RX in TAPI method", szBuf, TEXT_BUFFER_SIZE); break; case USAGE_SMS_RX_ISMS_METHOD: STR_TO_WSTR("SMS RX in ISMS method", szBuf, TEXT_BUFFER_SIZE); break; case USAGE_SMS_STORE_STATUS: STR_TO_WSTR("SMS Store Status", szBuf, TEXT_BUFFER_SIZE); break; case USAGE_SMS_STORE_ENUM_READ: STR_TO_WSTR("SMS Store Read", szBuf, TEXT_BUFFER_SIZE); break; default: STR_TO_WSTR("Unsupported fn", szBuf, TEXT_BUFFER_SIZE); } // Print the heading at the top of the screen IDISPLAY_DrawText(pMe->a.m_pIDisplay, AEE_FONT_NORMAL, szBuf, -1,10, 5, &rc, IDF_ALIGN_NONE| IDF_TEXT_TRANSPARENT); // Print a message at the bottom of the screen telling the user // how to return to the main app menu STR_TO_WSTR("Press Up/Down", szBuf, TEXT_BUFFER_SIZE); IDISPLAY_DrawText(pMe->a.m_pIDisplay, AEE_FONT_NORMAL, szBuf, -1,10, qrc.dy - 25, &rc, IDF_ALIGN_NONE | IDF_TEXT_TRANSPARENT); STR_TO_WSTR("keys to continue..", szBuf, TEXT_BUFFER_SIZE); IDISPLAY_DrawText(pMe->a.m_pIDisplay, AEE_FONT_NORMAL, szBuf, -1,10, qrc.dy - 15, &rc, IDF_ALIGN_NONE | IDF_TEXT_TRANSPARENT); IDISPLAY_UpdateEx(pMe->a.m_pIDisplay,TRUE); FREE(szBuf); }
/*=========================================================================== 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 ; } }