Nuvoton
/
NuMaker-mbed-emWin-example
NuMaker emWin HMI
Embed:
(wiki syntax)
Show/hide line numbers
WIDGET.h
00001 /********************************************************************* 00002 * SEGGER Software 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 by SEGGER Software GmbH to Nuvoton Technology Corporationat the address: No. 4, Creation Rd. III, Hsinchu Science Park, Taiwan 00019 for the purposes of creating libraries for its 00020 Arm Cortex-M and Arm9 32-bit microcontrollers, commercialized and distributed by Nuvoton Technology Corporation 00021 under the terms and conditions of an End User 00022 License Agreement supplied with the libraries. 00023 Full source code is available at: www.segger.com 00024 00025 We appreciate your understanding and fairness. 00026 ---------------------------------------------------------------------- 00027 Licensing information 00028 Licensor: SEGGER Software GmbH 00029 Licensed to: Nuvoton Technology Corporation, No. 4, Creation Rd. III, Hsinchu Science Park, 30077 Hsinchu City, Taiwan 00030 Licensed SEGGER software: emWin 00031 License number: GUI-00735 00032 License model: emWin License Agreement, signed February 27, 2018 00033 Licensed platform: Cortex-M and ARM9 32-bit series microcontroller designed and manufactured by or for Nuvoton Technology Corporation 00034 ---------------------------------------------------------------------- 00035 Support and Update Agreement (SUA) 00036 SUA period: 2018-03-26 - 2019-03-27 00037 Contact to extend SUA: sales@segger.com 00038 ---------------------------------------------------------------------- 00039 File : WIDGET.h 00040 Purpose : Widget interface 00041 ---------------------------END-OF-HEADER------------------------------ 00042 */ 00043 00044 #ifndef WIDGET_H /* Avoid multiple inclusion */ 00045 #define WIDGET_H 00046 00047 #if defined(__cplusplus) 00048 extern "C" { /* Make sure we have C-declarations in C++ programs */ 00049 #endif 00050 00051 #include "WM_Intern.h" /* Window manager, including some internals, which speed things up */ 00052 00053 #if GUI_WINSUPPORT 00054 00055 /********************************************************************* 00056 * 00057 * Typedefs 00058 * 00059 ********************************************************************** 00060 */ 00061 typedef struct { 00062 WM_HWIN hWin; 00063 int Cmd; /* WIDGET_ITEM_GET_XSIZE, WIDGET_ITEM_GET_YSIZE, WIDGET_ITEM_DRAW, */ 00064 int ItemIndex; 00065 int Col; 00066 int x0, y0, x1, y1; 00067 void * p; 00068 } WIDGET_ITEM_DRAW_INFO; 00069 00070 typedef int WIDGET_DRAW_ITEM_FUNC(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo); 00071 typedef void WIDGET_PAINT (WM_HWIN hObj); 00072 typedef void WIDGET_CREATE (WM_HWIN hObj); 00073 00074 typedef struct { 00075 WIDGET_PAINT * pfPaint; 00076 WIDGET_CREATE * pfCreate; 00077 void * pSkinPrivate; 00078 } WIDGET_SKIN; 00079 00080 /********************************************************************* 00081 * 00082 * Important: WIDGET_DRAW_ITEM_FUNC needs to be defined 00083 * in SCROLLBAR.h! 00084 * 00085 ********************************************************************** 00086 */ 00087 #include "SCROLLBAR.h" 00088 00089 /********************************************************************* 00090 * 00091 * Defines 00092 * 00093 ********************************************************************** 00094 */ 00095 /********************************************************************* 00096 * 00097 * Unique widget id's 00098 */ 00099 #define BUTTON_ID 0x42555454UL /* BUTT */ 00100 #define CHECKBOX_ID 0x43484543UL /* CHEC */ 00101 #define DROPDOWN_ID 0x44524f50UL /* DROP */ 00102 #define EDIT_ID 0x45444954UL /* EDIT */ 00103 #define FRAMEWIN_ID 0x4652414dUL /* FRAM */ 00104 #define FRAMECLNT_ID 0x46524143UL /* FRAC */ 00105 #define GRAPH_ID 0x47524150UL /* GRAP */ 00106 #define HEADER_ID 0x48454144UL /* HEAD */ 00107 #define LISTBOX_ID 0x4C495342UL /* LISB */ 00108 #define LISTVIEW_ID 0x4C495356UL /* LISV */ 00109 #define LISTWHEEL_ID 0x4C495357UL /* LISW */ 00110 #define MENU_ID 0x4d454e55UL /* MENU */ 00111 #define MULTIEDIT_ID 0x4d554c45UL /* MULE */ 00112 #define MULTIPAGE_ID 0x4d554c50UL /* MULP */ 00113 #define MPAGECLNT_ID 0x4d50434CUL /* MPCL */ 00114 #define PROGBAR_ID 0x50524f47UL /* PROG */ 00115 #define RADIO_ID 0x52414449UL /* RADI */ 00116 #define SCROLLBAR_ID 0x5343524fUL /* SCRO */ 00117 #define SLIDER_ID 0x534c4944UL /* SLID */ 00118 #define SWIPELIST_ID 0x53574950UL /* SWIP */ 00119 #define TEXT_ID 0x54455854UL /* TEXT */ 00120 #define TREEVIEW_ID 0x54524545UL /* TREE */ 00121 #define ICONVIEW_ID 0x49434f4eUL /* ICON */ 00122 #define IMAGE_ID 0x494d4147UL /* IMAG */ 00123 #define SPINBOX_ID 0x5350494eUL /* SPIN */ 00124 #define KNOB_ID 0x4b4e4f42UL /* KNOB */ 00125 #define WINDOW_ID 0x57494e44UL /* WIND */ 00126 00127 #define WIDGET_LOCK(hWin) ((WIDGET*)GUI_LOCK_H(hWin)) 00128 00129 /********************************************************************* 00130 * 00131 * Config switches 00132 */ 00133 00134 #ifndef WIDGET_USE_PARENT_EFFECT 00135 #define WIDGET_USE_PARENT_EFFECT 0 00136 #endif 00137 #ifndef WIDGET_USE_FLEX_SKIN 00138 #if WM_SUPPORT_TRANSPARENCY 00139 #define WIDGET_USE_FLEX_SKIN 1 00140 #else 00141 #define WIDGET_USE_FLEX_SKIN 0 00142 #endif 00143 #endif 00144 #if !defined(WIDGET_USE_SCHEME_SMALL) && !defined(WIDGET_USE_SCHEME_MEDIUM) && !defined(WIDGET_USE_SCHEME_LARGE) 00145 #define WIDGET_USE_SCHEME_SMALL 1 00146 #define WIDGET_USE_SCHEME_MEDIUM 0 00147 #define WIDGET_USE_SCHEME_LARGE 0 00148 #endif 00149 #ifndef WIDGET_USE_SCHEME_SMALL 00150 #define WIDGET_USE_SCHEME_SMALL 0 00151 #endif 00152 #ifndef WIDGET_USE_SCHEME_MEDIUM 00153 #define WIDGET_USE_SCHEME_MEDIUM 0 00154 #endif 00155 #ifndef WIDGET_USE_SCHEME_LARGE 00156 #define WIDGET_USE_SCHEME_LARGE 0 00157 #endif 00158 #if (WIDGET_USE_SCHEME_SMALL + WIDGET_USE_SCHEME_MEDIUM + WIDGET_USE_SCHEME_LARGE) > 1 00159 #error Only one scheme can be selected! 00160 #endif 00161 00162 /********************************************************************* 00163 * 00164 * States 00165 */ 00166 00167 #define WIDGET_STATE_FOCUS (1 << 0) 00168 #define WIDGET_STATE_VERTICAL (1 << 3) 00169 #define WIDGET_STATE_FOCUSABLE (1 << 4) 00170 00171 #define WIDGET_STATE_USER0 (1 << 8) /* Freely available for derived widget */ 00172 #define WIDGET_STATE_USER1 (1 << 9) /* Freely available for derived widget */ 00173 #define WIDGET_STATE_USER2 (1 << 10) /* Freely available for derived widget */ 00174 00175 #define WIDGET_STATE_FOCUSSABLE WIDGET_STATE_FOCUSABLE 00176 00177 /********************************************************************* 00178 * 00179 * Skinning message identifiers 00180 */ 00181 #define WIDGET_ITEM_CREATE 0 00182 #define WIDGET_ITEM_DRAW 1 00183 #define WIDGET_ITEM_DRAW_ARROW 2 00184 #define WIDGET_ITEM_DRAW_ARROW_L 3 00185 #define WIDGET_ITEM_DRAW_ARROW_R 4 00186 #define WIDGET_ITEM_DRAW_BACKGROUND 5 00187 #define WIDGET_ITEM_DRAW_BITMAP 6 00188 #define WIDGET_ITEM_DRAW_BUTTON 7 00189 #define WIDGET_ITEM_DRAW_BUTTON_L 8 00190 #define WIDGET_ITEM_DRAW_BUTTON_R 9 00191 #define WIDGET_ITEM_DRAW_FOCUS 10 00192 #define WIDGET_ITEM_DRAW_FRAME 11 00193 #define WIDGET_ITEM_DRAW_OVERLAP 12 00194 #define WIDGET_ITEM_DRAW_OVERLAY 13 00195 #define WIDGET_ITEM_DRAW_SEP 14 00196 #define WIDGET_ITEM_DRAW_SHAFT 15 00197 #define WIDGET_ITEM_DRAW_SHAFT_L 16 00198 #define WIDGET_ITEM_DRAW_SHAFT_R 17 00199 #define WIDGET_ITEM_DRAW_TEXT 18 00200 #define WIDGET_ITEM_DRAW_THUMB 19 00201 #define WIDGET_ITEM_DRAW_TICKS 20 00202 #define WIDGET_ITEM_GET_BORDERSIZE_B 21 00203 #define WIDGET_ITEM_GET_BORDERSIZE_L 22 00204 #define WIDGET_ITEM_GET_BORDERSIZE_R 23 00205 #define WIDGET_ITEM_GET_BORDERSIZE_T 24 00206 #define WIDGET_ITEM_GET_BUTTONSIZE 25 00207 #define WIDGET_ITEM_GET_XSIZE 26 00208 #define WIDGET_ITEM_GET_YSIZE 27 00209 #define WIDGET_ITEM_GET_RADIUS 28 00210 #define WIDGET_ITEM_APPLY_PROPS 29 // Not to be documented. Use this message identifier to update the 00211 // properties of attached widgets from <WIDGET>_DrawSkinFlex(). 00212 #define WIDGET_DRAW_BACKGROUND 30 00213 00214 #define WIDGET_DRAW_OVERLAY WIDGET_ITEM_DRAW_OVERLAY 00215 00216 /********************************************************************* 00217 * 00218 * Messages 00219 */ 00220 00221 #define WM_WIDGET_SET_EFFECT (WM_WIDGET + 0) 00222 00223 /********************************************************************* 00224 * 00225 * Create flags 00226 */ 00227 00228 #define WIDGET_CF_VERTICAL WIDGET_STATE_VERTICAL 00229 00230 /********************************************************************* 00231 * 00232 * Widget object 00233 * 00234 * The widget object is the base class for most widgets 00235 */ 00236 typedef struct { 00237 int EffectSize; 00238 void (* pfDrawUp) (void); 00239 void (* pfDrawUpRect) (const GUI_RECT * pRect); 00240 void (* pfDrawDown) (void); 00241 void (* pfDrawDownRect)(const GUI_RECT * pRect); 00242 void (* pfDrawFlat) (void); 00243 void (* pfDrawFlatRect)(const GUI_RECT * pRect); 00244 } WIDGET_EFFECT; 00245 00246 typedef struct { 00247 WM_Obj Win; 00248 const WIDGET_EFFECT* pEffect; 00249 I16 Id; 00250 U16 State; 00251 #if GUI_DEBUG_LEVEL > 1 00252 U32 DebugId; 00253 #endif 00254 } WIDGET; 00255 00256 00257 /********************************************************************* 00258 * 00259 * GUI_DRAW 00260 * 00261 * The GUI_DRAW object is used as base class for selfdrawing, 00262 * non-windows objects. They are used as content of different widgets, 00263 * such as the bitmap or header widgets. 00264 */ 00265 /* Declare Object struct */ 00266 typedef struct GUI_DRAW GUI_DRAW; 00267 typedef void GUI_DRAW_SELF_CB (WM_HWIN hWin); 00268 typedef WM_HMEM GUI_DRAW_HANDLE; 00269 00270 /* Declare Object constants (member functions etc) */ 00271 typedef struct { 00272 void (* pfDraw) (GUI_DRAW_HANDLE hDrawObj, WM_HWIN hObj, int x, int y); 00273 int (* pfGetXSize)(GUI_DRAW_HANDLE hDrawObj); 00274 int (* pfGetYSize)(GUI_DRAW_HANDLE hDrawObj); 00275 } GUI_DRAW_CONSTS; 00276 00277 /* Declare Object */ 00278 struct GUI_DRAW { 00279 const GUI_DRAW_CONSTS* pConsts; 00280 union { 00281 const void * pData; 00282 GUI_DRAW_SELF_CB* pfDraw; 00283 } Data; 00284 I16 xOff, yOff; 00285 }; 00286 00287 /* GUI_DRAW_ API */ 00288 void GUI_DRAW__Draw (GUI_DRAW_HANDLE hDrawObj, WM_HWIN hObj, int x, int y); 00289 int GUI_DRAW__GetXSize(GUI_DRAW_HANDLE hDrawObj); 00290 int GUI_DRAW__GetYSize(GUI_DRAW_HANDLE hDrawObj); 00291 00292 void GUI_DrawStreamedEnableAuto(void); 00293 00294 /* GUI_DRAW_ Constructurs for different objects */ 00295 WM_HMEM GUI_DRAW_BITMAP_Create (const GUI_BITMAP* pBitmap, int x, int y); 00296 WM_HMEM GUI_DRAW_BMP_Create (const void* pBMP, int x, int y); 00297 WM_HMEM GUI_DRAW_STREAMED_Create(const GUI_BITMAP_STREAM * pBitmap, int x, int y); 00298 WM_HMEM GUI_DRAW_SELF_Create(GUI_DRAW_SELF_CB* pfDraw, int x, int y); 00299 00300 /********************************************************************* 00301 * 00302 * Global data 00303 * 00304 ********************************************************************** 00305 */ 00306 00307 extern const WIDGET_EFFECT WIDGET_Effect_3D; 00308 extern const WIDGET_EFFECT WIDGET_Effect_3D1L; 00309 extern const WIDGET_EFFECT WIDGET_Effect_3D2L; 00310 extern const WIDGET_EFFECT WIDGET_Effect_None; 00311 extern const WIDGET_EFFECT WIDGET_Effect_Simple; 00312 00313 /********************************************************************* 00314 * 00315 * Internal API routines 00316 * 00317 ********************************************************************** 00318 */ 00319 00320 void WIDGET__DrawFocusRect (WIDGET * pWidget, const GUI_RECT * pRect, int Dist); 00321 void WIDGET__DrawHLine (WIDGET * pWidget, int y, int x0, int x1); 00322 void WIDGET__DrawTriangle (WIDGET * pWidget, int x, int y, int Size, int Inc); 00323 void WIDGET__DrawVLine (WIDGET * pWidget, int x, int y0, int y1); 00324 void WIDGET__EFFECT_DrawDownRect(WIDGET * pWidget, GUI_RECT * pRect); 00325 void WIDGET__EFFECT_DrawDown (WIDGET * pWidget); 00326 void WIDGET__EFFECT_DrawUpRect (WIDGET * pWidget, GUI_RECT * pRect); 00327 void WIDGET__FillRectEx (WIDGET * pWidget, const GUI_RECT * pRect); 00328 int WIDGET__GetWindowSizeX (WM_HWIN hWin); 00329 GUI_COLOR WIDGET__GetBkColor (WM_HWIN hObj); 00330 int WIDGET__GetXSize (const WIDGET * pWidget); 00331 int WIDGET__GetYSize (const WIDGET * pWidget); 00332 void WIDGET__GetClientRect (WIDGET * pWidget, GUI_RECT * pRect); 00333 void WIDGET__GetInsideRect (WIDGET * pWidget, GUI_RECT * pRect); 00334 void WIDGET__Init (WIDGET * pWidget, int Id, U16 State); 00335 void WIDGET__RotateRect90 (WIDGET * pWidget, GUI_RECT * pDest, const GUI_RECT * pRect); 00336 void WIDGET__SetScrollState (WM_HWIN hWin, const WM_SCROLL_STATE * pVState, const WM_SCROLL_STATE * pState); 00337 void WIDGET__FillStringInRect (const char * pText, const GUI_RECT * pFillRect, const GUI_RECT * pTextRectMax, const GUI_RECT * pTextRectAct); 00338 00339 // 00340 // Function pointers for drawing streamed bitmaps 00341 // 00342 extern void (* GUI__pfDrawStreamedBitmap) (const void * p, int x, int y); 00343 extern int (* GUI__pfDrawStreamedBitmapEx)(GUI_GET_DATA_FUNC * pfGetData, const void * p, int x, int y); 00344 00345 /********************************************************************* 00346 * 00347 * API routines 00348 * 00349 ********************************************************************** 00350 */ 00351 void WIDGET_SetState (WM_HWIN hObj, int State); 00352 void WIDGET_AndState (WM_HWIN hObj, int State); 00353 void WIDGET_OrState (WM_HWIN hObj, int State); 00354 int WIDGET_HandleActive (WM_HWIN hObj, WM_MESSAGE* pMsg); 00355 int WIDGET_GetState (WM_HWIN hObj); 00356 int WIDGET_SetWidth (WM_HWIN hObj, int Width); 00357 void WIDGET_SetFocusable (WM_HWIN hObj, int State); 00358 00359 void WIDGET_EFFECT_3D_DrawUp(void); 00360 00361 const WIDGET_EFFECT* WIDGET_SetDefaultEffect(const WIDGET_EFFECT* pEffect); 00362 00363 void WIDGET_SetEffect (WM_HWIN hObj, const WIDGET_EFFECT* pEffect); 00364 00365 const WIDGET_EFFECT* WIDGET_GetDefaultEffect(void); 00366 00367 void WIDGET_EFFECT_3D_SetColor (unsigned Index, GUI_COLOR Color); 00368 void WIDGET_EFFECT_3D1L_SetColor (unsigned Index, GUI_COLOR Color); 00369 void WIDGET_EFFECT_3D2L_SetColor (unsigned Index, GUI_COLOR Color); 00370 void WIDGET_EFFECT_Simple_SetColor(unsigned Index, GUI_COLOR Color); 00371 00372 GUI_COLOR WIDGET_EFFECT_3D_GetColor (unsigned Index); 00373 GUI_COLOR WIDGET_EFFECT_3D1L_GetColor (unsigned Index); 00374 GUI_COLOR WIDGET_EFFECT_3D2L_GetColor (unsigned Index); 00375 GUI_COLOR WIDGET_EFFECT_Simple_GetColor(unsigned Index); 00376 00377 int WIDGET_EFFECT_3D_GetNumColors(void); 00378 int WIDGET_EFFECT_3D1L_GetNumColors(void); 00379 int WIDGET_EFFECT_3D2L_GetNumColors(void); 00380 int WIDGET_EFFECT_Simple_GetNumColors(void); 00381 00382 /********************************************************************* 00383 * 00384 * Compatibility macros 00385 * 00386 ********************************************************************** 00387 */ 00388 #define WIDGET_EnableStreamAuto() GUI_DrawStreamedEnableAuto() 00389 00390 #define WIDGET_SetDefaultEffect_3D() WIDGET_SetDefaultEffect(&WIDGET_Effect_3D) 00391 #define WIDGET_SetDefaultEffect_3D1L() WIDGET_SetDefaultEffect(&WIDGET_Effect_3D1L) 00392 #define WIDGET_SetDefaultEffect_3D2L() WIDGET_SetDefaultEffect(&WIDGET_Effect_3D2L) 00393 #define WIDGET_SetDefaultEffect_None() WIDGET_SetDefaultEffect(&WIDGET_Effect_None) 00394 #define WIDGET_SetDefaultEffect_Simple() WIDGET_SetDefaultEffect(&WIDGET_Effect_Simple) 00395 00396 #endif /* GUI_WINSUPPORT */ 00397 00398 #if defined(__cplusplus) 00399 } 00400 #endif 00401 00402 #endif /* SLIDER_H */ 00403 00404 /*************************** End of file ****************************/
Generated on Mon Mar 4 2024 07:48:13 by 1.7.2