Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
WIDGET_Checkbox.c
00001 /********************************************************************* 00002 * SEGGER Microcontroller GmbH * 00003 * Solutions for real time microcontroller applications * 00004 ********************************************************************** 00005 * * 00006 * (c) 1996 - 2018 SEGGER Microcontroller GmbH * 00007 * * 00008 * Internet: www.segger.com Support: support@segger.com * 00009 * * 00010 ********************************************************************** 00011 00012 ** emWin V5.48 - Graphical user interface for embedded applications ** 00013 All Intellectual Property rights in the Software belongs to SEGGER. 00014 emWin is protected by international copyright laws. Knowledge of the 00015 source code may not be used to write a similar product. This file may 00016 only be used in accordance with the following terms: 00017 00018 The software has been licensed to Cypress Semiconductor Corporation, 00019 whose registered office is situated at 198 Champion Ct. San Jose, CA 00020 95134 USA solely for the purposes of creating libraries for Cypress 00021 PSoC3 and PSoC5 processor-based devices, sublicensed and distributed 00022 under the terms and conditions of the Cypress End User License 00023 Agreement. 00024 Full source code is available at: www.segger.com 00025 00026 We appreciate your understanding and fairness. 00027 ---------------------------------------------------------------------- 00028 Licensing information 00029 Licensor: SEGGER Microcontroller Systems LLC 00030 Licensed to: Cypress Semiconductor Corp, 198 Champion Ct., San Jose, CA 95134, USA 00031 Licensed SEGGER software: emWin 00032 License number: GUI-00319 00033 License model: Services and License Agreement, signed June 10th, 2009 00034 Licensed platform: Any Cypress platform (Initial targets are: PSoC3, PSoC5) 00035 ---------------------------------------------------------------------- 00036 Support and Update Agreement (SUA) 00037 SUA period: 2009-06-12 - 2022-07-27 00038 Contact to extend SUA: sales@segger.com 00039 ---------------------------------------------------------------------- 00040 File : WIDGET_CheckBox.c 00041 Purpose : Example demonstrating the use of a CHECKBOX widget 00042 Requirements: WindowManager - (x) 00043 MemoryDevices - ( ) 00044 AntiAliasing - ( ) 00045 VNC-Server - ( ) 00046 PNG-Library - ( ) 00047 TrueTypeFonts - ( ) 00048 ---------------------------------------------------------------------- 00049 */ 00050 00051 #include <stddef.h> 00052 #include "GUI.h" 00053 #include "DIALOG.h" 00054 #include "Main.h" 00055 00056 // 00057 // Recommended memory to run the sample with adequate performance 00058 // 00059 #define RECOMMENDED_MEMORY (1024L * 10) 00060 00061 /********************************************************************* 00062 * 00063 * Static data 00064 * 00065 ********************************************************************** 00066 */ 00067 00068 // 00069 // Dialog resource 00070 // 00071 static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = { 00072 { FRAMEWIN_CreateIndirect, "Check box sample", 0, 10, 10, 300, 220, FRAMEWIN_CF_MOVEABLE}, 00073 { TEXT_CreateIndirect, "Enabled:", 0, 5, 10, 120, 0 }, 00074 { CHECKBOX_CreateIndirect, 0, GUI_ID_CHECK0, 5, 30, 120, 0 }, 00075 { CHECKBOX_CreateIndirect, 0, GUI_ID_CHECK1, 5, 60, 120, 0 }, 00076 { CHECKBOX_CreateIndirect, 0, GUI_ID_CHECK2, 5, 90, 120, 20 }, 00077 { CHECKBOX_CreateIndirect, 0, GUI_ID_CHECK3, 5, 125, 120, 26 }, 00078 { TEXT_CreateIndirect, "Disabled:", 0, 150, 10, 120, 0 }, 00079 { CHECKBOX_CreateIndirect, 0, GUI_ID_CHECK4, 150, 30, 120, 0 }, 00080 { CHECKBOX_CreateIndirect, 0, GUI_ID_CHECK5, 150, 60, 120, 0 }, 00081 { CHECKBOX_CreateIndirect, 0, GUI_ID_CHECK6, 150, 90, 120, 26 }, 00082 { CHECKBOX_CreateIndirect, 0, GUI_ID_CHECK7, 150, 125, 120, 26 }, 00083 { BUTTON_CreateIndirect, "OK", GUI_ID_OK, 10, 170, 60, 20 }, 00084 { BUTTON_CreateIndirect, "Cancel", GUI_ID_CANCEL, 225, 170, 60, 20 }, 00085 }; 00086 00087 // 00088 // Check box text 00089 // 00090 static const char * _apLabel[] = { 00091 "Default", 00092 "3 States", 00093 "Box XL", 00094 "Box XXL" 00095 }; 00096 00097 /********************************************************************* 00098 * 00099 * Static code 00100 * 00101 ********************************************************************** 00102 */ 00103 /********************************************************************* 00104 * 00105 * _cbCallback 00106 */ 00107 static void _cbCallback(WM_MESSAGE * pMsg) { 00108 WM_HWIN hDlg; 00109 WM_HWIN hItem; 00110 int i; 00111 int NCode; 00112 int Id; 00113 00114 hDlg = pMsg->hWin; 00115 switch (pMsg->MsgId) { 00116 case WM_INIT_DIALOG: 00117 WM_GetDialogItem(hDlg, GUI_ID_CHECK0); 00118 for (i = 0; i < 8; i++) { 00119 int Index = i % 4; 00120 hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK0 + i); // Get the handle of the desired checkbox 00121 CHECKBOX_SetText(hItem, _apLabel[Index]); // Set the check box text 00122 switch (Index) { 00123 case 1: 00124 // 00125 // Set the number of possible states to 3 00126 // 00127 CHECKBOX_SetNumStates(hItem, 3); 00128 // 00129 // Use user defined bitmaps for the third state 00130 // 00131 CHECKBOX_SetImage(hItem, &_abmBar[0], CHECKBOX_BI_INACTIV_3STATE); // Used if widget is disabled 00132 CHECKBOX_SetImage(hItem, &_abmBar[1], CHECKBOX_BI_ACTIV_3STATE); // Used if widget is enabled 00133 CHECKBOX_SetState(hItem, 2); 00134 break; 00135 case 2: 00136 CHECKBOX_SetState(hItem, 1); 00137 // 00138 // Use user defined bitmaps for the 'checked' state 00139 // 00140 CHECKBOX_SetImage(hItem, &_abmXL[0], CHECKBOX_BI_INACTIV_CHECKED); // Used if widget is disabled 00141 CHECKBOX_SetImage(hItem, &_abmXL[1], CHECKBOX_BI_ACTIV_CHECKED); // Used if widget is enabled 00142 CHECKBOX_SetFont(hItem, &GUI_FontComic18B_ASCII); 00143 break; 00144 case 3: 00145 CHECKBOX_SetState(hItem, 1); 00146 // 00147 // Use user defined bitmaps for the 'checked' state 00148 // 00149 CHECKBOX_SetImage(hItem, &_abmXXL[0], CHECKBOX_BI_INACTIV_CHECKED); // Used if widget is disabled 00150 CHECKBOX_SetImage(hItem, &_abmXXL[1], CHECKBOX_BI_ACTIV_CHECKED); // Used if widget is enabled 00151 CHECKBOX_SetFont(hItem, &GUI_FontComic24B_ASCII); 00152 break; 00153 } 00154 // 00155 // Disable all check boxes shown on the right side of the dialog 00156 // 00157 if (i >= 4) { 00158 WM_DisableWindow(hItem); 00159 } 00160 } 00161 break; 00162 case WM_NOTIFY_PARENT: 00163 Id = WM_GetId(pMsg->hWinSrc); // Id of widget 00164 NCode = pMsg->Data.v; // Notification code 00165 switch (NCode) { 00166 case WM_NOTIFICATION_RELEASED: // React only if released 00167 if (Id == GUI_ID_OK) { // OK Button 00168 GUI_EndDialog(hDlg, 0); 00169 } 00170 if (Id == GUI_ID_CANCEL) { // Cancel Button 00171 GUI_EndDialog(hDlg, 1); 00172 } 00173 break; 00174 } 00175 break; 00176 default: 00177 WM_DefaultProc(pMsg); 00178 } 00179 } 00180 00181 /********************************************************************* 00182 * 00183 * Public code 00184 * 00185 ********************************************************************** 00186 */ 00187 /********************************************************************* 00188 * 00189 * MainTask 00190 */ 00191 void MainTask(void) { 00192 #if GUI_SUPPORT_MEMDEV 00193 WM_SetCreateFlags(WM_CF_MEMDEV); 00194 #endif 00195 GUI_Init(); 00196 // 00197 // Check if recommended memory for the sample is available 00198 // 00199 if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { 00200 GUI_ErrorOut("Not enough memory available."); 00201 return; 00202 } 00203 WM_SetDesktopColor(GUI_BLACK); 00204 while (1) { 00205 GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, 0, 0, 0); 00206 GUI_Delay(500); 00207 } 00208 } 00209 00210 /*************************** End of file ****************************/ 00211
Generated on Thu Jul 14 2022 12:58:43 by
