初级会员
- 积分
- 178
- 金钱
- 178
- 注册时间
- 2018-8-12
- 在线时间
- 100 小时
|
1金钱
emwin 官方实验 ICONVIEW 移植遇到的问题
平台:战舰V3 屏幕:4.3寸电容屏
我目的是显示屏幕的上半部分,下半部分不知道从哪冒出来的,程序里面也没找着,难道是镜像,还是虚拟屏幕?
[mw_shl_code=applescript,true]
/*********************************************************************
*
* _aBitmapItem
*/
static const BITMAP_ITEM _aBitmapItem[] = {
{&_bmBrowser, "Browser" , "Use the browser to explore the www"},
{&_bmClock, "Clock" , "Adjust current time and date"},
{&_bmDate, "Date" , "Use the diary"},
{&_bmEmail, "Email" , "Read an email"},
{&_bmSystem, "System" , "Change system settings"},
{&_bmRead, "Read" , "Read a document"},
{&_bmWrite, "Write" , "Write an email"},
{&_bmPassword,"Password", "Determine the system password"},
{&_bmRemote, "Network" , "Select network"},
};
/*********************************************************************
*
* Private routines
*
**********************************************************************
*/
/*********************************************************************
*
* _cbWin
*/
static void _cbWin(WM_MESSAGE * pMsg) {
static int yPosToucan=20;
static int yAdd=1;
GUI_RECT Rect = {0, 0, 0, 0};
WM_HWIN hItem;
WM_HWIN hDlg;
int NCode;
int Id;
int Sel;
hDlg = pMsg->hWin;
switch (pMsg->MsgId) {
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc); // Id of widget
NCode = pMsg->Data.v; // Notification code
switch (Id) {
case GUI_ID_ICONVIEW0:
switch (NCode) {
case WM_NOTIFICATION_SEL_CHANGED:
/*
* Change widget text changing the selection
*/
Sel = ICONVIEW_GetSel(pMsg->hWinSrc);
hItem = WM_GetDialogItem(hDlg, GUI_ID_TEXT1);
TEXT_SetText(hItem, _aBitmapItem[Sel].pExplanation);
break;
}
break;
}
break;
case MSG_MOVE:
/*
* Move toucan position and invalidate toucan area
*/
yPosToucan += yAdd;
if (yPosToucan >= 100) {
yAdd = -yAdd;
yPosToucan = 100;
} else if (yPosToucan <= 20) {
yAdd = -yAdd;
yPosToucan = 20;
}
Rect.x0 = 146;
Rect.y0 = yPosToucan - 5;
Rect.x1 = Rect.x0 + _bmToucan.XSize - 1;
Rect.y1 = Rect.y0 + _bmToucan.YSize - 1 + 5;
WM_InvalidateRect(pMsg->hWin, &Rect);
break;
case WM_PAINT:
/*
* Draw background and toucan
*/
GUI_DrawBitmap(&_bmHund, 0, 0);
GUI_DrawBitmap(&_bmToucan, 146, yPosToucan);
break;
}
}
/*********************************************************************
*
* Public routines
*
**********************************************************************
*/
/*********************************************************************
*
* MainTask
*/
void MainTask(void) {
GUI_FONT Font;
WM_HWIN hWin;
WM_HWIN hText;
unsigned i;
int Add;
int Sel;
int TimeNextInc;
GUI_Init();
#if (!defined(WIN32))
if ((LCD_GetMirrorYEx(0) == 1) && (LCD_GetSwapXYEx(0) == 1) && (LCD_GetVXSizeEx(0) > LCD_GetXSizeEx(0))){
GUI_SetOrg(320, 0); // Temporarilly required, will be solved in future
}
#endif
WM_EnableMemdev(WM_HBKWIN);
WM_SetCallback(WM_HBKWIN, _cbWin);
/*
* Create title of sample
*/
hText = TEXT_CreateEx(0, 0, 320, 30, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_TEXT0, "emWin ICONVIEW sample");
TEXT_SetFont(hText, &GUI_Font24B_ASCII);
TEXT_SetTextAlign(hText, GUI_TA_HCENTER | GUI_TA_VCENTER);
TEXT_SetTextColor(hText, 0xFF4040);
/*
* Create explanation
*/
hText = TEXT_CreateEx(160, 40, 140, 100, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_TEXT1, "");
GUI_SIF_CreateFont(_acFramed24B, &Font, GUI_SIF_TYPE_PROP_FRM);
TEXT_SetFont(hText, &Font);
TEXT_SetTextColor(hText, GUI_WHITE);
TEXT_SetWrapMode(hText, GUI_WRAPMODE_WORD);
TEXT_SetTextAlign(hText, GUI_TA_HCENTER | GUI_TA_VCENTER);
/*
* Create iconview widget
*/
hWin = ICONVIEW_CreateEx(10, 30, 750,440, //在指定位置创建ICONVIEW
WM_HBKWIN, WM_CF_SHOW | WM_CF_HASTRANS,
ICONVIEW_CF_AUTOSCROLLBAR_V, GUI_ID_ICONVIEW0, 55, 60);
for (i = 0; i < GUI_COUNTOF(_aBitmapItem); i++) {
/*
* Add icons to the widget
*/
ICONVIEW_AddBitmapItem(hWin, _aBitmapItem.pBitmap, _aBitmapItem.pText);//向小工具添加新的位图图标
}
ICONVIEW_SetBkColor(hWin, ICONVIEW_CI_SEL, GUI_BLUE | 0xC0000000); //设置小工具额背景色
ICONVIEW_SetFont(hWin, &GUI_Font13B_ASCII);//设置要用于绘制图标标签的字体
WM_SetFocus(hWin); //输入焦点进入ICONVIEW
Add = 1;
Sel = 0;
TimeNextInc = GUI_GetTime() + 1000;
while (1) {
GUI_Delay(50);
WM_SendMessageNoPara(WM_HBKWIN, MSG_MOVE); // Message for moving the toucan
// if (GUI_GetTime() >= TimeNextInc) {
// TimeNextInc += 1000;
// if (Sel == 0) {
// Add = 1;
// } else if (Sel == (GUI_COUNTOF(_aBitmapItem) - 1)) {
// Add = -1;
// }
// Sel += Add;
// ICONVIEW_SetSel(hWin, Sel);
// }
}
}[/mw_shl_code]
[/mw_shl_code]
|
|