void UseKeyBoard(WM_MESSAGE * pMsg,int id_lenth,int id_base,int id,EWorkState front_state) { float mid; if(!keyboard_h.use_now) { keyboard_h.use_now = 1; keyboard_h.work_state = front_state; WidgetLock(pMsg->hWin,LOCK,id_lenth,id_base,id); KeyBoard_Win(&keyboard_h); WidgetLock(pMsg->hWin,UNLOCK,id_lenth,id_base,id); if(front_state == CHINESE){ EDIT_SetFont(WM_GetDialogItem(pMsg->hWin, id), &GUI_FontHZ_SongTi_16); } else if((front_state == ENGLISH_S)||(front_state == ENGLISH_B)){ EDIT_SetFont(WM_GetDialogItem(pMsg->hWin, id), &GUI_Font16_ASCII); }else if(front_state == SFLOAT){ EDIT_SetFloatMode(WM_GetDialogItem(pMsg->hWin, id),0.0,-9000,9999,1,0); } if(front_state != SFLOAT) { EDIT_SetText(WM_GetDialogItem(pMsg->hWin, id), keyboard_h.res_ch_data_head); }else{ EDIT_SetFloatValue(WM_GetDialogItem(pMsg->hWin, id),atof(keyboard_h.res_ch_data_head)); } keyboard_h.use_now = 0; } }
int _ExecKeyboard(void) { int i; int Key; BUTTON_Handle ahButton[52]; BUTTON_Handle hButtonESC; EDIT_Handle hEdit; GUI_RECT rText = {000,0, LCD_XSIZE, 20}; GUI_SetBkColor(GUI_BLUE); GUI_Clear(); GUI_DrawBitmap(&bmMicriumLogo, 0, 0); GUI_SetFont(&GUI_Font16B_1); GUI_SetColor(GUI_WHITE); GUI_DispStringInRect("µC/GUI", &rText, GUI_TA_RIGHT | GUI_TA_VCENTER); rText.y0 +=20; rText.y1 +=20; GUI_DispStringInRect("Touch screen demo", &rText, GUI_TA_RIGHT | GUI_TA_VCENTER); /* Create Keyboard Buttons */ for (i=0; i< 51; i++) { int Pos = (i < 47) ? i : i+4; int x0 = 5 + 28*(Pos%11); int y0 = 100 + 28*(Pos/11); char c = _acText[i]; int Id = c ? c : 1; char ac[2] = {0}; char *s= ac; ac[0] = c; ahButton[i] = BUTTON_Create( x0, y0, 25, 25, Id,BUTTON_CF_SHOW ); BUTTON_SetText (ahButton[i], s); #if GUI_SUPPORT_MEMDEV BUTTON_EnableMemdev(ahButton[i]); #endif } ahButton[i] = BUTTON_Create( 89, 212, 109, 25, ' ',BUTTON_CF_SHOW ); hButtonESC = BUTTON_Create( 230, 40, 80, 25, GUI_ID_CANCEL,BUTTON_CF_SHOW ); BUTTON_SetText (hButtonESC, "ESC"); hEdit = EDIT_Create( 5, 70, 310, 25, ' ', 80, 0 ); EDIT_SetFont(hEdit, &GUI_Font8x16); BUTTON_SetBkColor(ahButton[49], 0, GUI_RED); BUTTON_SetBkColor(ahButton[50], 0, GUI_BLUE); /* Handle Keyboard until ESC or ENTER is pressed */ do { Key = GUIDEMO_WaitKey(); switch (Key) { case 0: case GUI_ID_CANCEL: break; default: EDIT_AddKey(hEdit, Key); } } while ((Key != 'N') && (Key!=GUI_ID_CANCEL) && (Key!=0)); /* Cleanup */ for (i=0; i< countof(ahButton); i++) { BUTTON_Delete(ahButton[i]); } BUTTON_Delete(hButtonESC); EDIT_Delete(hEdit); return Key; }
int _ExecKeyboard(void) { int y0 = 75; int XSize = LCD_GetXSize(); int YSize = LCD_GetYSize(); int XStep = XSize / 4; int YStep = (YSize - y0) / 4; int i; int Key; BUTTON_Handle ahButton[16]; BUTTON_Handle hButtonESC; EDIT_Handle hEdit; GUI_RECT rText = {0}; rText.x1 = LCD_GetXSize() - 3; rText.y1 = 20; GUI_SetBkColor(GUI_BLUE); GUI_Clear(); GUI_SetFont(&GUI_FontComic18B_ASCII); GUI_SetColor(GUI_WHITE); GUI_DispStringInRect("µC/GUI", &rText, GUI_TA_RIGHT | GUI_TA_VCENTER); rText.y0 +=20; rText.y1 +=20; GUI_DispStringInRect("Touch screen demo", &rText, GUI_TA_RIGHT | GUI_TA_VCENTER); /* Create Keyboard Buttons */ for (i=0; _acText[i]; i++) { int XPos = (i%4) * XStep + 3; int YPos = (i/4) * YStep + 3 + y0; char c = _acText[i]; int Id = c ? c : 1; char ac[2] = {0}; char *s= ac; ac[0] = c; ahButton[i] = BUTTON_Create( XPos, YPos, XStep - 5, YStep - 5, Id, BUTTON_CF_SHOW ); BUTTON_SetText(ahButton[i], s); BUTTON_EnableMemdev(ahButton[i]); } hButtonESC = BUTTON_Create( 3, 3, 80, 25, GUI_ID_CANCEL, BUTTON_CF_SHOW ); BUTTON_SetText(hButtonESC, "ESC"); hEdit = EDIT_Create( 5, y0 - 30, XSize - 10, 25, ' ', 80, 0 ); EDIT_SetFont(hEdit, &GUI_Font8x16); /* Handle Keyboard until ESC or ENTER is pressed */ do { Key = GUIDEMO_WaitKey(); switch (Key) { case 0: case GUI_ID_CANCEL: break; default: EDIT_AddKey(hEdit, Key); } } while ((Key != 'N') && (Key!=GUI_ID_CANCEL) && (Key!=0)); /* Cleanup */ for (i=0; i< countof(ahButton); i++) { BUTTON_Delete(ahButton[i]); } BUTTON_Delete(hButtonESC); EDIT_Delete(hEdit); return Key; }
void InitDialog_Cus(WM_MESSAGE * pMsg) { WM_HWIN hWin = pMsg->hWin; // //GUI_ID_TEXT_USER // TEXT_SetFont(WM_GetDialogItem(hWin,GUI_ID_TEXT_USER),&GUI_FontHZ_SongTi_16); EDIT_SetFont(WM_GetDialogItem(hWin,GUI_ID_EDIT_USER),&GUI_FontHZ_SongTi_16); TEXT_SetFont(WM_GetDialogItem(hWin,GUI_ID_TEXT_MODLE),&GUI_FontHZ_SongTi_16); EDIT_SetMaxLen(WM_GetDialogItem(hWin,GUI_ID_EDIT_USER),500); // //GUI_ID_TEXT_E_PROD // TEXT_SetFont(WM_GetDialogItem(hWin,GUI_ID_TEXT_E_PROD),&GUI_FontHZ_SongTi_16); EDIT_SetFont(WM_GetDialogItem(hWin,GUI_ID_EDIT_E_PROD),&GUI_FontHZ_SongTi_16); EDIT_SetMaxLen(WM_GetDialogItem(hWin,GUI_ID_EDIT_E_PROD),500); // //GUI_ID_TEXT_MODLE // TEXT_SetFont(WM_GetDialogItem(hWin,GUI_ID_TEXT_L_PROD),&GUI_FontHZ_SongTi_16); EDIT_SetFont(WM_GetDialogItem(hWin,GUI_ID_EDIT_L_PROD),&GUI_FontHZ_SongTi_16); EDIT_SetMaxLen(WM_GetDialogItem(hWin,GUI_ID_EDIT_L_PROD),500); // //GUI_ID_TEXT0 // TEXT_SetFont(WM_GetDialogItem(hWin,GUI_ID_TEXT_L_MODE),&GUI_FontHZ_SongTi_16); // // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON_HOME),&GUI_FontHZ_SongTi_16); EDIT_SetMaxLen(WM_GetDialogItem(hWin,GUI_ID_EDIT_L_MODE),500); EDIT_SetMaxLen(WM_GetDialogItem(hWin,GUI_ID_EDIT_MODLE),500); // EDIT_SetText(WM_GetDialogItem(hWin,GUI_ID_EDIT_USER),custormer.custorm); EDIT_SetText(WM_GetDialogItem(hWin,GUI_ID_EDIT_E_PROD),custormer.elevator_productor); EDIT_SetText(WM_GetDialogItem(hWin,GUI_ID_EDIT_MODLE),custormer.series_no); EDIT_SetText(WM_GetDialogItem(hWin,GUI_ID_EDIT_L_PROD),custormer.limitor_productor); EDIT_SetText(WM_GetDialogItem(hWin,GUI_ID_EDIT_L_MODE),custormer.limitor_series); }
/*---------------------------------------------------------------------------* * Routine: _cbDialog *---------------------------------------------------------------------------* * Description: * Callback function used by emWin to process events for the active window. * Inputs: * WM_MESSAGE *pMsg -- message structure for current dialog. *---------------------------------------------------------------------------*/ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int Id, NCode; T_keyboardMapping *p = G_keypadCurrentMapping; switch (pMsg->MsgId) { case WM_INIT_DIALOG: // // Initialization of 'Window' // hItem = pMsg->hWin; G_window = hItem; WINDOW_SetBkColor(hItem, KEYBOARD_BACKGROUND_COLOR); //BUTTON_SetDefaultBkColor(KEY_BACKGROUND_COLOR, BUTTON_CI_UNPRESSED); EDIT_SetDefaultFont(&KEYBOARD_DEFAULT_FONT); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_BOX); EDIT_SetMaxLen(hItem, MAX_NUMBER_OF_CHARS); EDIT_SetText(hItem, G_textBox); EDIT_SetFont(hItem, &KEYBOARD_DEFAULT_FONT); G_textBoxIndex = EDIT_GetNumChars(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_MESSAGE); TEXT_SetFont(hItem, &KEYBOARD_DEFAULT_FONT); TEXT_SetTextColor(hItem, GUI_BLACK); TEXT_SetBkColor(hItem, KEYBOARD_BACKGROUND_COLOR); TEXT_SetText(hItem, G_message); TEXT_SetTextAlign(hItem, GUI_TA_TOP); while (p->iID) { hItem = WM_GetDialogItem(pMsg->hWin, p->iID); BUTTON_SetFont(hItem, &KEYBOARD_DEFAULT_FONT); BUTTON_SetTextColor(hItem, BUTTON_CI_UNPRESSED, GUI_BLACK); BUTTON_SetTextColor(hItem, BUTTON_CI_PRESSED, GUI_BLACK); BUTTON_SetBkColor(hItem, BUTTON_CI_UNPRESSED, KEY_BACKGROUND_COLOR); BUTTON_SetBkColor(hItem, BUTTON_CI_PRESSED, GUI_LIGHTGRAY); //BUTTON_SetSkin(hItem, BUTTON_SKIN_FLEX); p++; } WM_MakeModal(pMsg->hWin); setNewButtonText(pMsg, 0, 0); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; if (!IKeyboardHandleEvent(pMsg, NCode, Id)) { // Special cases go here // Nothing happens otherwise } case WM_POST_PAINT: // Make sure the all presses up til now are gone TouchscreenClearPresses(); break; default: WM_DefaultProc(pMsg); break; } }
/********************************************************************* * * MainTask */ void MainTask(void) { EDIT_Handle hEdit; GUI_Init(); WM_SetCallback(WM_HBKWIN, _cbBk); hEdit = EDIT_CreateEx(50, 110, 220, 25, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_EDIT0, TEXT_MAXLEN); WM_SetCallback(hEdit, _cbEdit); EDIT_SetText(hEdit, "Press <ENTER> when done..."); EDIT_SetFont(hEdit, &GUI_Font8x16); EDIT_SetTextColor(hEdit, 0, GUI_RED); EDIT_EnableBlink(hEdit, 300, 1); while (1) { GUI_Delay(10); } }
static void CreateCalculator(WM_HWIN hWin) { int y0 = 55; int XSize = LCD_GetXSize(); int YSize = LCD_GetYSize(); int XStep = XSize / 5; int YStep = (YSize - y0 - 25) / 4; char ac[2]; char *s=NULL; int XPos,YPos; int i = 0; for (i = 0; i < 19; i++) { if (i == 14) i = 15; XPos = (i % 5) * XStep + 3; YPos = (i / 5) * YStep + 3 + y0; memset(&ac, 0, sizeof(char)* 2); s = ac; ac[0] = _acText[i]; if (i == 18) { hButton[i] = BUTTON_CreateAsChild(XPos, YPos, XStep * 2 - 5, YStep - 5, hWin, _acText[i], WM_CF_SHOW); } else if (i == 9) hButton[i] = BUTTON_CreateAsChild(XPos, YPos, XStep - 5, YStep * 2 - 5, hWin, _acText[i], WM_CF_SHOW); else hButton[i] = BUTTON_CreateAsChild(XPos, YPos, XStep - 5, YStep - 5, hWin, _acText[i], WM_CF_SHOW); BUTTON_SetBkColor(hButton[i], BUTTON_CI_UNPRESSED, 0x50A0FF); BUTTON_SetBkColor(hButton[i], BUTTON_CI_PRESSED, 0x004080); BUTTON_SetTextColor(hButton[i], BUTTON_CI_UNPRESSED, GUI_WHITE); BUTTON_SetTextColor(hButton[i], BUTTON_CI_PRESSED, GUI_WHITE); BUTTON_SetFont(hButton[i], &GUI_Font24B_ASCII); if (i == 18) { BUTTON_SetText(hButton[i], "EXIT"); } else BUTTON_SetText(hButton[i], s); } hEdit = EDIT_CreateAsChild(0, 0, 320, 50, hWin, 0, WM_CF_SHOW, 80); EDIT_SetTextColor(hEdit, 0, 0x0080FF); EDIT_SetFont(hEdit, &GUI_Font24B_ASCII); EDIT_SetBkColor(hEdit, 0, GUI_RED); }
void OnxxxClicked_Lprod(WM_MESSAGE * pMsg) { if(!keyboard_h.use_now) { keyboard_h.use_now = 1; keyboard_h.work_state = CHINESE; WidgetLock(pMsg->hWin,LOCK,10,GUI_ID_USER,GUI_ID_EDIT_L_PROD); KeyBoard_Win(&keyboard_h); WidgetLock(pMsg->hWin,UNLOCK,10,GUI_ID_USER,GUI_ID_EDIT_L_PROD); EDIT_SetFont(WM_GetDialogItem(pMsg->hWin, GUI_ID_EDIT_L_PROD), &GUI_FontHZ_SongTi_16); EDIT_SetText(WM_GetDialogItem(pMsg->hWin, GUI_ID_EDIT_L_PROD), keyboard_h.res_ch_data_head); keyboard_h.use_now = 0; } }
/******************************************************************* * * _DemoEdit * Edit a string until ESC or ENTER is pressed */ static void _DemoEdit(void) { EDIT_Handle hEdit; char aBuffer[28]; int Key; GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("WIDGET_Edit - Sample", 160, 5); GUI_SetFont(&GUI_Font8x16); GUI_DispStringHCenterAt("Use keyboard to modify string...", 160, 90); /* Create edit widget */ hEdit = EDIT_Create( 50, 110, 220, 25, ' ', sizeof(aBuffer), WM_CF_SHOW); /* Modify edit widget */ EDIT_SetText(hEdit, "Press <ENTER> when done..."); EDIT_SetFont(hEdit, &GUI_Font8x16); EDIT_SetTextColor(hEdit, 0, GUI_RED); /* Set keyboard focus to edit widget */ WM_SetFocus(hEdit); /* Handle keyboard until ESC or ENTER is pressed */ do { WM_Exec(); Key = GUI_GetKey(); } while ((Key != GUI_KEY_ENTER) && (Key != GUI_KEY_ESCAPE)); /* Fetch result from edit widget */ if (Key == GUI_KEY_ENTER) { EDIT_GetText(hEdit, aBuffer, sizeof(aBuffer)); } /* Delete the edit widget */ EDIT_Delete(hEdit); GUI_ClearRect(0, 50, 319, 239); /* Display the changed string */ if (Key == GUI_KEY_ENTER) { GUI_Delay(250); GUI_DispStringHCenterAt("The string you have modified is:", 160, 90); GUI_DispStringHCenterAt(aBuffer, 160, 110); GUI_Delay(3000); GUI_ClearRect(0, 50, 319, 239); } GUI_Delay(500); }
/******************************************************************* * * _DemoScrollbarMove This function creates the window and his child objects. Then it runs into a idle-loop, so that the window manager can handle the objects. */ static void _DemoScrollbarMove(void) { int x, y; WM_HWIN hWindow; SCROLLBAR_Handle hScroll; /* Clear display and display headline */ GUI_SetBkColor(GUI_BLUE); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_SetTextAlign(GUI_TA_HCENTER); GUI_DispStringAt("SCROLLBAR_Move - Sample", 160, 5); GUI_SetTextAlign(GUI_TA_LEFT); GUI_SetColor(0xFFFFFF); GUI_SetFont(&GUI_Font8x16); /* Create the window */ hWindow = WM_CreateWindow(50, 90, 220, 79, WM_CF_SHOW, &_cbWindow, 0); /* Create the scrollbar */ hScroll = SCROLLBAR_CreateAttached(hWindow, 0); SCROLLBAR_SetNumItems(hScroll, 48 * EDIT_MAX_X); SCROLLBAR_SetPageSize(hScroll, 220); /* Create the edit-fields */ for (y = 0; y < EDIT_MAX_Y; y++) { for (x = 0; x < EDIT_MAX_X; x++) { _aahEdit[y][x] = EDIT_CreateAsChild(x * 48, y * 22, 48, 22, hWindow, 13, WM_CF_SHOW, 5); EDIT_SetTextAlign(_aahEdit[y][x], GUI_TA_RIGHT | GUI_TA_VCENTER); EDIT_SetFont(_aahEdit[y][x], &GUI_Font8x16); EDIT_SetDecMode(_aahEdit[y][x], ((y * EDIT_MAX_X) + x) * 100, -99999, +99999, 2, 0); } } /* idle-loop */ while (1) { GUI_Exec(); GUI_Delay(20); } /* delete window and clear display */ WM_DeleteWindow(hWindow); GUI_Clear(); }
/******************************************************************************************************* * * 函数名称: * * 函数功能: * * 入口参数: * * 出口参数: 无 * * 说明: * *******************************************************************************************************/ void InitKBDlg(WM_MESSAGE * pMsg) { int i; char str_buff[10]; WM_HWIN hWin = pMsg->hWin; FRAMEWIN_SetClientColor(hWin,RGB(185,205,232)); BUTTON_SetBkColor(WM_GetDialogItem(hWin,GUI_ID_BUTTON_NUM0),BUTTON_CI_UNPRESSED, RGB(70,77,106)); BUTTON_SetBkColor(WM_GetDialogItem(hWin,GUI_ID_BUTTON_NUM0),BUTTON_CI_PRESSED, RGB(123,128,106)); BUTTON_SetTextColor(WM_GetDialogItem(hWin,GUI_ID_BUTTON_NUM0),BUTTON_CI_UNPRESSED, GUI_WHITE); BUTTON_SetTextColor(WM_GetDialogItem(hWin,GUI_ID_BUTTON_NUM0),BUTTON_CI_PRESSED, GUI_WHITE); BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON_NUM0),&GUI_Font16_ASCII); for (i = 2; i < 2 + 14; i++) //共14个按钮,在数组中的索引从2开始 { BUTTON_SetBkColor(WM_GetDialogItem(hWin,_aTextDialogCreate[i].Id),BUTTON_CI_UNPRESSED, RGB(70,77,106)); BUTTON_SetBkColor(WM_GetDialogItem(hWin,_aTextDialogCreate[i].Id),BUTTON_CI_PRESSED, RGB(123,128,106)); BUTTON_SetTextColor(WM_GetDialogItem(hWin,_aTextDialogCreate[i].Id),BUTTON_CI_UNPRESSED, GUI_WHITE); BUTTON_SetTextColor(WM_GetDialogItem(hWin,_aTextDialogCreate[i].Id),BUTTON_CI_PRESSED, GUI_WHITE); BUTTON_SetFont(WM_GetDialogItem(hWin,_aTextDialogCreate[i].Id),&GUI_Font16_ASCII); } //GUI_ID_EDIT_KEYBOART // EDIT_SetTextAlign(WM_GetDialogItem(hWin,GUI_ID_EDIT_KB_INPUT), EDIT_CF_RIGHT|EDIT_CF_BOTTOM); EDIT_SetBkColor(WM_GetDialogItem(hWin,GUI_ID_EDIT_KB_INPUT), EDIT_CI_ENABLED,0xe7eaeb ); EDIT_SetFont(WM_GetDialogItem(hWin,GUI_ID_EDIT_KB_INPUT),&GUI_FontD32); EDIT_SetTextColor(WM_GetDialogItem(hWin,GUI_ID_EDIT_KB_INPUT),0,GUI_RED); sprintf(str_buff,"%ld",ParentParam); EDIT_SetText(WM_GetDialogItem(hWin,GUI_ID_EDIT_KB_INPUT),str_buff); }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE *pMsg) { WM_HWIN hItem; WM_HWIN const hEdit = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0); int NCode; int Id; float fre; int tab = 0; static int ratio[] = { 1, 1000, 1000000}; static const char *sel[] = {"Hz", "kHz", "MHz"}; // USER START (Optionally insert additional variables) // USER END switch (pMsg->MsgId) { case WM_PAINT: WM_SetFocus(hEdit); break; case WM_INIT_DIALOG: // // Initialization of 'MeasureSet' // hItem = pMsg->hWin; FRAMEWIN_SetText(hItem, "Set Frequency"); FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); // // Initialization of 'Edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0); EDIT_SetText(hItem, ""); EDIT_SetFont(hItem, GUI_FONT_20B_1); EDIT_SetTextAlign(hItem, GUI_TA_RIGHT | GUI_TA_VCENTER); fre = ptrDDS->GetFrequency(); while(fre > 999.99) { fre /= 1000; tab++; } EDIT_SetFloatMode(hItem, fre, 0.00, 999.99, 2, GUI_EDIT_NORMAL); // // Initialization of 'Button' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0); BUTTON_SetFont(hItem, GUI_FONT_16_1); BUTTON_SetText(hItem, "Set"); // // Initialization of 'Radio' // hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO_0); RADIO_SetFont(hItem, GUI_FONT_20_1); RADIO_SetText(hItem, sel[0], 0); RADIO_SetText(hItem, sel[1], 1); RADIO_SetText(hItem, sel[2], 2); RADIO_SetValue(hItem, tab); // // Initialization of 'Button' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1); BUTTON_SetFont(hItem, GUI_FONT_16_1); BUTTON_SetText(hItem, "Cancel"); // // Initialization of 'btn1' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_2); BUTTON_SetText(hItem, "1"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btn2' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_3); BUTTON_SetText(hItem, "2"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btn3' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_4); BUTTON_SetText(hItem, "3"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btn4' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_5); BUTTON_SetText(hItem, "4"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btn5' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_6); BUTTON_SetText(hItem, "5"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btn6' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_7); BUTTON_SetText(hItem, "6"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btn7' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_8); BUTTON_SetText(hItem, "7"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btn8' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_9); BUTTON_SetText(hItem, "8"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btn9' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_10); BUTTON_SetText(hItem, "9"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btn0' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_11); BUTTON_SetText(hItem, "0"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btnBS' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_12); BUTTON_SetText(hItem, "<--"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btnC' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_13); BUTTON_SetText(hItem, "-->"); BUTTON_SetFocussable(hItem, 0); // USER START (Optionally insert additional code for further widget initialization) // USER END break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { case ID_EDIT_0: // Notifications sent by 'Edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_0: // Notifications sent by 'Button' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) fre = EDIT_GetFloatValue(hEdit); tab = RADIO_GetValue(WM_GetDialogItem(pMsg->hWin, ID_RADIO_0)); ptrDDS->SetFrequency(fre * ratio[tab]); GUI_EndDialog(pMsg->hWin, 0); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_RADIO_0: // Notifications sent by 'Radio' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_1: // Notifications sent by 'Button' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) GUI_EndDialog(pMsg->hWin, 0); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_2: // Notifications sent by 'btn1' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '1'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_3: // Notifications sent by 'btn2' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '2'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_4: // Notifications sent by 'btn3' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '3'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_5: // Notifications sent by 'btn4' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '4'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_6: // Notifications sent by 'btn5' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '5'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_7: // Notifications sent by 'btn6' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '6'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_8: // Notifications sent by 'btn7' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '7'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_9: // Notifications sent by 'btn8' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '8'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_10: // Notifications sent by 'btn9' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '9'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_11: // Notifications sent by 'btn0' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '0'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_12: // Notifications sent by 'btnBS' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, GUI_KEY_LEFT); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_13: // Notifications sent by 'btnC' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, GUI_KEY_RIGHT); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; // USER START (Optionally insert additional code for further Ids) // USER END } break; // USER START (Optionally insert additional message handling) // USER END default: WM_DefaultProc(pMsg); break; } }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int NCode; int Id; // USER START (Optionally insert additional variables) // USER END GUI_DrawBitmap(&bmlogo,40,10); #if(Gradient_Rectangle) { GUI_DrawGradientRoundedH(220,120,580,380,20,REC_color1,REC_color2); } #endif #if(RoundedFrame) GUI_SetColor(GUI_GREEN); GUI_DrawRoundedFrame(218,118,582,382,20,3); #endif #if(FillRoundedRect) GUI_SetColor(RoundedRect); GUI_FillRoundedRect(220,120,580,380,20); #endif switch (pMsg->MsgId) { case WM_INIT_DIALOG: // // Initialization of 'inuse' // hItem = pMsg->hWin; FRAMEWIN_SetTitleVis(hItem, 0); FRAMEWIN_SetClientColor( hItem, framewin_backcolor); FRAMEWIN_SetFont(hItem, GUI_FONT_8_1); FRAMEWIN_SetText(hItem, "Framewin"); FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); FRAMEWIN_SetTextColor(hItem, 0x00000000); hItem = pMsg->hWin; FRAMEWIN_SetTitleVis(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1); BUTTON_SetFont(hItem, &GUI_Fonthz_song30); BUTTON_SetText(hItem, "返回 "); #if(Button_3Dskin) BUTTON_SetSkin(hItem,BUTTON_SKIN_FLEX); #endif #if(!Button_3Dskin) BUTTON_SetBkColor( hItem,BUTTON_CI_UNPRESSED,Button_unpress_color); BUTTON_SetBkColor( hItem,BUTTON_CI_PRESSED,Button_press_color); #endif // // Initialization of 'Button' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0); BUTTON_SetFont(hItem, &GUI_Fonthz_song30); BUTTON_SetText(hItem, "停止充电 "); #if(Button_3Dskin) BUTTON_SetSkin(hItem,BUTTON_SKIN_FLEX); #endif #if(!Button_3Dskin) BUTTON_SetBkColor( hItem,BUTTON_CI_UNPRESSED,Button_unpress_color); BUTTON_SetBkColor( hItem,BUTTON_CI_PRESSED,Button_press_color); #endif // // Initialization of 'Button' // // // Initialization of 'Edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0); EDIT_EnableBlink( hItem,1 ,0); EDIT_SetDecMode(hItem,0,0,99,0,0); EDIT_SetFont(hItem, GUI_FONT_32_ASCII); EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); // // Initialization of 'Edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1); EDIT_EnableBlink( hItem,1 ,0); EDIT_SetDecMode(hItem,0,0,99,0,0); EDIT_SetFont(hItem, GUI_FONT_32_ASCII); EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); EDIT_SetTextColor(hItem, EDIT_CI_ENABLED, 0x00000000); // // Initialization of 'Edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_2); EDIT_EnableBlink( hItem,1 ,0); EDIT_SetDecMode(hItem,0,0,99,0,0); EDIT_SetFont(hItem, GUI_FONT_32_ASCII); EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); EDIT_SetTextColor(hItem, EDIT_CI_ENABLED, 0x00000000); // // Initialization of 'Edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_3); EDIT_EnableBlink( hItem,1 ,0); EDIT_SetDecMode(hItem,0,0,9999,0,0); EDIT_SetFont(hItem, GUI_FONT_32_ASCII); EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); EDIT_SetTextColor(hItem, EDIT_CI_ENABLED, 0x00000000); // // Initialization of 'cddianliang' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0); TEXT_SetFont(hItem, &GUI_Fonthz_song24); TEXT_SetText(hItem, "使用电量 "); TEXT_SetTextAlign(hItem, GUI_TA_RIGHT); TEXT_SetTextColor(hItem, 0x00000000); // // Initialization of 'Text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); TEXT_SetFont(hItem, &GUI_Fonthz_song24); TEXT_SetText(hItem, "使用时间 "); TEXT_SetTextColor(hItem, 0x00000000); TEXT_SetTextAlign(hItem, GUI_TA_RIGHT); // // Initialization of 'Text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2); TEXT_SetFont(hItem, &GUI_Fonthz_song24); TEXT_SetText(hItem, "消费金额 "); TEXT_SetTextAlign(hItem, GUI_TA_RIGHT); TEXT_SetTextColor(hItem, 0x00000000); // // Initialization of 'Text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3); TEXT_SetFont(hItem, &GUI_Fonthz_song24); TEXT_SetText(hItem, "账户余额 "); TEXT_SetTextAlign(hItem, GUI_TA_RIGHT); TEXT_SetTextColor(hItem, 0x00000000); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4); TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_TOP); TEXT_SetText(hItem, "安徽绿建科技有限公司 "); TEXT_SetTextColor(hItem, 0x00000000); TEXT_SetFont(hItem, &GUI_FontSong_60); // // Initialization of 'Text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_5); TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_TOP); TEXT_SetTextColor(hItem, 0x00000000); TEXT_SetText(hItem, "ANHUI GREEN BUILDING TECHNOLOGY CO.,LTD."); TEXT_SetFont(hItem, GUI_FONT_24_ASCII); // USER START (Optionally insert additional code for further widget initialization) // USER END break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { case ID_BUTTON_0: // Notifications sent by 'Button' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END // op=ensure; // handle_button(); GUI_EndDialog( pMsg->hWin,1); Createensure(); break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_1: // Notifications sent by 'Button' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END GUI_EndDialog( pMsg->hWin,1); Createwindow0(); break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_EDIT_0: // Notifications sent by 'Edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_EDIT_1: // Notifications sent by 'Edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_EDIT_2: // Notifications sent by 'Edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_EDIT_3: // Notifications sent by 'Edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; // USER START (Optionally insert additional code for further Ids) // USER END } break; // USER START (Optionally insert additional message handling) // USER END default: WM_DefaultProc(pMsg); break; } }
/***************************** Initializacija paneli comunikaciji *****************************/ void Modbus_panel_show(void) { if (Modbus_FrameWin == WM_UNATTACHED) { //Stvorjujemo FrameWin Modbus_FrameWin = FRAMEWIN_CreateEx(X0, Y0, X_SIZE, Y_SIZE, 0, WM_CF_HIDE, 0, ID_MODBUS_FRAMEWIN, Modbus_panel_title.ptitle[sel_language], _cbProtection_FrameWin); FRAMEWIN_SetFont(Modbus_FrameWin, &GUI_FontArialBold14_8_Unicode); FRAMEWIN_SetTextAlign(Modbus_FrameWin, GUI_TA_HCENTER); FRAMEWIN_SetBarColor(Modbus_FrameWin, 1, GUI_GREEN); FRAMEWIN_SetBarColor(Modbus_FrameWin, 0, GUI_LIGHTGRAY); FRAMEWIN_SetTextColor(Modbus_FrameWin, GUI_BLUE); #define COL_1_X 5 #define ROW_1_Y 10 #define HIGHT_Y 20 #define SHIFT_Y (ROW_1_Y + HIGHT_Y) #define WIDTH_X_T 165 #define WIDTH_X_V 60 #define SHIFT_X1 (WIDTH_X_T + 10) #define SHIFT_X2 (SHIFT_X1 + WIDTH_X_V + 10) ScrollBar_Modbus = SCROLLBAR_CreateAttached(WM_GetClientWindow(Modbus_FrameWin), SCROLLBAR_CF_VERTICAL); SCROLLBAR_SetNumItems(ScrollBar_Modbus, MAX_NUMBER_ITEMS_MODBUS*SHIFT_Y); SCROLLBAR_SetPageSize(ScrollBar_Modbus, 6*SHIFT_Y); //Address Modbus_t[0] = TEXT_CreateEx(COL_1_X, ROW_1_Y + 0*SHIFT_Y, WIDTH_X_T, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, TEXT_CF_LEFT | TEXT_CF_VCENTER, ID_MODBUS_ADDRESS_TITLE, Modbus_title[0].ptitle[sel_language]); TEXT_SetFont(Modbus_t[0], &GUI_FontArialStandard14_8_Unicode); Modbus_v[0] = EDIT_CreateUser(COL_1_X + SHIFT_X1, ROW_1_Y + 0*SHIFT_Y, WIDTH_X_V, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, 0, ID_MODBUS_ADDRESS_VALUE, 3, sizeof(__info_data)); EDIT_SetFont(Modbus_v[0], &GUI_FontArialStandard14_8_Unicode); __info_data info_data; int shift = 0, max = KOEF_ADDRESS_MAX, min = 0; info_data.extra_param = 0; info_data.shift = shift; float _shift = 0.0f; for (int rozrjad = 0; rozrjad < shift; rozrjad++) { _shift /= 10.0f; _shift += 0.9f; } // int max_tmp = max; // float _max = 10; // while ( abs(max_tmp /= 10) >= 1) _max *= 10.0f; // if (max > 0) // { // _max = _max - 1 + _shift; // } // else if (max < 0) // { // _max = -(_max / 10); // } // else _max = 0; // info_data.max = _max; float _max = 255; //maksymalne odnobajtne chyslo, bo adresu ob'javleno jak typ char info_data.max = _max; int min_tmp = min; float _min = 10; while ( abs(min_tmp /= 10) >= 1) _min *= 10.0f; if (min > 0) { _min = (_min / 10); } else if (min < 0) { _min = -(_min - 1 + _shift); } else _min = 0; info_data.min = _min; EDIT_SetUserData(Modbus_v[0], &info_data, sizeof(__info_data)); EDIT_SetFloatMode(Modbus_v[0], 0, _min, _max, shift, GUI_EDIT_SUPPRESS_LEADING_ZEROES); //Baud Rate Modbus_t[1] = TEXT_CreateEx(COL_1_X, ROW_1_Y + 1*SHIFT_Y, WIDTH_X_T, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, TEXT_CF_LEFT | TEXT_CF_VCENTER, ID_MODBUS_BAUD_RATE_TITLE, Modbus_title[1].ptitle[sel_language]); TEXT_SetFont(Modbus_t[1], &GUI_FontArialStandard14_8_Unicode); Modbus_v[1] = DROPDOWN_CreateEx(COL_1_X + SHIFT_X1, ROW_1_Y + 1*SHIFT_Y, WIDTH_X_V, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, DROPDOWN_CF_AUTOSCROLLBAR, ID_MODBUS_BAUD_RATE_VALUE); DROPDOWN_SetFont(Modbus_v[1], &GUI_FontArialStandard14_8_Unicode); DROPDOWN_SetBkColor(Modbus_v[1],DROPDOWN_CI_UNSEL, GUI_GRAY); DROPDOWN_SetBkColor(Modbus_v[1],DROPDOWN_CI_SEL, GUI_GRAY); DROPDOWN_SetBkColor(Modbus_v[1],DROPDOWN_CI_SELFOCUS, GUI_BLUE); DROPDOWN_AddString(Modbus_v[1], ""); for (int i = 0; i < 7; i++) DROPDOWN_AddString(Modbus_v[1], Baud_rate_title[i]); //Parity Modbus_t[2] = TEXT_CreateEx(COL_1_X, ROW_1_Y + 2*SHIFT_Y, WIDTH_X_T, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, TEXT_CF_LEFT | TEXT_CF_VCENTER, ID_MODBUS_PARITY_TITLE, Modbus_title[2].ptitle[sel_language]); TEXT_SetFont(Modbus_t[2], &GUI_FontArialStandard14_8_Unicode); Modbus_v[2] = DROPDOWN_CreateEx(COL_1_X + SHIFT_X1, ROW_1_Y + 2*SHIFT_Y, WIDTH_X_V, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, DROPDOWN_CF_AUTOSCROLLBAR, ID_MODBUS_PARITY_VALUE); DROPDOWN_SetFont(Modbus_v[2], &GUI_FontArialStandard14_8_Unicode); DROPDOWN_SetBkColor(Modbus_v[2],DROPDOWN_CI_UNSEL, GUI_GRAY); DROPDOWN_SetBkColor(Modbus_v[2],DROPDOWN_CI_SEL, GUI_GRAY); DROPDOWN_SetBkColor(Modbus_v[2],DROPDOWN_CI_SELFOCUS, GUI_BLUE); DROPDOWN_AddString(Modbus_v[2], ""); for (int i = 0; i < 3; i++) DROPDOWN_AddString(Modbus_v[2], Parity_title[i].ptitle[sel_language]); //Stop bits Modbus_t[3] = TEXT_CreateEx(COL_1_X, ROW_1_Y + 3*SHIFT_Y, WIDTH_X_T, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, TEXT_CF_LEFT | TEXT_CF_VCENTER, ID_MODBUS_STOP_BITS_TITLE, Modbus_title[3].ptitle[sel_language]); TEXT_SetFont(Modbus_t[3], &GUI_FontArialStandard14_8_Unicode); Modbus_v[3] = DROPDOWN_CreateEx(COL_1_X + SHIFT_X1, ROW_1_Y + 3*SHIFT_Y, WIDTH_X_V, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, DROPDOWN_CF_AUTOSCROLLBAR, ID_MODBUS_STOP_BITS_VALUE); DROPDOWN_SetFont(Modbus_v[3], &GUI_FontArialStandard14_8_Unicode); DROPDOWN_SetBkColor(Modbus_v[3],DROPDOWN_CI_UNSEL, GUI_GRAY); DROPDOWN_SetBkColor(Modbus_v[3],DROPDOWN_CI_SEL, GUI_GRAY); DROPDOWN_SetBkColor(Modbus_v[3],DROPDOWN_CI_SELFOCUS, GUI_BLUE); DROPDOWN_AddString(Modbus_v[3], ""); for (int i = 0; i < 2; i++) DROPDOWN_AddString(Modbus_v[3], Stop_bits_title[i]); //Time-Out Modbus_t[4] = TEXT_CreateEx(COL_1_X, ROW_1_Y + 4*SHIFT_Y, WIDTH_X_T, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, TEXT_CF_LEFT | TEXT_CF_VCENTER, ID_MODBUS_TIMEOUT_TITLE, Modbus_title[4].ptitle[sel_language]); TEXT_SetFont(Modbus_t[4], &GUI_FontArialStandard14_8_Unicode); Modbus_v[4] = EDIT_CreateUser(COL_1_X + SHIFT_X1, ROW_1_Y + 4*SHIFT_Y, WIDTH_X_V, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, 0, ID_MODBUS_TIMEOUT_VALUE, 5, sizeof(__info_data)); EDIT_SetFont(Modbus_v[4], &GUI_FontArialStandard14_8_Unicode); shift = 1; max = VALUE_TIME_OUT_1_INTERFACE_MAX/10; min = 0; info_data.extra_param = 0; info_data.shift = shift; _shift = 0.0f; for (int rozrjad = 0; rozrjad < shift; rozrjad++) { _shift /= 10.0f; _shift += 0.9f; } int max_tmp = max; _max = 10; while ( abs(max_tmp /= 10) >= 1) _max *= 10.0f; if (max > 0) { _max = _max - 1 + _shift; } else if (max < 0) { _max = -(_max / 10); } else _max = 0; info_data.max = _max; min_tmp = min; _min = 10; while ( abs(min_tmp /= 10) >= 1) _min *= 10.0f; if (min > 0) { _min = (_min / 10); } else if (min < 0) { _min = -(_min - 1 + _shift); } else _min = 0; info_data.min = _min; EDIT_SetUserData(Modbus_v[4], &info_data, sizeof(__info_data)); EDIT_SetFloatMode(Modbus_v[4], 0, _min, _max, shift, GUI_EDIT_SUPPRESS_LEADING_ZEROES); Modbus_d = TEXT_CreateEx(COL_1_X + SHIFT_X2 , ROW_1_Y + 4*SHIFT_Y, 40, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, TEXT_CF_LEFT | TEXT_CF_VCENTER, ID_MODBUS_TIMEOUT_DIMENSION, Modbus_Timeout_dimention.ptitle[sel_language]); TEXT_SetFont(Modbus_d, &GUI_FontArialStandard14_8_Unicode); #undef COL_1_X #undef ROW_1_Y #undef HIGHT_Y #undef SHIFT_Y #undef WIDTH_X_T #undef WIDTH_X_V #undef SHIFT_X1 #undef SHIFT_X2 } WM_BringToTop(Modbus_FrameWin); WM_ShowWindow(Modbus_FrameWin); }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int NCode; int Id; int i; switch (pMsg->MsgId) { case WM_INIT_DIALOG: hItem = pMsg->hWin; FRAMEWIN_SetTextColor(hItem, 0x00000000); // hItem = WM_GetDialogItem(pMsg->hWin, ID_TIMESET_TEXT_0); // TEXT_SetFont(hItem, &GUI_Font32_ASCII); // TEXT_SetTextColor(hItem, GUI_WHITE); hItem = WM_GetDialogItem(pMsg->hWin, ID_TIMESET_BUTTON_TITLE); BUTTON_SetSkinClassic(hItem); WIDGET_SetEffect(hItem, &WIDGET_Effect_None); BUTTON_SetText(hItem, ""); BUTTON_Set_Bitmap_Ex(pMsg->hWin, ID_TIMESET_BUTTON_TITLE, &_bmWhiteTimeCHN, 0, 13); Button_Set_BkColor(pMsg->hWin, ID_TIMESET_BUTTON_TITLE, GUI_BLACK); for(i=ID_TIMESET_BUTTON_CONFIRM;i<=ID_TIMESET_BUTTON_RESERVE5;i++){ hItem = WM_GetDialogItem(pMsg->hWin, i); Button_Init(hItem); if(i%2){ BUTTON_SetBkColor(hItem, BUTTON_CI_UNPRESSED, GUI_LIGHTGRAY); }else{ } } BUTTON_DispConfirmCHNStr(pMsg->hWin, ID_TIMESET_BUTTON_CONFIRM, 18, 43); BUTTON_DispCheckCHNStr(pMsg->hWin, ID_TIMESET_BUTTON_CHECK, 18, 43); BUTTON_DispResetCHNStr(pMsg->hWin, ID_TIMESET_BUTTON_RESET, 18, 43); BUTTON_DispCancelCHNStr(pMsg->hWin, ID_TIMESET_BUTTON_CANCEL, 18, 43); BUTTON_DispSerialNumCHNStr(pMsg->hWin, ID_TIMESET_BUTTON_SNSET, 14, 18); BUTTON_DispTimeCHNStr(pMsg->hWin, ID_TIMESET_BUTTON_TIMESET, 26, 18); BUTTON_DispTestSelCHNStr(pMsg->hWin, ID_TIMESET_BUTTON_TESTSELECT, 14, 18); // // Initialization of 'lwYear' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TIMESET_LISTWHEEL_YEAR); ListWheel_Init(hItem); ListWheel_AddNumString(hItem, 2015, 2025); // // Initialization of 'lwMonth' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TIMESET_LISTWHEEL_MONTH); ListWheel_Init(hItem); ListWheel_AddNumString(hItem, 1, 12); // // Initialization of 'lwDay' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TIMESET_LISTWHEEL_DAY); ListWheel_Init(hItem); ListWheel_AddNumString(hItem, 1, 31); // // Initialization of 'lwHour' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TIMESET_LISTWHEEL_HOUR); ListWheel_Init(hItem); ListWheel_AddNumString(hItem, 0, 23); // // Initialization of 'lwMin,lwSec' // for(i=ID_TIMESET_LISTWHEEL_MIN;i<=ID_TIMESET_LISTWHEEL_SEC;i++){ hItem = WM_GetDialogItem(pMsg->hWin, i); ListWheel_Init(hItem); ListWheel_AddNumString(hItem, 0, 59); } // // Initialization of 'edit' // for(i=ID_TIMESET_EDIT_SETVALUE;i<=ID_TIMESET_EDIT_SEC;i++){ hItem = WM_GetDialogItem(pMsg->hWin, i); EDIT_SetFont(hItem, GUI_FONT_24_ASCII); EDIT_SetTextMode(hItem); EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); } hItem = WM_GetDialogItem(pMsg->hWin, ID_TIMESET_EDIT_SETVALUE); EDIT_SetMaxLen(hItem, 30); hItem = WM_GetDialogItem(pMsg->hWin, ID_TIMESET_EDIT_ACTVALUE); EDIT_SetMaxLen(hItem, 30); WM_HideWin(pMsg->hWin); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { case ID_TIMESET_BUTTON_CONFIRM: // Notifications sent by 'Confirm' switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: Button_ConfirmProc(pMsg->hWin); break; } break; case ID_TIMESET_BUTTON_CHECK: // Notifications sent by 'Check' switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: Button_CheckProc(pMsg->hWin); break; } break; case ID_TIMESET_BUTTON_RESET: // Notifications sent by 'Reset' switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: Button_ResetProc(pMsg->hWin); break; } break; case ID_TIMESET_BUTTON_CANCEL: // Notifications sent by 'Cancel' switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: Button_CancelProc(pMsg->hWin); break; } break; case ID_TIMESET_BUTTON_SNSET: switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: Button_SNSetProc(pMsg->hWin); break; } break; case ID_TIMESET_BUTTON_TESTSELECT: switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: Button_TestSelSetProc(pMsg->hWin); break; } break; case ID_TIMESET_LISTWHEEL_YEAR: // Notifications sent by 'lwYear' switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: break; case WM_NOTIFICATION_SEL_CHANGED: ListWheel_SelChangeProc(pMsg->hWin, ID_TIMESET_LISTWHEEL_YEAR, ID_TIMESET_EDIT_YEAR); break; } break; case ID_TIMESET_LISTWHEEL_MONTH: // Notifications sent by 'lwMonth' switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: break; case WM_NOTIFICATION_SEL_CHANGED: ListWheel_SelChangeProc(pMsg->hWin, ID_TIMESET_LISTWHEEL_MONTH, ID_TIMESET_EDIT_MONTH); break; } break; case ID_TIMESET_LISTWHEEL_DAY: // Notifications sent by 'lwDay' switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: break; case WM_NOTIFICATION_SEL_CHANGED: ListWheel_SelChangeProc(pMsg->hWin, ID_TIMESET_LISTWHEEL_DAY, ID_TIMESET_EDIT_DAY); break; } break; case ID_TIMESET_LISTWHEEL_HOUR: // Notifications sent by 'lwHour' switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: break; case WM_NOTIFICATION_SEL_CHANGED: ListWheel_SelChangeProc(pMsg->hWin, Id, ID_TIMESET_EDIT_HOUR); break; } break; case ID_TIMESET_LISTWHEEL_MIN: // Notifications sent by 'lwMin' switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: break; case WM_NOTIFICATION_SEL_CHANGED: ListWheel_SelChangeProc(pMsg->hWin, Id, ID_TIMESET_EDIT_MIN); break; } break; case ID_TIMESET_LISTWHEEL_SEC: // Notifications sent by 'lwSec' switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: break; case WM_NOTIFICATION_SEL_CHANGED: ListWheel_SelChangeProc(pMsg->hWin, Id, ID_TIMESET_EDIT_SEC); break; } break; } default: WM_DefaultProc(pMsg); break; } }
static void InitDialog(WM_MESSAGE * pMsg) { WM_HWIN hWin = pMsg->hWin; // //FRAMEWIN // FRAMEWIN_SetTitleVis(hWin,0); // //GUI_ID_BUTTON7 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON7),&GUI_FontHZ_SongTi_16); // //GUI_ID_BUTTON4 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON4),&GUI_FontHZ_SongTi_16); // //GUI_ID_BUTTON5 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON5),&GUI_FontHZ_SongTi_16); // //GUI_ID_BUTTON3 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON3),&GUI_FontHZ_SongTi_16); // //GUI_ID_BUTTON6 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON6),&GUI_FontHZ_SongTi_16); // //GUI_ID_BUTTON2 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON2),&GUI_FontHZ_SongTi_16); // //GUI_ID_BUTTON0 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON0),&GUI_FontHZ_SongTi_16); // //GUI_ID_BUTTON1 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON1),&GUI_FontHZ_SongTi_16); // //GUI_ID_CANCEL // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_CANCEL),&GUI_FontHZ_SongTi_16); // //GUI_ID_OK // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_OK),&GUI_FontHZ_SongTi_16); // //GUI_ID_BUTTON8 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON8),&GUI_FontHZ_SongTi_16); // //GUI_ID_BUTTON9 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON9),&GUI_FontHZ_SongTi_16); // //GUI_ID_EDIT0 // EDIT_SetFont(WM_GetDialogItem(hWin,GUI_ID_EDIT0),&GUI_FontHZ_SongTi_16); EDIT_SetDecMode(WM_GetDialogItem(hWin,GUI_ID_EDIT0),0,0,999999999,0,0); }
void MeasureData_InitDialog (WM_MESSAGE* pMsg) { WM_HWIN hWin = pMsg->hWin; // //FRAMEWIN // FRAMEWIN_SetBarColor(hWin, 1, 0xff901e); FRAMEWIN_SetClientColor(hWin, 0xc0c0c0); FRAMEWIN_SetTextColor(hWin, 0xcc3299); FRAMEWIN_SetFont(hWin, &GUI_Font16B_ASCII); FRAMEWIN_SetTextAlign(hWin, GUI_TA_VCENTER | GUI_TA_CENTER); FRAMEWIN_AddCloseButton(hWin, FRAMEWIN_BUTTON_RIGHT, 0); FRAMEWIN_AddMaxButton(hWin, FRAMEWIN_BUTTON_RIGHT, 1); FRAMEWIN_AddMinButton(hWin, FRAMEWIN_BUTTON_RIGHT, 2); FRAMEWIN_SetTitleHeight(hWin, 16); // //GUI_ID_TEXT0 // TEXT_SetBkColor(WM_GetDialogItem(hWin, GUI_ID_TEXT0), 0xc0c0c0); TEXT_SetTextColor(WM_GetDialogItem(hWin, GUI_ID_TEXT0), 0x228b22); TEXT_SetFont(WM_GetDialogItem(hWin, GUI_ID_TEXT0), &GUI_Font24B_ASCII); // //GUI_ID_TEXT2 // TEXT_SetBkColor(WM_GetDialogItem(hWin, GUI_ID_TEXT2), 0xc0c0c0); TEXT_SetTextColor(WM_GetDialogItem(hWin, GUI_ID_TEXT2), 0x4763ff); TEXT_SetFont(WM_GetDialogItem(hWin, GUI_ID_TEXT2), &GUI_Font24B_ASCII); // //GUI_ID_TEXT1 // TEXT_SetBkColor(WM_GetDialogItem(hWin, GUI_ID_TEXT1), 0xc0c0c0); TEXT_SetTextColor(WM_GetDialogItem(hWin, GUI_ID_TEXT1), 0xe16941); TEXT_SetFont(WM_GetDialogItem(hWin, GUI_ID_TEXT1), &GUI_Font24B_ASCII); // //GUI_ID_EDIT1 // EDIT_SetFont(WM_GetDialogItem(hWin, GUI_ID_EDIT1), &GUI_Font24B_ASCII); EDIT_SetTextAlign(WM_GetDialogItem(hWin, GUI_ID_EDIT1), GUI_TA_VCENTER | GUI_TA_LEFT); // //GUI_ID_EDIT2 // EDIT_SetFont(WM_GetDialogItem(hWin, GUI_ID_EDIT2), &GUI_Font24B_ASCII); EDIT_SetTextAlign(WM_GetDialogItem(hWin, GUI_ID_EDIT2), GUI_TA_VCENTER | GUI_TA_LEFT); // //GUI_ID_EDIT3 // EDIT_SetFont(WM_GetDialogItem(hWin, GUI_ID_EDIT3), &GUI_Font24B_ASCII); EDIT_SetTextAlign(WM_GetDialogItem(hWin, GUI_ID_EDIT3), GUI_TA_VCENTER | GUI_TA_LEFT); // //GUI_ID_EDIT4 // EDIT_SetTextColor(WM_GetDialogItem(hWin, GUI_ID_EDIT4), 0, 0x228b22); EDIT_SetFont(WM_GetDialogItem(hWin, GUI_ID_EDIT4), &GUI_Font24B_ASCII); EDIT_SetTextAlign(WM_GetDialogItem(hWin, GUI_ID_EDIT4), GUI_TA_VCENTER | GUI_TA_CENTER); // //GUI_ID_EDIT5 // EDIT_SetTextColor(WM_GetDialogItem(hWin, GUI_ID_EDIT5), 0, 0xff901e); EDIT_SetFont(WM_GetDialogItem(hWin, GUI_ID_EDIT5), &GUI_Font24B_ASCII); EDIT_SetTextAlign(WM_GetDialogItem(hWin, GUI_ID_EDIT5), GUI_TA_VCENTER | GUI_TA_CENTER); // //GUI_ID_EDIT6 // EDIT_SetTextColor(WM_GetDialogItem(hWin, GUI_ID_EDIT6), 0, 0x4763ff); EDIT_SetFont(WM_GetDialogItem(hWin, GUI_ID_EDIT6), &GUI_Font24B_ASCII); EDIT_SetTextAlign(WM_GetDialogItem(hWin, GUI_ID_EDIT6), GUI_TA_VCENTER | GUI_TA_CENTER); }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE * pMsg) { const WM_KEY_INFO* pInfo; WM_HWIN hItem; int NCode; int Id; // USER START (Optionally insert additional variables) // USER END switch (pMsg->MsgId) { case WM_KEY: pInfo = (WM_KEY_INFO*)pMsg->Data.p; switch(pInfo->Key) { case GUI_KEY_LEFT: WM_SetFocus(menuWin); break; default: WM_DefaultProc(pMsg); break; } break; case WM_INIT_DIALOG: // // Initialization of 'Window' // hItem = pMsg->hWin; WINDOW_SetBkColor(hItem, 0x00D9FFB3); // // Initialization of 'Multipage' // hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIPAGE_0); MULTIPAGE_AddEmptyPage(hItem, 0, "Page1"); MULTIPAGE_AddEmptyPage(hItem, 0, "Page2"); // // Initialization of 'Text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0); TEXT_SetText(hItem, "Vol:"); TEXT_SetFont(hItem, GUI_FONT_24B_ASCII); // // Initialization of 'Edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0); EDIT_SetText(hItem, "OFF"); EDIT_SetFont(hItem, GUI_FONT_16B_1); WM_SetCallback(hItem, &myEditTextListener); // USER START (Optionally insert additional code for further widget initialization) // USER END break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { case ID_MULTIPAGE_0: // Notifications sent by 'Multipage' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_MOVED_OUT: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_EDIT_0: // Notifications sent by 'Edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; // USER START (Optionally insert additional code for further Ids) // USER END } break; // USER START (Optionally insert additional message handling) // USER END default: WM_DefaultProc(pMsg); break; } }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int NCode; int Id; // USER START (Optionally insert additional variables) // USER END switch (pMsg->MsgId) { case WM_INIT_DIALOG: // // Initialization of 'START' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0); BUTTON_SetFont(hItem, GUI_FONT_24_ASCII); // // Initialization of 'Msg Edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0); EDIT_SetText(hItem, "123"); EDIT_SetFont(hItem, GUI_FONT_20_ASCII); // // Initialization of 'cbxWheel Test' // hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_0); CHECKBOX_SetText(hItem, "Wheel Test"); CHECKBOX_SetFont(hItem, GUI_FONT_16B_ASCII); // // Initialization of 'cbxSBrush Test' // hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_1); CHECKBOX_SetText(hItem, "SBrush Test"); CHECKBOX_SetFont(hItem, GUI_FONT_16B_ASCII); // // Initialization of 'cbxMBrush Test' // hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_2); CHECKBOX_SetText(hItem, "MBrush Test"); CHECKBOX_SetFont(hItem, GUI_FONT_16B_ASCII); // // Initialization of 'cbxFan Test' // hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_3); CHECKBOX_SetText(hItem, "Fan Test"); CHECKBOX_SetFont(hItem, GUI_FONT_16B_ASCII); // // Initialization of 'cbxIFRD Test' // hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_4); CHECKBOX_SetText(hItem, "IFRD Test"); CHECKBOX_SetFont(hItem, GUI_FONT_16B_ASCII); // // Initialization of 'cbxCollision Test' // hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_5); CHECKBOX_SetText(hItem, "Collision Test"); CHECKBOX_SetFont(hItem, GUI_FONT_16B_ASCII); // // Initialization of 'cbxWheelFloat Test' // hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_6); CHECKBOX_SetText(hItem, "WheelFloat Test"); CHECKBOX_SetFont(hItem, GUI_FONT_16B_ASCII); // // Initialization of 'cbxAshTray Test' // hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_7); CHECKBOX_SetText(hItem, "AshTray Test"); CHECKBOX_SetFont(hItem, GUI_FONT_16B_ASCII); // // Initialization of 'cbxUniWheel Test' // hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_8); CHECKBOX_SetText(hItem, "UniWheel Test"); CHECKBOX_SetFont(hItem, GUI_FONT_16B_ASCII); // // Initialization of 'cbxKey Test' // hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_9); CHECKBOX_SetText(hItem, "Key Test"); CHECKBOX_SetFont(hItem, GUI_FONT_16B_ASCII); // // Initialization of 'cbxIRDA Test' // hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_10); CHECKBOX_SetText(hItem, "IRDA Test"); CHECKBOX_SetFont(hItem, GUI_FONT_16B_ASCII); // // Initialization of 'cbxBuzzer Test' // hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_11); CHECKBOX_SetText(hItem, "Buzzer Test"); CHECKBOX_SetFont(hItem, GUI_FONT_16B_ASCII); // // Initialization of 'STOP' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1); BUTTON_SetFont(hItem, GUI_FONT_24_ASCII); // USER START (Optionally insert additional code for further widget initialization) // USER END break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { case ID_BUTTON_0: // Notifications sent by 'START' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_EDIT_0: // Notifications sent by 'Msg Edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_CHECKBOX_0: // Notifications sent by 'cbxWheel Test' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_CHECKBOX_1: // Notifications sent by 'cbxSBrush Test' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_CHECKBOX_2: // Notifications sent by 'cbxMBrush Test' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_CHECKBOX_3: // Notifications sent by 'cbxFan Test' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_CHECKBOX_4: // Notifications sent by 'cbxIFRD Test' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_CHECKBOX_5: // Notifications sent by 'cbxCollision Test' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_CHECKBOX_6: // Notifications sent by 'cbxWheelFloat Test' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_CHECKBOX_7: // Notifications sent by 'cbxAshTray Test' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_CHECKBOX_8: // Notifications sent by 'cbxUniWheel Test' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_CHECKBOX_9: // Notifications sent by 'cbxKey Test' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_CHECKBOX_10: // Notifications sent by 'cbxIRDA Test' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_CHECKBOX_11: // Notifications sent by 'cbxBuzzer Test' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_1: // Notifications sent by 'STOP' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; // USER START (Optionally insert additional code for further Ids) // USER END } break; // USER START (Optionally insert additional message handling) // USER END default: WM_DefaultProc(pMsg); break; } }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int cursorpos=0; int index=0; uint8_t res=0; uint8_t sel=0; char str[60]; uint8_t filename[110]; uint8_t NumChars=0; hItem = pMsg->hWin; WINDOW_SetBkColor(hItem, GUI_LIGHTGRAY); switch (pMsg->MsgId) { case WM_INIT_DIALOG: hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0); TEXT_SetFont(hItem,&GUI_FontHZ_Song_16); TEXT_SetTextAlign(hItem, TEXT_CF_HCENTER | TEXT_CF_VCENTER); TEXT_SetText(hItem, (char *)"保存自学习文件"); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); TEXT_SetFont(hItem,&GUI_FontHZ_Song_16); TEXT_SetText(hItem, (char *)"文件名称:"); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2); TEXT_SetFont(hItem,&GUI_FontHZ_Song_16); TEXT_SetText(hItem, (char *)"文件类型:WTR"); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3); TEXT_SetFont(hItem,&GUI_FontHZ_Song_16); TEXT_SetText(hItem, (char *)"保存路径:"); hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0); DROPDOWN_SetFont(hItem,&GUI_FontHZ_Song_16); DROPDOWN_AddString(hItem, (char *)"U盘"); DROPDOWN_AddString(hItem, (char *)"SD卡"); if(k_StorageGetStatus(MSD_DISK_UNIT) != 0) DROPDOWN_SetSel(hItem,1); else DROPDOWN_SetSel(hItem,0); hItemwarn = WM_GetDialogItem(pMsg->hWin, ID_TEXT_WARNING); TEXT_SetFont(hItemwarn,&GUI_FontHZ_Song_12); TEXT_SetTextColor(hItemwarn,GUI_RED); TEXT_SetText(hItemwarn, (char *)"警告:文件名不能为空!"); WM_HideWindow(hItemwarn); hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_INFO); TEXT_SetFont(hIteminfo,&GUI_FontHZ_Song_12); TEXT_SetTextColor(hIteminfo,GUI_RED); TEXT_SetText(hIteminfo, (char *)"文件保存成功!"); WM_HideWindow(hIteminfo); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH); //EDIT_SetDecMode(hItem, 24, 1,256, 0, 0); EDIT_SetFont(hItem,GUI_FONT_32_1); EDIT_SetMaxLen(hItem, 50); EDIT_EnableBlink(hItem, 600, 1); EDIT_SetInsertMode(hItem,1); //strcpy ((char*)str,(char *)path_studyfile); //strcat ((char*)str,"/"); //strcat ((char*)str,"A.wtr"); EDIT_SetText(hItem,"A"); cursorindex=EDIT_GetCursorCharPos(hItem); WM_SetFocus(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OK); BUTTON_SetFont(hItem,&GUI_FontHZ_Song_12); BUTTON_SetSkinClassic(hItem); BUTTON_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED, GUI_GREEN); BUTTON_SetFocussable(hItem,0);//不接收焦点 hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CANCEL); BUTTON_SetFont(hItem,&GUI_FontHZ_Song_12); BUTTON_SetSkinClassic(hItem); BUTTON_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED, GUI_RED); BUTTON_SetFocussable(hItem,0);//不接收焦点 break; // USER START (Optionally insert additional message handling) // USER END case WM_KEY: //GUI_SendKeyMsg(GUI_KEY_TAB, 1);//改变输入焦点 break; case MY_MESSAGE_CLICK: GUI_SendKeyMsg(GUI_KEY_TAB, 1);//改变输入焦点 break; case MY_MESSAGE_OK: hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH); if(EDIT_GetNumChars(hItem)==0) { hItemwarn = WM_GetDialogItem(pMsg->hWin, ID_TEXT_WARNING); WM_ShowWindow(hItemwarn); break; } else { hItemwarn = WM_GetDialogItem(pMsg->hWin, ID_TEXT_WARNING); WM_HideWindow(hItemwarn); } hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0); store_dev=DROPDOWN_GetSel(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH); EDIT_GetText(hItem, str, 51); if(store_dev == 0)//usb { if(sizeof(path_studyfile) < 50) strcpy ((char*)filename,(char *)path_studyfile); else strcpy ((char*)filename,(char *)path_Default); } if(store_dev == 1)//sd { if(sizeof(path_studyfile) < 50) strcpy ((char*)filename,(char *)path_studyfile_sd); else strcpy ((char*)filename,(char *)path_Default_sd); } strcat ((char*)filename,"/"); strcat ((char*)filename,str); strcat ((char*)filename,".wtr"); hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_INFO); TEXT_SetText(hIteminfo, "正在保存自学习文件!"); WM_ShowWindow(hIteminfo); GUI_Exec(); res=WT_StudyFiles_Write(filename);//0-ok, 1-hardware error, 2-file operate error, if(res==0) { hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_INFO); TEXT_SetText(hIteminfo, (char *)"文件保存成功!"); WM_ShowWindow(hIteminfo); } else { hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_INFO); TEXT_SetText(hIteminfo, "警告:保存失败,未检测到存储设备!"); WM_ShowWindow(hIteminfo); break; } GUI_EndDialog(pMsg->hWin,0); break; case MY_MESSAGE_DOWN://向右移动光标 hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0); if(WM_HasFocus(hItem))//选择存储路径 { sel=DROPDOWN_GetSel(hItem); if(sel<1) { DROPDOWN_IncSel(hItem); } else //sel>=2 { DROPDOWN_SetSel(hItem,0); } } hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH); cursorpos=EDIT_GetCursorCharPos(hItem); NumChars = EDIT_GetNumChars(hItem); if(cursorpos <= (NumChars-1) ) { EDIT_SetCursorAtChar(hItem,cursorpos+1); EDIT_SetSel(hItem,cursorpos+1,cursorpos+1); cursorindex=EDIT_GetCursorCharPos(hItem); } //KeyLed_State.wheel=0; break; case MY_MESSAGE_UP://向左移动光标 hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH); cursorpos=EDIT_GetCursorCharPos(hItem); EDIT_SetCursorAtChar(hItem,cursorpos-1); EDIT_SetSel(hItem,cursorpos-1,cursorpos-1); cursorindex=EDIT_GetCursorCharPos(hItem); break; case MY_MESSAGE_WHEEL://处理滚轮事件 hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH); EDIT_SetCursorAtChar(hItem,cursorindex); index=KeyLed_State.wheel; if(KeyLed_State.wheel>=65 && KeyLed_State.wheel <130) index=KeyLed_State.wheel-65; if(KeyLed_State.wheel>=130 && KeyLed_State.wheel <195) index=KeyLed_State.wheel-130; if(KeyLed_State.wheel>=195) index=64; if(KeyLed_State.wheel<0 && KeyLed_State.wheel >= -65) index=KeyLed_State.wheel+65; if(KeyLed_State.wheel<-65 && KeyLed_State.wheel >= -130) index=KeyLed_State.wheel+130; if(KeyLed_State.wheel<-130) index=0; if(cursorindex==EDIT_GetCursorCharPos(hItem)) { EDIT_AddKey(hItem,GUI_KEY_DELETE); EDIT_AddKey(hItem,input_char[index]); cursorpos=EDIT_GetCursorCharPos(hItem); EDIT_SetSel(hItem,cursorpos-1,cursorpos-1); } break; case MY_MESSAGE_BUTTONDELETE://删除字符 hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH); if(WM_HasFocus(hItem)) { EDIT_AddKey(hItem,GUI_KEY_BACKSPACE); cursorindex=EDIT_GetCursorCharPos(hItem); } break; case WM_PAINT://绘制标题栏 GUI_SetColor(GUI_DARKBLUE); GUI_FillRect(0,0,480,22); GUI_SetColor(GUI_DARKGRAY); GUI_SetPenSize(6); GUI_DrawRect(0,0,480-2,222-2); break; default: WM_DefaultProc(pMsg); break; } }