NuMaker emWin HMI

Committer:
csyang2
Date:
Wed Feb 27 14:34:09 2019 +0800
Revision:
1:c0f972361605
Add emWin related materials

Who changed what in which revision?

UserRevisionLine numberNew contents of line
csyang2 1:c0f972361605 1 /*********************************************************************
csyang2 1:c0f972361605 2 * SEGGER Software GmbH *
csyang2 1:c0f972361605 3 * Solutions for real time microcontroller applications *
csyang2 1:c0f972361605 4 **********************************************************************
csyang2 1:c0f972361605 5 * *
csyang2 1:c0f972361605 6 * (c) 1996 - 2018 SEGGER Microcontroller GmbH *
csyang2 1:c0f972361605 7 * *
csyang2 1:c0f972361605 8 * Internet: www.segger.com Support: support@segger.com *
csyang2 1:c0f972361605 9 * *
csyang2 1:c0f972361605 10 **********************************************************************
csyang2 1:c0f972361605 11
csyang2 1:c0f972361605 12 ** emWin V5.48 - Graphical user interface for embedded applications **
csyang2 1:c0f972361605 13 All Intellectual Property rights in the Software belongs to SEGGER.
csyang2 1:c0f972361605 14 emWin is protected by international copyright laws. Knowledge of the
csyang2 1:c0f972361605 15 source code may not be used to write a similar product. This file may
csyang2 1:c0f972361605 16 only be used in accordance with the following terms:
csyang2 1:c0f972361605 17
csyang2 1:c0f972361605 18 The software has been licensed by SEGGER Software GmbH to Nuvoton Technology Corporationat the address: No. 4, Creation Rd. III, Hsinchu Science Park, Taiwan
csyang2 1:c0f972361605 19 for the purposes of creating libraries for its
csyang2 1:c0f972361605 20 Arm Cortex-M and Arm9 32-bit microcontrollers, commercialized and distributed by Nuvoton Technology Corporation
csyang2 1:c0f972361605 21 under the terms and conditions of an End User
csyang2 1:c0f972361605 22 License Agreement supplied with the libraries.
csyang2 1:c0f972361605 23 Full source code is available at: www.segger.com
csyang2 1:c0f972361605 24
csyang2 1:c0f972361605 25 We appreciate your understanding and fairness.
csyang2 1:c0f972361605 26 ----------------------------------------------------------------------
csyang2 1:c0f972361605 27 Licensing information
csyang2 1:c0f972361605 28 Licensor: SEGGER Software GmbH
csyang2 1:c0f972361605 29 Licensed to: Nuvoton Technology Corporation, No. 4, Creation Rd. III, Hsinchu Science Park, 30077 Hsinchu City, Taiwan
csyang2 1:c0f972361605 30 Licensed SEGGER software: emWin
csyang2 1:c0f972361605 31 License number: GUI-00735
csyang2 1:c0f972361605 32 License model: emWin License Agreement, signed February 27, 2018
csyang2 1:c0f972361605 33 Licensed platform: Cortex-M and ARM9 32-bit series microcontroller designed and manufactured by or for Nuvoton Technology Corporation
csyang2 1:c0f972361605 34 ----------------------------------------------------------------------
csyang2 1:c0f972361605 35 Support and Update Agreement (SUA)
csyang2 1:c0f972361605 36 SUA period: 2018-03-26 - 2019-03-27
csyang2 1:c0f972361605 37 Contact to extend SUA: sales@segger.com
csyang2 1:c0f972361605 38 ----------------------------------------------------------------------
csyang2 1:c0f972361605 39 File : MENU.h
csyang2 1:c0f972361605 40 Purpose : MENU include
csyang2 1:c0f972361605 41 --------------------END-OF-HEADER-------------------------------------
csyang2 1:c0f972361605 42 */
csyang2 1:c0f972361605 43
csyang2 1:c0f972361605 44 #ifndef MENU_H
csyang2 1:c0f972361605 45 #define MENU_H
csyang2 1:c0f972361605 46
csyang2 1:c0f972361605 47 #include "WM.h"
csyang2 1:c0f972361605 48 #include "WIDGET.h"
csyang2 1:c0f972361605 49 #include "DIALOG_Intern.h" // Required for Create indirect data structure
csyang2 1:c0f972361605 50
csyang2 1:c0f972361605 51 #if GUI_WINSUPPORT
csyang2 1:c0f972361605 52
csyang2 1:c0f972361605 53 #if defined(__cplusplus)
csyang2 1:c0f972361605 54 extern "C" { // Make sure we have C-declarations in C++ programs
csyang2 1:c0f972361605 55 #endif
csyang2 1:c0f972361605 56
csyang2 1:c0f972361605 57 /*********************************************************************
csyang2 1:c0f972361605 58 *
csyang2 1:c0f972361605 59 * Defines
csyang2 1:c0f972361605 60 *
csyang2 1:c0f972361605 61 **********************************************************************
csyang2 1:c0f972361605 62 */
csyang2 1:c0f972361605 63 #define MENU_SKIN_FLEX MENU_DrawSkinFlex
csyang2 1:c0f972361605 64
csyang2 1:c0f972361605 65 /*********************************************************************
csyang2 1:c0f972361605 66 *
csyang2 1:c0f972361605 67 * Create flags
csyang2 1:c0f972361605 68 */
csyang2 1:c0f972361605 69 #define MENU_CF_HORIZONTAL (0<<0)
csyang2 1:c0f972361605 70 #define MENU_CF_VERTICAL (1<<0)
csyang2 1:c0f972361605 71 #define MENU_CF_OPEN_ON_POINTEROVER (1<<1) // Normally a menu opens first when clicked on it
csyang2 1:c0f972361605 72 #define MENU_CF_CLOSE_ON_SECOND_CLICK (1<<2) // Normally a menu closes only when clicked outside it
csyang2 1:c0f972361605 73 #define MENU_CF_HIDE_DISABLED_SEL (1<<3) // Hides the selection when a disabled item is selected
csyang2 1:c0f972361605 74
csyang2 1:c0f972361605 75 /*********************************************************************
csyang2 1:c0f972361605 76 *
csyang2 1:c0f972361605 77 * Menu item flags
csyang2 1:c0f972361605 78 */
csyang2 1:c0f972361605 79 #define MENU_IF_DISABLED (1<<0) // Indicates that item is disabled
csyang2 1:c0f972361605 80 #define MENU_IF_SEPARATOR (1<<1) // Indicates that item is a separator
csyang2 1:c0f972361605 81
csyang2 1:c0f972361605 82 /*********************************************************************
csyang2 1:c0f972361605 83 *
csyang2 1:c0f972361605 84 * Color indices
csyang2 1:c0f972361605 85 */
csyang2 1:c0f972361605 86 #define MENU_CI_ENABLED 0
csyang2 1:c0f972361605 87 #define MENU_CI_SELECTED 1
csyang2 1:c0f972361605 88 #define MENU_CI_DISABLED 2
csyang2 1:c0f972361605 89 #define MENU_CI_DISABLED_SEL 3
csyang2 1:c0f972361605 90 #define MENU_CI_ACTIVE_SUBMENU 4
csyang2 1:c0f972361605 91
csyang2 1:c0f972361605 92 /*********************************************************************
csyang2 1:c0f972361605 93 *
csyang2 1:c0f972361605 94 * Border indices
csyang2 1:c0f972361605 95 */
csyang2 1:c0f972361605 96 #define MENU_BI_LEFT 0
csyang2 1:c0f972361605 97 #define MENU_BI_RIGHT 1
csyang2 1:c0f972361605 98 #define MENU_BI_TOP 2
csyang2 1:c0f972361605 99 #define MENU_BI_BOTTOM 3
csyang2 1:c0f972361605 100
csyang2 1:c0f972361605 101 /*********************************************************************
csyang2 1:c0f972361605 102 *
csyang2 1:c0f972361605 103 * Message types
csyang2 1:c0f972361605 104 */
csyang2 1:c0f972361605 105 #define MENU_ON_ITEMSELECT 0 // Send to owner when selecting a menu item
csyang2 1:c0f972361605 106 #define MENU_ON_INITMENU 1 // Send to owner when for the first time selecting a submenu
csyang2 1:c0f972361605 107 #define MENU_ON_INITSUBMENU 2 // Send to owner when selecting a submenu
csyang2 1:c0f972361605 108 #define MENU_ON_OPEN 3 // Internal message of menu widget (only send to submenus)
csyang2 1:c0f972361605 109 #define MENU_ON_CLOSE 4 // Internal message of menu widget (only send to submenus)
csyang2 1:c0f972361605 110 #define MENU_IS_MENU 5 // Internal message of menu widget. Owner must call
csyang2 1:c0f972361605 111 // WM_DefaultProc() when not handle the message
csyang2 1:c0f972361605 112 #define MENU_ON_ITEMACTIVATE 6 // Send to owner when highlighting a menu item
csyang2 1:c0f972361605 113 #define MENU_ON_ITEMPRESSED 7 // Send to owner when a menu item has been pressed
csyang2 1:c0f972361605 114
csyang2 1:c0f972361605 115 /*********************************************************************
csyang2 1:c0f972361605 116 *
csyang2 1:c0f972361605 117 * Skinning property indices
csyang2 1:c0f972361605 118 */
csyang2 1:c0f972361605 119 #define MENU_SKINFLEX_PI_ENABLED 0
csyang2 1:c0f972361605 120 #define MENU_SKINFLEX_PI_SELECTED 1
csyang2 1:c0f972361605 121 #define MENU_SKINFLEX_PI_DISABLED 2
csyang2 1:c0f972361605 122 #define MENU_SKINFLEX_PI_DISABLED_SEL 3
csyang2 1:c0f972361605 123 #define MENU_SKINFLEX_PI_ACTIVE_SUBMENU 4
csyang2 1:c0f972361605 124
csyang2 1:c0f972361605 125 /*********************************************************************
csyang2 1:c0f972361605 126 *
csyang2 1:c0f972361605 127 * Types
csyang2 1:c0f972361605 128 *
csyang2 1:c0f972361605 129 **********************************************************************
csyang2 1:c0f972361605 130 */
csyang2 1:c0f972361605 131
csyang2 1:c0f972361605 132 typedef WM_HMEM MENU_Handle;
csyang2 1:c0f972361605 133
csyang2 1:c0f972361605 134 typedef struct {
csyang2 1:c0f972361605 135 //
csyang2 1:c0f972361605 136 // Background
csyang2 1:c0f972361605 137 //
csyang2 1:c0f972361605 138 GUI_COLOR aBkColorH[2];
csyang2 1:c0f972361605 139 GUI_COLOR BkColorV;
csyang2 1:c0f972361605 140 GUI_COLOR FrameColorH;
csyang2 1:c0f972361605 141 GUI_COLOR FrameColorV;
csyang2 1:c0f972361605 142 //
csyang2 1:c0f972361605 143 // Selection
csyang2 1:c0f972361605 144 //
csyang2 1:c0f972361605 145 GUI_COLOR aSelColorH[2];
csyang2 1:c0f972361605 146 GUI_COLOR aSelColorV[2];
csyang2 1:c0f972361605 147 GUI_COLOR FrameColorSelH;
csyang2 1:c0f972361605 148 GUI_COLOR FrameColorSelV;
csyang2 1:c0f972361605 149 //
csyang2 1:c0f972361605 150 // Separator
csyang2 1:c0f972361605 151 //
csyang2 1:c0f972361605 152 GUI_COLOR aSepColorH[2];
csyang2 1:c0f972361605 153 GUI_COLOR aSepColorV[2];
csyang2 1:c0f972361605 154 //
csyang2 1:c0f972361605 155 // Arrow
csyang2 1:c0f972361605 156 //
csyang2 1:c0f972361605 157 GUI_COLOR ArrowColor;
csyang2 1:c0f972361605 158 //
csyang2 1:c0f972361605 159 // Text
csyang2 1:c0f972361605 160 //
csyang2 1:c0f972361605 161 GUI_COLOR TextColor;
csyang2 1:c0f972361605 162 } MENU_SKINFLEX_PROPS;
csyang2 1:c0f972361605 163
csyang2 1:c0f972361605 164 /*********************************************************************
csyang2 1:c0f972361605 165 *
csyang2 1:c0f972361605 166 * Menu message data
csyang2 1:c0f972361605 167 */
csyang2 1:c0f972361605 168 typedef struct {
csyang2 1:c0f972361605 169 U16 MsgType;
csyang2 1:c0f972361605 170 U16 ItemId;
csyang2 1:c0f972361605 171 } MENU_MSG_DATA;
csyang2 1:c0f972361605 172
csyang2 1:c0f972361605 173 /*********************************************************************
csyang2 1:c0f972361605 174 *
csyang2 1:c0f972361605 175 * Menu item data
csyang2 1:c0f972361605 176 */
csyang2 1:c0f972361605 177 typedef struct {
csyang2 1:c0f972361605 178 const char * pText;
csyang2 1:c0f972361605 179 U16 Id;
csyang2 1:c0f972361605 180 U16 Flags;
csyang2 1:c0f972361605 181 MENU_Handle hSubmenu;
csyang2 1:c0f972361605 182 } MENU_ITEM_DATA;
csyang2 1:c0f972361605 183
csyang2 1:c0f972361605 184 /*********************************************************************
csyang2 1:c0f972361605 185 *
csyang2 1:c0f972361605 186 * Create functions
csyang2 1:c0f972361605 187 *
csyang2 1:c0f972361605 188 **********************************************************************
csyang2 1:c0f972361605 189 */
csyang2 1:c0f972361605 190 MENU_Handle MENU_CreateIndirect(const GUI_WIDGET_CREATE_INFO * pCreateInfo, WM_HWIN hWinParent, int x0, int y0, WM_CALLBACK * cb);
csyang2 1:c0f972361605 191 MENU_Handle MENU_CreateEx (int x0, int y0, int xSize, int ySize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id);
csyang2 1:c0f972361605 192 MENU_Handle MENU_CreateUser (int x0, int y0, int xSize, int ySize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id, int NumExtraBytes);
csyang2 1:c0f972361605 193
csyang2 1:c0f972361605 194 /*********************************************************************
csyang2 1:c0f972361605 195 *
csyang2 1:c0f972361605 196 * The callback ...
csyang2 1:c0f972361605 197 *
csyang2 1:c0f972361605 198 * Do not call it directly ! It is only to be used from within an
csyang2 1:c0f972361605 199 * overwritten callback.
csyang2 1:c0f972361605 200 */
csyang2 1:c0f972361605 201 void MENU_Callback(WM_MESSAGE * pMsg);
csyang2 1:c0f972361605 202
csyang2 1:c0f972361605 203 /*********************************************************************
csyang2 1:c0f972361605 204 *
csyang2 1:c0f972361605 205 * Individual member functions
csyang2 1:c0f972361605 206 *
csyang2 1:c0f972361605 207 **********************************************************************
csyang2 1:c0f972361605 208 */
csyang2 1:c0f972361605 209 void MENU_AddItem (MENU_Handle hObj, const MENU_ITEM_DATA * pItemData);
csyang2 1:c0f972361605 210 void MENU_Attach (MENU_Handle hObj, WM_HWIN hDestWin, int x, int y, int xSize, int ySize, int Flags);
csyang2 1:c0f972361605 211 void MENU_DeleteItem (MENU_Handle hObj, U16 ItemId);
csyang2 1:c0f972361605 212 void MENU_DisableItem (MENU_Handle hObj, U16 ItemId);
csyang2 1:c0f972361605 213 void MENU_EnableItem (MENU_Handle hObj, U16 ItemId);
csyang2 1:c0f972361605 214 GUI_COLOR MENU_GetBkColor (MENU_Handle hObj, unsigned ColorIndex);
csyang2 1:c0f972361605 215 const GUI_FONT * MENU_GetFont (MENU_Handle hObj);
csyang2 1:c0f972361605 216 void MENU_GetItem (MENU_Handle hObj, U16 ItemId, MENU_ITEM_DATA * pItemData);
csyang2 1:c0f972361605 217 void MENU_GetItemText (MENU_Handle hObj, U16 ItemId, char * pBuffer, unsigned BufferSize);
csyang2 1:c0f972361605 218 unsigned MENU_GetNumItems (MENU_Handle hObj);
csyang2 1:c0f972361605 219 WM_HWIN MENU_GetOwner (MENU_Handle hObj);
csyang2 1:c0f972361605 220 GUI_COLOR MENU_GetTextColor (MENU_Handle hObj, unsigned ColorIndex);
csyang2 1:c0f972361605 221 int MENU_GetUserData (MENU_Handle hObj, void * pDest, int NumBytes);
csyang2 1:c0f972361605 222 void MENU_InsertItem (MENU_Handle hObj, U16 ItemId, const MENU_ITEM_DATA * pItemData);
csyang2 1:c0f972361605 223 void MENU_Popup (MENU_Handle hObj, WM_HWIN hDestWin, int x, int y, int xSize, int ySize, int Flags);
csyang2 1:c0f972361605 224 void MENU_SetBkColor (MENU_Handle hObj, unsigned ColorIndex, GUI_COLOR Color);
csyang2 1:c0f972361605 225 void MENU_SetBorderSize (MENU_Handle hObj, unsigned BorderIndex, U8 BorderSize);
csyang2 1:c0f972361605 226 void MENU_SetFont (MENU_Handle hObj, const GUI_FONT * pFont);
csyang2 1:c0f972361605 227 void MENU_SetItem (MENU_Handle hObj, U16 ItemId, const MENU_ITEM_DATA * pItemData);
csyang2 1:c0f972361605 228 void MENU_SetOwner (MENU_Handle hObj, WM_HWIN hOwner);
csyang2 1:c0f972361605 229 int MENU_SetSel (MENU_Handle hObj, int Sel);
csyang2 1:c0f972361605 230 void MENU_SetTextColor (MENU_Handle hObj, unsigned ColorIndex, GUI_COLOR Color);
csyang2 1:c0f972361605 231 int MENU_SetUserData (MENU_Handle hObj, const void * pSrc, int NumBytes);
csyang2 1:c0f972361605 232
csyang2 1:c0f972361605 233 /*********************************************************************
csyang2 1:c0f972361605 234 *
csyang2 1:c0f972361605 235 * Managing default values
csyang2 1:c0f972361605 236 *
csyang2 1:c0f972361605 237 **********************************************************************
csyang2 1:c0f972361605 238 */
csyang2 1:c0f972361605 239 GUI_COLOR MENU_GetDefaultTextColor (unsigned ColorIndex);
csyang2 1:c0f972361605 240 GUI_COLOR MENU_GetDefaultBkColor (unsigned ColorIndex);
csyang2 1:c0f972361605 241 U8 MENU_GetDefaultBorderSize (unsigned BorderIndex);
csyang2 1:c0f972361605 242 const WIDGET_EFFECT * MENU_GetDefaultEffect (void);
csyang2 1:c0f972361605 243 const GUI_FONT * MENU_GetDefaultFont (void);
csyang2 1:c0f972361605 244 void MENU_SetDefaultTextColor (unsigned ColorIndex, GUI_COLOR Color);
csyang2 1:c0f972361605 245 void MENU_SetDefaultBkColor (unsigned ColorIndex, GUI_COLOR Color);
csyang2 1:c0f972361605 246 void MENU_SetDefaultBorderSize (unsigned BorderIndex, U8 BorderSize);
csyang2 1:c0f972361605 247 void MENU_SetDefaultEffect (const WIDGET_EFFECT * pEffect);
csyang2 1:c0f972361605 248 void MENU_SetDefaultFont (const GUI_FONT * pFont);
csyang2 1:c0f972361605 249
csyang2 1:c0f972361605 250 /*********************************************************************
csyang2 1:c0f972361605 251 *
csyang2 1:c0f972361605 252 * Member functions: Skinning
csyang2 1:c0f972361605 253 *
csyang2 1:c0f972361605 254 **********************************************************************
csyang2 1:c0f972361605 255 */
csyang2 1:c0f972361605 256 int MENU_DrawSkinFlex (const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo);
csyang2 1:c0f972361605 257 void MENU_GetSkinFlexProps (MENU_SKINFLEX_PROPS * pProps, int Index);
csyang2 1:c0f972361605 258 WIDGET_DRAW_ITEM_FUNC * MENU_SetDefaultSkin (WIDGET_DRAW_ITEM_FUNC * pfDrawSkin);
csyang2 1:c0f972361605 259 void MENU_SetDefaultSkinClassic(void);
csyang2 1:c0f972361605 260 void MENU_SetSkinClassic (MENU_Handle hObj);
csyang2 1:c0f972361605 261 void MENU_SetSkin (MENU_Handle hObj, WIDGET_DRAW_ITEM_FUNC * pfDrawSkin);
csyang2 1:c0f972361605 262 void MENU_SetSkinFlexProps (const MENU_SKINFLEX_PROPS * pProps, int Index);
csyang2 1:c0f972361605 263 void MENU_SkinEnableArrow (MENU_Handle hObj, int OnOff);
csyang2 1:c0f972361605 264
csyang2 1:c0f972361605 265 #if defined(__cplusplus)
csyang2 1:c0f972361605 266 }
csyang2 1:c0f972361605 267 #endif
csyang2 1:c0f972361605 268
csyang2 1:c0f972361605 269 #endif // GUI_WINSUPPORT
csyang2 1:c0f972361605 270 #endif // MENU_H
csyang2 1:c0f972361605 271
csyang2 1:c0f972361605 272 /*************************** End of file ****************************/