/********************************************************************* * * Client Callback */ static void FRAMEWIN__cbClient(WM_MESSAGE* pMsg) { WM_HWIN hWin = pMsg->hWin; WM_HWIN hParent = WM_GetParent(pMsg->hWin); FRAMEWIN_Obj* pObj = FRAMEWIN_H2P(hParent); WM_CALLBACK* cb = pObj->cb; switch (pMsg->MsgId) { case WM_PAINT: GUI_SetBkColor(pObj->ClientColor); GUI_Clear(); if (pObj->cb) { WM_MESSAGE msg; msg.hWin = hWin; msg.MsgId = WM_PAINT; (*pObj->cb)(&msg); } return; case WM_GET_FOCUSSED_CHILD: pMsg->Data.v = pObj->hFocussedChild; return; case WM_SET_FOCUS: if (pMsg->Data.v) { /* Focus received */ if (pObj->hFocussedChild) { WM_SendMessage(pObj->hFocussedChild, pMsg); } else { pObj->hFocussedChild = WM_SetFocusOnNextChild(hWin); } } return; case WM_KEY: if ( ((WM_KEY_INFO*)(pMsg->Data.p))->PressedCnt >0) { int Key = ((WM_KEY_INFO*)(pMsg->Data.p))->Key; switch (Key) { case GUI_KEY_TAB: pObj->hFocussedChild = WM_SetFocusOnNextChild(hWin); break; /* Send to parent by not doing anything */ } } break; case WM_NOTIFY_CHILD_HAS_FOCUS: pObj->hFocussedChild = pMsg->hWinSrc; if (pMsg->Data.v) { pObj->Widget.State |= WIDGET_STATE_CHILD_HAS_FOCUS; } else { pObj->Widget.State &= ~WIDGET_STATE_CHILD_HAS_FOCUS; } WM_InvalidateWindow(hParent); break; case WM_GET_BKCOLOR: pMsg->Data.Color = pObj->ClientColor; return; /* Message handled */ case WM_GETCLIENTRECT_ABS: /* return client window in absolute (screen) coordinates */ case WM_GET_CLIENT_WINDOW: /* return handle to client window. For most windows, there is no seperate client window, so it is the same handle */ WM_DefaultProc(pMsg); return; /* We are done ! */ } if (cb) { pMsg->hWin = hParent; (*cb)(pMsg); } }
/********************************************************************* * * WINDOW_Callback */ void WINDOW_Callback(WM_MESSAGE* pMsg) { WM_HWIN hObj; WINDOW_OBJ* pObj; WM_CALLBACK* cb; hObj = pMsg->hWin; pObj = WINDOW_H2P(hObj); cb = pObj->cb; switch (pMsg->MsgId) { case WM_HANDLE_DIALOG_STATUS: if (pMsg->Data.p) { /* set pointer to Dialog status */ pObj->pDialogStatus = (WM_DIALOG_STATUS*)pMsg->Data.p; } else { /* return pointer to Dialog status */ pMsg->Data.p = pObj->pDialogStatus; } return; case WM_SET_FOCUS: if (pMsg->Data.v) { /* Focus received */ if (pObj->hFocussedChild && (pObj->hFocussedChild != hObj)) { WM_SetFocus(pObj->hFocussedChild); } else { pObj->hFocussedChild = WM_SetFocusOnNextChild(hObj); } pMsg->Data.v = 0; /* Focus change accepted */ } return; case WM_GET_ACCEPT_FOCUS: WIDGET_HandleActive(hObj, pMsg); return; case WM_NOTIFY_CHILD_HAS_FOCUS: _OnChildHasFocus(hObj, pObj, pMsg); return; case WM_KEY: if (((const WM_KEY_INFO*)(pMsg->Data.p))->PressedCnt > 0) { int Key = ((const WM_KEY_INFO*)(pMsg->Data.p))->Key; switch (Key) { case GUI_KEY_BACKTAB: pObj->hFocussedChild = WM_SetFocusOnPrevChild(hObj); break; /* Send to parent by not doing anything */ case GUI_KEY_TAB: pObj->hFocussedChild = WM_SetFocusOnNextChild(hObj); break; /* Send to parent by not doing anything */ } } break; case WM_PAINT: LCD_SetBkColor(WINDOW__DefaultBkColor); GUI_Clear(); break; case WM_GET_BKCOLOR: pMsg->Data.Color = WINDOW__DefaultBkColor; return; /* Message handled */ } if (cb) { (*cb)(pMsg); } else { WM_DefaultProc(pMsg); } }
/********************************************************************* * * xCreateDialogBoxArray */ WM_HWIN xCreateDialogBoxArray(const xDIALOGBOX_Obj* paDialogBox, int NumDialogBox, WM_CALLBACK* cb, WM_HWIN hParent, int x0, int y0) { WM_HWIN hDialog; WM_HWIN hDialogClient; if((NumDialogBox <= 0) || (paDialogBox==NULL) || (paDialogBox->paWidget->pfCreateIndirect==NULL) )return 0; //Creat Parent Window DEBUGOUT("xCreateDialogBoxArray: Create Parent Win\r\n"); hDialog = paDialogBox->paWidget->pfCreateIndirect(paDialogBox->paWidget, hParent, x0, y0, cb); /* Create parent window */ hDialogClient = WM_GetClientWindow(hDialog); WIDGET_OrState(hDialog, paDialogBox->paWidget->Flags); WM_ShowWindow(hDialog); WM_ShowWindow(hDialogClient); while (--NumDialogBox > 0) { WM_HWIN hChildDialog; paDialogBox++; DEBUGOUT("xCreateDialogBoxArray: Create Child DownCounter:%d\r\n", NumDialogBox); hChildDialog = GUI_CreateDialogBox(paDialogBox->paWidget, paDialogBox->NumWidgets, paDialogBox->cb, hDialogClient, 0, 0); /* Create child Dialog */ WM_ShowWindow(hChildDialog); } DEBUGOUT("xCreateDialogBoxArray: Create Child DownCounter:%d\r\n", NumDialogBox); DEBUGOUT("xCreateDialogBoxArray: Create Child OK\r\n", NumDialogBox); WM_SetFocusOnNextChild(hDialog); /* Set the focus to the first child */ WM_SendMessageNoPara(hDialogClient, WM_INIT_DIALOG); return hDialog; }
/********************************************************************* * * GUI_CreateDialogbox */ WM_HWIN GUI_CreateDialogBox(const GUI_WIDGET_CREATE_INFO* paWidget, int NumWidgets, WM_CALLBACK* cb, WM_HWIN hParent, int x0, int y0) { WM_HWIN hDialog, hDialogClient; hDialog = paWidget->pfCreateIndirect(paWidget, hParent, x0, y0, cb); /* Create parent window */ if (!hDialog) { return 0; } hDialogClient = WM_GetClientWindow(hDialog); WIDGET_OrState(hDialog, paWidget->Flags); WM_ShowWindow(hDialog); WM_ShowWindow(hDialogClient); while (--NumWidgets > 0) { WM_HWIN hChild; paWidget++; hChild = paWidget->pfCreateIndirect(paWidget, hDialogClient, 0, 0, 0); /* Create child window */ if (!hChild) { WM_DeleteWindow(hDialog); return 0; } WM_ShowWindow(hChild); } WM_SetFocusOnNextChild(hDialog); /* Set the focus to the first child */ WM_SendMessageNoPara(hDialogClient, WM_INIT_DIALOG); return hDialog; }
/********************************************************** * _OnKey * */ static void _OnKey(SLIDER_Handle hObj, WM_MESSAGE * pMsg) { const WM_KEY_INFO * pKeyInfo; int Key; pKeyInfo = (const WM_KEY_INFO*)(pMsg->Data.p); Key = pKeyInfo->Key; if(pKeyInfo->PressedCnt > 0) { switch(Key) { case GUI_KEY_RIGHT: HSD_SLIDER_Inc(hObj); break; case GUI_KEY_LEFT: HSD_SLIDER_Dec(hObj); break; case GUI_KEY_UP: WM_SetFocusOnPrevChild(WM_GetParent(pMsg->hWin)); break; case GUI_KEY_DOWN: WM_SetFocusOnNextChild(WM_GetParent(pMsg->hWin)); break; case GUI_KEY_MOVE: default: SLIDER_Callback(pMsg); break ; } } }
/** * 函 数 名: _cbSysInfo(WM_MESSAGE* pMsg) * 描 述: 显示系统信息 * 参 数: pMsg * 返 回 值: 无 */ void _cbSysInfo(WM_MESSAGE* pMsg) { BUTTON_Handle ReurnButton; WM_HWIN hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_CREATE: /* 设置聚焦*/ WM_SetFocus(hWin); /* 创建返回按键按钮 */ ReurnButton = BUTTON_CreateEx(118,174,94, 52, hWin, WM_CF_SHOW, 0, SYS_INFO_BUTTON_RETURN); BUTTON_SetBitmapEx(ReurnButton,BUTTON_BI_UNPRESSED, &bmSys_return_xg, 0 ,0); BUTTON_SetBitmapEx(ReurnButton,BUTTON_BI_PRESSED, &bmSys_return, 0 ,0); break; case WM_KEY: /* 按下某个键后发送到当前包含焦点的窗口*/ switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) { case GUI_KEY_ESCAPE: GUI_EndDialog(hWin, 1); break; case GUI_KEY_TAB: WM_SetFocusOnNextChild(hWin); break; } break; case WM_PAINT: GUI_SetBkColor(BK_COLOR_2); GUI_Clear(); GUI_UC_SetEncodeNone(); GUI_SetFont(&GUI_FontHZ16); GUI_DispStringAt("MODEL:7H3DFDM-FW ",30,20); GUI_DispStringAt("VERSION: V0.01",30,50); GUI_DispStringAt("SYSINFO: IN TEST ",30,80); GUI_DispStringAt(__DATE__ " " __TIME__,50,110); GUI_UC_SetEncodeUTF8(); //_ShowBMPEx("1.bmp"); break; case WM_NOTIFY_PARENT: if (pMsg->Data.v == WM_NOTIFICATION_RELEASED) { int Id = WM_GetId(pMsg->hWinSrc); switch (Id) { case SYS_INFO_BUTTON_RETURN: _DeleteFrame(); _CreateFrame(&_cbSysSet); break; } } break; default: WM_DefaultProc(pMsg); } }
/** * 函 数 名: _cbChooseFrame(WM_MESSAGE* pMsg) * 描 述: 选择对话框 * 参 数: pMsg * 返 回 值: 无 */ void _cbChooseFrame(WM_MESSAGE* pMsg) { BUTTON_Handle YesButton,NoButton,CancelButton; WM_HWIN hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_CREATE: /* 设置聚焦*/ WM_SetFocus(hWin); /* 创建返回按键按钮 */ YesButton = BUTTON_CreateEx(80,80,30, 15, hWin, WM_CF_SHOW, 0, SYS_INFO_BUTTON_RETURN); //BUTTON_SetBitmapEx(YesButton,BUTTON_BI_UNPRESSED, &bmSys_return_xg, 0 ,0); break; case WM_KEY: /* 按下某个键后发送到当前包含焦点的窗口*/ switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) { case GUI_KEY_ESCAPE: GUI_EndDialog(hWin, 1); break; case GUI_KEY_TAB: WM_SetFocusOnNextChild(hWin); break; } break; case WM_PAINT: GUI_SetBkColor(BK_COLOR_2); GUI_Clear(); // GUI_SetFont(&GUI_FontHZ16); // GUI_DispStringAt("firmware version : V0.01",30,30); // GUI_DispStringAt("Compile time: ",30,80); // GUI_DispStringAt(STRING_VERSION_CONFIG_H,50,130); //_ShowBMPEx("1.bmp"); break; case WM_NOTIFY_PARENT: if (pMsg->Data.v == WM_NOTIFICATION_RELEASED) { int Id = WM_GetId(pMsg->hWinSrc); switch (Id) { case SYS_INFO_BUTTON_RETURN: _DeleteFrame(); _CreateFrame(&_cbSysSet); break; } } break; default: WM_DefaultProc(pMsg); } }
/********************************************************************* * * _cbBkWin */ static void _cbBkWin(WM_MESSAGE * pMsg) { const WM_KEY_INFO * pKeyInfo; int NCode; int Id; switch (pMsg->MsgId) { case WM_KEY: pKeyInfo = (const WM_KEY_INFO*)pMsg->Data.p; if (pKeyInfo->PressedCnt > 0) { switch (pKeyInfo->Key) { case GUI_KEY_TAB: WM_SetFocusOnNextChild(pMsg->hWin); break; case GUI_KEY_BACKTAB: WM_SetFocusOnPrevChild(pMsg->hWin); break; case GUI_KEY_ESCAPE: _Break = 1; break; } } break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); // Id of widget NCode = pMsg->Data.v; // Notification code switch (NCode) { case WM_NOTIFICATION_RELEASED: // React only if released switch (Id) { case GUI_ID_BUTTON0: _AppSelection = APP_DASHBOARD; break; case GUI_ID_BUTTON1: _AppSelection = APP_CASHTERMINAL; break; } break; } break; case WM_PAINT: GUI_DrawGradientV(0, 0, 639, 479, GUI_BLUE, GUI_BLACK); GUI_SetFont(&GUI_FontAA2_32); GUI_SetTextMode(GUI_TM_TRANS); GUI_SetColor(GUI_WHITE); GUI_DispStringHCenterAt("emWin VGA Demonstration\n", 400, 44); GUI_SetFont(&GUI_FontAA2_21); GUI_DispStringHCenterAt("Press the 'Dashboard' or the 'Cash Terminal'\nbutton to start one of the applications\n", 320, 150); GUI_DrawBitmap(&bmSeggerLogo, 30, 30); break; } }
void _cbWindowSetting(WM_MESSAGE* pMsg) { WM_HWIN hWin = pMsg->hWin; WM_HWIN _edit0; WM_HWIN _edit1; int edit_id = 256; int VALUE; int i = 0; switch (pMsg->MsgId) { case WM_CREATE: WIDGET_SetDefaultEffect (&WIDGET_Effect_None); EDIT_SetDefaultTextAlign(GUI_TA_HCENTER | GUI_TA_VCENTER); EDIT_SetDefaultFont(&GUI_Font28); EDIT_CreateEx(200,60,62,30,hWin,WM_CF_SHOW,0,GUI_ID_EDIT0,1);//夜间模式 EDIT_CreateEx(150,110,62,30,hWin,WM_CF_SHOW,0,GUI_ID_EDIT1,1);//音量 EDIT_CreateEx(150,160,62,30,hWin,WM_CF_SHOW,0,GUI_ID_EDIT2,1);//亮度 EDIT_CreateEx(150,210,62,30,hWin,WM_CF_SHOW,0,GUI_ID_EDIT3,2);//时区 EDIT_CreateEx(240,260,62,30,hWin,WM_CF_SHOW,0,GUI_ID_EDIT4,1);//报警音1 EDIT_CreateEx(170,310,62,30,hWin,WM_CF_SHOW,0,GUI_ID_EDIT5,1);//按键音1 EDIT_CreateEx(200,360,62,30,hWin,WM_CF_SHOW,0,GUI_ID_EDIT6,1);//单位显示 EDIT_CreateEx(200,410,62,30,hWin,WM_CF_SHOW,0,GUI_ID_EDIT7,1);//船形显示 for (i = 0; i < 8; i++) { _edit0 = WM_GetDialogItem(hWin, GUI_ID_EDIT0 + i); EDIT_SetText(_edit0,"0"); EDIT_SetpfAddKeyEx (_edit0,_cbEditAddKey); EDIT_SetBkColor(_edit0,1,GUI_LIGHTBLUE); EDIT_SetBkColor(_edit0,0,GUI_WHITE); } break; case WM_PAINT: GUI_SetBkColor (GUI_LIGHTBLUE); GUI_Clear(); for (i = 0; i < 8; i++) { _edit0 = WM_GetDialogItem(hWin, GUI_ID_EDIT0 + i); EDIT_SetTextColor(_edit0,0,GUI_BLACK); } EDIT_SetTextColor (WM_GetDialogItem(hWin, edit_id),0,GUI_WHITE); GUI_SetTextMode(GUI_TEXTMODE_TRANS); GUI_SetColor (GUI_BLACK); GUI_SetFont (&GUI_Font28); GUI_DispStringAt ("系统设置",230,10); GUI_DispStringAt ("01:夜间模式:",5,60); GUI_DispStringAt ("02:音量:",5,110); GUI_DispStringAt ("03:亮度:",5,160); GUI_DispStringAt ("04:时区:",5,210); GUI_DispStringAt ("05:报警音选择:",5,260); GUI_DispStringAt ("06:按键音:",5,310); GUI_DispStringAt ("07:单位设置:",5,360); GUI_DispStringAt ("08:船位显示:",5,410); GUI_DispStringAt ("09:船迹存储时间:",330,60); GUI_DispStringAt ("10:软件更新:",330,110); GUI_DispStringAt ("11:系统版本:",330,160); GUI_SetColor (GUI_WHITE); GUI_SetPenSize(2); GUI_DrawLine(1,50,1,470); GUI_DrawLine(1,50,673,50); GUI_DrawLine(673,50,673,470); GUI_DrawLine(1,470,673,470); break; case WM_KEY: switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) { case GUI_KEY_TAB: //判断当前焦点所在的位置,将焦点移至下一个窗口 downlistfocus++; if (downlistfocus == 369) downlistfocus = 384; if (downlistfocus == 388) downlistfocus = 256; if (downlistfocus == 257) downlistfocus = 368; //设置焦点 WM_SetFocus(WM_GetDialogItem (hWin, downlistfocus)); break; case GUI_KEY_BACKTAB: //判断当前焦点所在的位置,将焦点移至上一个窗口 downlistfocus--; if (downlistfocus == 383) downlistfocus = 368; if (downlistfocus == 367) downlistfocus = 256; if (downlistfocus == 255) downlistfocus = 387; //设置焦点 WM_SetFocus (WM_GetDialogItem(hWin, downlistfocus)); break; case GUI_KEY_RIGHT: break; case GUI_KEY_F1: break; case GUI_KEY_F2: break; case GUI_KEY_SPACE: printf ("ddsf"); break; case GUI_KEY_ENTER: break; case GUI_KEY_UP: break; case GUI_KEY_DOWN: WM_SetFocusOnNextChild(hWin); //edit_id ++; break; case GUI_KEY_LEFT: menufocus -= 5; focuschange = 0; WM_SetFocus(WM_GetDialogItem (hDlg_Menu, menufocus)); WM_Paint(hDlg_Menu); break; case GUI_KEY_MENU: WM_BringToTop (hDlg_FishMap); WM_SetFocus (hDlg_FishMap); menufocus = 368; break; } break; default: WM_DefaultProc(pMsg); } }
void _cbSysSet(WM_MESSAGE* pMsg) { int i=0; BUTTON_Handle SysInfoButton,MonitCalibraButton,SetDefaultButton,ReturnButton; WM_HWIN hWin = pMsg->hWin; WM_HWIN hItem; switch (pMsg->MsgId) { case WM_CREATE: /* 设置聚焦*/ WM_SetFocus(hWin); /* 创建四个图片按钮 */ SysInfoButton = BUTTON_CreateEx(11, 44, 94, 94, hWin, WM_CF_SHOW, 0, SYS_BUTTON_INFO); BUTTON_SetBitmapEx(SysInfoButton,BUTTON_BI_UNPRESSED, &bmSys_info_xg, 0 ,0); BUTTON_SetBitmapEx(SysInfoButton,BUTTON_BI_PRESSED, &bmSys_info, 0 ,0); MonitCalibraButton = BUTTON_CreateEx(111, 44, 94, 94, hWin, WM_CF_SHOW, 0, SYS_BUTTON_MONIT); BUTTON_SetBitmapEx(MonitCalibraButton,BUTTON_BI_UNPRESSED, &bmSys_moniter_xg, 0 ,0); BUTTON_SetBitmapEx(MonitCalibraButton,BUTTON_BI_PRESSED, &bmSys_moniter, 0 ,0); SetDefaultButton = BUTTON_CreateEx(211, 44, 94, 94 ,hWin, WM_CF_SHOW, 0, SYS_BUTTON_DEFAULT); BUTTON_SetBitmapEx(SetDefaultButton,BUTTON_BI_UNPRESSED, &bmSys_default_xg, 0 ,0); BUTTON_SetBitmapEx(SetDefaultButton,BUTTON_BI_PRESSED, &bmSys_default, 0 ,0); ReturnButton = BUTTON_CreateEx(116, 170, 94, 52, hWin, WM_CF_SHOW, 0, SYS_BUTTON_RETURN); BUTTON_SetBitmapEx(ReturnButton,BUTTON_BI_UNPRESSED, &bmSys_return_xg, 0 ,0); BUTTON_SetBitmapEx(ReturnButton,BUTTON_BI_PRESSED, &bmSys_return, 0 ,0); break; case WM_KEY: /* 按下某个键后发送到当前包含焦点的窗口*/ switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) { case GUI_KEY_ESCAPE: GUI_EndDialog(hWin, 1); break; case GUI_KEY_TAB: WM_SetFocusOnNextChild(hWin); break; } break; case WM_PAINT: GUI_SetBkColor(BK_COLOR_2); GUI_Clear(); break; case WM_NOTIFY_PARENT: if (pMsg->Data.v == WM_NOTIFICATION_RELEASED) { int Id = WM_GetId(pMsg->hWinSrc); switch (Id) { case SYS_BUTTON_INFO: _DeleteFrame(); _CreateFrame(&_cbSysInfo); break; case SYS_BUTTON_MONIT: /* ts_calibrate是属于是循环函数,关闭 TIM_TOUCH 避免不要 的扫描坐标,以免影响GUI的运行 */ TIM_Cmd(TIM_TOUCH,DISABLE); ts_calibrate(); _DeleteFrame(); _CreateFrame(&_cbSysSet); TIM_Cmd(TIM_TOUCH,ENABLE); break; case SYS_BUTTON_WIFI: break; case SYS_BUTTON_DEFAULT: /* 增加对话框机制*/ _hWarningDlg = CreateSetDefaultWaring(); break; case SYS_BUTTON_LANGUAGE: break; case SYS_BUTTON_RETURN: _DeleteFrame(); _CreateFrame(&_cbIndex); break; } } break; default: WM_DefaultProc(pMsg); } }