Пример #1
0
/*
*	函数名称: 
		 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);  //将剪切矩形设回来

}
/*===========================================================================
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;
}
Пример #3
0
/*===========================================================================

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 ;
	}
}