📄 gmenu.c
字号:
}
}
switch(wParam)
{
case AVK_1:
if(IMENUCTL_IsActive(pMe->pIMenuCtl)==FALSE)
IMENUCTL_SetActive(pMe->pIMenuCtl,TRUE);
break;
}
return(TRUE);
// If nothing fits up to this point then we'll just break out
default:
break;
}
return FALSE;
}
// this function is called when your application is starting up
boolean gmenu_InitAppData(gmenu* pMe)
{
// Get the device information for this handset.
// Reference all the data by looking at the pMe->DeviceInfo structure
// Check the API reference guide for all the handy device info you can get
pMe->DeviceInfo.wStructSize = sizeof(pMe->DeviceInfo);
ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&pMe->DeviceInfo);
// Insert your code here for initializing or allocating resources...
pMe->pIDisplay = pMe->a.m_pIDisplay;
pMe->pIShell = pMe->a.m_pIShell;
// pMe->pIMenuCtl = pMe->a.m_pIMenuCtl;
// if there have been no failures up to this point then return success
return TRUE;
}
// this function is called when your application is exiting
void gmenu_FreeAppData(gmenu* pMe)
{
// insert your code here for freeing any resources you have allocated...
// example to use for releasing each interface:
// if ( pMe->pIMenuCtl != NULL ) // check for NULL first
// {
// IMENUCTL_Release(pMe->pIMenuCtl); // release the interface
// pMe->pIMenuCtl = NULL; // set to NULL so no problems trying to free later
// }
//
IMENUCTL_Release(pMe->pIMenuCtl);
}
boolean g_init_menu(gmenu* pMe)
{
IImage *pImage;
AEEImageInfo imageInfo;
AEERect rect; //定义菜单显示的区域
CtlAddItem ai1,ai2,ai3,ai4; //定义 带图标菜单的结构
AEEMenuColors pc;
rect.x = 0;
rect.y = 0;
rect.dx = pMe->DeviceInfo.cxScreen; //全屏显示菜单
rect.dy = pMe->DeviceInfo.cyScreen;
pc.cSelBack=MAKE_RGB(255,255,255);
pc.cSelText=MAKE_RGB(255,0,0);
pc.cTitleText=MAKE_RGB(255,255,255);
pc.cFrame=MAKE_RGB(255,255,0);
DBGPRINTF("rect.dx is%d",rect.dx);
DBGPRINTF("rect.dy is%d",rect.dy);
pImage=ISHELL_LoadImage(pMe->a.m_pIShell,"gmenu.bci");
IIMAGE_GetInfo(pImage,&imageInfo);
IIMAGE_SetAnimationRate(pImage,10000);
IIMAGE_Start(pImage,50,110);
//IIMAGE_Release(pImage);
ISHELL_CreateInstance(pMe->pIShell,AEECLSID_MENUCTL,&pMe->pIMenuCtl); //创建菜单实例
IMENUCTL_SetColors (pMe->pIMenuCtl , &pc ) ;
//------定义一个带图标菜单-------
ai1.dwData =213;
ai1.pszResImage = GMENU_RES_FILE; //包含有菜单图标的资源文件名
ai1.pszResText = GMENU_RES_FILE; //包含有菜单文本字符串的资源文件名
ai1.wItemID = MY_MENU_ID_M1; //该菜单项的ID
ai1.wText = IDS_STRING_1001; //资源文件中菜单文本字符串的ID
ai1.wImage = IDI_OBJECT_5001; //资源文件中菜单图标的ID
ai1.pText = NULL;
ai1.pImage = NULL;
ai1.wFont = 0; //字体
//------定义一个带图标菜单-------
ai2.dwData =213;
ai2.pszResImage = GMENU_RES_FILE; //包含有菜单图标的资源文件名
ai2.pszResText = GMENU_RES_FILE; //包含有菜单文本字符串的资源文件名
ai2.wItemID = MY_MENU_ID_M2; //该菜单项的ID
ai2.wText = IDS_STRING_1002; //资源文件中菜单文本字符串的ID
ai2.wImage = IDI_OBJECT_5002; //资源文件中菜单图标的ID
ai2.pText = NULL;
ai2.pImage = NULL;
ai2.wFont = 0; //字体
ai3.dwData =213;
ai3.pszResImage = GMENU_RES_FILE; //包含有菜单图标的资源文件名
ai3.pszResText = GMENU_RES_FILE; //包含有菜单文本字符串的资源文件名
ai3.wItemID = MY_MENU_ID_M3; //该菜单项的ID
ai3.wText = IDS_STRING_1005; //资源文件中菜单文本字符串的ID
ai3.wImage = IDI_OBJECT_5003; //资源文件中菜单图标的ID
ai3.pText = NULL;
ai3.pImage = NULL;
ai3.wFont = 0; //字体
ai4.dwData =213;
ai4.pszResImage = GMENU_RES_FILE; //包含有菜单图标的资源文件名
ai4.pszResText = GMENU_RES_FILE; //包含有菜单文本字符串的资源文件名
ai4.wItemID = MY_MENU_ID_M4; //该菜单项的ID
ai4.wText = IDS_STRING_1003; //资源文件中菜单文本字符串的ID
ai4.wImage = IDI_OBJECT_5004; //资源文件中菜单图标的ID
ai4.pText = NULL;
ai4.pImage = NULL;
ai4.wFont = 0; //字体
//-------设置菜单的标题----------------
IMENUCTL_SetTitle(pMe->pIMenuCtl,GMENU_RES_FILE,IDS_STRING_1004,NULL);
//-------使用IMENUCTL_AddItem()函数添加两个不带图标的菜单----------------
// IMENUCTL_AddItem(pMe->pIMenuCtl,GMENU_RES_FILE,IDS_STRING_1001,MY_MENU_ID_M1,NULL,0);
// IMENUCTL_AddItem(pMe->pIMenuCtl,GMENU_RES_FILE,IDS_STRING_1002,MY_MENU_ID_M2,NULL,0);
// IMENUCTL_AddItem(pMe->pIMenuCtl,GMENU_RES_FILE,IDS_STRING_1005,MY_MENU_ID_M3,NULL,0);
// IMENUCTL_AddItem(pMe->pIMenuCtl,GMENU_RES_FILE,IDS_STRING_1003,MY_MENU_ID_M4,NULL,0);
//-------使用IMENUCTL_AddItemEx()函数添加1个带图标的菜单----------------
if (IMENUCTL_AddItemEx(pMe->pIMenuCtl,&ai1) == TRUE)
{
DBGPRINTF("icon menu item add success");
}else
{
DBGPRINTF("icon menu item add faild");
}
//-------使用IMENUCTL_AddItemEx()函数添加1个带图标的菜单----------------
if (IMENUCTL_AddItemEx(pMe->pIMenuCtl,&ai2) == TRUE)
{
DBGPRINTF("icon menu item add success");
}else
{
DBGPRINTF("icon menu item add faild");
}
//-------使用IMENUCTL_AddItemEx()函数添加1个带图标的菜单----------------
if (IMENUCTL_AddItemEx(pMe->pIMenuCtl,&ai3) == TRUE)
{
DBGPRINTF("icon menu item add success");
}else
{
DBGPRINTF("icon menu item add faild");
}
//-------使用IMENUCTL_AddItemEx()函数添加1个带图标的菜单----------------
if (IMENUCTL_AddItemEx(pMe->pIMenuCtl,&ai4) == TRUE)
{
DBGPRINTF("icon menu item add success");
}else
{
DBGPRINTF("icon menu item add faild");
}
IMENUCTL_EnableCommand(pMe->pIMenuCtl,TRUE);
IMENUCTL_SetRect(pMe->pIMenuCtl,&rect);
IMENUCTL_SetActive(pMe->pIMenuCtl,TRUE);
return TRUE;
}
void DrawStr(gmenu* pMe, uint16 DrawStringID)
{
AECHAR* pBuffer;
uint32 bufSize;
ISHELL_GetResSize(pMe->pIShell,GMENU_RES_FILE,DrawStringID,RESTYPE_STRING,&bufSize);
pBuffer = (AECHAR*)MALLOC(bufSize);
IDISPLAY_ClearScreen(pMe->pIDisplay);
ISHELL_LoadResString(pMe->pIShell,
GMENU_RES_FILE,
DrawStringID,
pBuffer,
bufSize);
IDISPLAY_DrawText(pMe->pIDisplay,
AEE_FONT_NORMAL,
pBuffer,
-1,50,50,
NULL,
IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);
IDISPLAY_Update(pMe->pIDisplay);
FREE(pBuffer);
}
/*void DrawTextById(gmenu *pMe,int16 nResID,int x,int y,RGBVAL rgb)
{
AECHAR* pBuffer;
uint32 bufSize;
ISHELL_GetResSize(pMe->pIShell,GMENU_RES_FILE,nResID,RESTYPE_STRING,&bufSize);
pBuffer = (AECHAR*)MALLOC(bufSize);
ISHELL_LoadResString(pMe->pIShell,GMENU_RES_FILE,nResID,pBuffer,
bufSize);
DrawTextByBuffer(pMe,pBuffer,x,y,rgb);
FREE(pBuffer);
}
void DrawTextByBuffer(gmenu *pMe,const AECHAR *pBuffer,int x,int y,RGBVAL rgb)
{
// IDISPLAY_SetByBuffer(pMe->pIDisplay,CLR_USER_TEXT.rgb);
IDISPLAY_DrawText(pMe->pIDisplay,AEE_FONT_NORMAL,pBuffer,-1,50,50,NULL,IDF_TEXT_TRANSPARENT);
}
void DrawTextCenterById(gmenu *pMe,int16 nResID,int y,RGBVAL rgb)
{
AECHAR* pBuffer;
uint32 bufSize;
ISHELL_GetResSize(pMe->pIShell,GMENU_RES_FILE,nResID,RESTYPE_STRING,&bufSize);
pBuffer=(AECHAR*)MALLOC(bufSize);
ISHELL_LoadResString(pMe->pIShell,GMENU_RES_FILE,nResID,pBuffer,bufSize);
DrawTextCenterByBuffer(pMe,pBuffer,y,rgb);
FREE(pBuffer);
}
void DrawTextCenterByBuffer(gmenu *pMe,const AECHAR *pBuffer,int y,RGBVAL rgb)
{
int width = IDISPLAY_MeasureText(pMe->pIDisplay,AEE_FONT_NORMAL,pBuffer);
DrawStr(pMe,pBuffer,(pMe->DeviceInfo.cxScreen-width)/2,y,rgb);
}*/
/*AEEMenuColors pc;
pc.cBack=MAKE_RGB(255,0,0)
IMENUCTL_SetColors ( pIMenuCtl, &pc ) ;*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -