RT1050 GUI demo using emWin library

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MENU.h Source File

MENU.h

00001 /*********************************************************************
00002 *                SEGGER Microcontroller GmbH & Co. KG                *
00003 *        Solutions for real time microcontroller applications        *
00004 **********************************************************************
00005 *                                                                    *
00006 *        (c) 1996 - 2016  SEGGER Microcontroller GmbH & Co. KG       *
00007 *                                                                    *
00008 *        Internet: www.segger.com    Support:  support@segger.com    *
00009 *                                                                    *
00010 **********************************************************************
00011 
00012 ** emWin V5.38 - 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  NXP Semiconductors USA, Inc.  whose
00019 registered  office  is  situated  at 411 E. Plumeria Drive, San  Jose,
00020 CA 95134, USA  solely for  the  purposes  of  creating  libraries  for
00021 NXPs M0, M3/M4 and  ARM7/9 processor-based  devices,  sublicensed  and
00022 distributed under the terms and conditions of the NXP 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 
00030 Licensor:                 SEGGER Microcontroller Systems LLC
00031 Licensed to:              NXP Semiconductors, 1109 McKay Dr, M/S 76, San Jose, CA 95131, USA
00032 Licensed SEGGER software: emWin
00033 License number:           GUI-00186
00034 License model:            emWin License Agreement, dated August 20th 2011
00035 Licensed product:         -
00036 Licensed platform:        NXP's ARM 7/9, Cortex-M0,M3,M4
00037 Licensed number of seats: -
00038 ----------------------------------------------------------------------
00039 File        : MENU.h
00040 Purpose     : MENU include
00041 --------------------END-OF-HEADER-------------------------------------
00042 */
00043 
00044 #ifndef MENU_H
00045 #define MENU_H
00046 
00047 #include "WM.h"
00048 #include "WIDGET.h"
00049 #include "DIALOG_Intern.h"      // Required for Create indirect data structure
00050 
00051 #if GUI_WINSUPPORT
00052 
00053 #if defined(__cplusplus)
00054   extern "C" {     // Make sure we have C-declarations in C++ programs
00055 #endif
00056 
00057 /*********************************************************************
00058 *
00059 *       Defines
00060 *
00061 **********************************************************************
00062 */
00063 #define MENU_SKIN_FLEX    MENU_DrawSkinFlex
00064 
00065 /*********************************************************************
00066 *
00067 *       Create flags
00068 */
00069 #define MENU_CF_HORIZONTAL              (0<<0)
00070 #define MENU_CF_VERTICAL                (1<<0)
00071 #define MENU_CF_OPEN_ON_POINTEROVER     (1<<1)  // Normally a menu opens first when clicked on it
00072 #define MENU_CF_CLOSE_ON_SECOND_CLICK   (1<<2)  // Normally a menu closes only when clicked outside it
00073 #define MENU_CF_HIDE_DISABLED_SEL       (1<<3)  // Hides the selection when a disabled item is selected
00074 
00075 /*********************************************************************
00076 *
00077 *       Menu item flags
00078 */
00079 #define MENU_IF_DISABLED                (1<<0)  // Indicates that item is disabled
00080 #define MENU_IF_SEPARATOR               (1<<1)  // Indicates that item is a separator
00081 
00082 /*********************************************************************
00083 *
00084 *       Color indices
00085 */
00086 #define MENU_CI_ENABLED                 0
00087 #define MENU_CI_SELECTED                1
00088 #define MENU_CI_DISABLED                2
00089 #define MENU_CI_DISABLED_SEL            3
00090 #define MENU_CI_ACTIVE_SUBMENU          4
00091 
00092 /*********************************************************************
00093 *
00094 *       Border indices
00095 */
00096 #define MENU_BI_LEFT                    0
00097 #define MENU_BI_RIGHT                   1
00098 #define MENU_BI_TOP                     2
00099 #define MENU_BI_BOTTOM                  3
00100 
00101 /*********************************************************************
00102 *
00103 *       Message types
00104 */
00105 #define MENU_ON_ITEMSELECT              0   // Send to owner when selecting a menu item
00106 #define MENU_ON_INITMENU                1   // Send to owner when for the first time selecting a submenu
00107 #define MENU_ON_INITSUBMENU             2   // Send to owner when selecting a submenu
00108 #define MENU_ON_OPEN                    3   // Internal message of menu widget (only send to submenus)
00109 #define MENU_ON_CLOSE                   4   // Internal message of menu widget (only send to submenus)
00110 #define MENU_IS_MENU                    5   // Internal message of menu widget. Owner must call
00111                                             // WM_DefaultProc() when not handle the message
00112 #define MENU_ON_ITEMACTIVATE            6   // Send to owner when highlighting a menu item
00113 #define MENU_ON_ITEMPRESSED             7   // Send to owner when a menu item has been pressed
00114 
00115 /*********************************************************************
00116 *
00117 *       Skinning property indices
00118 */
00119 #define MENU_SKINFLEX_PI_ENABLED        0
00120 #define MENU_SKINFLEX_PI_SELECTED       1
00121 #define MENU_SKINFLEX_PI_DISABLED       2
00122 #define MENU_SKINFLEX_PI_DISABLED_SEL   3
00123 #define MENU_SKINFLEX_PI_ACTIVE_SUBMENU 4
00124 
00125 /*********************************************************************
00126 *
00127 *       Types
00128 *
00129 **********************************************************************
00130 */
00131 
00132 typedef WM_HMEM MENU_Handle;
00133 
00134 typedef struct {
00135   //
00136   // Background
00137   //  
00138   GUI_COLOR aBkColorH[2];
00139   GUI_COLOR BkColorV;
00140   GUI_COLOR FrameColorH;
00141   GUI_COLOR FrameColorV;
00142   //
00143   // Selection
00144   //
00145   GUI_COLOR aSelColorH[2];
00146   GUI_COLOR aSelColorV[2];
00147   GUI_COLOR FrameColorSelH;
00148   GUI_COLOR FrameColorSelV;
00149   //
00150   // Separator
00151   //
00152   GUI_COLOR aSepColorH[2];
00153   GUI_COLOR aSepColorV[2];
00154   //
00155   // Arrow
00156   //
00157   GUI_COLOR ArrowColor;
00158   //
00159   // Text
00160   //
00161   GUI_COLOR TextColor;
00162 } MENU_SKINFLEX_PROPS;
00163 
00164 /*********************************************************************
00165 *
00166 *       Menu message data
00167 */
00168 typedef struct {
00169   U16 MsgType;
00170   U16 ItemId;
00171 } MENU_MSG_DATA;
00172 
00173 /*********************************************************************
00174 *
00175 *       Menu item data
00176 */
00177 typedef struct {
00178   const char  * pText;
00179   U16           Id;
00180   U16           Flags;
00181   MENU_Handle   hSubmenu;
00182 } MENU_ITEM_DATA;
00183 
00184 /*********************************************************************
00185 *
00186 *       Create functions
00187 *
00188 **********************************************************************
00189 */
00190 MENU_Handle MENU_CreateIndirect(const GUI_WIDGET_CREATE_INFO * pCreateInfo, WM_HWIN hWinParent, int x0, int y0, WM_CALLBACK * cb);
00191 MENU_Handle MENU_CreateEx      (int x0, int y0, int xSize, int ySize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id);
00192 MENU_Handle MENU_CreateUser    (int x0, int y0, int xSize, int ySize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id, int NumExtraBytes);
00193 
00194 /*********************************************************************
00195 *
00196 *       The callback ...
00197 *
00198 * Do not call it directly ! It is only to be used from within an
00199 * overwritten callback.
00200 */
00201 void MENU_Callback(WM_MESSAGE * pMsg);
00202 
00203 /*********************************************************************
00204 *
00205 *       Individual member functions
00206 *
00207 **********************************************************************
00208 */
00209 void      MENU_AddItem      (MENU_Handle hObj, const MENU_ITEM_DATA * pItemData);
00210 void      MENU_Attach       (MENU_Handle hObj, WM_HWIN hDestWin, int x, int y, int xSize, int ySize, int Flags);
00211 void      MENU_DeleteItem   (MENU_Handle hObj, U16 ItemId);
00212 void      MENU_DisableItem  (MENU_Handle hObj, U16 ItemId);
00213 void      MENU_EnableItem   (MENU_Handle hObj, U16 ItemId);
00214 void      MENU_GetItem      (MENU_Handle hObj, U16 ItemId, MENU_ITEM_DATA * pItemData);
00215 void      MENU_GetItemText  (MENU_Handle hObj, U16 ItemId, char * pBuffer, unsigned BufferSize);
00216 unsigned  MENU_GetNumItems  (MENU_Handle hObj);
00217 WM_HWIN   MENU_GetOwner     (MENU_Handle hObj);
00218 int       MENU_GetUserData  (MENU_Handle hObj, void * pDest, int NumBytes);
00219 void      MENU_InsertItem   (MENU_Handle hObj, U16 ItemId, const MENU_ITEM_DATA * pItemData);
00220 void      MENU_Popup        (MENU_Handle hObj, WM_HWIN hDestWin, int x, int y, int xSize, int ySize, int Flags);
00221 void      MENU_SetBkColor   (MENU_Handle hObj, unsigned ColorIndex, GUI_COLOR Color);
00222 void      MENU_SetBorderSize(MENU_Handle hObj, unsigned BorderIndex, U8 BorderSize);
00223 void      MENU_SetFont      (MENU_Handle hObj, const GUI_FONT * pFont);
00224 void      MENU_SetItem      (MENU_Handle hObj, U16 ItemId, const MENU_ITEM_DATA * pItemData);
00225 void      MENU_SetOwner     (MENU_Handle hObj, WM_HWIN hOwner);
00226 int       MENU_SetSel       (MENU_Handle hObj, int Sel);
00227 void      MENU_SetTextColor (MENU_Handle hObj, unsigned ColorIndex, GUI_COLOR Color);
00228 int       MENU_SetUserData  (MENU_Handle hObj, const void * pSrc, int NumBytes);
00229 
00230 /*********************************************************************
00231 *
00232 *       Managing default values
00233 *
00234 **********************************************************************
00235 */
00236 GUI_COLOR             MENU_GetDefaultTextColor  (unsigned ColorIndex);
00237 GUI_COLOR             MENU_GetDefaultBkColor    (unsigned ColorIndex);
00238 U8                    MENU_GetDefaultBorderSize (unsigned BorderIndex);
00239 const WIDGET_EFFECT * MENU_GetDefaultEffect     (void);
00240 const GUI_FONT      * MENU_GetDefaultFont       (void);
00241 void                  MENU_SetDefaultTextColor  (unsigned ColorIndex, GUI_COLOR Color);
00242 void                  MENU_SetDefaultBkColor    (unsigned ColorIndex, GUI_COLOR Color);
00243 void                  MENU_SetDefaultBorderSize (unsigned BorderIndex, U8 BorderSize);
00244 void                  MENU_SetDefaultEffect     (const WIDGET_EFFECT * pEffect);
00245 void                  MENU_SetDefaultFont       (const GUI_FONT * pFont);
00246 
00247 /*********************************************************************
00248 *
00249 *       Member functions: Skinning
00250 *
00251 **********************************************************************
00252 */
00253 int                     MENU_DrawSkinFlex         (const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo);
00254 void                    MENU_GetSkinFlexProps     (MENU_SKINFLEX_PROPS * pProps, int Index);
00255 WIDGET_DRAW_ITEM_FUNC * MENU_SetDefaultSkin       (WIDGET_DRAW_ITEM_FUNC * pfDrawSkin);
00256 void                    MENU_SetDefaultSkinClassic(void);
00257 void                    MENU_SetSkinClassic       (MENU_Handle hObj);
00258 void                    MENU_SetSkin              (MENU_Handle hObj, WIDGET_DRAW_ITEM_FUNC * pfDrawSkin);
00259 void                    MENU_SetSkinFlexProps     (const MENU_SKINFLEX_PROPS * pProps, int Index);
00260 void                    MENU_SkinEnableArrow      (MENU_Handle hObj, int OnOff);
00261 
00262 #if defined(__cplusplus)
00263   }
00264 #endif
00265 
00266 #endif  // GUI_WINSUPPORT
00267 #endif  // MENU_H
00268 
00269 /*************************** End of file ****************************/