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; }
/********************************************************************* * * EDIT_Callback */ void EDIT_Callback (WM_MESSAGE * pMsg) { int IsEnabled; EDIT_Handle hObj; EDIT_Obj* pObj; hObj = (EDIT_Handle) pMsg->hWin; pObj = (EDIT_Obj *)GUI_ALLOC_h2p(hObj); /* Don't use use WIDGET_H2P because WIDGET_INIT_ID() has not be called at this point */ IsEnabled = WM__IsEnabled(hObj); /* Let widget handle the standard messages */ if (WIDGET_HandleActive(hObj, pMsg) == 0) { return; } switch (pMsg->MsgId) { case WM_TOUCH: _OnTouch(hObj, pObj, pMsg); break; case WM_PAINT: GUI_DEBUG_LOG("EDIT: _Callback(WM_PAINT)\n"); _Paint(pObj, hObj); return; case WM_DELETE: GUI_DEBUG_LOG("EDIT: _Callback(WM_DELETE)\n"); _Delete(pObj); break; /* No return here ... WM_DefaultProc needs to be called */ case WM_KEY: if (IsEnabled) { 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_ENTER: case GUI_KEY_ESCAPE: case GUI_KEY_TAB: case GUI_KEY_BACKTAB: break; /* Send to parent by not doing anything */ default: EDIT_AddKey(hObj, Key); return; } } } break; } WM_DefaultProc(pMsg); }
/********************************************************************* * * Callback */ static void EDIT__Callback (WM_MESSAGE * pMsg) { int IsEnabled; EDIT_Handle hObj = (EDIT_Handle)pMsg->hWin; EDIT_Obj* pObj = (EDIT_Obj*)WM_HMEM2Ptr(hObj); IsEnabled = WIDGET__IsEnabled(&pObj->Widget); /* Let widget handle the standard messages */ if (WIDGET_HandleActive(hObj, pMsg) == 0) { return; } switch (pMsg->MsgId) { case WM_TOUCH: if (IsEnabled) { _OnTouch(hObj, pObj, pMsg); } break; case WM_PAINT: GUI_DEBUG_LOG("EDIT: _Callback(WM_PAINT)\n"); _Paint(pObj); return; case WM_DELETE: GUI_DEBUG_LOG("EDIT: _Callback(WM_DELETE)\n"); _Delete(pObj); break; /* No return here ... WM_DefaultProc needs to be called */ case WM_KEY: if (IsEnabled) { if ( ((WM_KEY_INFO*)(pMsg->Data.p))->PressedCnt >0) { int Key = ((WM_KEY_INFO*)(pMsg->Data.p))->Key; switch (Key) { case GUI_KEY_TAB: break; /* Send to parent by not doing anything */ default: EDIT_AddKey(hObj, Key); return; } } } break; } WM_DefaultProc(pMsg); }
/******************************************************************************************************* * * 函数名称: * * 函数功能: * * 入口参数: * * 出口参数: 无 * * 说明: * *******************************************************************************************************/ void _cbKBDlgCallback1(WM_MESSAGE * pMsg) { int NCode; int id; int i; char str_buff[10]; WM_HWIN hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_PAINT: //TextNumPaintDialog(pMsg); break; case WM_INIT_DIALOG: InitKBDlg(pMsg); break; case WM_KEY: break; case WM_NOTIFY_PARENT: id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch (NCode) { case WM_NOTIFICATION_RELEASED: switch (id) { case GUI_ID_OK: GUI_EndDialog(hWindKB, 0); break; case GUI_ID_CANCEL: GUI_EndDialog(hWindKB, 0); break; } break; case WM_NOTIFICATION_CLICKED: switch(id) { case GUI_ID_BUTTON_CLR: //清除 EDIT_SetText(WM_GetDialogItem(hWin,GUI_ID_EDIT_KB_INPUT),"0"); break; case GUI_ID_BUTTON_BK_SPC: //退格 WM_SetFocus(WM_GetDialogItem(hWin,GUI_ID_EDIT_KB_INPUT)); GUI_SendKeyMsg(GUI_KEY_BACKSPACE,1); break; case GUI_ID_BUTTON_OK: EDIT_AddKey(WM_GetDialogItem(hWin,GUI_ID_EDIT_KB_INPUT),'\0'); EDIT_GetText(WM_GetDialogItem(hWin,GUI_ID_EDIT_KB_INPUT),str_buff,sizeof(str_buff)); GUI_EndDialog(hWin, atoi(str_buff)); break; case GUI_ID_BUTTON_CANCEL: GUI_EndDialog(hWin, -1); break; default: for (i = 0; i < 10; i++) //10个数字 { if (NumBtn09ID[i] == id) { EDIT_AddKey(WM_GetDialogItem(hWin,GUI_ID_EDIT_KB_INPUT),'0' + i); break; } } } break; } break; default: WM_DefaultProc(pMsg); } }
/********************************************************************* * * Dialog callback routine */ static void _cbBk_Frame(WM_MESSAGE * pMsg) { int NCode, Id; WM_HWIN hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_PAINT: PaintDialog(pMsg); break; case WM_INIT_DIALOG: InitDialog(pMsg); break; case WM_KEY: switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) { case GUI_KEY_ESCAPE: GUI_EndDialog(hWin, 1); break; case GUI_KEY_ENTER: GUI_EndDialog(hWin, 0); break; } break; case WM_NOTIFY_PARENT: GUI_DispStringAt("Frame",10,220); Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(NCode) { case WM_NOTIFICATION_RELEASED: { if(Id == GUI_ID_BUTTON0) { EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'0'); } if(Id == GUI_ID_BUTTON1) { EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'1'); } if(Id == GUI_ID_BUTTON2) { EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'2'); } if(Id == GUI_ID_BUTTON3) { EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'3'); } if(Id == GUI_ID_BUTTON4) { EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'4'); } if(Id == GUI_ID_BUTTON5) { EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'5'); } if(Id == GUI_ID_BUTTON6) { EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'6'); } if(Id == GUI_ID_BUTTON7) { EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'7'); } if(Id == GUI_ID_BUTTON8) { EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'8'); } if(Id == GUI_ID_BUTTON9) { EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'9'); } if(Id == GUI_ID_BUTTON10) { EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'.'); } /* BackSpace */ if(Id == GUI_ID_BUTTON11) { //EDIT_SetText(WM_GetDialogItem(hWin,GUI_ID_EDIT0),NULL);//清空输入框,挨个删除用下面两行 WM_SetFocus(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT)); GUI_SendKeyMsg(GUI_KEY_BACKSPACE,1); GPIO_ResetBits(GPIOF,GPIO_Pin_7); } /* PID Parameter Edit choese*/ { if(Id == GUI_ID_BUTTON12 || Id == GUI_ID_EDIT0) { PID_Para_Edit_Flag = Kp; PID_EDIT = PID_Para_Edit_Flag + GUI_ID_EDIT0; } if(Id == GUI_ID_BUTTON13 || Id == GUI_ID_EDIT1) { PID_Para_Edit_Flag = Ki; PID_EDIT = PID_Para_Edit_Flag + GUI_ID_EDIT0; } if(Id == GUI_ID_BUTTON14 || Id == GUI_ID_EDIT2) { PID_Para_Edit_Flag = Kd; PID_EDIT = PID_Para_Edit_Flag + GUI_ID_EDIT0; //GUI_ID_EDIT2 } if(Id == GUI_ID_BUTTON15 || Id == GUI_ID_EDIT3) { PID_Para_Edit_Flag = E; PID_EDIT = PID_Para_Edit_Flag + GUI_ID_EDIT0; } if(Id == GUI_ID_BUTTON17 || Id == GUI_ID_EDIT4) { PID_Para_Edit_Flag = Set; PID_EDIT = PID_Para_Edit_Flag + GUI_ID_EDIT0; //GUI_ID_EDIT2 } /* OK Key */ if(Id == GUI_ID_BUTTON16) { /* Store the last array(5) */ value_PID[CounterPID].Proportion = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT0) ); value_PID[CounterPID].Integral = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT1) ); value_PID[CounterPID].Derivative = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT2) ); value_PID[CounterPID].SetPoint = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT4) ); BK_Light = SLIDER_GetValue(WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_SLIDER0)); SetPWM(BK_Light,PWM_BACK_LIGHT); //!< Not the PID configuration Period PID_CFG_Flag = 0; WM_DeleteWindow(hWN_Dialog_PID_Frame); WM_ShowWindow(hWM_HBKWIN_CURVE); WM_HideWindow(hWM_HBKWIN_CFG_PID); } } /* Up and down of the order of the PID Array */ { if(Id == GUI_ID_BUTTON18) { value_PID[CounterPID].Proportion = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT0) ); value_PID[CounterPID].Integral = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT1) ); value_PID[CounterPID].Derivative = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT2) ); value_PID[CounterPID].SetPoint = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT4) ); /* Get the E_Percent */ { if(0 == CounterPID) { E_Percent[0] = EDIT_GetFloatValue ( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT3) ); E_Percent[1] = 1 - E_Percent[0]; } } CounterPID++; if(6 == CounterPID) { CounterPID = 0; } itoa(CounterPID,bufTextOrder,10); TEXT_SetText( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_TEXT0),bufTextOrder); if(1 == CounterPID) { EDIT_SetFloatValue ( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT3), E_Percent[1]); } /* Set the same value to edit */ if( 2 == CounterPID || 4 == CounterPID) { EDIT_SetFloatValue(WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT3),E_Percent[0]); EDIT_SetFloatValue(WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT4),value_PID[0].SetPoint); } else if( 3 == CounterPID || 5 == CounterPID) { EDIT_SetFloatValue(WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT3),E_Percent[1]); EDIT_SetFloatValue(WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT4),value_PID[1].SetPoint); } } /** Previous button **/ if(Id == GUI_ID_BUTTON19) { value_PID[CounterPID].Proportion = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT0) ); value_PID[CounterPID].Integral = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT1) ); value_PID[CounterPID].Derivative = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT2) ); value_PID[CounterPID].SetPoint = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT4) ); CounterPID--; if(-1 == CounterPID) { CounterPID = 5; } itoa(CounterPID,bufTextOrder,10); TEXT_SetText( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_TEXT0),bufTextOrder); } } if(Id == GUI_ID_SLIDER0) { BK_Light = SLIDER_GetValue(WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_SLIDER0)); SetPWM(BK_Light,PWM_BACK_LIGHT); } } break; } default: WM_DefaultProc(pMsg); } }
static void _cbCalculator(WM_MESSAGE *pMsg) { int NCode, Id; static float num1 = 0.00f, num2 = 0.00f, result = 0.00f; static U8 countnum1 = 0; static char str1[10] = { 0 }; static char oper = 0; char resultbuffer[80]; static U8 finishflag = 0; static U8 pointflag = 0; switch (pMsg->MsgId) { case WM_PAINT: GUI_SetBkColor(GUI_WHITE); GUI_Clear(); GUI_SetColor(GUI_RED); 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: /* Released */ switch (Id) { case BUTTON_ID_EXIT: GUI_SetAppIndex(APP_MainMenu); GUI_SetAppDirection(MEMDEV_ANIMATION_LEFT); //_MoveShiftWindow(&pMsg->hWin, MEMDEV_ANIMATION_RIGHT, 1, 1); GUI_SetCancel(APP_Calculator); GUI_ClearHalt(); break; case BUTTON_ID_CLEAR: memset(&str1, 0, sizeof(char)* 10); countnum1 = num1 = num2 = 0; pointflag = 0; EDIT_SetText(hEdit, " "); break; case BUTTON_ID_ADD: case BUTTON_ID_DIV: case BUTTON_ID_SUB: case BUTTON_ID_MUL: oper = Id; num1 = atof(str1); memset(&str1, 0, sizeof(char)* 10); countnum1 = 0; EDIT_AddKey(hEdit, Id); break; case BUTTON_ID_EQUAL: num2 = atof(str1); memset(&str1, 0, sizeof(char)* 10); countnum1 = 0; switch (oper) { case '+': result = num1 + num2; break; case '-': result = num1 - num2; break; case '*': result = num1 * num2; break; case '/': result = num1 / num2; break; default: break; } if ((pointflag == 1) || (oper == '/')) sprintf(resultbuffer, "%f", result); else sprintf(resultbuffer, "%d", (int)result); EDIT_SetText(hEdit, resultbuffer); finishflag = 1; pointflag = 0; break; default: if (finishflag == 1) { finishflag = 0; EDIT_SetText(hEdit, " "); } if (Id == '.') pointflag = 1; EDIT_AddKey(hEdit, Id); str1[countnum1] = Id; countnum1++; break; } break; default: break; } break; default: WM_DefaultProc(pMsg); } }
/********************************************************************* * * _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 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; } }