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_Edit.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_Edit.c 00041 Purpose : Example demonstrating the use of a EDIT widget 00042 Requirements: WindowManager - (x) 00043 MemoryDevices - ( ) 00044 AntiAliasing - ( ) 00045 VNC-Server - ( ) 00046 PNG-Library - ( ) 00047 TrueTypeFonts - ( ) 00048 ---------------------------------------------------------------------- 00049 */ 00050 #include "GUI.h" 00051 #include "EDIT.h" 00052 00053 /********************************************************************* 00054 * 00055 * Defines 00056 * 00057 ********************************************************************** 00058 */ 00059 #define WM_APP_SHOW_TEXT (WM_USER + 0) 00060 #define TEXT_MAXLEN 40 00061 00062 // 00063 // Recommended memory to run the sample with adequate performance 00064 // 00065 #define RECOMMENDED_MEMORY (1024L * 5) 00066 00067 /********************************************************************* 00068 * 00069 * Static code 00070 * 00071 ********************************************************************** 00072 */ 00073 /********************************************************************* 00074 * 00075 * _cbBk 00076 */ 00077 static void _cbBk(WM_MESSAGE * pMsg) { 00078 static WM_HWIN hEdit; 00079 static U8 ShowText; 00080 char aBuffer[TEXT_MAXLEN]; 00081 00082 switch (pMsg->MsgId) { 00083 case WM_PAINT: 00084 GUI_SetBkColor(GUI_DARKGRAY); 00085 GUI_Clear(); 00086 GUI_SetFont(&GUI_Font24_ASCII); 00087 GUI_DispStringHCenterAt("WIDGET_Edit - Sample", 160, 5); 00088 GUI_SetFont(&GUI_Font8x16); 00089 if (ShowText) { 00090 GUI_DispStringHCenterAt("The string you have modified is:", 160, 90); 00091 EDIT_GetText(hEdit, aBuffer, TEXT_MAXLEN); 00092 GUI_DispStringHCenterAt(aBuffer, 160, 110); 00093 } else { 00094 GUI_DispStringHCenterAt("Use keyboard to modify string...", 160, 90); 00095 } 00096 break; 00097 case WM_APP_SHOW_TEXT: 00098 if (hEdit == 0) { 00099 hEdit = pMsg->hWinSrc; 00100 } 00101 WM_HideWindow(hEdit); 00102 ShowText = 1; 00103 WM_InvalidateWindow(WM_HBKWIN); 00104 WM_CreateTimer(WM_HBKWIN, 0, 3000, 0); 00105 break; 00106 case WM_TIMER: 00107 ShowText = 0; 00108 WM_InvalidateWindow(WM_HBKWIN); 00109 WM_ShowWindow(hEdit); 00110 break; 00111 default: 00112 WM_DefaultProc(pMsg); 00113 } 00114 } 00115 00116 /********************************************************************* 00117 * 00118 * _cbEdit 00119 */ 00120 static void _cbEdit(WM_MESSAGE * pMsg) { 00121 const WM_KEY_INFO * pInfo; 00122 WM_MESSAGE Msg; 00123 00124 switch (pMsg->MsgId) { 00125 case WM_KEY: 00126 pInfo = (WM_KEY_INFO *)pMsg->Data.p; 00127 if (pInfo->Key == GUI_KEY_ENTER) { 00128 if (pInfo->PressedCnt == 0) { 00129 Msg.MsgId = WM_APP_SHOW_TEXT; 00130 Msg.hWinSrc = pMsg->hWin; 00131 WM_SendMessage(WM_HBKWIN, &Msg); 00132 return; 00133 } 00134 } 00135 } 00136 EDIT_Callback(pMsg); 00137 } 00138 00139 /********************************************************************* 00140 * 00141 * Public code 00142 * 00143 ********************************************************************** 00144 */ 00145 /********************************************************************* 00146 * 00147 * MainTask 00148 */ 00149 void MainTask(void) { 00150 EDIT_Handle hEdit; 00151 00152 GUI_Init(); 00153 // 00154 // Check if recommended memory for the sample is available 00155 // 00156 if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { 00157 GUI_ErrorOut("Not enough memory available."); 00158 return; 00159 } 00160 WM_SetCallback(WM_HBKWIN, _cbBk); 00161 hEdit = EDIT_CreateEx(50, 110, 220, 25, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_EDIT0, TEXT_MAXLEN); 00162 WM_SetCallback(hEdit, _cbEdit); 00163 EDIT_SetText(hEdit, "Press <ENTER> when done..."); 00164 EDIT_SetFont(hEdit, &GUI_Font8x16); 00165 EDIT_SetTextColor(hEdit, 0, GUI_RED); 00166 EDIT_EnableBlink(hEdit, 300, 1); 00167 WM_SetFocus(hEdit); 00168 while (1) { 00169 GUI_Delay(10); 00170 } 00171 } 00172 00173 /*************************** End of file ****************************/
Generated on Thu Jul 14 2022 12:58:43 by
