Andrew Reed / Mbed OS CITY1082-i2c_master_wifi_mqtt
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers WIDGET_Window.c Source File

WIDGET_Window.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_Window.c
00041 Purpose     : Example demonstrating the use of a WINDOW widget
00042 Requirements: WindowManager - (x)
00043               MemoryDevices - ( )
00044               AntiAliasing  - ( )
00045               VNC-Server    - ( )
00046               PNG-Library   - ( )
00047               TrueTypeFonts - ( )
00048 ----------------------------------------------------------------------
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 * 5)
00064 
00065 /*********************************************************************
00066 *
00067 *       Static data
00068 *
00069 **********************************************************************
00070 */
00071 /*********************************************************************
00072 *
00073 *       _aDialog
00074 *
00075 * Function description
00076 *   Dialog resource using a WINDOW widget
00077 */
00078 static const GUI_WIDGET_CREATE_INFO _aDialog[] = {
00079   { WINDOW_CreateIndirect, "",       0,               0,  0,   260, 200, 0               },
00080   { TEXT_CreateIndirect,   "Dialog", 0,               80, 5,   100, 20,  TEXT_CF_HCENTER },
00081   { BUTTON_CreateIndirect, "Close",  GUI_ID_BUTTON0,  80, 160, 100, 20,  0               }
00082 };
00083 
00084 /*********************************************************************
00085 *
00086 *       Static code
00087 *
00088 **********************************************************************
00089 */
00090 /*********************************************************************
00091 *
00092 *       _cbDialog
00093 *
00094 * Function description
00095 *   Callback routine of the dialog
00096 */
00097 static void _cbDialog(WM_MESSAGE *pMsg) {
00098   int NCode;
00099   int Id;
00100 
00101   switch (pMsg->MsgId) {
00102   case WM_PAINT:
00103     GUI_SetBkColor(GUI_GREEN);
00104     GUI_Clear();
00105     break;
00106   case WM_NOTIFY_PARENT:
00107     Id    = WM_GetId(pMsg->hWinSrc);    // Id of widget
00108     NCode = pMsg->Data.v;               // Notification code
00109     switch (NCode) {
00110     case WM_NOTIFICATION_RELEASED:      // React only if released
00111       switch (Id) {
00112       case GUI_ID_BUTTON0:
00113         GUI_EndDialog(pMsg->hWin, 0);
00114         break;
00115       }
00116       break;
00117     }
00118     break;
00119   default:
00120     WM_DefaultProc(pMsg);
00121   }
00122 }
00123 
00124 /*********************************************************************
00125 *
00126 *       Public code
00127 *
00128 **********************************************************************
00129 */
00130 /*********************************************************************
00131 *
00132 *       MainTask
00133 */
00134 void MainTask(void) {
00135   GUI_Init();
00136   //
00137   // Check if recommended memory for the sample is available
00138   //
00139   if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) {
00140     GUI_ErrorOut("Not enough memory available."); 
00141     return;
00142   }
00143   while(1) {
00144     GUI_DispStringHCenterAt("WIDGET_Window sample\nshows how to use a WINDOW widget", 160, 5);
00145     GUI_ExecDialogBox(_aDialog, GUI_COUNTOF(_aDialog), _cbDialog, WM_HBKWIN, 30, 30);
00146     GUI_Clear();
00147     GUI_DispStringHCenterAt("Dialog has been closed", 160, 5);
00148     GUI_Delay(1000);
00149     GUI_Clear();
00150   }
00151 }
00152 
00153 /*************************** End of file ****************************/