📄 dialog_radio.c
字号:
/*********************************************************************************************************** uC/GUI* Universal graphic software for embedded applications** (c) Copyright 2002, Micrium Inc., Weston, FL* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH** 礐/GUI is protected by international copyright laws. Knowledge of the* source code may not be used to write a similar product. This file may* only be used in accordance with a license and should not be redistributed* in any way. We appreciate your understanding and fairness.*----------------------------------------------------------------------File : DIALOG_SliderColor.cPurpose : Example demonstrating the use of a DIALOG widget----------------------------------------------------------------------*/#include <stddef.h>#include "GUI.H"#include "DIALOG.h"/*********************************************************************** static data************************************************************************//*********************************************************************** Dialog resource** This table conatins the info required to create the dialog.* It has been created manually, but could also be created by a GUI-builder.*//*static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = { { FRAMEWIN_CreateIndirect, "Radio button sample", 0, 0, 0, 150, 140, FRAMEWIN_CF_MOVEABLE}, { RADIO_CreateIndirect, NULL, GUI_ID_RADIO0, 5, 10,0,0,0, 3 }, { TEXT_CreateIndirect, "Suspend" , 0, 25, 10, 70, 20, TEXT_CF_LEFT }, { TEXT_CreateIndirect, "Shut down", 0, 25, 30, 70, 20, TEXT_CF_LEFT }, { TEXT_CreateIndirect, "Restart after", 0, 25, 50, 70, 20, TEXT_CF_LEFT }, { TEXT_CreateIndirect, "seconds", 0, 40, 70, 70, 20, TEXT_CF_LEFT }, { EDIT_CreateIndirect, "200", GUI_ID_EDIT0, 5, 70, 30, 19, 0, 3}, { BUTTON_CreateIndirect, "OK", GUI_ID_OK, 5, 95, 60, 20 }, { BUTTON_CreateIndirect, "Cancel", GUI_ID_CANCEL, 80, 95, 60, 20 }};*/static GUI_WIDGET_CREATE_INFO _aDialogCreate[] = { { FRAMEWIN_CreateIndirect, "Radio button sample", 0, 0, 0, 320,240, FRAMEWIN_CF_MOVEABLE}, { TEXT_CreateIndirect, "Red:" , 0, 5, 20, 35, 20, TEXT_CF_LEFT }, { BUTTON_CreateIndirect, "Experiment 2", GUI_ID_BUTTON2, 1, 65, 70, 38}, { BUTTON_CreateIndirect, "Experiment 3", GUI_ID_BUTTON3, 1, 120, 70, 38}, { BUTTON_CreateIndirect, "Experiment 4", GUI_ID_BUTTON4, 1, 175, 70, 38}, { BUTTON_CreateIndirect, "Experiment 5", GUI_ID_BUTTON5, 120, 10, 70, 38}, { BUTTON_CreateIndirect, "Experiment 6", GUI_ID_BUTTON6, 120, 65, 70, 38}, { BUTTON_CreateIndirect, "Experiment 7", GUI_ID_BUTTON7, 120, 120, 70, 38}, { BUTTON_CreateIndirect, "Experiment 8", GUI_ID_BUTTON8, 120, 175, 70, 38}, { BUTTON_CreateIndirect, "Experiment 9", GUI_ID_BUTTON9, 243, 10, 70, 38}, { BUTTON_CreateIndirect, "Experiment 10", GUI_ID_BUTTON7, 243, 65, 70, 38}, { BUTTON_CreateIndirect, "Experiment 11", GUI_ID_BUTTON8, 243, 120, 70, 38}, { BUTTON_CreateIndirect, "Next", GUI_ID_BUTTON9, 243, 175, 70, 38}};static GUI_WIDGET_CREATE_INFO _aDialogCreate1[] = { { FRAMEWIN_CreateIndirect, "Radio button sample", 0, 0, 0, 320,240, FRAMEWIN_CF_MOVEABLE}, { TEXT_CreateIndirect, "好好好好好 Experi\nment 好" , 1, 10, 70, 38,GUI_TA_TOP | GUI_TA_HCENTER}, { BUTTON_CreateIndirect, "Experiment 2", GUI_ID_BUTTON2, 1, 65, 70, 38}, { BUTTON_CreateIndirect, "Experiment 3", GUI_ID_BUTTON3, 1, 120, 70, 38}, { BUTTON_CreateIndirect, "Experiment 4", GUI_ID_BUTTON4, 1, 175, 70, 38}, { BUTTON_CreateIndirect, "Experiment 5", GUI_ID_BUTTON5, 120, 10, 70, 38}, { BUTTON_CreateIndirect, "Experiment 6", GUI_ID_BUTTON6, 120, 65, 70, 38}, { BUTTON_CreateIndirect, "Experiment 7", GUI_ID_BUTTON7, 120, 120, 70, 38}, { BUTTON_CreateIndirect, "Next", GUI_ID_BUTTON9, 243, 175, 70, 38}};/*********************************************************************** static code************************************************************************//*********************************************************************** Dialog callback routine*/static void _cbCallback(WM_MESSAGE * pMsg) {/* int Sel; int NCode, Id; WM_HWIN hDlg, hItem; hDlg = pMsg->hWin; switch (pMsg->MsgId) { case WM_INIT_DIALOG: hItem = WM_GetDialogItem(hDlg, GUI_ID_EDIT0); EDIT_SetDecMode(hItem, 30, 0, 999, 0, 0); /* Select decimal mode *//* WM_DisableWindow(hItem); break; case WM_KEY: switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) { case GUI_ID_ESCAPE: GUI_EndDialog(hDlg, 1); break; case GUI_ID_ENTER: GUI_EndDialog(hDlg, 0); break; } break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); /* Id of widget *//* NCode = pMsg->Data.v; /* Notification code *//* switch (NCode) { case WM_NOTIFICATION_RELEASED: /* React only if released *//* if (Id == GUI_ID_OK) { /* OK Button *//* GUI_EndDialog(hDlg, 0); } if (Id == GUI_ID_CANCEL) { /* Cancel Button *//* GUI_EndDialog(hDlg, 1); } break; case WM_NOTIFICATION_VALUE_CHANGED: hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO0); Sel = RADIO_GetValue(hItem); hItem = WM_GetDialogItem(hDlg, GUI_ID_EDIT0); WM_SetEnableState(hItem, Sel == 2); break; } break; default: WM_DefaultProc(pMsg); }*/}/*********************************************************************** main************************************************************************/void Dialog_Radio(void) { GUI_Clear(); WM_SetDesktopColor(GUI_RED); /* Automacally update desktop window */ WM_SetCreateFlags(WM_CF_MEMDEV); /* Use memory devices on all windows to avoid flicker */ GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, 0, 0, 0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -