NXP
/
rt1050_emwin_gui_demo
RT1050 GUI demo using emWin library
Embed:
(wiki syntax)
Show/hide line numbers
WIDGET.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 : 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 #define WIDGET_USE_FLEX_SKIN 1 00139 #endif 00140 #if !defined(WIDGET_USE_SCHEME_SMALL) && !defined(WIDGET_USE_SCHEME_MEDIUM) && !defined(WIDGET_USE_SCHEME_LARGE) 00141 #define WIDGET_USE_SCHEME_SMALL 1 00142 #define WIDGET_USE_SCHEME_MEDIUM 0 00143 #define WIDGET_USE_SCHEME_LARGE 0 00144 #endif 00145 #ifndef WIDGET_USE_SCHEME_SMALL 00146 #define WIDGET_USE_SCHEME_SMALL 0 00147 #endif 00148 #ifndef WIDGET_USE_SCHEME_MEDIUM 00149 #define WIDGET_USE_SCHEME_MEDIUM 0 00150 #endif 00151 #ifndef WIDGET_USE_SCHEME_LARGE 00152 #define WIDGET_USE_SCHEME_LARGE 0 00153 #endif 00154 #if (WIDGET_USE_SCHEME_SMALL + WIDGET_USE_SCHEME_MEDIUM + WIDGET_USE_SCHEME_LARGE) > 1 00155 #error Only one scheme can be selected! 00156 #endif 00157 00158 /********************************************************************* 00159 * 00160 * States 00161 */ 00162 00163 #define WIDGET_STATE_FOCUS (1 << 0) 00164 #define WIDGET_STATE_VERTICAL (1 << 3) 00165 #define WIDGET_STATE_FOCUSSABLE (1 << 4) 00166 00167 #define WIDGET_STATE_USER0 (1 << 8) /* Freely available for derived widget */ 00168 #define WIDGET_STATE_USER1 (1 << 9) /* Freely available for derived widget */ 00169 #define WIDGET_STATE_USER2 (1 << 10) /* Freely available for derived widget */ 00170 00171 /********************************************************************* 00172 * 00173 * Skinning message identifiers 00174 */ 00175 #define WIDGET_ITEM_CREATE 0 00176 #define WIDGET_ITEM_DRAW 1 00177 #define WIDGET_ITEM_DRAW_ARROW 2 00178 #define WIDGET_ITEM_DRAW_ARROW_L 3 00179 #define WIDGET_ITEM_DRAW_ARROW_R 4 00180 #define WIDGET_ITEM_DRAW_BACKGROUND 5 00181 #define WIDGET_ITEM_DRAW_BITMAP 6 00182 #define WIDGET_ITEM_DRAW_BUTTON 7 00183 #define WIDGET_ITEM_DRAW_BUTTON_L 8 00184 #define WIDGET_ITEM_DRAW_BUTTON_R 9 00185 #define WIDGET_ITEM_DRAW_FOCUS 10 00186 #define WIDGET_ITEM_DRAW_FRAME 11 00187 #define WIDGET_ITEM_DRAW_OVERLAP 12 00188 #define WIDGET_ITEM_DRAW_OVERLAY 13 00189 #define WIDGET_ITEM_DRAW_SEP 14 00190 #define WIDGET_ITEM_DRAW_SHAFT 15 00191 #define WIDGET_ITEM_DRAW_SHAFT_L 16 00192 #define WIDGET_ITEM_DRAW_SHAFT_R 17 00193 #define WIDGET_ITEM_DRAW_TEXT 18 00194 #define WIDGET_ITEM_DRAW_THUMB 19 00195 #define WIDGET_ITEM_DRAW_TICKS 20 00196 #define WIDGET_ITEM_GET_BORDERSIZE_B 21 00197 #define WIDGET_ITEM_GET_BORDERSIZE_L 22 00198 #define WIDGET_ITEM_GET_BORDERSIZE_R 23 00199 #define WIDGET_ITEM_GET_BORDERSIZE_T 24 00200 #define WIDGET_ITEM_GET_BUTTONSIZE 25 00201 #define WIDGET_ITEM_GET_XSIZE 26 00202 #define WIDGET_ITEM_GET_YSIZE 27 00203 #define WIDGET_ITEM_GET_RADIUS 28 00204 #define WIDGET_ITEM_APPLY_PROPS 29 // Not to be documented. Use this message identifier to update the 00205 // properties of attached widgets from <WIDGET>_DrawSkinFlex(). 00206 00207 #define WIDGET_DRAW_OVERLAY WIDGET_ITEM_DRAW_OVERLAY 00208 #define WIDGET_DRAW_BACKGROUND WIDGET_ITEM_DRAW_BACKGROUND 00209 00210 /********************************************************************* 00211 * 00212 * Messages 00213 */ 00214 00215 #define WM_WIDGET_SET_EFFECT (WM_WIDGET + 0) 00216 00217 /********************************************************************* 00218 * 00219 * Create flags 00220 */ 00221 00222 #define WIDGET_CF_VERTICAL WIDGET_STATE_VERTICAL 00223 00224 /********************************************************************* 00225 * 00226 * Widget object 00227 * 00228 * The widget object is the base class for most widgets 00229 */ 00230 typedef struct { 00231 int EffectSize; 00232 void (* pfDrawUp) (void); 00233 void (* pfDrawUpRect) (const GUI_RECT * pRect); 00234 void (* pfDrawDown) (void); 00235 void (* pfDrawDownRect)(const GUI_RECT * pRect); 00236 void (* pfDrawFlat) (void); 00237 void (* pfDrawFlatRect)(const GUI_RECT * pRect); 00238 } WIDGET_EFFECT; 00239 00240 typedef struct { 00241 WM_Obj Win; 00242 const WIDGET_EFFECT* pEffect; 00243 I16 Id; 00244 U16 State; 00245 #if GUI_DEBUG_LEVEL > 1 00246 U32 DebugId; 00247 #endif 00248 } WIDGET; 00249 00250 00251 /********************************************************************* 00252 * 00253 * GUI_DRAW 00254 * 00255 * The GUI_DRAW object is used as base class for selfdrawing, 00256 * non-windows objects. They are used as content of different widgets, 00257 * such as the bitmap or header widgets. 00258 */ 00259 /* Declare Object struct */ 00260 typedef struct GUI_DRAW GUI_DRAW; 00261 typedef void GUI_DRAW_SELF_CB (WM_HWIN hWin); 00262 typedef WM_HMEM GUI_DRAW_HANDLE; 00263 00264 /* Declare Object constants (member functions etc) */ 00265 typedef struct { 00266 void (* pfDraw) (GUI_DRAW_HANDLE hDrawObj, WM_HWIN hObj, int x, int y); 00267 int (* pfGetXSize)(GUI_DRAW_HANDLE hDrawObj); 00268 int (* pfGetYSize)(GUI_DRAW_HANDLE hDrawObj); 00269 } GUI_DRAW_CONSTS; 00270 00271 /* Declare Object */ 00272 struct GUI_DRAW { 00273 const GUI_DRAW_CONSTS* pConsts; 00274 union { 00275 const void * pData; 00276 GUI_DRAW_SELF_CB* pfDraw; 00277 } Data; 00278 I16 xOff, yOff; 00279 }; 00280 00281 /* GUI_DRAW_ API */ 00282 void GUI_DRAW__Draw (GUI_DRAW_HANDLE hDrawObj, WM_HWIN hObj, int x, int y); 00283 int GUI_DRAW__GetXSize(GUI_DRAW_HANDLE hDrawObj); 00284 int GUI_DRAW__GetYSize(GUI_DRAW_HANDLE hDrawObj); 00285 00286 /* GUI_DRAW_ Constructurs for different objects */ 00287 WM_HMEM GUI_DRAW_BITMAP_Create (const GUI_BITMAP* pBitmap, int x, int y); 00288 WM_HMEM GUI_DRAW_BMP_Create (const void* pBMP, int x, int y); 00289 WM_HMEM GUI_DRAW_STREAMED_Create(const GUI_BITMAP_STREAM * pBitmap, int x, int y); 00290 WM_HMEM GUI_DRAW_SELF_Create(GUI_DRAW_SELF_CB* pfDraw, int x, int y); 00291 00292 /********************************************************************* 00293 * 00294 * Global data 00295 * 00296 ********************************************************************** 00297 */ 00298 00299 extern const WIDGET_EFFECT WIDGET_Effect_3D; 00300 extern const WIDGET_EFFECT WIDGET_Effect_3D1L; 00301 extern const WIDGET_EFFECT WIDGET_Effect_3D2L; 00302 extern const WIDGET_EFFECT WIDGET_Effect_None; 00303 extern const WIDGET_EFFECT WIDGET_Effect_Simple; 00304 00305 /********************************************************************* 00306 * 00307 * Internal API routines 00308 * 00309 ********************************************************************** 00310 */ 00311 00312 void WIDGET__DrawFocusRect (WIDGET * pWidget, const GUI_RECT * pRect, int Dist); 00313 void WIDGET__DrawHLine (WIDGET * pWidget, int y, int x0, int x1); 00314 void WIDGET__DrawTriangle (WIDGET * pWidget, int x, int y, int Size, int Inc); 00315 void WIDGET__DrawVLine (WIDGET * pWidget, int x, int y0, int y1); 00316 void WIDGET__EFFECT_DrawDownRect(WIDGET * pWidget, GUI_RECT * pRect); 00317 void WIDGET__EFFECT_DrawDown (WIDGET * pWidget); 00318 void WIDGET__EFFECT_DrawUpRect (WIDGET * pWidget, GUI_RECT * pRect); 00319 void WIDGET__FillRectEx (WIDGET * pWidget, const GUI_RECT * pRect); 00320 int WIDGET__GetWindowSizeX (WM_HWIN hWin); 00321 GUI_COLOR WIDGET__GetBkColor (WM_HWIN hObj); 00322 int WIDGET__GetXSize (const WIDGET * pWidget); 00323 int WIDGET__GetYSize (const WIDGET * pWidget); 00324 void WIDGET__GetClientRect (WIDGET * pWidget, GUI_RECT * pRect); 00325 void WIDGET__GetInsideRect (WIDGET * pWidget, GUI_RECT * pRect); 00326 void WIDGET__Init (WIDGET * pWidget, int Id, U16 State); 00327 void WIDGET__RotateRect90 (WIDGET * pWidget, GUI_RECT * pDest, const GUI_RECT * pRect); 00328 void WIDGET__SetScrollState (WM_HWIN hWin, const WM_SCROLL_STATE * pVState, const WM_SCROLL_STATE * pState); 00329 void WIDGET__FillStringInRect (const char * pText, const GUI_RECT * pFillRect, const GUI_RECT * pTextRectMax, const GUI_RECT * pTextRectAct); 00330 00331 /********************************************************************* 00332 * 00333 * API routines 00334 * 00335 ********************************************************************** 00336 */ 00337 void WIDGET_SetState (WM_HWIN hObj, int State); 00338 void WIDGET_AndState (WM_HWIN hObj, int State); 00339 void WIDGET_OrState (WM_HWIN hObj, int State); 00340 int WIDGET_HandleActive (WM_HWIN hObj, WM_MESSAGE* pMsg); 00341 int WIDGET_GetState (WM_HWIN hObj); 00342 int WIDGET_SetWidth (WM_HWIN hObj, int Width); 00343 00344 void WIDGET_EFFECT_3D_DrawUp(void); 00345 00346 const WIDGET_EFFECT* WIDGET_SetDefaultEffect(const WIDGET_EFFECT* pEffect); 00347 00348 void WIDGET_SetEffect (WM_HWIN hObj, const WIDGET_EFFECT* pEffect); 00349 00350 const WIDGET_EFFECT* WIDGET_GetDefaultEffect(void); 00351 00352 void WIDGET_EFFECT_3D_SetColor (unsigned Index, GUI_COLOR Color); 00353 void WIDGET_EFFECT_3D1L_SetColor (unsigned Index, GUI_COLOR Color); 00354 void WIDGET_EFFECT_3D2L_SetColor (unsigned Index, GUI_COLOR Color); 00355 void WIDGET_EFFECT_Simple_SetColor(unsigned Index, GUI_COLOR Color); 00356 00357 GUI_COLOR WIDGET_EFFECT_3D_GetColor (unsigned Index); 00358 GUI_COLOR WIDGET_EFFECT_3D1L_GetColor (unsigned Index); 00359 GUI_COLOR WIDGET_EFFECT_3D2L_GetColor (unsigned Index); 00360 GUI_COLOR WIDGET_EFFECT_Simple_GetColor(unsigned Index); 00361 00362 int WIDGET_EFFECT_3D_GetNumColors(void); 00363 int WIDGET_EFFECT_3D1L_GetNumColors(void); 00364 int WIDGET_EFFECT_3D2L_GetNumColors(void); 00365 int WIDGET_EFFECT_Simple_GetNumColors(void); 00366 00367 /********************************************************************* 00368 * 00369 * Compatibility macros 00370 * 00371 ********************************************************************** 00372 */ 00373 #define WIDGET_SetDefaultEffect_3D() WIDGET_SetDefaultEffect(&WIDGET_Effect_3D) 00374 #define WIDGET_SetDefaultEffect_3D1L() WIDGET_SetDefaultEffect(&WIDGET_Effect_3D1L) 00375 #define WIDGET_SetDefaultEffect_3D2L() WIDGET_SetDefaultEffect(&WIDGET_Effect_3D2L) 00376 #define WIDGET_SetDefaultEffect_None() WIDGET_SetDefaultEffect(&WIDGET_Effect_None) 00377 #define WIDGET_SetDefaultEffect_Simple() WIDGET_SetDefaultEffect(&WIDGET_Effect_Simple) 00378 00379 #endif /* GUI_WINSUPPORT */ 00380 00381 #if defined(__cplusplus) 00382 } 00383 #endif 00384 00385 #endif /* SLIDER_H */ 00386 00387 00388 00389
Generated on Tue Jul 12 2022 19:43:37 by 1.7.2