?? dialog_all.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_All.cPurpose : Example demonstrating DIALOG and widgets----------------------------------------------------------------------*/#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, "HFRK", 0, 0, 0, 159, 230, FRAMEWIN_CF_MOVEABLE, 0 }, { BUTTON_CreateIndirect, "OK", GUI_ID_OK, 80, 5, 60, 20 }, { BUTTON_CreateIndirect, "Cancel", GUI_ID_CANCEL, 80, 30, 60, 20 }, { TEXT_CreateIndirect, "LText", 0, 0, 55, 48, 15, TEXT_CF_LEFT }, { TEXT_CreateIndirect, "RText", 0, 0, 80, 48, 15, TEXT_CF_LEFT }, { EDIT_CreateIndirect, NULL, GUI_ID_EDIT0, 50, 55, 100, 15, 0, 50 }, { EDIT_CreateIndirect, NULL, GUI_ID_EDIT1, 50, 80, 100, 15, 0, 50 }, { TEXT_CreateIndirect, "Hex", 0, 0, 100, 48, 15, TEXT_CF_LEFT }, { EDIT_CreateIndirect, NULL, GUI_ID_EDIT2, 50, 100, 100, 15, 0, 6 }, { TEXT_CreateIndirect, "Bin", 0, 0, 120, 48, 15, TEXT_CF_LEFT }, { EDIT_CreateIndirect, NULL, GUI_ID_EDIT3, 50, 120, 100, 15 }, { LISTBOX_CreateIndirect, NULL, GUI_ID_LISTBOX0,0, 10, 60, 40 }, { CHECKBOX_CreateIndirect, NULL, GUI_ID_CHECK0, 0, 140, 0, 0 }, { CHECKBOX_CreateIndirect, NULL, GUI_ID_CHECK1, 20, 140, 0, 0 }, { SLIDER_CreateIndirect, NULL, GUI_ID_SLIDER0, 50, 140, 100, 20 }, { SLIDER_CreateIndirect, NULL, GUI_ID_SLIDER1, 0, 170, 150, 30 }};/*********************************************************************** Initializers for listbox*/static const GUI_ConstString _apListBox[] = { "English", "Deutsch", "Fran鏰is", "Japanese", "Italiano", NULL};/*********************************************************************** static code************************************************************************//*********************************************************************** Dialog callback routine*/static void _cbCallback(WM_MESSAGE * pMsg) { int NCode, Id; WM_HWIN hEdit0, hEdit1, hEdit2, hEdit3, hListBox; WM_HWIN hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_INIT_DIALOG: /* Get window handles for all widgets */ hEdit0 = WM_GetDialogItem(hWin, GUI_ID_EDIT0); hEdit1 = WM_GetDialogItem(hWin, GUI_ID_EDIT1); hEdit2 = WM_GetDialogItem(hWin, GUI_ID_EDIT2); hEdit3 = WM_GetDialogItem(hWin, GUI_ID_EDIT3); hListBox = WM_GetDialogItem(hWin, GUI_ID_LISTBOX0); /* Initialize all widgets */ EDIT_SetText(hEdit0, "Edit0"); EDIT_SetText(hEdit1, "Edit1"); EDIT_SetTextAlign(hEdit1, GUI_TA_LEFT); EDIT_SetHexMode(hEdit2, 0x1234, 0, 0xffff); EDIT_SetBinMode(hEdit3, 0x1234, 0, 0xffff); LISTBOX_SetText(hListBox, _apListBox); WM_DisableWindow (WM_GetDialogItem(hWin, GUI_ID_CHECK1)); CHECKBOX_Check( WM_GetDialogItem(hWin, GUI_ID_CHECK0)); CHECKBOX_Check( WM_GetDialogItem(hWin, GUI_ID_CHECK1)); SLIDER_SetWidth( WM_GetDialogItem(hWin, GUI_ID_SLIDER0), 5); SLIDER_SetValue( WM_GetDialogItem(hWin, GUI_ID_SLIDER1), 50); SCROLLBAR_CreateAttached(hListBox, SCROLLBAR_CF_VERTICAL); 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); /* 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(hWin, 0); } if (Id == GUI_ID_CANCEL) { /* Cancel Button */ GUI_EndDialog(hWin, 1); } break; } break; default: WM_DefaultProc(pMsg); }}/*********************************************************************** main************************************************************************/void Dialog_All(void) { GUI_Clear(); GUI_SetFont(&GUI_FontComic24B_ASCII); WM_SetDesktopColor(GUI_BLACK); WM_SetCreateFlags(WM_CF_MEMDEV); GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, 0, 0, 0);}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -