STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
WIDGET.h
Go to the documentation of this file.
1 /*********************************************************************
2 * SEGGER Microcontroller GmbH & Co. KG *
3 * Solutions for real time microcontroller applications *
4 **********************************************************************
5 * *
6 * (c) 1996 - 2015 SEGGER Microcontroller GmbH & Co. KG *
7 * *
8 * Internet: www.segger.com Support: support@segger.com *
9 * *
10 **********************************************************************
11 
12 ** emWin V5.28 - Graphical user interface for embedded applications **
13 All Intellectual Property rights in the Software belongs to SEGGER.
14 emWin is protected by international copyright laws. Knowledge of the
15 source code may not be used to write a similar product. This file may
16 only be used in accordance with the following terms:
17 
18 The software has been licensed to STMicroelectronics International
19 N.V. a Dutch company with a Swiss branch and its headquarters in Plan-
20 les-Ouates, Geneva, 39 Chemin du Champ des Filles, Switzerland for the
21 purposes of creating libraries for ARM Cortex-M-based 32-bit microcon_
22 troller products commercialized by Licensee only, sublicensed and dis_
23 tributed under the terms and conditions of the End User License Agree_
24 ment supplied by STMicroelectronics International N.V.
25 Full source code is available at: www.segger.com
26 
27 We appreciate your understanding and fairness.
28 ----------------------------------------------------------------------
29 File : WIDGET.h
30 Purpose : Widget interface
31 ---------------------------END-OF-HEADER------------------------------
32 */
33 
34 #ifndef WIDGET_H /* Avoid multiple inclusion */
35 #define WIDGET_H
36 
37 #if defined(__cplusplus)
38 extern "C" { /* Make sure we have C-declarations in C++ programs */
39 #endif
40 
41 #include "WM_Intern.h" /* Window manager, including some internals, which speed things up */
42 
43 #if GUI_WINSUPPORT
44 
45 /*********************************************************************
46 *
47 * Typedefs
48 *
49 **********************************************************************
50 */
51 typedef struct {
52  WM_HWIN hWin;
53  int Cmd; /* WIDGET_ITEM_GET_XSIZE, WIDGET_ITEM_GET_YSIZE, WIDGET_ITEM_DRAW, */
54  int ItemIndex;
55  int Col;
56  int x0, y0, x1, y1;
57  void * p;
58 } WIDGET_ITEM_DRAW_INFO;
59 
60 typedef int WIDGET_DRAW_ITEM_FUNC(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo);
61 typedef void WIDGET_PAINT (WM_HWIN hObj);
62 typedef void WIDGET_CREATE (WM_HWIN hObj);
63 
64 typedef struct {
65  WIDGET_PAINT * pfPaint;
66  WIDGET_CREATE * pfCreate;
67  void * pSkinPrivate;
68 } WIDGET_SKIN;
69 
70 /*********************************************************************
71 *
72 * Important: WIDGET_DRAW_ITEM_FUNC needs to be defined
73 * in SCROLLBAR.h!
74 *
75 **********************************************************************
76 */
77 #include "SCROLLBAR.h"
78 
79 /*********************************************************************
80 *
81 * Defines
82 *
83 **********************************************************************
84 */
85 /*********************************************************************
86 *
87 * Unique widget id's
88 */
89 #define BUTTON_ID 0x42555454UL /* BUTT */
90 #define CHECKBOX_ID 0x43484543UL /* CHEC */
91 #define DROPDOWN_ID 0x44524f50UL /* DROP */
92 #define EDIT_ID 0x45444954UL /* EDIT */
93 #define FRAMEWIN_ID 0x4652414dUL /* FRAM */
94 #define FRAMECLNT_ID 0x46524143UL /* FRAC */
95 #define GRAPH_ID 0x47524150UL /* GRAP */
96 #define HEADER_ID 0x48454144UL /* HEAD */
97 #define LISTBOX_ID 0x4C495342UL /* LISB */
98 #define LISTVIEW_ID 0x4C495356UL /* LISV */
99 #define LISTWHEEL_ID 0x4C495357UL /* LISW */
100 #define MENU_ID 0x4d454e55UL /* MENU */
101 #define MULTIEDIT_ID 0x4d554c45UL /* MULE */
102 #define MULTIPAGE_ID 0x4d554c50UL /* MULP */
103 #define MPAGECLNT_ID 0x4d50434CUL /* MPCL */
104 #define PROGBAR_ID 0x50524f47UL /* PROG */
105 #define RADIO_ID 0x52414449UL /* RADI */
106 #define SCROLLBAR_ID 0x5343524fUL /* SCRO */
107 #define SLIDER_ID 0x534c4944UL /* SLID */
108 #define TEXT_ID 0x54455854UL /* TEXT */
109 #define TREEVIEW_ID 0x54524545UL /* TREE */
110 #define ICONVIEW_ID 0x49434f4eUL /* ICON */
111 #define IMAGE_ID 0x494d4147UL /* IMAG */
112 #define SPINBOX_ID 0x5350494eUL /* SPIN */
113 #define KNOB_ID 0x4b4e4f42UL /* KNOB */
114 #define WINDOW_ID 0x57494e44UL /* WIND */
115 
116 #define WIDGET_LOCK(hWin) ((WIDGET*)GUI_LOCK_H(hWin))
117 
118 /*********************************************************************
119 *
120 * Config switches
121 */
122 
123 #ifndef WIDGET_USE_PARENT_EFFECT
124  #define WIDGET_USE_PARENT_EFFECT 0
125 #endif
126 #ifndef WIDGET_USE_FLEX_SKIN
127  #define WIDGET_USE_FLEX_SKIN 1
128 #endif
129 #if !defined(WIDGET_USE_SCHEME_SMALL) && !defined(WIDGET_USE_SCHEME_MEDIUM) && !defined(WIDGET_USE_SCHEME_LARGE)
130  #define WIDGET_USE_SCHEME_SMALL 1
131  #define WIDGET_USE_SCHEME_MEDIUM 0
132  #define WIDGET_USE_SCHEME_LARGE 0
133 #endif
134 #ifndef WIDGET_USE_SCHEME_SMALL
135  #define WIDGET_USE_SCHEME_SMALL 0
136 #endif
137 #ifndef WIDGET_USE_SCHEME_MEDIUM
138  #define WIDGET_USE_SCHEME_MEDIUM 0
139 #endif
140 #ifndef WIDGET_USE_SCHEME_LARGE
141  #define WIDGET_USE_SCHEME_LARGE 0
142 #endif
143 #if (WIDGET_USE_SCHEME_SMALL + WIDGET_USE_SCHEME_MEDIUM + WIDGET_USE_SCHEME_LARGE) > 1
144  #error Only one scheme can be selected!
145 #endif
146 
147 /*********************************************************************
148 *
149 * States
150 */
151 
152 #define WIDGET_STATE_FOCUS (1 << 0)
153 #define WIDGET_STATE_VERTICAL (1 << 3)
154 #define WIDGET_STATE_FOCUSSABLE (1 << 4)
155 
156 #define WIDGET_STATE_USER0 (1 << 8) /* Freely available for derived widget */
157 #define WIDGET_STATE_USER1 (1 << 9) /* Freely available for derived widget */
158 #define WIDGET_STATE_USER2 (1 << 10) /* Freely available for derived widget */
159 
160 /*********************************************************************
161 *
162 * Skinning message identifiers
163 */
164 #define WIDGET_ITEM_CREATE 0
165 #define WIDGET_ITEM_DRAW 1
166 #define WIDGET_ITEM_DRAW_ARROW 2
167 #define WIDGET_ITEM_DRAW_ARROW_L 3
168 #define WIDGET_ITEM_DRAW_ARROW_R 4
169 #define WIDGET_ITEM_DRAW_BACKGROUND 5
170 #define WIDGET_ITEM_DRAW_BITMAP 6
171 #define WIDGET_ITEM_DRAW_BUTTON 7
172 #define WIDGET_ITEM_DRAW_BUTTON_L 8
173 #define WIDGET_ITEM_DRAW_BUTTON_R 9
174 #define WIDGET_ITEM_DRAW_FOCUS 10
175 #define WIDGET_ITEM_DRAW_FRAME 11
176 #define WIDGET_ITEM_DRAW_OVERLAP 12
177 #define WIDGET_ITEM_DRAW_OVERLAY 13
178 #define WIDGET_ITEM_DRAW_SEP 14
179 #define WIDGET_ITEM_DRAW_SHAFT 15
180 #define WIDGET_ITEM_DRAW_SHAFT_L 16
181 #define WIDGET_ITEM_DRAW_SHAFT_R 17
182 #define WIDGET_ITEM_DRAW_TEXT 18
183 #define WIDGET_ITEM_DRAW_THUMB 19
184 #define WIDGET_ITEM_DRAW_TICKS 20
185 #define WIDGET_ITEM_GET_BORDERSIZE_B 21
186 #define WIDGET_ITEM_GET_BORDERSIZE_L 22
187 #define WIDGET_ITEM_GET_BORDERSIZE_R 23
188 #define WIDGET_ITEM_GET_BORDERSIZE_T 24
189 #define WIDGET_ITEM_GET_BUTTONSIZE 25
190 #define WIDGET_ITEM_GET_XSIZE 26
191 #define WIDGET_ITEM_GET_YSIZE 27
192 #define WIDGET_ITEM_GET_RADIUS 28
193 #define WIDGET_ITEM_APPLY_PROPS 29 // Not to be documented. Use this message identifier to update the
194  // properties of attached widgets from <WIDGET>_DrawSkinFlex().
195 
196 #define WIDGET_DRAW_OVERLAY WIDGET_ITEM_DRAW_OVERLAY
197 #define WIDGET_DRAW_BACKGROUND WIDGET_ITEM_DRAW_BACKGROUND
198 
199 /*********************************************************************
200 *
201 * Messages
202 */
203 
204 #define WM_WIDGET_SET_EFFECT (WM_WIDGET + 0)
205 
206 /*********************************************************************
207 *
208 * Create flags
209 */
210 
211 #define WIDGET_CF_VERTICAL WIDGET_STATE_VERTICAL
212 
213 /*********************************************************************
214 *
215 * Widget object
216 *
217 * The widget object is the base class for most widgets
218 */
219 typedef struct {
220  int EffectSize;
221  void (* pfDrawUp) (void);
222  void (* pfDrawUpRect) (const GUI_RECT * pRect);
223  void (* pfDrawDown) (void);
224  void (* pfDrawDownRect)(const GUI_RECT * pRect);
225  void (* pfDrawFlat) (void);
226  void (* pfDrawFlatRect)(const GUI_RECT * pRect);
227 } WIDGET_EFFECT;
228 
229 typedef struct {
230  WM_Obj Win;
231  const WIDGET_EFFECT* pEffect;
232  I16 Id;
233  U16 State;
234  #if GUI_DEBUG_LEVEL > 1
235  U32 DebugId;
236  #endif
237 } WIDGET;
238 
239 
240 /*********************************************************************
241 *
242 * GUI_DRAW
243 *
244 * The GUI_DRAW object is used as base class for selfdrawing,
245 * non-windows objects. They are used as content of different widgets,
246 * such as the bitmap or header widgets.
247 */
248 /* Declare Object struct */
249 typedef struct GUI_DRAW GUI_DRAW;
250 typedef void GUI_DRAW_SELF_CB (WM_HWIN hWin);
251 typedef WM_HMEM GUI_DRAW_HANDLE;
252 
253 /* Declare Object constants (member functions etc) */
254 typedef struct {
255  void (* pfDraw) (GUI_DRAW_HANDLE hDrawObj, WM_HWIN hObj, int x, int y);
256  int (* pfGetXSize)(GUI_DRAW_HANDLE hDrawObj);
257  int (* pfGetYSize)(GUI_DRAW_HANDLE hDrawObj);
258 } GUI_DRAW_CONSTS;
259 
260 /* Declare Object */
261 struct GUI_DRAW {
262  const GUI_DRAW_CONSTS* pConsts;
263  union {
264  const void * pData;
265  GUI_DRAW_SELF_CB* pfDraw;
266  } Data;
267  I16 xOff, yOff;
268 };
269 
270 /* GUI_DRAW_ API */
271 void GUI_DRAW__Draw (GUI_DRAW_HANDLE hDrawObj, WM_HWIN hObj, int x, int y);
272 int GUI_DRAW__GetXSize(GUI_DRAW_HANDLE hDrawObj);
273 int GUI_DRAW__GetYSize(GUI_DRAW_HANDLE hDrawObj);
274 
275 /* GUI_DRAW_ Constructurs for different objects */
276 WM_HMEM GUI_DRAW_BITMAP_Create (const GUI_BITMAP* pBitmap, int x, int y);
277 WM_HMEM GUI_DRAW_BMP_Create (const void* pBMP, int x, int y);
278 WM_HMEM GUI_DRAW_STREAMED_Create(const GUI_BITMAP_STREAM * pBitmap, int x, int y);
279 WM_HMEM GUI_DRAW_SELF_Create(GUI_DRAW_SELF_CB* pfDraw, int x, int y);
280 
281 /*********************************************************************
282 *
283 * Global data
284 *
285 **********************************************************************
286 */
287 
288 extern const WIDGET_EFFECT WIDGET_Effect_3D;
289 extern const WIDGET_EFFECT WIDGET_Effect_3D1L;
290 extern const WIDGET_EFFECT WIDGET_Effect_3D2L;
291 extern const WIDGET_EFFECT WIDGET_Effect_None;
292 extern const WIDGET_EFFECT WIDGET_Effect_Simple;
293 
294 /*********************************************************************
295 *
296 * Internal API routines
297 *
298 **********************************************************************
299 */
300 
301 void WIDGET__DrawFocusRect (WIDGET * pWidget, const GUI_RECT * pRect, int Dist);
302 void WIDGET__DrawHLine (WIDGET * pWidget, int y, int x0, int x1);
303 void WIDGET__DrawTriangle (WIDGET * pWidget, int x, int y, int Size, int Inc);
304 void WIDGET__DrawVLine (WIDGET * pWidget, int x, int y0, int y1);
305 void WIDGET__EFFECT_DrawDownRect(WIDGET * pWidget, GUI_RECT * pRect);
306 void WIDGET__EFFECT_DrawDown (WIDGET * pWidget);
307 void WIDGET__EFFECT_DrawUpRect (WIDGET * pWidget, GUI_RECT * pRect);
308 void WIDGET__FillRectEx (WIDGET * pWidget, const GUI_RECT * pRect);
309 int WIDGET__GetWindowSizeX (WM_HWIN hWin);
310 GUI_COLOR WIDGET__GetBkColor (WM_HWIN hObj);
311 int WIDGET__GetXSize (const WIDGET * pWidget);
312 int WIDGET__GetYSize (const WIDGET * pWidget);
313 void WIDGET__GetClientRect (WIDGET * pWidget, GUI_RECT * pRect);
314 void WIDGET__GetInsideRect (WIDGET * pWidget, GUI_RECT * pRect);
315 void WIDGET__Init (WIDGET * pWidget, int Id, U16 State);
316 void WIDGET__RotateRect90 (WIDGET * pWidget, GUI_RECT * pDest, const GUI_RECT * pRect);
317 void WIDGET__SetScrollState (WM_HWIN hWin, const WM_SCROLL_STATE * pVState, const WM_SCROLL_STATE * pState);
318 void WIDGET__FillStringInRect (const char * pText, const GUI_RECT * pFillRect, const GUI_RECT * pTextRectMax, const GUI_RECT * pTextRectAct);
319 
320 /*********************************************************************
321 *
322 * API routines
323 *
324 **********************************************************************
325 */
326 void WIDGET_SetState (WM_HWIN hObj, int State);
327 void WIDGET_AndState (WM_HWIN hObj, int State);
328 void WIDGET_OrState (WM_HWIN hObj, int State);
329 int WIDGET_HandleActive (WM_HWIN hObj, WM_MESSAGE* pMsg);
330 int WIDGET_GetState (WM_HWIN hObj);
331 int WIDGET_SetWidth (WM_HWIN hObj, int Width);
332 
333 void WIDGET_EFFECT_3D_DrawUp(void);
334 
335 const WIDGET_EFFECT* WIDGET_SetDefaultEffect(const WIDGET_EFFECT* pEffect);
336 
337 void WIDGET_SetEffect (WM_HWIN hObj, const WIDGET_EFFECT* pEffect);
338 
339 const WIDGET_EFFECT* WIDGET_GetDefaultEffect(void);
340 
341 void WIDGET_EFFECT_3D_SetColor (unsigned Index, GUI_COLOR Color);
342 void WIDGET_EFFECT_3D1L_SetColor (unsigned Index, GUI_COLOR Color);
343 void WIDGET_EFFECT_3D2L_SetColor (unsigned Index, GUI_COLOR Color);
344 void WIDGET_EFFECT_Simple_SetColor(unsigned Index, GUI_COLOR Color);
345 
346 GUI_COLOR WIDGET_EFFECT_3D_GetColor (unsigned Index);
347 GUI_COLOR WIDGET_EFFECT_3D1L_GetColor (unsigned Index);
348 GUI_COLOR WIDGET_EFFECT_3D2L_GetColor (unsigned Index);
349 GUI_COLOR WIDGET_EFFECT_Simple_GetColor(unsigned Index);
350 
351 int WIDGET_EFFECT_3D_GetNumColors(void);
352 int WIDGET_EFFECT_3D1L_GetNumColors(void);
353 int WIDGET_EFFECT_3D2L_GetNumColors(void);
354 int WIDGET_EFFECT_Simple_GetNumColors(void);
355 
356 /*********************************************************************
357 *
358 * Compatibility macros
359 *
360 **********************************************************************
361 */
362 #define WIDGET_SetDefaultEffect_3D() WIDGET_SetDefaultEffect(&WIDGET_Effect_3D)
363 #define WIDGET_SetDefaultEffect_3D1L() WIDGET_SetDefaultEffect(&WIDGET_Effect_3D1L)
364 #define WIDGET_SetDefaultEffect_3D2L() WIDGET_SetDefaultEffect(&WIDGET_Effect_3D2L)
365 #define WIDGET_SetDefaultEffect_None() WIDGET_SetDefaultEffect(&WIDGET_Effect_None)
366 #define WIDGET_SetDefaultEffect_Simple() WIDGET_SetDefaultEffect(&WIDGET_Effect_Simple)
367 
368 #endif /* GUI_WINSUPPORT */
369 
370 #if defined(__cplusplus)
371  }
372 #endif
373 
374 #endif /* SLIDER_H */
375 
376 
377 
378 
#define U32
Definition: Global.h:50
Definition: LCD.h:102
LCD_COLOR GUI_COLOR
Definition: GUI_Type.h:50
#define I16
Definition: Global.h:56
#define U16
Definition: Global.h:47