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_Spinbox.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_Spinbox.c 00041 Purpose : Shows how to use the SPINBOX widget. 00042 Requirements: WindowManager - (x) 00043 MemoryDevices - ( ) 00044 AntiAliasing - ( ) 00045 VNC-Server - ( ) 00046 PNG-Library - ( ) 00047 TrueTypeFonts - ( ) 00048 ---------------------------END-OF-HEADER------------------------------ 00049 */ 00050 00051 #include "GUI.h" 00052 #include "DIALOG.h" 00053 00054 /********************************************************************* 00055 * 00056 * Defines 00057 * 00058 ********************************************************************** 00059 */ 00060 // 00061 // Recommended memory to run the sample with adequate performance 00062 // 00063 #define RECOMMENDED_MEMORY (1024L * 10) 00064 00065 /********************************************************************* 00066 * 00067 * Static data 00068 * 00069 ********************************************************************** 00070 */ 00071 static const GUI_WIDGET_CREATE_INFO _aDialogSpinbox[] = { 00072 { FRAMEWIN_CreateIndirect, "Spinbox", 0, 0, 0, 260, 160, 0, 0, 0 }, 00073 { TEXT_CreateIndirect, "Step value", GUI_ID_TEXT0, 20, 15, 100, 21, 0, 0, 0 }, 00074 { TEXT_CreateIndirect, "Editmode \"Step\"", GUI_ID_TEXT1, 20, 42, 100, 21, 0, 0, 0 }, 00075 { TEXT_CreateIndirect, "Editmode \"Edit\"", GUI_ID_TEXT2, 20, 75, 100, 21, 0, 0, 0 }, 00076 { SPINBOX_CreateIndirect, NULL, GUI_ID_SPINBOX0, 130, 15, 60, 21, 0, 0, 0 }, 00077 { SPINBOX_CreateIndirect, NULL, GUI_ID_SPINBOX1, 130, 42, 60, 21, 0, 0, 0 }, 00078 { SPINBOX_CreateIndirect, NULL, GUI_ID_SPINBOX2, 130, 75, 60, 21, 0, 0, 0 }, 00079 }; 00080 00081 /********************************************************************* 00082 * 00083 * Static code 00084 * 00085 ********************************************************************** 00086 */ 00087 /********************************************************************* 00088 * 00089 * _cbBk 00090 */ 00091 static void _cbBk(WM_MESSAGE * pMsg) { 00092 int xSize; 00093 int ySize; 00094 00095 switch (pMsg->MsgId) { 00096 case WM_PAINT: 00097 xSize = LCD_GetXSize(); 00098 ySize = LCD_GetYSize(); 00099 GUI_DrawGradientV(0, 0, xSize, ySize, GUI_BLUE, GUI_BLACK); 00100 GUI_SetColor(GUI_WHITE); 00101 GUI_SetFont(&GUI_Font24_ASCII); 00102 GUI_SetTextMode(GUI_TM_TRANS); 00103 GUI_DispStringHCenterAt("WIDGET_Spinbox - Sample", xSize / 2, 5); 00104 break; 00105 default: 00106 WM_DefaultProc(pMsg); 00107 } 00108 } 00109 00110 /********************************************************************* 00111 * 00112 * _cbClient 00113 */ 00114 static void _cbClient(WM_MESSAGE * pMsg) { 00115 EDIT_Handle hEdit; 00116 WM_HWIN hItem; 00117 int Value; 00118 int NCode; 00119 int Id; 00120 00121 switch (pMsg->MsgId) { 00122 case WM_INIT_DIALOG: 00123 FRAMEWIN_SetFont(pMsg->hWin, GUI_FONT_16B_ASCII); 00124 FRAMEWIN_SetSkin(pMsg->hWin, FRAMEWIN_SKIN_FLEX); 00125 hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_TEXT0); 00126 TEXT_SetTextAlign(hItem, GUI_TA_VCENTER | GUI_TA_RIGHT); 00127 hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_TEXT1); 00128 TEXT_SetTextAlign(hItem, GUI_TA_VCENTER | GUI_TA_RIGHT); 00129 hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_TEXT2); 00130 TEXT_SetTextAlign(hItem, GUI_TA_VCENTER | GUI_TA_RIGHT); 00131 hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_SPINBOX0); 00132 SPINBOX_SetSkin(hItem, SPINBOX_SKIN_FLEX); 00133 hEdit = SPINBOX_GetEditHandle(hItem); 00134 EDIT_SetDecMode(hEdit, 1, 1, 10, 0, 0); 00135 hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_SPINBOX1); 00136 SPINBOX_SetSkin(hItem, SPINBOX_SKIN_FLEX); 00137 hEdit = SPINBOX_GetEditHandle(hItem); 00138 EDIT_SetDecMode(hEdit, 1, 0, 99999, 0, 0); 00139 hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_SPINBOX2); 00140 SPINBOX_SetSkin(hItem, SPINBOX_SKIN_FLEX); 00141 SPINBOX_SetEditMode(hItem, SPINBOX_EM_EDIT); 00142 SPINBOX_SetRange(hItem, 0, 99999); 00143 break; 00144 case WM_NOTIFY_PARENT: 00145 NCode = pMsg->Data.v; 00146 switch (NCode) { 00147 case WM_NOTIFICATION_VALUE_CHANGED: 00148 Id = WM_GetId(pMsg->hWinSrc); 00149 if (Id == GUI_ID_SPINBOX0) { 00150 Value = SPINBOX_GetValue(pMsg->hWinSrc); 00151 hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_SPINBOX1); 00152 SPINBOX_SetStep(hItem, Value); 00153 } 00154 break; 00155 default: 00156 WM_DefaultProc(pMsg); 00157 } 00158 break; 00159 case WM_PAINT: 00160 GUI_SetBkColor(GUI_MAKE_COLOR(0xAE9E8D)); 00161 GUI_Clear(); 00162 break; 00163 default: 00164 WM_DefaultProc(pMsg); 00165 } 00166 } 00167 00168 /********************************************************************* 00169 * 00170 * Public code 00171 * 00172 ********************************************************************** 00173 */ 00174 /********************************************************************* 00175 * 00176 * MainTask 00177 */ 00178 void MainTask(void) { 00179 GUI_Init(); 00180 // 00181 // Check if recommended memory for the sample is available 00182 // 00183 if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { 00184 GUI_ErrorOut("Not enough memory available."); 00185 return; 00186 } 00187 WM_SetCallback(WM_HBKWIN, _cbBk); 00188 TEXT_SetDefaultTextColor(GUI_WHITE); 00189 GUI_CreateDialogBox(_aDialogSpinbox, GUI_COUNTOF(_aDialogSpinbox), _cbClient, WM_HBKWIN, 30, 60); 00190 while (1) { 00191 GUI_Delay(100); 00192 } 00193 } 00194 00195 /*************************** End of file ****************************/
Generated on Thu Jul 14 2022 12:58:43 by
