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

« Back to documentation index

Show/hide line numbers WIDGET_Multipage.c Source File

WIDGET_Multipage.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_Multipage.c
00041 Purpose     : Demonstrates the use of the MULTIPAGE widget
00042 Requirements: WindowManager - (x)
00043               MemoryDevices - (x)
00044               AntiAliasing  - ( )
00045               VNC-Server    - ( )
00046               PNG-Library   - ( )
00047               TrueTypeFonts - ( )
00048 ---------------------------END-OF-HEADER------------------------------
00049 */
00050 
00051 #include <stdlib.h>
00052 
00053 #include "GUI.h"
00054 #include "MULTIPAGE.h"
00055 
00056 /*********************************************************************
00057 *
00058 *       Defines
00059 *
00060 **********************************************************************
00061 */
00062 //
00063 // Recommended memory to run the sample with adequate performance
00064 //
00065 #define RECOMMENDED_MEMORY (1024L * 20)
00066 
00067 /*********************************************************************
00068 *
00069 *       Static data
00070 *
00071 **********************************************************************
00072 */
00073 /*********************************************************************
00074 *
00075 *       Dialog resource
00076 *
00077 *  These tables contain the information required to create the dialogs.
00078 *  It has been created manually, but could also be created by the GUIBuilder.
00079 */
00080 static const GUI_WIDGET_CREATE_INFO _aDialogCreate1[] = {
00081   { WINDOW_CreateIndirect,    "Dialog 1", 0,                   0,   0, 260, 100, FRAMEWIN_CF_MOVEABLE },
00082   { BUTTON_CreateIndirect,    "Button",   GUI_ID_BUTTON0,      5,  30,  80,  20, 0},
00083   { TEXT_CreateIndirect,      "Dialog 1", 0,                   5,  10,  50,  20, TEXT_CF_LEFT }
00084 };
00085 
00086 static const GUI_WIDGET_CREATE_INFO _aDialogCreate2[] = {
00087   { WINDOW_CreateIndirect,    "Dialog 2", 0,                   0,   0, 260, 100, FRAMEWIN_CF_MOVEABLE },
00088   { CHECKBOX_CreateIndirect,  "",         GUI_ID_CHECK0,       5,  30,   0,   0, 0},
00089   { CHECKBOX_CreateIndirect,  "",         GUI_ID_CHECK1,       5,  50,   0,   0, 0},
00090   { TEXT_CreateIndirect,      "Select 0", GUI_ID_TEXT0,       25,  30,  50,  15, TEXT_CF_LEFT },
00091   { TEXT_CreateIndirect,      "Select 1", GUI_ID_TEXT1,       25,  50,  50,  15, TEXT_CF_LEFT },
00092   { TEXT_CreateIndirect,      "Dialog 2", 0,                   5,  10,  50,  20, TEXT_CF_LEFT }
00093 };
00094 
00095 static const GUI_WIDGET_CREATE_INFO _aDialogCreate3[] = {
00096   { WINDOW_CreateIndirect,    "Dialog 3", 0,                   0,   0, 260, 100, FRAMEWIN_CF_MOVEABLE },
00097   { RADIO_CreateIndirect,     "",         GUI_ID_RADIO0,       5,  30,   0,   0, 0, 3},
00098   { TEXT_CreateIndirect,      "Option 1", GUI_ID_TEXT0,       25,  30,  50,  15, TEXT_CF_LEFT },
00099   { TEXT_CreateIndirect,      "Option 2", GUI_ID_TEXT1,       25,  50,  50,  15, TEXT_CF_LEFT },
00100   { TEXT_CreateIndirect,      "Option 3", GUI_ID_TEXT2,       25,  70,  50,  15, TEXT_CF_LEFT },
00101   { TEXT_CreateIndirect,      "Dialog 3", 0,                   5,  10,  50,  20, TEXT_CF_LEFT }
00102 };
00103 
00104 static const GUI_WIDGET_CREATE_INFO _aDialogCreate4[] = {
00105   { WINDOW_CreateIndirect,    "Dialog 4", 0,                   0,   0, 260, 100, FRAMEWIN_CF_MOVEABLE },
00106   { MULTIEDIT_CreateIndirect, "Text",     GUI_ID_MULTIEDIT0,   5,  30, 200,  40  },
00107   { TEXT_CreateIndirect,      "Dialog 4", 0,                   5,  10,  50,  20, TEXT_CF_LEFT }
00108 };
00109 
00110 static const GUI_WIDGET_CREATE_INFO _aDialogCreate5[] = {
00111   { WINDOW_CreateIndirect,    "Dialog 5", 0,                   0,   0, 260, 100, FRAMEWIN_CF_MOVEABLE },
00112   { SLIDER_CreateIndirect,    "",         GUI_ID_SLIDER0,      5,  30, 200,  40  },
00113   { TEXT_CreateIndirect,      "Dialog 5", 0,                   5,  10,  50,  20, TEXT_CF_LEFT }
00114 };
00115 
00116 static const GUI_WIDGET_CREATE_INFO _aDialogCreate6[] = {
00117   { WINDOW_CreateIndirect,    "Dialog 6", 0,                   0,   0, 260, 100, FRAMEWIN_CF_MOVEABLE },
00118   { SCROLLBAR_CreateIndirect, "",         GUI_ID_SCROLLBAR0,   5,  30, 200,  40  },
00119   { TEXT_CreateIndirect,      "Dialog 6", 0,                   5,  10,  50,  20, TEXT_CF_LEFT }
00120 };
00121 
00122 /*********************************************************************
00123 *
00124 *       Static code
00125 *
00126 **********************************************************************
00127 */
00128 /*********************************************************************
00129 *
00130 *       _cbDialog4
00131 */
00132 static void _cbDialog4(WM_MESSAGE * pMsg) {
00133   WM_HWIN hItem;
00134   WM_HWIN hDlg;
00135 
00136   hDlg = pMsg->hWin;
00137   switch (pMsg->MsgId) {
00138   case WM_INIT_DIALOG:
00139     hItem = WM_GetDialogItem(hDlg, GUI_ID_MULTIEDIT0);
00140     MULTIEDIT_SetText(hItem, "MULTIEDIT widget");
00141     MULTIEDIT_SetInsertMode(hItem, 1);
00142     break;
00143   default:
00144     WM_DefaultProc(pMsg);
00145   }
00146 }
00147 
00148 /*********************************************************************
00149 *
00150 *       _cbBkWindow
00151 *
00152 *  Function description
00153 *    Callback routine of the background window.
00154 *    It shows the sample title and draws the background.
00155 */
00156 static void _cbBkWindow(WM_MESSAGE * pMsg) {
00157   switch (pMsg->MsgId) {
00158   case WM_PAINT:
00159     GUI_SetBkColor(GUI_BLUE);
00160     GUI_Clear();
00161     GUI_SetColor(GUI_WHITE);
00162     GUI_SetFont(&GUI_Font24_ASCII);
00163     GUI_DispStringHCenterAt("WIDGET_Multipage - Sample", 160, 5);
00164     break;
00165   default:
00166     WM_DefaultProc(pMsg);
00167   }
00168 }
00169 
00170 /*********************************************************************
00171 *
00172 *       Public code
00173 *
00174 **********************************************************************
00175 */
00176 /*********************************************************************
00177 *
00178 *       MainTask
00179 */
00180 void MainTask(void) {
00181   WM_HWIN hMultiPage;
00182   WM_HWIN hFrameWin;
00183   WM_HWIN hDialog;
00184 
00185   //
00186   // Enable use of memory devices
00187   //
00188   WM_SetCreateFlags(WM_CF_MEMDEV);
00189   GUI_Init();
00190   //
00191   // Check if recommended memory for the sample is available
00192   //
00193   if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) {
00194     GUI_ErrorOut("Not enough memory available."); 
00195     return;
00196   }
00197   WM_SetCallback(WM_HBKWIN, _cbBkWindow);
00198   //
00199   // Create the frame window
00200   //
00201   hFrameWin = FRAMEWIN_Create("FrameWindow", NULL, WM_CF_SHOW, 40, 44, 240, 152);
00202   FRAMEWIN_SetClientColor(hFrameWin, GUI_GREEN);
00203   FRAMEWIN_SetActive(hFrameWin, 1);
00204   FRAMEWIN_SetMoveable(hFrameWin, 1);
00205   //
00206   // Create the MULTIPAGE widget
00207   //
00208   hMultiPage = MULTIPAGE_CreateEx(7, 6, 220, 120, WM_GetClientWindow(hFrameWin), WM_CF_SHOW, 0, 0);
00209   GUI_Delay(500);
00210   //
00211   // Create and attach the MULTIPAGE dialog windows
00212   //
00213   hDialog = GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), NULL,       WM_UNATTACHED, 0, 0);
00214   MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 1");
00215   GUI_Delay(500);
00216   hDialog = GUI_CreateDialogBox(_aDialogCreate2, GUI_COUNTOF(_aDialogCreate2), NULL,       WM_UNATTACHED, 0, 0);
00217   MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 2");
00218   GUI_Delay(500);
00219   hDialog = GUI_CreateDialogBox(_aDialogCreate3, GUI_COUNTOF(_aDialogCreate3), NULL,       WM_UNATTACHED, 0, 0);
00220   MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 3");
00221   GUI_Delay(500);
00222   hDialog = GUI_CreateDialogBox(_aDialogCreate4, GUI_COUNTOF(_aDialogCreate4), _cbDialog4, WM_UNATTACHED, 0, 0);
00223   MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 4");
00224   GUI_Delay(500);
00225   hDialog = GUI_CreateDialogBox(_aDialogCreate5, GUI_COUNTOF(_aDialogCreate5), NULL,       WM_UNATTACHED, 0, 0);
00226   MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 5");
00227   GUI_Delay(500);
00228   hDialog = GUI_CreateDialogBox(_aDialogCreate6, GUI_COUNTOF(_aDialogCreate6), NULL,       WM_UNATTACHED, 0, 0);
00229   MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 6");
00230   GUI_Delay(500);
00231   //
00232   // Demonstrate the use of MULTIPAGE_SetAlign
00233   //
00234   MULTIPAGE_SetAlign(hMultiPage, MULTIPAGE_ALIGN_RIGHT);
00235   GUI_Delay(500);
00236   MULTIPAGE_SetAlign(hMultiPage, MULTIPAGE_ALIGN_RIGHT | MULTIPAGE_ALIGN_BOTTOM);
00237   GUI_Delay(500);
00238   MULTIPAGE_SetAlign(hMultiPage, MULTIPAGE_ALIGN_LEFT | MULTIPAGE_ALIGN_BOTTOM);
00239   while (1) {
00240     GUI_Delay(100);
00241   }
00242 }
00243 
00244 /*************************** End of file ****************************/