version 2.8
gwin_button.c
Go to the documentation of this file.
1 /*
2  * This file is subject to the terms of the GFX License. If a copy of
3  * the license was not distributed with this file, you can obtain one at:
4  *
5  * http://ugfx.org/license.html
6  */
7 
8 /**
9  * @file src/gwin/gwin_button.c
10  * @brief GWIN sub-system button code
11  */
12 
13 #include "../../gfx.h"
14 
15 #if GFX_USE_GWIN && GWIN_NEED_BUTTON
16 
17 #include "gwin_class.h"
18 
19 // Parameters for various shapes
20 #define BTN_CNR_SIZE 5 // Rounded corner size for rounded buttons
21 #define BTN_ARROWHEAD_DIV 0 // What fraction of the length for the arrow head. Use 0 for 45 degree arrow head.
22 #define BTN_ARROWBODY_DIV 2 // What fraction of the width for the arrow body
23 #define BTN_TOP_FADE 50 // (BTN_TOP_FADE/255)% fade to white for top of button
24 #define BTN_BOTTOM_FADE 25 // (BTN_BOTTOM_FADE/255)% fade to black for bottom of button
25 
26 #if GINPUT_NEED_MOUSE
27  // A mouse down has occurred over the button
28  static void ButtonMouseDown(GWidgetObject *gw, coord_t x, coord_t y) {
29  (void) x; (void) y;
31  _gwinUpdate((GHandle)gw);
32  }
33 
34  // A mouse up has occurred (it may or may not be over the button)
35  static void ButtonMouseUp(GWidgetObject *gw, coord_t x, coord_t y) {
36  (void) x; (void) y;
37  gw->g.flags &= ~GBUTTON_FLG_PRESSED;
38  _gwinUpdate((GHandle)gw);
39 
40  #if !GWIN_BUTTON_LAZY_RELEASE
41  // If the mouse up was not over the button then cancel the event
42  if (x < 0 || y < 0 || x >= gw->g.width || y >= gw->g.height)
43  return;
44  #endif
45 
46  _gwinSendEvent(&gw->g, GEVENT_GWIN_BUTTON);
47  }
48 #endif
49 
50 #if GINPUT_NEED_KEYBOARD || GWIN_NEED_KEYBOARD
51  static void ButtonKeyboard(GWidgetObject* gw, GEventKeyboard* pke)
52  {
53  // ENTER and SPACE keys to press the button
54  if (pke->c[0] == GKEY_ENTER || pke->c[0] == GKEY_SPACE) {
55 
56  // Some keyboards (eg the virtual keyboard) can't send keyup events.
57  // Even for those that do we may not be listening for them.
58  // We should really process on a keydown and then set a timer to display
59  // the button release but that requires an extra timer and lots of
60  // complication. Instead we cheat by not providing user feedback of the keypress.
61  if (!(pke->keystate & GKEYSTATE_KEYUP))
62  _gwinSendEvent(&gw->g, GEVENT_GWIN_BUTTON);
63  }
64 
65  }
66 #endif
67 
68 #if GINPUT_NEED_TOGGLE
69  // A toggle off has occurred
70  static void ButtonToggleOff(GWidgetObject *gw, uint16_t role) {
71  (void) role;
72  gw->g.flags &= ~GBUTTON_FLG_PRESSED;
73  _gwinUpdate((GHandle)gw);
74  }
75 
76  // A toggle on has occurred
77  static void ButtonToggleOn(GWidgetObject *gw, uint16_t role) {
78  (void) role;
80  _gwinUpdate((GHandle)gw);
81  // Trigger the event on button down (different than for mouse/touch)
82  _gwinSendEvent(&gw->g, GEVENT_GWIN_BUTTON);
83  }
84 
85  static void ButtonToggleAssign(GWidgetObject *gw, uint16_t role, uint16_t instance) {
86  (void) role;
87  ((GButtonObject *)gw)->toggle = instance;
88  }
89 
90  static uint16_t ButtonToggleGet(GWidgetObject *gw, uint16_t role) {
91  (void) role;
92  return ((GButtonObject *)gw)->toggle;
93  }
94 #endif
95 
96 // The button VMT table
97 static const gwidgetVMT buttonVMT = {
98  {
99  "Button", // The classname
100  sizeof(GButtonObject), // The object size
101  _gwidgetDestroy, // The destroy routine
102  _gwidgetRedraw, // The redraw routine
103  0, // The after-clear routine
104  },
105  gwinButtonDraw_Normal, // The default drawing routine
107  {
108  ButtonMouseDown, // Process mouse down events
109  ButtonMouseUp, // Process mouse up events
110  0, // Process mouse move events (NOT USED)
111  },
112  #endif
113  #if GINPUT_NEED_KEYBOARD || GWIN_NEED_KEYBOARD
114  {
115  ButtonKeyboard // Process keyboard events
116  },
117  #endif
118  #if GINPUT_NEED_TOGGLE
119  {
120  1, // 1 toggle role
121  ButtonToggleAssign, // Assign Toggles
122  ButtonToggleGet, // Get Toggles
123  ButtonToggleOff, // Process toggle off events
124  ButtonToggleOn, // Process toggle on events
125  },
126  #endif
127  #if GINPUT_NEED_DIAL
128  {
129  0, // No dial roles
130  0, // Assign Dials (NOT USED)
131  0, // Get Dials (NOT USED)
132  0, // Process dial move events (NOT USED)
133  },
134  #endif
135 };
136 
137 GHandle gwinGButtonCreate(GDisplay *g, GButtonObject *gw, const GWidgetInit *pInit) {
138  if (!(gw = (GButtonObject *)_gwidgetCreate(g, &gw->w, pInit, &buttonVMT)))
139  return 0;
140 
141  #if GINPUT_NEED_TOGGLE
142  gw->toggle = GWIDGET_NO_INSTANCE;
143  #endif
144  gwinSetVisible((GHandle)gw, pInit->g.show);
145  return (GHandle)gw;
146 }
147 
148 bool_t gwinButtonIsPressed(GHandle gh) {
149  if (gh->vmt != (gwinVMT *)&buttonVMT)
150  return FALSE;
151 
152  return (gh->flags & GBUTTON_FLG_PRESSED) ? TRUE : FALSE;
153 }
154 
155 /*----------------------------------------------------------
156  * Custom Draw Routines
157  *----------------------------------------------------------*/
158 
159 static const GColorSet *getButtonColors(GWidgetObject *gw) {
160  if (!(gw->g.flags & GWIN_FLG_SYSENABLED)) return &gw->pstyle->disabled;
161  if ((gw->g.flags & GBUTTON_FLG_PRESSED)) return &gw->pstyle->pressed;
162  return &gw->pstyle->enabled;
163 }
164 
165 #if GWIN_FLAT_STYLING
166  void gwinButtonDraw_Normal(GWidgetObject *gw, void *param) {
167  const GColorSet * pcol;
168 
169  (void) param;
170 
171  if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
172  pcol = getButtonColors(gw);
173 
174  gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width-1, gw->g.height-1, gw->text, gw->g.font, pcol->text, pcol->fill, justifyCenter);
175  gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge);
176  gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+gw->g.height-1, gw->g.x+gw->g.width-2, gw->g.y+gw->g.height-1, pcol->edge);
177 
178  // Render highlighted border if focused
179  _gwidgetDrawFocusRect(gw, 1, 1, gw->g.width-2, gw->g.height-2);
180  }
181 #else
182  void gwinButtonDraw_Normal(GWidgetObject *gw, void *param) {
183  const GColorSet * pcol;
184  fixed alpha;
185  fixed dalpha;
186  coord_t i;
187  color_t tcol, bcol;
188 
189  (void) param;
190 
191  if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
192  pcol = getButtonColors(gw);
193 
194  /* Fill the box blended from variants of the fill color */
195  tcol = gdispBlendColor(White, pcol->fill, BTN_TOP_FADE);
196  bcol = gdispBlendColor(Black, pcol->fill, BTN_BOTTOM_FADE);
197  dalpha = FIXED(255)/gw->g.height;
198  for(alpha = 0, i = 0; i < gw->g.height; i++, alpha += dalpha)
199  gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+i, gw->g.x+gw->g.width-2, gw->g.y+i, gdispBlendColor(bcol, tcol, NONFIXED(alpha)));
200 
201  gdispGDrawStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width-1, gw->g.height-1, gw->text, gw->g.font, pcol->text, justifyCenter);
202  gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge);
203  gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+gw->g.height-1, gw->g.x+gw->g.width-2, gw->g.y+gw->g.height-1, pcol->edge);
204 
205  // Render highlighted border if focused
206  _gwidgetDrawFocusRect(gw, 0, 0, gw->g.width-1, gw->g.height-1);
207  }
208 #endif
209 
210 #if GDISP_NEED_ARC
211  void gwinButtonDraw_Rounded(GWidgetObject *gw, void *param) {
212  const GColorSet * pcol;
213 
214  (void) param;
215 
216  if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
217  pcol = getButtonColors(gw);
218 
219  gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->pstyle->background);
220  if (gw->g.width >= 2*BTN_CNR_SIZE+10) {
221  gdispGFillRoundedBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, BTN_CNR_SIZE-1, pcol->fill);
222  gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+BTN_CNR_SIZE, gw->g.width-2, gw->g.height-(2*BTN_CNR_SIZE), gw->text, gw->g.font, pcol->text, justifyCenter);
223  gdispGDrawRoundedBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, BTN_CNR_SIZE, pcol->edge);
224  } else {
225  gdispGFillStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, gw->text, gw->g.font, pcol->text, pcol->fill, justifyCenter);
226  gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, pcol->edge);
227  }
228  }
229 #endif
230 
231 #if GDISP_NEED_ELLIPSE
232  void gwinButtonDraw_Ellipse(GWidgetObject *gw, void *param) {
233  const GColorSet * pcol;
234 
235  (void) param;
236 
237  if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
238  pcol = getButtonColors(gw);
239 
240  gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->pstyle->background);
241  gdispGFillEllipse(gw->g.display, gw->g.x+gw->g.width/2, gw->g.y+gw->g.height/2, gw->g.width/2-2, gw->g.height/2-2, pcol->fill);
242  gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, gw->text, gw->g.font, pcol->text, justifyCenter);
243  gdispGDrawEllipse(gw->g.display, gw->g.x+gw->g.width/2, gw->g.y+gw->g.height/2, gw->g.width/2-1, gw->g.height/2-1, pcol->edge);
244  }
245 #endif
246 
247 #if GDISP_NEED_CONVEX_POLYGON
248  void gwinButtonDraw_ArrowUp(GWidgetObject *gw, void *param) {
249  const GColorSet * pcol;
250  point arw[7];
251 
252  (void) param;
253 
254  if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
255  pcol = getButtonColors(gw);
256 
257  // Create the arrow polygon
258  arw[0].x = (gw->g.width-1)/2; // Point center
259  arw[0].y = 0; // Arrow start
260  arw[3].y = gw->g.height-1; // Arrow end
261  #if BTN_ARROWHEAD_DIV == 0
262  if (gw->g.height <= arw[0].x) {
263  arw[1].y = arw[3].y; // End of head
264  arw[1].x = arw[0].x+arw[3].y; // Width of head (side 1)
265  arw[2].x = arw[1].x; // Width of shaft (side 1)
266  arw[4].x = arw[0].x-arw[3].y; // Width of head (side 2)
267  arw[6].x = arw[4].x; // Width of shaft (side 2)
268  } else {
269  arw[1].y = arw[0].x;
270  arw[1].x = arw[0].x << 1;
271  arw[2].x = arw[0].x + arw[0].x/BTN_ARROWBODY_DIV;
272  arw[4].x = arw[0].x - arw[0].x/BTN_ARROWBODY_DIV;
273  arw[6].x = 0;
274  }
275  #else
276  arw[1].y = gw->g.height/BTN_ARROWHEAD_DIV;
277  arw[1].x = arw[0].x << 1;
278  arw[2].x = arw[0].x + arw[0].x/BTN_ARROWBODY_DIV;
279  arw[4].x = arw[0].x - arw[0].x/BTN_ARROWBODY_DIV;
280  arw[6].x = 0;
281  #endif
282 
283  // Fill in the rest from the special points
284  /* arw[0].x set */ /* arw[0].y set */
285  /* arw[1].x set */ /* arw[1].y set */
286  /* arw[2].x set */ arw[2].y = arw[1].y;
287  arw[3].x = arw[2].x; /* arw[3].y set */
288  /* arw[4].x set */ arw[4].y = arw[3].y;
289  arw[5].x = arw[4].x; arw[5].y = arw[1].y;
290  /* arw[6].x set */ arw[6].y = arw[1].y;
291 
292  // Draw
293  gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->pstyle->background);
294  gdispGFillConvexPoly(gw->g.display, gw->g.x, gw->g.y, arw, 7, pcol->fill);
295  gdispGDrawPoly(gw->g.display, gw->g.x, gw->g.y, arw, 7, pcol->edge);
296  gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, gw->text, gw->g.font, pcol->text, justifyCenter);
297  }
298 
299  void gwinButtonDraw_ArrowDown(GWidgetObject *gw, void *param) {
300  const GColorSet * pcol;
301  point arw[7];
302 
303  (void) param;
304 
305  if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
306  pcol = getButtonColors(gw);
307 
308  // Create the arrow polygon
309  arw[0].x = (gw->g.width-1)/2; // Point center
310  arw[0].y = gw->g.height-1; // Arrow start
311  arw[3].y = 0; // Arrow end
312  #if BTN_ARROWHEAD_DIV == 0
313  if (gw->g.height <= arw[0].x) {
314  arw[1].y = arw[3].y; // End of head
315  arw[1].x = arw[0].x+arw[0].y; // Width of head (side 1)
316  arw[2].x = arw[1].x; // Width of shaft (side 1)
317  arw[4].x = arw[0].x-arw[0].y; // Width of head (side 2)
318  arw[6].x = arw[4].x; // Width of shaft (side 2)
319  } else {
320  arw[1].y = arw[0].y - arw[0].x;
321  arw[1].x = arw[0].x << 1;
322  arw[2].x = arw[0].x + arw[0].x/BTN_ARROWBODY_DIV;
323  arw[4].x = arw[0].x - arw[0].x/BTN_ARROWBODY_DIV;
324  arw[6].x = 0;
325  }
326  #else
327  arw[1].y = arw[0].y - gw->g.height/BTN_ARROWHEAD_DIV;
328  arw[1].x = arw[0].x << 1;
329  arw[2].x = arw[0].x + arw[0].x/BTN_ARROWBODY_DIV;
330  arw[4].x = arw[0].x - arw[0].x/BTN_ARROWBODY_DIV;
331  arw[6].x = 0;
332  #endif
333 
334  // Fill in the rest from the special points
335  /* arw[0].x set */ /* arw[0].y set */
336  /* arw[1].x set */ /* arw[1].y set */
337  /* arw[2].x set */ arw[2].y = arw[1].y;
338  arw[3].x = arw[2].x; /* arw[3].y set */
339  /* arw[4].x set */ arw[4].y = arw[3].y;
340  arw[5].x = arw[4].x; arw[5].y = arw[1].y;
341  /* arw[6].x set */ arw[6].y = arw[1].y;
342 
343  // Draw
344  gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->pstyle->background);
345  gdispGFillConvexPoly(gw->g.display, gw->g.x, gw->g.y, arw, 7, pcol->fill);
346  gdispGDrawPoly(gw->g.display, gw->g.x, gw->g.y, arw, 7, pcol->edge);
347  gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, gw->text, gw->g.font, pcol->text, justifyCenter);
348  }
349 
350  void gwinButtonDraw_ArrowLeft(GWidgetObject *gw, void *param) {
351  const GColorSet * pcol;
352  point arw[7];
353 
354  (void) param;
355 
356  if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
357  pcol = getButtonColors(gw);
358 
359  // Create the arrow polygon
360  arw[0].y = (gw->g.height-1)/2; // Point center
361  arw[0].x = 0; // Arrow start
362  arw[3].x = gw->g.width-1; // Arrow end
363  #if BTN_ARROWHEAD_DIV == 0
364  if (gw->g.width <= arw[0].y) {
365  arw[1].x = arw[3].x; // End of head
366  arw[1].y = arw[0].y+arw[3].x; // Width of head (side 1)
367  arw[2].y = arw[1].y; // Width of shaft (side 1)
368  arw[4].y = arw[0].y-arw[3].x; // Width of head (side 2)
369  arw[6].y = arw[4].y; // Width of shaft (side 2)
370  } else {
371  arw[1].x = arw[0].y;
372  arw[1].y = arw[0].y << 1;
373  arw[2].y = arw[0].y + arw[0].y/BTN_ARROWBODY_DIV;
374  arw[4].y = arw[0].y - arw[0].y/BTN_ARROWBODY_DIV;
375  arw[6].y = 0;
376  }
377  #else
378  arw[1].x = gw->g.width/BTN_ARROWHEAD_DIV;
379  arw[1].y = arw[0].y << 1;
380  arw[2].y = arw[0].y + arw[0].y/BTN_ARROWBODY_DIV;
381  arw[4].y = arw[0].y - arw[0].y/BTN_ARROWBODY_DIV;
382  arw[6].y = 0;
383  #endif
384 
385  // Fill in the rest from the special points
386  /* arw[0].x set */ /* arw[0].y set */
387  /* arw[1].x set */ /* arw[1].y set */
388  arw[2].x = arw[1].x; /* arw[2].y set */
389  /* arw[3].y set */ arw[3].y = arw[2].y;
390  arw[4].x = arw[3].x; /* arw[4].y set */
391  arw[5].x = arw[1].x; arw[5].y = arw[4].y;
392  arw[6].x = arw[1].x; /* arw[6].y set */
393 
394  // Draw
395  gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->pstyle->background);
396  gdispGFillConvexPoly(gw->g.display, gw->g.x, gw->g.y, arw, 7, pcol->fill);
397  gdispGDrawPoly(gw->g.display, gw->g.x, gw->g.y, arw, 7, pcol->edge);
398  gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, gw->text, gw->g.font, pcol->text, justifyCenter);
399  }
400 
401  void gwinButtonDraw_ArrowRight(GWidgetObject *gw, void *param) {
402  const GColorSet * pcol;
403  point arw[7];
404 
405  (void) param;
406 
407  if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
408  pcol = getButtonColors(gw);
409 
410  // Create the arrow polygon
411  arw[0].y = (gw->g.height-1)/2; // Point center
412  arw[0].x = gw->g.width-1; // Arrow start
413  arw[3].x = 0; // Arrow end
414  #if BTN_ARROWHEAD_DIV == 0
415  if (gw->g.width <= arw[0].y) {
416  arw[1].x = arw[3].x; // End of head
417  arw[1].y = arw[0].y+arw[0].x; // Width of head (side 1)
418  arw[2].y = arw[1].y; // Width of shaft (side 1)
419  arw[4].y = arw[0].y-arw[0].x; // Width of head (side 2)
420  arw[6].y = arw[4].y; // Width of shaft (side 2)
421  } else {
422  arw[1].x = arw[0].x - arw[0].y;
423  arw[1].y = arw[0].y << 1;
424  arw[2].y = arw[0].y + arw[0].y/BTN_ARROWBODY_DIV;
425  arw[4].y = arw[0].y - arw[0].y/BTN_ARROWBODY_DIV;
426  arw[6].y = 0;
427  }
428  #else
429  arw[1].x = arw[0].x - gw->g.width/BTN_ARROWHEAD_DIV;
430  arw[1].y = arw[0].y << 1;
431  arw[2].y = arw[0].y + arw[0].y/BTN_ARROWBODY_DIV;
432  arw[4].y = arw[0].y - arw[0].y/BTN_ARROWBODY_DIV;
433  arw[6].y = 0;
434  #endif
435 
436  // Fill in the rest from the special points
437  /* arw[0].x set */ /* arw[0].y set */
438  /* arw[1].x set */ /* arw[1].y set */
439  arw[2].x = arw[1].x; /* arw[2].y set */
440  /* arw[3].y set */ arw[3].y = arw[2].y;
441  arw[4].x = arw[3].x; /* arw[4].y set */
442  arw[5].x = arw[1].x; arw[5].y = arw[4].y;
443  arw[6].x = arw[1].x; /* arw[6].y set */
444 
445  // Draw
446  gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->pstyle->background);
447  gdispGFillConvexPoly(gw->g.display, gw->g.x, gw->g.y, arw, 7, pcol->fill);
448  gdispGDrawPoly(gw->g.display, gw->g.x, gw->g.y, arw, 7, pcol->edge);
449  gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, gw->text, gw->g.font, pcol->text, justifyCenter);
450  }
451 #endif
452 
453 #if GDISP_NEED_IMAGE || defined(__DOXYGEN__)
454  void gwinButtonDraw_Image(GWidgetObject *gw, void *param) {
455  const GColorSet * pcol;
456  coord_t sy;
457 
458  if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
459  pcol = getButtonColors(gw);
460 
461  if (!(gw->g.flags & GWIN_FLG_SYSENABLED)) {
462  sy = 2 * gw->g.height;
463  } else if ((gw->g.flags & GBUTTON_FLG_PRESSED)) {
464  sy = gw->g.height;
465  } else {
466  sy = 0;
467  }
468 
469  gdispGImageDraw(gw->g.display, (gdispImage *)param, gw->g.x, gw->g.y, gw->g.width, gw->g.height, 0, sy);
470  gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, gw->text, gw->g.font, pcol->text, justifyCenter);
471  }
472 #endif
473 
474 #endif /* GFX_USE_GWIN && GWIN_NEED_BUTTON */
void gdispGFillStringBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, const char *str, font_t font, color_t color, color_t bgColor, justify_t justify)
Draw a text string vertically centered within the specified box. The box background is filled with th...
void gdispGDrawEllipse(GDisplay *g, coord_t x, coord_t y, coord_t a, coord_t b, color_t color)
Draw an ellipse.
color_t gdispBlendColor(color_t fg, color_t bg, uint8_t alpha)
Blend 2 colors according to the alpha.
const struct gwinVMT * vmt
Definition: gwin.h:45
void gwinButtonDraw_Normal(GWidgetObject *gw, void *param)
The default rendering function for the button widget.
uint32_t flags
Definition: gwin.h:53
int16_t coord_t
The type for a coordinate or length on the screen.
Definition: gdisp.h:39
The structure to initialise a widget.
Definition: gwin_widget.h:97
void gdispGFillConvexPoly(GDisplay *g, coord_t tx, coord_t ty, const point *pntarray, unsigned cnt, color_t color)
Fill a convex polygon.
color_t background
Definition: gwin_widget.h:53
void gwinButtonDraw_ArrowRight(GWidgetObject *gw, void *param)
Renders a button in a shape of an arrow pointing right.
coord_t y
Definition: gwin.h:48
coord_t x
Definition: gwin.h:47
void gwinButtonDraw_ArrowUp(GWidgetObject *gw, void *param)
Renders a button in a shape of an arrow pointing up.
struct GButtonObject GButtonObject
The button widget structure.
int32_t fixed
The type for a fixed point type.
Definition: gmisc.h:60
void gdispGDrawPoly(GDisplay *g, coord_t tx, coord_t ty, const point *pntarray, unsigned cnt, color_t color)
Draw an enclosed polygon (convex, non-convex or complex).
color_t text
Definition: gwin_widget.h:38
GWindowInit g
Definition: gwin_widget.h:98
coord_t y
Definition: gdisp.h:53
#define GINPUT_NEED_MOUSE
Should mouse/touch functions be included.
The GColorSet structure.
Definition: gwin_widget.h:37
void gwinButtonDraw_Image(GWidgetObject *gw, void *param)
Renders a button using individual images for each button state.
GWindowObject g
Definition: gwin_widget.h:119
#define FALSE
Generic &#39;false&#39; boolean constant.
Definition: gfx.h:31
bool_t gwinButtonIsPressed(GHandle gh)
Is the button current pressed.
void gdispGFillEllipse(GDisplay *g, coord_t x, coord_t y, coord_t a, coord_t b, color_t color)
Draw a filled ellipse.
void gdispGDrawLine(GDisplay *g, coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color)
Draw a line.
GColorSet pressed
Definition: gwin_widget.h:57
GColorSet disabled
Definition: gwin_widget.h:56
void gdispGFillArea(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color)
Fill an area with a color.
#define GEVENT_GWIN_BUTTON
The Event Type for a Button Event.
Definition: gwin_button.h:34
GColorSet enabled
Definition: gwin_widget.h:55
const char * text
Definition: gwin_widget.h:120
void gwinSetVisible(GHandle gh, bool_t visible)
Sets whether a window is visible or not.
const GWidgetStyle * pstyle
Definition: gwin_widget.h:123
The button widget structure.
Definition: gwin_button.h:54
The GWIN Widget structure.
Definition: gwin_widget.h:118
bool_t show
Definition: gwin.h:80
GDisplay * display
Definition: gwin.h:46
void gdispGDrawRoundedBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t radius, color_t color)
Draw a rectangular box with rounded corners.
#define GBUTTON_FLG_PRESSED
The internal button flags.
Definition: gwin_button.h:47
void gdispGDrawStringBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, const char *str, font_t font, color_t color, justify_t justify)
Draw a text string vertically centered within the specified box.
coord_t height
Definition: gwin.h:50
GHandle gwinGButtonCreate(GDisplay *g, GButtonObject *gb, const GWidgetInit *pInit)
Create a button widget.
The Virtual Method Table for a widget.
Definition: gwin_class.h:85
#define FIXED(x)
Macros to convert to and from a fixed point.
Definition: gmisc.h:66
Type for a 2D point on the screen.
Definition: gdisp.h:51
coord_t width
Definition: gwin.h:49
void gwinButtonDraw_ArrowLeft(GWidgetObject *gw, void *param)
Renders a button in a shape of an arrow pointing left.
gdispImageError gdispGImageDraw(GDisplay *g, gdispImage *img, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t sx, coord_t sy)
Draw the image.
void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color)
Draw a rectangular box.
The structure for an image.
Definition: gdisp_image.h:59
void gwinButtonDraw_Rounded(GWidgetObject *gw, void *param)
Renders a rectangular button with rounded corners.
color_t fill
Definition: gwin_widget.h:40
The Virtual Method Table for a GWIN window.
Definition: gwin_class.h:55
A window object structure.
Definition: gwin.h:40
COLOR_TYPE color_t
The color type definition.
Definition: gdisp_colors.h:412
void gwinButtonDraw_Ellipse(GWidgetObject *gw, void *param)
Renders a button with an elliptical shape.
coord_t x
Definition: gdisp.h:52
void gwinButtonDraw_ArrowDown(GWidgetObject *gw, void *param)
Renders a button in a shape of an arrow pointing down.
#define TRUE
Generic &#39;true&#39; boolean constant.
Definition: gfx.h:38
color_t edge
Definition: gwin_widget.h:39
void gdispGFillRoundedBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t radius, color_t color)
Draw a filled rectangular box with rounded corners.