/********************************************************************* * * _OnValueChanged */ static void _OnValueChanged(WM_HWIN hDlg, int Id) { unsigned Index; unsigned v; WM_HWIN hSlider; WM_HWIN hEdit; Index = 0; v = 0; if ((Id >= GUI_ID_SLIDER0) && (Id <= GUI_ID_SLIDER2)) { Index = Id - GUI_ID_SLIDER0; // // SLIDER-widget has changed, update EDIT-widget // hSlider = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + Index); hEdit = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + Index); v = SLIDER_GetValue(hSlider); EDIT_SetValue(hEdit, v); } else if ((Id >= GUI_ID_EDIT0) && (Id <= GUI_ID_EDIT2)) { Index = Id - GUI_ID_EDIT0; // // If EDIT-widget has changed, update SLIDER-widget // hSlider = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + Index); hEdit = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + Index); v = EDIT_GetValue(hEdit); SLIDER_SetValue(hSlider, v); } _duty[Index] = v; // // At last invalidate dialog client window // WM_InvalidateWindow(WM_GetClientWindow(hDlg)); }
/********************************************************************* * * _cbCallback */ static void _cbCallback(WM_MESSAGE * pMsg) { int NCode; int Id; int Sel; char ac[80]; WM_HWIN hDlg; WM_HWIN hMulti; WM_HWIN hItem; hDlg = pMsg->hWin; hMulti = WM_GetDialogItem(hDlg, GUI_ID_MULTIEDIT0); switch (pMsg->MsgId) { case WM_INIT_DIALOG: hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0); SLIDER_SetRange(hItem, 1, 100); SLIDER_SetValue(hItem, 100); hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER1); SLIDER_SetRange(hItem, 1, 152); SLIDER_SetValue(hItem, 152); hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER2); SLIDER_SetRange(hItem, 0, 5); SLIDER_SetValue(hItem, 2); hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER3); SLIDER_SetRange(hItem, 0, 100); SLIDER_SetValue(hItem, 0); hItem = WM_GetDialogItem(hDlg, GUI_ID_EDIT1); EDIT_SetDecMode(hItem, 0, 0, 1000, 0, 0); hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO2); RADIO_SetText(hItem, "None", 0); RADIO_SetText(hItem, "Char", 1); RADIO_SetText(hItem, "Word", 2); hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO3); RADIO_SetText(hItem, "None", 0); RADIO_SetText(hItem, "Simple", 1); RADIO_SetText(hItem, "3D", 2); RADIO_SetValue(hItem, 2); RADIO_SetTextColor(hItem, GUI_BLUE); MULTIEDIT_EnableBlink(hMulti, 300, 1); MULTIEDIT_SetFont(hMulti, &GUI_Font8x16); MULTIEDIT_SetBkColor(hMulti, 0, GUI_YELLOW); MULTIEDIT_SetTextColor(hMulti, 0, GUI_BLUE); MULTIEDIT_SetAutoScrollV(hMulti, 1); MULTIEDIT_SetInsertMode(hMulti, 1); MULTIEDIT_SetPrompt(hMulti, "C:\\>"); MULTIEDIT_SetHBorder(hMulti, 2); MULTIEDIT_SetText(hMulti, "Multiedit - long line 12345678901234567890\nThis demonstrates the use of a MULTIEDIT widget"); MULTIEDIT_AddKey(hMulti, 'A'); MULTIEDIT_AddKey(hMulti, 'B'); MULTIEDIT_AddKey(hMulti, 'C'); MULTIEDIT_AddKey(hMulti, GUI_KEY_ENTER); MULTIEDIT_SetAutoScrollH(hMulti, 1); hItem = WM_GetDialogItem(hDlg, GUI_ID_BUTTON5); BUTTON_SetFocussable(hItem, 0); break; case WM_KEY: switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) { case GUI_KEY_ESCAPE: GUI_EndDialog(hDlg, 1); break; case GUI_KEY_ENTER: GUI_EndDialog(hDlg, 0); break; } break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; hItem = WM_GetDialogItem(hDlg, Id); switch (NCode) { case WM_NOTIFICATION_VALUE_CHANGED: switch (Id) { case GUI_ID_SLIDER0: Sel = SLIDER_GetValue(hItem); WM_SetYSize(hMulti, Sel); break; case GUI_ID_SLIDER1: Sel = SLIDER_GetValue(hItem); WM_SetXSize(hMulti, Sel); break; case GUI_ID_SLIDER2: Sel = SLIDER_GetValue(hItem); MULTIEDIT_SetHBorder(hMulti, Sel); break; case GUI_ID_SLIDER3: Sel = SLIDER_GetValue(hItem); MULTIEDIT_SetMaxNumChars(hMulti, Sel); break; case GUI_ID_RADIO0: // // Horizontal scrollbar // Sel = RADIO_GetValue(hItem); switch (Sel) { case 0: MULTIEDIT_SetAutoScrollH(hMulti, 1); // Auto break; case 1: MULTIEDIT_SetAutoScrollH(hMulti, 0); // Off WM_SetScrollbarH(hMulti, 0); break; case 2: MULTIEDIT_SetAutoScrollH(hMulti, 0); // On WM_SetScrollbarH(hMulti, 1); break; } break; case GUI_ID_RADIO1: // // Vertical scrollbar // Sel = RADIO_GetValue(hItem); switch (Sel) { case 0: MULTIEDIT_SetAutoScrollV(hMulti, 1); break; case 1: MULTIEDIT_SetAutoScrollV(hMulti, 0); WM_SetScrollbarV(hMulti, 0); break; case 2: MULTIEDIT_SetAutoScrollV(hMulti, 0); WM_SetScrollbarV(hMulti, 1); break; } break; case GUI_ID_RADIO2: // // Wrap // Sel = RADIO_GetValue(hItem); switch (Sel) { case 0: MULTIEDIT_SetWrapNone(hMulti); break; case 1: MULTIEDIT_SetWrapChar(hMulti); break; case 2: MULTIEDIT_SetWrapWord(hMulti); break; } break; case GUI_ID_RADIO3: // // Effect type // Sel = RADIO_GetValue(hItem); switch (Sel) { case 0: WIDGET_SetEffect(hMulti, &WIDGET_Effect_None); break; case 1: WIDGET_SetEffect(hMulti, &WIDGET_Effect_Simple); break; case 2: WIDGET_SetEffect(hMulti, &WIDGET_Effect_3D); break; } break; } break; case WM_NOTIFICATION_RELEASED: // React only if released WM_GetDialogItem(hDlg, Id); switch (Id) { case GUI_ID_OK: GUI_EndDialog(hDlg, 0); break; case GUI_ID_CANCEL: GUI_EndDialog(hDlg, 1); break; case GUI_ID_CHECK0: _RdOnly ^= 1; MULTIEDIT_SetReadOnly(hMulti, _RdOnly); break; case GUI_ID_CHECK1: _RTF8 ^= 1; if (_RTF8) { GUI_UC_SetEncodeUTF8(); } else { GUI_UC_SetEncodeNone(); } WM_InvalidateWindow(hMulti); break; case GUI_ID_CHECK2: _Password ^= 1; MULTIEDIT_SetPasswordMode(hMulti, _Password); break; case GUI_ID_BUTTON1: hItem = WM_GetDialogItem(hDlg, GUI_ID_EDIT0); EDIT_GetText(hItem, &ac[0], sizeof(ac)); MULTIEDIT_SetPrompt(hMulti, ac); break; case GUI_ID_BUTTON2: hItem = WM_GetDialogItem(hDlg, GUI_ID_EDIT1); MULTIEDIT_SetCursorOffset(hMulti, EDIT_GetValue(hItem)); WM_SetFocus(hMulti); break; case GUI_ID_BUTTON3: MULTIEDIT_SetText(hMulti, "Short text"); break; case GUI_ID_BUTTON4: MULTIEDIT_SetText(hMulti, "Long text\n123456789012345678901234567890\nLast line\n"); break; case GUI_ID_BUTTON5: MULTIEDIT_AddText(hMulti, "Added"); break; case GUI_ID_BUTTON6: MULTIEDIT_SetFont(hMulti, &GUI_Font8x16); break; case GUI_ID_BUTTON7: MULTIEDIT_SetFont(hMulti, &GUI_Font16_1); break; } break; } break; default: WM_DefaultProc(pMsg); } }
static void _cbDialog_VNC_SETTINGS(WM_MESSAGE * pMsg) { WM_HWIN hItem; int Id, NCode; switch (pMsg->MsgId) { case WM_INIT_DIALOG: /* Restore VNC settings */ _VNCServer_RestoreSettings(); /* Initialization of 'VNC Server Settings' */ hItem = pMsg->hWin; FRAMEWIN_SetTitleHeight(hItem, 18); /* Initialization of 'DHCP' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_DHCP); CHECKBOX_SetText(hItem, "Enable DHCP"); CHECKBOX_SetState(hItem, VNCSettings.dhcp_use.b.dhcp); /* Initialization of 'Edit' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_3); EDIT_SetDecMode(hItem, VNCSettings.ipaddr.b.addr3, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES); /* Initialization of 'Edit' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_2); EDIT_SetDecMode(hItem, VNCSettings.ipaddr.b.addr2, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES); /* Initialization of 'Edit' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_1); EDIT_SetDecMode(hItem, VNCSettings.ipaddr.b.addr1, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES); /* Initialization of 'Edit' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_0); EDIT_SetDecMode(hItem, VNCSettings.ipaddr.b.addr0, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES); /* Initialization of 'Edit' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_3); EDIT_SetDecMode(hItem, VNCSettings.maskaddr.b.addr3, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES); /* Initialization of 'Edit' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_2); EDIT_SetDecMode(hItem, VNCSettings.maskaddr.b.addr2, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES); /* Initialization of 'Edit' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_1); EDIT_SetDecMode(hItem, VNCSettings.maskaddr.b.addr1, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES); /* Initialization of 'Edit' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_0); EDIT_SetDecMode(hItem, VNCSettings.maskaddr.b.addr0, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES); /* Initialization of 'Edit' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_3); EDIT_SetDecMode(hItem, VNCSettings.gwaddr.b.addr3, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES); /* Initialization of 'Edit' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_2); EDIT_SetDecMode(hItem, VNCSettings.gwaddr.b.addr2, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES); /* Initialization of 'Edit' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_1); EDIT_SetDecMode(hItem, VNCSettings.gwaddr.b.addr1, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES); /* Initialization of 'Edit' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_0); EDIT_SetDecMode(hItem, VNCSettings.gwaddr.b.addr0, 0, 255, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES); /* If DHCP enabled: disable all Edits*/ if (VNCSettings.dhcp_use.b.dhcp) { hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_3); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_2); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_1); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_0); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_3); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_2); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_1); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_0); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_3); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_2); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_1); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_0); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); } break; case WM_DELETE: hWinVNC_Settings = 0; break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */ NCode = pMsg->Data.v; /* Notification code */ switch (NCode) { case WM_NOTIFICATION_RELEASED: /* React only if released */ switch (Id) { case ID_BUTTON_SETTINGS_CANCEL: /* Settings: Cancel */ /* Delete NumPad VNC Window */ WM_DeleteWindow(hNumPad); GUI_EndDialog(pMsg->hWin, 0); break; case ID_BUTTON_SETTINGS_OK: /* Settings: OK */ /* Save Settings */ hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_DHCP); if (CHECKBOX_GetState(hItem)) /* Use DHCP to allocate dynamic IP address */ { if(VNCSettings.dhcp_use.b.dhcp == 0) { VNCSettings.dhcp_use.b.dhcp = 1; VNCSettings.ipaddr.b.addr0 = 0; VNCSettings.ipaddr.b.addr1 = 0; VNCSettings.ipaddr.b.addr2 = 0; VNCSettings.ipaddr.b.addr3 = 0; VNCSettings.maskaddr.b.addr0 = 0; VNCSettings.maskaddr.b.addr1 = 0; VNCSettings.maskaddr.b.addr2 = 0; VNCSettings.maskaddr.b.addr3 = 0; VNCSettings.gwaddr.b.addr0 = 0; VNCSettings.gwaddr.b.addr1 = 0; VNCSettings.gwaddr.b.addr2 = 0; VNCSettings.gwaddr.b.addr3 = 0; hItem = WM_GetDialogItem(hWinVNC, ID_TEXT_DHCP_STATE); TEXT_SetText(hItem, (char const *)"Enabled"); hItem = WM_GetDialogItem(hWinVNC, ID_TEXT_IPADDR_VALUE); TEXT_SetText(hItem, (char const *)"Not assigned"); hItem = WM_GetDialogItem(hWinVNC, ID_TEXT_SUBNETMASK_VALUE); TEXT_SetText(hItem, (char const *)"Not assigned"); hItem = WM_GetDialogItem(hWinVNC, ID_TEXT_GWADDR_VALUE); TEXT_SetText(hItem, (char const *)"Not assigned"); if (start_button == VNC_HIDE) { hItem = WM_GetDialogItem(hWinVNC, ID_MULTIEDIT_VNC); MULTIEDIT_AddText(hItem, (const char *) "Network settings has been modified\r\n"); MULTIEDIT_AddText(hItem, (const char *) "Restart to apply new settings\r\n"); } } } /* Use static IP address */ else { if (VNCSettings.dhcp_use.b.dhcp == 1) { VNCSettings.dhcp_use.b.dhcp = 0; } if (start_button == VNC_HIDE) { hItem = WM_GetDialogItem(hWinVNC, ID_MULTIEDIT_VNC); MULTIEDIT_AddText(hItem, (const char *) "Network settings has been modified\r\n"); MULTIEDIT_AddText(hItem, (const char *) "Restart to apply new settings\r\n"); } /* Get the new network addresses configuration */ hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_3); VNCSettings.ipaddr.b.addr3 = EDIT_GetValue(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_2); VNCSettings.ipaddr.b.addr2 = EDIT_GetValue(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_1); VNCSettings.ipaddr.b.addr1 = EDIT_GetValue(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_0); VNCSettings.ipaddr.b.addr0 = EDIT_GetValue(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_3); VNCSettings.maskaddr.b.addr3 = EDIT_GetValue(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_2); VNCSettings.maskaddr.b.addr2 = EDIT_GetValue(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_1); VNCSettings.maskaddr.b.addr1 = EDIT_GetValue(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_0); VNCSettings.maskaddr.b.addr0 = EDIT_GetValue(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_3); VNCSettings.gwaddr.b.addr3 = EDIT_GetValue(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_2); VNCSettings.gwaddr.b.addr2 = EDIT_GetValue(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_1); VNCSettings.gwaddr.b.addr1 = EDIT_GetValue(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_0); VNCSettings.gwaddr.b.addr0 = EDIT_GetValue(hItem); _VNCApp_GetIPAddress(IP_ADDRESS, VNCSettings.ipaddr.b.addr3, VNCSettings.ipaddr.b.addr2, VNCSettings.ipaddr.b.addr1, VNCSettings.ipaddr.b.addr0); _VNCApp_GetIPAddress(SUBNET_MASK, VNCSettings.maskaddr.b.addr3, VNCSettings.maskaddr.b.addr2, VNCSettings.maskaddr.b.addr1, VNCSettings.maskaddr.b.addr0); _VNCApp_GetIPAddress(GW_ADDRESS, VNCSettings.gwaddr.b.addr3, VNCSettings.gwaddr.b.addr2, VNCSettings.gwaddr.b.addr1, VNCSettings.gwaddr.b.addr0); } /********** Save Settings ***********/ _VNCServer_SaveSettings(); /* Delete NumPad VNC Window */ WM_DeleteWindow(hNumPad); GUI_EndDialog(pMsg->hWin, 0); break; } break; case WM_NOTIFICATION_VALUE_CHANGED: switch (Id) { case ID_CHECKBOX_DHCP: { hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_DHCP); if (CHECKBOX_IsChecked(hItem)) { hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_3); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_2); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_1); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_0); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_3); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_2); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_1); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_0); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_3); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_2); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_1); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_0); WM_DisableWindow(hItem); EDIT_SetFocussable(hItem, 0); } else { hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_3); WM_EnableWindow(hItem); EDIT_SetFocussable(hItem, 1); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_2); WM_EnableWindow(hItem); EDIT_SetFocussable(hItem, 1); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_1); WM_EnableWindow(hItem); EDIT_SetFocussable(hItem, 1); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_IPADDRESS_0); WM_EnableWindow(hItem); EDIT_SetFocussable(hItem, 1); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_3); WM_EnableWindow(hItem); EDIT_SetFocussable(hItem, 1); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_2); WM_EnableWindow(hItem); EDIT_SetFocussable(hItem, 1); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_1); WM_EnableWindow(hItem); EDIT_SetFocussable(hItem, 1); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_SNMASK_0); WM_EnableWindow(hItem); EDIT_SetFocussable(hItem, 1); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_3); WM_EnableWindow(hItem); EDIT_SetFocussable(hItem, 1); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_2); WM_EnableWindow(hItem); EDIT_SetFocussable(hItem, 1); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_1); WM_EnableWindow(hItem); EDIT_SetFocussable(hItem, 1); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_GWADDRESS_0); WM_EnableWindow(hItem); EDIT_SetFocussable(hItem, 1); } } break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
/********************************************************************* * * Dialog callback routine */ static void _cbCallback(WM_MESSAGE * pMsg) { int NCode, Id; static int num_backup = 0; 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: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch (Id) { case GUI_ID_OK: if(NCode==WM_NOTIFICATION_RELEASED) { GUI_EndDialog(hWin, EDIT_GetValue(WM_GetDialogItem(hWin,GUI_ID_EDIT0))); num_backup = 0; } break; case GUI_ID_CANCEL: if(NCode==WM_NOTIFICATION_CLICKED) { num_backup = 0; EDIT_SetValue(WM_GetDialogItem(hWin,GUI_ID_EDIT0),num_backup); // GUI_EndDialog(hWin, 0); } break; case GUI_ID_EDIT0: switch(NCode) { case WM_NOTIFICATION_CLICKED: OnEditNumberClicked(pMsg); break; } break; case GUI_ID_BUTTON0: case GUI_ID_BUTTON1: case GUI_ID_BUTTON2: case GUI_ID_BUTTON3: case GUI_ID_BUTTON4: case GUI_ID_BUTTON5: case GUI_ID_BUTTON6: case GUI_ID_BUTTON7: case GUI_ID_BUTTON8: case GUI_ID_BUTTON9: if(NCode==WM_NOTIFICATION_CLICKED) { if(num_backup < 999999999) { num_backup = num_backup *10 +(Id - GUI_ID_BUTTON0); } if(num_backup > 999999999) { num_backup = 999999999; } EDIT_SetValue(WM_GetDialogItem(hWin,GUI_ID_EDIT0),num_backup); } break; } break; default: WM_DefaultProc(pMsg); } }
/********************************************************************* * * _cbDialogColor * * Function description * Callback routine of DialogColor */ static void _cbDialogColor(WM_MESSAGE * pMsg) { GUI_COLOR Color; WM_HWIN hDlg; WM_HWIN hItem; int i; int NCode; int Id; hDlg = pMsg->hWin; Color = 0; switch (pMsg->MsgId) { case WM_PAINT: // // Draw RGB values // GUI_SetColor(_aColorSep[0]); GUI_FillRect(180, 60, 199, 79); GUI_SetColor(_aColorSep[1] << 8); GUI_FillRect(180, 90, 199, 109); GUI_SetColor(((U32)_aColorSep[2]) << 16); GUI_FillRect(180, 120, 199, 139); // // Draw resulting color // GUI_SetColor(_aColorSep[0] | (((U32)_aColorSep[1]) << 8) | (((U32)_aColorSep[2]) << 16)); GUI_FillRect(205, 60, 285, 139); return; case WM_INIT_DIALOG: _ColorIndex = 0; for (i = 0; i < 3; i++) { hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + i); _aColorSep[i] = (_ColorBackGround & (0xff << (i * 8))) >> (i * 8); SLIDER_SetRange(hItem, 0, 255); SLIDER_SetValue(hItem, _aColorSep[i]); // // Init EDIT-widgets // hItem = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + i); EDIT_SetDecMode(hItem, _aColorSep[i], 0, 255, 0, 0); } // // Init dropdown widgets // hItem = WM_GetDialogItem(hDlg, GUI_ID_DROPDOWN0); DROPDOWN_SetAutoScroll(hItem, 1); DROPDOWN_AddString(hItem, "Background"); DROPDOWN_AddString(hItem, "Grid"); DROPDOWN_AddString(hItem, "Label"); DROPDOWN_AddString(hItem, "Temperature 1"); DROPDOWN_AddString(hItem, "Temperature 2"); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); // Id of widget NCode = pMsg->Data.v; // Notification code switch (NCode) { case WM_NOTIFICATION_RELEASED: // React only if released if (Id == GUI_ID_OK) { // OK Button _SaveCurrentColor(); _UpdateTextColors(_hDialogMain); hItem = WM_GetClientWindow(WM_GetDialogItem(_hDialogMain, ID_TEMPERATURE)); WM_InvalidateWindow(hItem); WM_SetFocus(WM_GetDialogItem(_hDialogMain, ID_TEMPERATURE)); GUI_SetOrg(0, 0); } break; case WM_NOTIFICATION_SEL_CHANGED: _SaveCurrentColor(); if (Id == GUI_ID_DROPDOWN0) { for (i = 0; i < 3; i++) { hItem = WM_GetDialogItem(hDlg, GUI_ID_DROPDOWN0); _ColorIndex = DROPDOWN_GetSel(hItem); hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + i); switch (_ColorIndex) { case 0: Color = _ColorBackGround; break; case 1: Color = _ColorGrid; break; case 2: Color = _ColorLabel; break; case 3: Color = _ColorTemp1; break; case 4: Color = _ColorTemp2; break; } _aColorSep[i] = (Color & (0xff << (i * 8))) >> (i * 8); SLIDER_SetRange(hItem, 0, 255); SLIDER_SetValue(hItem, _aColorSep[i]); // // Init EDIT-widgets // hItem = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + i); EDIT_SetDecMode(hItem, _aColorSep[i], 0, 255, 0, 0); } } break; case WM_NOTIFICATION_VALUE_CHANGED: // Value has changed { unsigned Index, v; WM_HWIN hSlider, hEdit; Index = 0; v = 0; if ((Id >= GUI_ID_SLIDER0) && (Id <= GUI_ID_SLIDER2)) { Index = Id - GUI_ID_SLIDER0; // // SLIDER-widget has changed, update EDIT-widget // hSlider = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + Index); hEdit = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + Index); v = SLIDER_GetValue(hSlider); EDIT_SetValue(hEdit, v); } else if ((Id >= GUI_ID_EDIT0) && (Id <= GUI_ID_EDIT2)) { Index = Id - GUI_ID_EDIT0; // // If EDIT-widget has changed, update SLIDER-widget // hSlider = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + Index); hEdit = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + Index); v = EDIT_GetValue(hEdit); SLIDER_SetValue(hSlider, v); } _aColorSep[Index] = v; // // At last invalidate dialog client window // WM_InvalidateWindow(WM_GetClientWindow(hDlg)); } break; } break; default: WM_DefaultProc(pMsg); } }