µGFX  2.9
version 2.9
gwin.h
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.io/license.html
6  */
7 
8 /**
9  * @file src/gwin/gwin.h
10  *
11  * @defgroup Window Window
12  * @ingroup Windows
13  *
14  * @brief The basic window implementation (base class).
15  *
16  * @details GWIN provides a basic window manager which allows it to easily
17  * create and destroy different windows at runtime. Each window
18  * will have it's own properties such as colors as well as
19  * it's own drawing origin.
20  *
21  * @pre GFX_USE_GWIN must be set to GFXON in your gfxconf.h
22  * @{
23  */
24 
25 #ifndef _GWIN_H
26 #define _GWIN_H
27 
28 #include "../../gfx.h"
29 
30 #if GFX_USE_GWIN || defined(__DOXYGEN__)
31 
32 /* Forward declaration */
33 typedef struct GWindowObject *GHandle;
34 
35 /**
36  * @brief A window object structure
37  * @note Do not access the members directly. Treat it as a black-box and use the method functions.
38  * @{
39  */
40 typedef struct GWindowObject {
41  #if GWIN_NEED_WINDOWMANAGER
42  // This MUST be the first member of the structure
43  gfxQueueASyncItem wmq; /**< The next window (for the window manager) */
44  #endif
45  const struct gwinVMT* vmt; /**< The VMT for this GWIN */
46  GDisplay * display; /**< The display this window is on */
47  gCoord x; /**< The position relative to the screen */
48  gCoord y; /**< The position relative to the screen */
49  gCoord width; /**< The width of this window */
50  gCoord height; /**< The height of this window */
51  gColor color; /**< The current foreground drawing color */
52  gColor bgcolor; /**< The current background drawing color */
53  gU32 flags; /**< Window flags (the meaning is private to the GWIN class) */
54  #if GDISP_NEED_TEXT
55  gFont font; /**< The current font */
56  #endif
57  #if GWIN_NEED_CONTAINERS
58  GHandle parent; /**< The parent window */
59  #endif
61 /** @} */
62 
63 /**
64  * @brief The structure to initialise a GWIN.
65  *
66  * @note Some gwin's will need extra parameters.
67  * @note The dimensions and position may be changed to fit on the real screen.
68  * @note If you create this structure on the stack, you should always memset
69  * it to all zero's first in case a future version of the software
70  * add's extra fields. Alternatively you can use @p gwinClearInit()
71  * to clear it.
72  *
73  * @{
74  */
75 typedef struct GWindowInit {
76  gCoord x; /**< The initial position relative to its parent */
77  gCoord y; /**< The initial position relative to its parent */
78  gCoord width; /**< The width */
79  gCoord height; /**< The height */
80  gBool show; /**< Should the window be visible initially */
81  #if GWIN_NEED_CONTAINERS
82  GHandle parent; /**< The parent - must be a container or NULL */
83  #endif
85 /** @} */
86 
87 /**
88  * @brief A window's minimized, maximized or normal size
89  */
90 typedef enum { GWIN_NORMAL, GWIN_MAXIMIZE, GWIN_MINIMIZE } GWindowMinMax;
91 
92 /*-------------------------------------------------
93  * Window Manager functions
94  *-------------------------------------------------*/
95 
96 #if GWIN_NEED_WINDOWMANAGER || defined(__DOXYGEN__)
97  // Forward definition
98  struct GWindowManager;
99 
100  /**
101  * @brief Set the window manager for the GWIN system.
102  *
103  * @param[in] gwm The window manager to use. Can be NULL to turn off the existing window manager.
104  *
105  * @note A window manager is responsible for handling when window visibility is changed or
106  * a window is resized for moved. Note that only saved window states will be redrawn. Each
107  * window type can save different information (or none at all). See the documentation on each window
108  * type to see which information it saves (and can therefore be automatically redrawn).
109  * For window types that do not save any state information, the window manager determines what to do.
110  * Generally it will just clear the window to its background color.
111  *
112  * @api
113  */
114  void gwinSetWindowManager(struct GWindowManager *gwm);
115 #endif
116 
117 /*-------------------------------------------------
118  * Functions that affect all windows
119  *-------------------------------------------------*/
120 
121  /**
122  * @brief Clear a GWindowInit structure to all zero's
123  * @note This function is provided just to prevent problems
124  * on operating systems where using memset() causes issues
125  * in the users application.
126  *
127  * @param[in] pwi The GWindowInit structure to clear
128  *
129  * @api
130  */
132 
133  /**
134  * @brief Set the default foreground color for all new GWIN windows
135  *
136  * @param[in] clr The color to be set
137  *
138  * @api
139  */
141 
142  /**
143  * @brief Get the default foreground color for all new GWIN windows
144  *
145  * @return The current default color for all new GWIN windows
146  *
147  * @api
148  */
150 
151  /**
152  * @brief Set the default background color for all new GWIN windows
153  *
154  * @param[in] bgclr The background color
155  *
156  * @api
157  */
159 
160  /**
161  * @brief Get the default background color for all new GWIN windows
162  *
163  * @return The current default background color for all new GWIN windows
164  *
165  * @api
166  */
168 
169  #if GDISP_NEED_TEXT || defined(__DOXYGEN__)
170  /**
171  * @brief Set the default font for all new GWIN windows
172  *
173  * @param[in] font The new font to be set
174  *
175  * @api
176  */
178 
179  /**
180  * @brief Get the current default font
181  *
182  * @return The current default font
183  *
184  * @api
185  */
187  #endif
188 
189 /*-------------------------------------------------
190  * Base functions
191  *-------------------------------------------------*/
192 
193  /**
194  * @brief Create a basic window.
195  * @return NULL if there is no resultant drawing area, otherwise a window handle.
196  *
197  * @param[in] g The GDisplay to display this window on
198  * @param[in] pgw The window structure to initialize. If this is NULL the structure is dynamically allocated.
199  * @param[in] pInit How to initialise the window
200  *
201  * @note The drawing color and the background color get set to the current defaults. If you haven't called
202  * @p gwinSetDefaultColor() or @p gwinSetDefaultBgColor() then these are GFX_WHITE and GFX_BLACK respectively.
203  * @note The font gets set to the current default font. If you haven't called @p gwinSetDefaultFont() then there
204  * is no default font and text drawing operations will no nothing.
205  * @note A basic window does not save the drawing state. It is not automatically redrawn if the window is moved or
206  * its visibility state is changed.
207  *
208  * @api
209  */
210  GHandle gwinGWindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit);
211  #define gwinWindowCreate(pgw, pInit) gwinGWindowCreate(GDISP, pgw, pInit);
212 
213  /**
214  * @brief Destroy a window (of any type). Releases any dynamically allocated memory.
215  *
216  * @param[in] gh The window handle
217  *
218  * @api
219  */
221 
222  /**
223  * @brief Get the real class name of the GHandle
224  * @details Returns a string describing the object class.
225  *
226  * @param[in] gh The window
227  *
228  * @return A string describing the object class.
229  *
230  * @api
231  */
232  const char* gwinGetClassName(GHandle gh);
233 
234  /**
235  * @brief Get an ID that uniquely describes the class of the GHandle
236  *
237  * @param[in] gh The window
238  *
239  * @api
240  */
241  #define gwinGetClassID(gh) ((void *)((gh)->vmt))
242 
243  /**
244  * @brief Get the X coordinate of the window
245  * @details Returns the X coordinate of the origin of the window.
246  * The coordinate is relative to the physical screen zero point.
247  *
248  * @param[in] gh The window
249  *
250  * @api
251  */
252  #define gwinGetScreenX(gh) ((gh)->x)
253 
254  /**
255  * @brief Get the Y coordinate of the window
256  * @details Returns the Y coordinate of the origin of the window.
257  * The coordinate is relative to the physical screen zero point.
258  *
259  * @param[in] gh The window
260  *
261  * @api
262  */
263  #define gwinGetScreenY(gh) ((gh)->y)
264 
265  /**
266  * @brief Get the width of the window
267  *
268  * @param[in] gh The window
269  *
270  * @api
271  */
272  #define gwinGetWidth(gh) ((gh)->width)
273 
274  /**
275  * @brief Get the height of the window
276  *
277  * @param[in] gh The window
278  *
279  * @api
280  */
281  #define gwinGetHeight(gh) ((gh)->height)
282 
283  /**
284  * @brief Set foreground color
285  * @details Set the color which will be used to draw
286  *
287  * @param[in] gh The window
288  * @param[in] clr The color to be set
289  *
290  * @api
291  */
292  #define gwinSetColor(gh, clr) (gh)->color = (clr)
293 
294  /**
295  * @brief Set background color
296  * @details Set the color which will be used as background
297  * @note gwinClear() must be called to set the background color
298  *
299  * @param[in] gh The window
300  * @param[in] bgclr The background color
301  *
302  * @api
303  */
304  #define gwinSetBgColor(gh, bgclr) (gh)->bgcolor = (bgclr)
305 
306  /**
307  * @brief Get the foreground color of a window
308  *
309  * @param[in] gh The window
310  *
311  * @api
312  */
313  #define gwinGetColor(gh) (gh)->color
314 
315  /**
316  * @brief Get the background color of a window
317  *
318  * @param[in] gh The window
319  *
320  * @api
321  */
322  #define gwinGetBgColor(gh) (gh)->bgcolor
323 
324  /**
325  * @brief Sets whether a window is visible or not
326  *
327  * @param[in] gh The window
328  * @param[in] visible Whether the window should be visible or not
329  *
330  * @note When a window is marked as not visible, drawing operations
331  * on the window do nothing.
332  * @note When a window is marked as visible, it is not automatically
333  * redrawn as many window types don't remember their drawing state.
334  * Widgets such as Buttons, Sliders etc will be redrawn.
335  * @note If there is no window manager in use, when a window is marked
336  * as not visible, nothing is done to remove the window from the screen.
337  * When there is a window manager, it is up to the window manager to
338  * handle what happens.
339  * @note Even when you mark a window as visible, it may still not be displayed
340  * if it's parent is invisible. When the parent becomes visible this child
341  * will automatically be shown because it is already marked as visible.
342  *
343  * @api
344  */
345  void gwinSetVisible(GHandle gh, gBool visible);
346 
347  /**
348  * @brief Makes a widget become visible
349  *
350  * @param[in] gh The window handle
351  *
352  * @api
353  */
354  #define gwinShow(gh) gwinSetVisible(gh, gTrue)
355 
356  /**
357  * @brief Makes a widget become invisible
358  *
359  * @param[in] gh The window handle
360  *
361  * @api
362  */
363  #define gwinHide(gh) gwinSetVisible(gh, gFalse)
364 
365  /**
366  * @brief Gets the visibility of a window
367  * @return gTrue if visible
368  *
369  * @note It is possible for a child to be marked as visible by @p gwinSetVisible()
370  * but for this call to return gFalse if one of its parents are not visible.
371  *
372  * @param[in] gh The window
373  *
374  * @api
375  */
377 
378  /**
379  * @brief Enable or disable a window
380  *
381  * @param[in] gh The window handle
382  * @param[in] enabled Enable or disable the window
383  *
384  * @note The window is automatically redrawn if it supports self-redrawing.
385  * @note Even when you mark a window as enabled, it may still remain disabled
386  * if it's parent is disabled. When the parent becomes enabled this child
387  * will automatically be enabled because it is already marked as enabled.
388  *
389  * @api
390  */
391  void gwinSetEnabled(GHandle gh, gBool enabled);
392 
393  /**
394  * @brief Enables a widget
395  *
396  * @param[in] gh The window handle
397  *
398  * @api
399  */
400  #define gwinEnable(gh) gwinSetEnabled(gh, gTrue)
401 
402  /**
403  * @brief Disables a widget
404  *
405  * @param[in] gh The window handle
406  *
407  * @api
408  */
409  #define gwinDisable(gh) gwinSetEnabled(gh, gFalse)
410 
411  /**
412  * @brief Gets the enabled state of a window
413  * @return gTrue if enabled
414  *
415  * @note It is possible for a child to be marked as enabled by @p gwinSetEnabled()
416  * but for this call to return gFalse if one of its parents are not enabled.
417  *
418  * @param[in] gh The window
419  *
420  * @api
421  */
423 
424  /**
425  * @brief Move a window
426  *
427  * @param[in] gh The window
428  * @param[in] x, y The new position (screen relative) for this window
429  *
430  * @note The final window position may not be the requested position. Windows
431  * are clipped to the screen area and the window manager may also affect the position.
432  * @note The window is redrawn if it is visible. See the comments in @p gwinSetVisible()
433  * with regard to what can be redrawn and what can't.
434  * @note It is up to the window manager to determine what happens with the screen area
435  * uncovered by moving the window. When there is no window manager, nothing
436  * is done with the uncovered area.
437  *
438  * @api
439  */
440  void gwinMove(GHandle gh, gCoord x, gCoord y);
441 
442  /**
443  * @brief Resize a window
444  *
445  * @param[in] gh The window
446  * @param[in] width, height The new size of the window
447  *
448  * @note The final window size may not be the requested size. Windows
449  * are clipped to the screen area and the window manager may also affect the size.
450  * @note The window is redrawn if it is visible. See the comments in @p gwinSetVisible()
451  * with regard to what can be redrawn and what can't.
452  * @note It is up to the window manager to determine what happens with any screen area
453  * uncovered by resizing the window. When there is no window manager, nothing
454  * is done with the uncovered area.
455  *
456  * @api
457  */
458  void gwinResize(GHandle gh, gCoord width, gCoord height);
459 
460  /**
461  * @brief Redraw a window
462  *
463  * @param[in] gh The window
464  *
465  * @note This is normally never required as windows and widgets will redraw as required.
466  * Note that some windows are incapable of redrawing themselves as they don't save
467  * their drawing state.
468  *
469  * @api
470  */
471  void gwinRedraw(GHandle gh);
472 
473  #if GWIN_NEED_WINDOWMANAGER || defined (__DOXYGEN__)
474  /**
475  * @brief Redraw a display
476  *
477  * @param[in] g The display to redraw. Passing NULL will redraw all displays.
478  * @param[in] preserve Should the redraw try to preserve existing screen data for those
479  * windows that can't redraw themselves?
480  *
481  * @note This is normally never required as windows and widgets will redraw as required.
482  * @note Some windows are incapable of redrawing themselves as they don't save
483  * their drawing state.
484  * @note This does not clear the background - just redraws the gwin windows (where possible)
485  *
486  * @api
487  */
488  void gwinRedrawDisplay(GDisplay *g, gBool preserve);
489 
490  /**
491  * @brief Minimize, Maximize or Restore a window
492  * @pre GWIN_NEED_WINDOWMANAGER must be GFXON
493  *
494  * @param[in] gh The window
495  * @param[in] minmax The new minimized/maximized state
496  *
497  * @note The final window state may not be the requested state. Window Managers
498  * do not need to implement changing the minmax state. If there is no
499  * window manager this call is ignored.
500  * @note The window is redrawn if it is changed. See the comments in @p gwinSetVisible()
501  * with regard to what can be redrawn and what can't.
502  * @note It is up to the window manager to determine what happens with any screen area
503  * uncovered by resizing the window.
504  * @note When a window is minimised it may be asked to draw the window or the window
505  * manager may draw the minimised window.
506  *
507  * @api
508  */
510 
511  /**
512  * @brief Get the Minimized/Maximized state of a window
513  * @pre GWIN_NEED_WINDOWMANAGER must be GFXON
514  *
515  * @param[in] gh The window
516  *
517  * @return GWIN_NORMAL, GWIN_MAXIMIZE or GWIN_MINIMIZE
518  *
519  * @api
520  */
522 
523  /**
524  * @brief Raise a window to the top of the z-order
525  * @pre GWIN_NEED_WINDOWMANAGER must be GFXON
526  *
527  * @param[in] gh The window
528  *
529  * @note The window z-order is only supported by some window managers. See the comments
530  * in @p gwinSetVisible() with regard to what can be redrawn and what can't.
531  *
532  * @api
533  */
534  void gwinRaise(GHandle gh);
535 
536  /**
537  * @brief Get the next window in the z-order
538  * @return The next window or NULL if no more windows
539  *
540  * @param[in] gh The previous window or NULL to get the first window
541  *
542  * @note This returns the next window in the system from top to bottom.
543  * @note Where there are parent child relationships, this ignores them
544  * and will list all windows in the system. There is no defined
545  * order between children of siblings and they can in fact be mixed
546  * in order. The only relationship honored is that parents will be
547  * listed before their children.
548  *
549  * @api
550  */
552 
553  /**
554  * @brief Set a window or widget to flash
555  *
556  * @param[in] gh The window handle
557  * @param[in] flash Enable or disable the flashing of the window
558  *
559  * @note The window is automatically redrawn if it supports self-redrawing.
560  * @note When a window is set to flash, its appearance changes in some
561  * way every flash period (GWIN_FLASHING_PERIOD). How its appearance
562  * changes depends on the draw for each window/widget.
563  *
564  * @pre Requires GWIN_NEED_FLASHING to be GFXON
565  *
566  * @api
567  */
568  void gwinSetFlashing(GHandle gh, gBool flash);
569 
570  /**
571  * @brief Enables flashing of a window or widget
572  *
573  * @param[in] gh The window handle
574  *
575  * @api
576  */
577  #define gwinFlash(gh) gwinSetFlashing(gh, gTrue)
578 
579  /**
580  * @brief Disables a widget
581  *
582  * @param[in] gh The window handle
583  *
584  * @api
585  */
586  #define gwinNoFlash(gh) gwinSetFlashing(gh, gFalse)
587  #endif
588 
589  #if GDISP_NEED_TEXT || defined(__DOXYGEN__)
590  /**
591  * @brief Set the current font for this window.
592  *
593  * @param[in] gh The window handle
594  * @param[in] font The font to use for text functions
595  *
596  * @api
597  */
598  void gwinSetFont(GHandle gh, gFont font);
599  #endif
600 
601 /*-------------------------------------------------
602  * Drawing functions
603  *-------------------------------------------------*/
604 
605  /**
606  * @brief Clear the window
607  * @note Uses the current background color to clear the window
608  *
609  * @param[in] gh The window handle
610  *
611  * @api
612  */
613  void gwinClear(GHandle gh);
614 
615  /**
616  * @brief Set a pixel in the window
617  * @note Uses the current foreground color to set the pixel
618  * @note May leave GDISP clipping to this window's dimensions
619  *
620  * @param[in] gh The window handle
621  * @param[in] x,y The coordinates of the pixel
622  *
623  * @api
624  */
626 
627  /**
628  * @brief Draw a line in the window
629  * @note Uses the current foreground color to draw the line
630  * @note May leave GDISP clipping to this window's dimensions
631  *
632  * @param[in] gh The window handle
633  * @param[in] x0,y0 The start position
634  * @param[in] x1,y1 The end position
635  *
636  * @api
637  */
638  void gwinDrawLine(GHandle gh, gCoord x0, gCoord y0, gCoord x1, gCoord y1);
639 
640  /**
641  * @brief Draw a box in the window
642  * @note Uses the current foreground color to draw the box
643  * @note May leave GDISP clipping to this window's dimensions
644  *
645  * @param[in] gh The window handle
646  * @param[in] x,y The start position
647  * @param[in] cx,cy The size of the box (outside dimensions)
648  *
649  * @api
650  */
651  void gwinDrawBox(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy);
652 
653  /**
654  * @brief Fill an rectangular area in the window
655  * @note Uses the current foreground color to fill the box
656  * @note May leave GDISP clipping to this window's dimensions
657  *
658  * @param[in] gh The window handle
659  * @param[in] x,y The start position
660  * @param[in] cx,cy The size of the box (outside dimensions)
661  *
662  * @api
663  */
664  void gwinFillArea(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy);
665 
666  /**
667  * @brief Fill an area in the window using the supplied bitmap.
668  * @details The bitmap is in the pixel format specified by the low level driver
669  * @note If GDISP_NEED_ASYNC is defined then the buffer must be static
670  * or at least retained until this call has finished the blit. You can
671  * tell when all graphics drawing is finished by @p gdispIsBusy() going gFalse.
672  * @note May leave GDISP clipping to this window's dimensions
673  *
674  * @param[in] gh The window handle
675  * @param[in] x, y The start filled area
676  * @param[in] cx, cy The width and height to be filled
677  * @param[in] srcx, srcy The bitmap position to start the fill from
678  * @param[in] srccx The width of a line in the bitmap.
679  * @param[in] buffer The pixels to use to fill the area.
680  *
681  * @api
682  */
683  void gwinBlitArea(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord srcx, gCoord srcy, gCoord srccx, const gPixel *buffer);
684 
685 /*-------------------------------------------------
686  * Circle, ellipse, arc and arc-sectors functions
687  *-------------------------------------------------*/
688 
689  #if GDISP_NEED_CIRCLE || defined(__DOXYGEN__)
690  /**
691  * @brief Draw a circle in the window.
692  * @note Uses the current foreground color to draw the circle
693  * @note May leave GDISP clipping to this window's dimensions
694  *
695  * @param[in] gh The window handle
696  * @param[in] x, y The center of the circle
697  * @param[in] radius The radius of the circle
698  *
699  * @api
700  */
701  void gwinDrawCircle(GHandle gh, gCoord x, gCoord y, gCoord radius);
702 
703  /**
704  * @brief Draw a filled circle in the window.
705  * @note Uses the current foreground color to draw the filled circle
706  * @note May leave GDISP clipping to this window's dimensions
707  *
708  * @param[in] gh The window handle
709  * @param[in] x, y The center of the circle
710  * @param[in] radius The radius of the circle
711  *
712  * @api
713  */
714  void gwinFillCircle(GHandle gh, gCoord x, gCoord y, gCoord radius);
715  #endif
716 
717  #if GDISP_NEED_DUALCIRCLE || defined(__DOXYGEN__)
718  /**
719  * @brief Draw two filled circles with the same centre in the window.
720  * @note Uses the current foreground color to draw the inner circle
721  * @note Uses the current background color to draw the outer circle
722  * @note May leave GDISP clipping to this window's dimensions
723  * @pre GDISP_NEED_DUALCIRCLE must be GFXON in your gfxconf.h
724  *
725  * @param[in] gh The window handle
726  * @param[in] x,y The center of the circle
727  * @param[in] radius1 The radius of the larger circle
728  * @param[in] radius2 The radius of the smaller circle
729  *
730  * @api
731  */
732  void gwinFillDualCircle(GHandle gh, gCoord x, gCoord y, gCoord radius1, gCoord radius2);
733  #endif
734 
735  #if GDISP_NEED_ELLIPSE || defined(__DOXYGEN__)
736  /**
737  * @brief Draw an ellipse.
738  * @note Uses the current foreground color to draw the ellipse
739  * @note May leave GDISP clipping to this window's dimensions
740  *
741  * @param[in] gh The window handle
742  * @param[in] x,y The center of the ellipse
743  * @param[in] a,b The dimensions of the ellipse
744  *
745  * @api
746  */
748 
749  /**
750  * @brief Draw an filled ellipse.
751  * @note Uses the current foreground color to draw the filled ellipse
752  * @note May leave GDISP clipping to this window's dimensions
753  *
754  * @param[in] gh The window handle
755  * @param[in] x,y The center of the ellipse
756  * @param[in] a,b The dimensions of the ellipse
757  *
758  * @api
759  */
761  #endif
762 
763  #if GDISP_NEED_ARC || defined(__DOXYGEN__)
764  /*
765  * @brief Draw an arc in the window.
766  * @note Uses the current foreground color to draw the arc
767  * @note May leave GDISP clipping to this window's dimensions
768  *
769  * @param[in] gh The window handle
770  * @param[in] x,y The center point
771  * @param[in] radius The radius of the arc
772  * @param[in] start The start angle (0 to 360)
773  * @param[in] end The end angle (0 to 360)
774  *
775  * @api
776  */
777  void gwinDrawArc(GHandle gh, gCoord x, gCoord y, gCoord radius, gCoord startangle, gCoord endangle);
778 
779  /*
780  * @brief Draw a filled arc in the window.
781  * @note Uses the current foreground color to draw the filled arc
782  * @note May leave GDISP clipping to this window's dimensions
783  *
784  * @param[in] gh The window handle
785  * @param[in] x,y The center point
786  * @param[in] radius The radius of the arc
787  * @param[in] start The start angle (0 to 360)
788  * @param[in] end The end angle (0 to 360)
789  *
790  * @api
791  */
792  void gwinFillArc(GHandle gh, gCoord x, gCoord y, gCoord radius, gCoord startangle, gCoord endangle);
793 
794  /*
795  * @brief Draw a thick arc in the window.
796  * @note Uses the current foreground color to draw the thick arc
797  * @note May leave GDISP clipping to this window's dimensions
798  *
799  * @param[in] gh The window handle
800  * @param[in] x,y The center point
801  * @param[in] startradius The inner radius of the thick arc
802  * @param[in] endradius The outer radius of the thick arc
803  * @param[in] startangle The start angle (0 to 360)
804  * @param[in] endangle The end angle (0 to 360)
805  *
806  * @api
807  */
808  void gwinDrawThickArc(GHandle gh, gCoord x, gCoord y, gCoord startradius, gCoord endradius, gCoord startangle, gCoord endangle);
809  #endif
810 
811  #if GDISP_NEED_ARCSECTORS || defined(__DOXYGEN__)
812  /*
813  * @brief Draw a selection of 45 degree arcs of a circle in the window.
814  * @note Uses the current foreground color to draw the arc sector
815  * @note May leave GDISP clipping to this window's dimensions
816  *
817  * @param[in] gh The window handle
818  * @param[in] x,y The center of the circle
819  * @param[in] radius The radius of the circle
820  * @param[in] sectors Bits determine which sectors are drawn.
821  * Bits go anti-clockwise from the 0 degree mark (y = 0, x is positive), as follows:
822  * bit 0 - upper right right -----
823  * bit 1 - upper upper right /2 1\
824  * bit 2 - upper upper left /3 0\
825  * bit 3 - upper left left \4 7/
826  * bit 4 - lower left left \5 6/
827  * bit 5 - lower lower left -----
828  * bit 6 - lower lower right
829  * bit 7 - lower left left
830  *
831  * @api
832  */
833  void gwinDrawArcSectors(GHandle gh, gCoord x, gCoord y, gCoord radius, gU8 sectors);
834 
835  /*
836  * @brief Draw a filled selection of 45 degree arcs of a circle in the window.
837  * @note Uses the current foreground color to draw the arc sector
838  * @note May leave GDISP clipping to this window's dimensions
839  *
840  * @param[in] gh The window handle
841  * @param[in] x,y The center of the circle
842  * @param[in] radius The radius of the circle
843  * @param[in] sectors Bits determine which sectors are drawn.
844  * Bits go anti-clockwise from the 0 degree mark (y = 0, x is positive), as follows:
845  * bit 0 - upper right right -----
846  * bit 1 - upper upper right /2 1\
847  * bit 2 - upper upper left /3 0\
848  * bit 3 - upper left left \4 7/
849  * bit 4 - lower left left \5 6/
850  * bit 5 - lower lower left -----
851  * bit 6 - lower lower right
852  * bit 7 - lower left left
853  *
854  * @api
855  */
856  void gwinFillArcSectors(GHandle gh, gCoord x, gCoord y, gCoord radius, gU8 sectors);
857  #endif
858 
859 /*-------------------------------------------------
860  * Pixel read-back functions
861  *-------------------------------------------------*/
862 
863  #if GDISP_NEED_PIXELREAD || defined(__DOXYGEN__)
864  /**
865  * @brief Get the color of a pixel in the window.
866  * @return The color of the pixel.
867  * @note May leave GDISP clipping to this window's dimensions
868  *
869  * @param[in] gh The window handle
870  * @param[in] x,y The position in the window
871  *
872  * @api
873  */
875  #endif
876 
877 /*-------------------------------------------------
878  * Text functions
879  *-------------------------------------------------*/
880 
881  #if GDISP_NEED_TEXT || defined(__DOXYGEN__)
882  /**
883  * @brief Draw a text character at the specified position in the window.
884  * @pre The font must have been set.
885  * @note Uses the current foreground color to draw the character
886  * @note May leave GDISP clipping to this window's dimensions
887  *
888  * @param[in] gh The window handle
889  * @param[in] x,y The position for the text
890  * @param[in] c The character to draw
891  *
892  * @api
893  */
894  void gwinDrawChar(GHandle gh, gCoord x, gCoord y, char c);
895 
896  /**
897  * @brief Draw a text character with a filled background at the specified position in the window.
898  * @pre The font must have been set.
899  * @note Uses the current foreground color to draw the character and fills the background using the background drawing color
900  * @note May leave GDISP clipping to this window's dimensions
901  *
902  * @param[in] gh The window handle
903  * @param[in] x,y The position for the text
904  * @param[in] c The character to draw
905  *
906  * @api
907  */
908  void gwinFillChar(GHandle gh, gCoord x, gCoord y, char c);
909 
910  /**
911  * @brief Draw a text string in the window
912  * @pre The font must have been set.
913  * @note Uses the current foreground color to draw the character
914  * @note May leave GDISP clipping to this window's dimensions
915  *
916  * @param[in] gh The window handle
917  * @param[in] x,y The position for the text
918  * @param[in] str The string to draw
919  *
920  * @api
921  */
922  void gwinDrawString(GHandle gh, gCoord x, gCoord y, const char *str);
923 
924  /**
925  * @brief Draw a text string with a filled background in the window
926  * @pre The font must have been set.
927  * @note Uses the current foreground color to draw the character and fills the background using the background drawing color
928  * @note May leave GDISP clipping to this window's dimensions
929  *
930  * @param[in] gh The window handle
931  * @param[in] x,y The position for the text
932  * @param[in] str The string to draw
933  *
934  * @api
935  */
936  void gwinFillString(GHandle gh, gCoord x, gCoord y, const char *str);
937 
938  /**
939  * @brief Draw a text string verticly centered within the specified box.
940  * @pre The font must have been set.
941  * @note Uses the current foreground color to draw the character.
942  * @note The specified box does not need to align with the window box
943  * @note May leave GDISP clipping to this window's dimensions
944  *
945  * @param[in] gh The window handle
946  * @param[in] x,y The position for the text (need to define top-right or base-line - check code)
947  * @param[in] cx,cy The width and height of the box
948  * @param[in] str The string to draw
949  * @param[in] justify Justify the text left, center or right within the box
950  *
951  * @api
952  */
953  void gwinDrawStringBox(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, gJustify justify);
954 
955  /**
956  * @brief Draw a text string verticly centered within the specified filled box.
957  * @pre The font must have been set.
958  * @note Uses the current foreground color to draw the character and fills the background using the background drawing color
959  * @note The entire box is filled. Note this box does not need to align with the window box
960  * @note May leave GDISP clipping to this window's dimensions
961  *
962  * @param[in] gh The window handle
963  * @param[in] x,y The position for the text (need to define top-right or base-line - check code)
964  * @param[in] cx,cy The width and height of the box
965  * @param[in] str The string to draw
966  * @param[in] justify Justify the text left, center or right within the box
967  *
968  * @api
969  */
970  void gwinFillStringBox(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, gJustify justify);
971  #endif
972 
973 /*-------------------------------------------------
974  * Polygon functions
975  *-------------------------------------------------*/
976 
977  #if GDISP_NEED_CONVEX_POLYGON || defined(__DOXYGEN__)
978  /**
979  * @brief Draw an enclosed polygon (convex, non-convex or complex).
980  *
981  * @note Uses the current foreground color.
982  *
983  * @param[in] gh The window handle
984  * @param[in] tx, ty Transform all points in pntarray by tx, ty
985  * @param[in] pntarray An array of points
986  * @param[in] cnt The number of points in the array
987  *
988  * @api
989  */
990  void gwinDrawPoly(GHandle gh, gCoord tx, gCoord ty, const gPoint *pntarray, unsigned cnt);
991 
992  /**
993  * @brief Fill a convex polygon
994  * @details Doesn't handle non-convex or complex polygons.
995  *
996  * @note Uses the current foreground color.
997  *
998  * @param[in] gh The window handle
999  * @param[in] tx, ty Transform all points in pntarray by tx, ty
1000  * @param[in] pntarray An array of points
1001  * @param[in] cnt The number of points in the array
1002  *
1003  * @note Convex polygons are those that have no internal angles. That is;
1004  * you can draw a line from any point on the polygon to any other point
1005  * on the polygon without it going outside the polygon. In our case we generalise
1006  * this a little by saying that an infinite horizontal line (at any y value) will cross
1007  * no more than two edges on the polygon. Some non-convex polygons do fit this criteria
1008  * and can therefore be drawn.
1009  * @note This routine is designed to be very efficient with even simple display hardware.
1010  *
1011  * @api
1012  */
1013  void gwinFillConvexPoly(GHandle gh, gCoord tx, gCoord ty, const gPoint *pntarray, unsigned cnt);
1014 
1015  /**
1016  * @brief Draw a thick line in the window
1017  * @details The line thickness is specified in pixels. The line ends can
1018  * be selected to be either flat or round.
1019  * @note Uses gdispGFillConvexPoly() internally to perform the drawing.
1020  * @note Uses the current foreground color to draw the line
1021  *
1022  * @param[in] gh The window handle
1023  * @param[in] x0,y0 The start position
1024  * @param[in] x1,y1 The end position
1025  * @param[in] width The width of the line
1026  * @param[in] round Use round ends for the line
1027  *
1028  * @api
1029  */
1030  void gwinDrawThickLine(GHandle gh, gCoord x0, gCoord y0, gCoord x1, gCoord y1, gCoord width, gBool round);
1031  #endif
1032 
1033 /*-------------------------------------------------
1034  * Image functions
1035  *-------------------------------------------------*/
1036 
1037  #if GDISP_NEED_IMAGE || defined(__DOXYGEN__)
1038  /**
1039  * @brief Draw the image
1040  * @return GDISP_IMAGE_ERR_OK (0) on success or an error code.
1041  *
1042  * @param[in] gh The window handle
1043  * @param[in] img The image structure
1044  * @param[in] x,y The window location to draw the image
1045  * @param[in] cx,cy The area on the screen to draw
1046  * @param[in] sx,sy The image position to start drawing at
1047  *
1048  * @pre gdispImageOpen() must have returned successfully.
1049  *
1050  * @note If sx,sy + cx,cy is outside the image boundaries the area outside the image
1051  * is simply not drawn.
1052  * @note If @p gdispImageCache() has been called first for this frame, this routine will draw using a
1053  * fast blit from the cached frame. If not, it reads the input and decodes it as it
1054  * is drawing. This may be significantly slower than if the image has been cached (but
1055  * uses a lot less RAM)
1056  *
1057  * @api
1058  */
1060  #endif
1061 
1062 /*-------------------------------------------------
1063  * Additional functionality
1064  *-------------------------------------------------*/
1065 
1066  /* Include widgets */
1067  #if GWIN_NEED_WIDGET || defined(__DOXYGEN__)
1068  #include "gwin_widget.h"
1069  #endif
1070 
1071  /* Include containers */
1072  #if GWIN_NEED_CONTAINERS || defined(__DOXYGEN__)
1073  #include "gwin_container.h"
1074  #endif
1075 
1076  /* Include vanilla window objects */
1077  #if GWIN_NEED_CONSOLE || defined(__DOXYGEN__)
1078  #include "gwin_console.h"
1079  #endif
1080  #if GWIN_NEED_GRAPH || defined(__DOXYGEN__)
1081  #include "gwin_graph.h"
1082  #endif
1083  #if GWIN_NEED_IMAGE || defined(__DOXYGEN__)
1084  #include "gwin_image.h"
1085  #endif
1086  #if GWIN_NEED_GL3D || defined(__DOXYGEN__)
1087  #include "gwin_gl3d.h"
1088  #endif
1089 
1090 #endif /* GFX_USE_GWIN */
1091 
1092 #endif /* _GWIN_H */
1093 /** @} */
COLOR_TYPE gColor
The color type definition.
Definition: gdisp_colors.h:437
const struct mf_font_s * gFont
The type of a font.
Definition: gdisp.h:93
gColor gPixel
The pixel format.
Definition: gdisp.h:226
gJustify
Type for the text justification.
Definition: gdisp.h:60
gI16 gCoord
The type for a coordinate or length on the screen.
Definition: gdisp.h:39
gU16 gdispImageError
An image error code.
Definition: gdisp_image.h:37
struct GWindowInit GWindowInit
The structure to initialise a GWIN.
void gwinDrawBox(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy)
Draw a box in the window.
struct GWindowObject GWindowObject
A window object structure.
void gwinFillEllipse(GHandle gh, gCoord x, gCoord y, gCoord a, gCoord b)
Draw an filled ellipse.
void gwinDrawPoly(GHandle gh, gCoord tx, gCoord ty, const gPoint *pntarray, unsigned cnt)
Draw an enclosed polygon (convex, non-convex or complex).
void gwinDrawCircle(GHandle gh, gCoord x, gCoord y, gCoord radius)
Draw a circle in the window.
void gwinDrawPixel(GHandle gh, gCoord x, gCoord y)
Set a pixel in the window.
void gwinRedrawDisplay(GDisplay *g, gBool preserve)
Redraw a display.
void gwinFillChar(GHandle gh, gCoord x, gCoord y, char c)
Draw a text character with a filled background at the specified position in the window.
gBool gwinGetEnabled(GHandle gh)
Gets the enabled state of a window.
void gwinFillConvexPoly(GHandle gh, gCoord tx, gCoord ty, const gPoint *pntarray, unsigned cnt)
Fill a convex polygon.
void gwinDrawChar(GHandle gh, gCoord x, gCoord y, char c)
Draw a text character at the specified position in the window.
void gwinDrawString(GHandle gh, gCoord x, gCoord y, const char *str)
Draw a text string in the window.
void gwinSetDefaultFont(gFont font)
Set the default font for all new GWIN windows.
void gwinDrawEllipse(GHandle gh, gCoord x, gCoord y, gCoord a, gCoord b)
Draw an ellipse.
void gwinRaise(GHandle gh)
Raise a window to the top of the z-order.
void gwinClear(GHandle gh)
Clear the window.
void gwinClearInit(GWindowInit *pwi)
Clear a GWindowInit structure to all zero's.
gFont gwinGetDefaultFont(void)
Get the current default font.
void gwinFillArea(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy)
Fill an rectangular area in the window.
void gwinFillDualCircle(GHandle gh, gCoord x, gCoord y, gCoord radius1, gCoord radius2)
Draw two filled circles with the same centre in the window.
void gwinRedraw(GHandle gh)
Redraw a window.
void gwinDestroy(GHandle gh)
Destroy a window (of any type). Releases any dynamically allocated memory.
void gwinFillCircle(GHandle gh, gCoord x, gCoord y, gCoord radius)
Draw a filled circle in the window.
void gwinSetVisible(GHandle gh, gBool visible)
Sets whether a window is visible or not.
void gwinSetFlashing(GHandle gh, gBool flash)
Set a window or widget to flash.
void gwinSetFont(GHandle gh, gFont font)
Set the current font for this window.
GHandle gwinGWindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit)
Create a basic window.
gColor gwinGetDefaultColor(void)
Get the default foreground color for all new GWIN windows.
void gwinBlitArea(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord srcx, gCoord srcy, gCoord srccx, const gPixel *buffer)
Fill an area in the window using the supplied bitmap.
const char * gwinGetClassName(GHandle gh)
Get the real class name of the GHandle.
gdispImageError gwinDrawImage(GHandle gh, gImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy)
Draw the image.
void gwinFillStringBox(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy, const char *str, gJustify justify)
Draw a text string verticly centered within the specified filled box.
void gwinSetDefaultColor(gColor clr)
Set the default foreground color for all new GWIN windows.
GHandle gwinGetNextWindow(GHandle gh)
Get the next window in the z-order.
gColor gwinGetDefaultBgColor(void)
Get the default background color for all new GWIN windows.
void gwinDrawLine(GHandle gh, gCoord x0, gCoord y0, gCoord x1, gCoord y1)
Draw a line in the window.
GWindowMinMax
A window's minimized, maximized or normal size.
Definition: gwin.h:90
void gwinDrawStringBox(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy, const char *str, gJustify justify)
Draw a text string verticly centered within the specified box.
void gwinSetEnabled(GHandle gh, gBool enabled)
Enable or disable a window.
void gwinSetDefaultBgColor(gColor bgclr)
Set the default background color for all new GWIN windows.
GWindowMinMax gwinGetMinMax(GHandle gh)
Get the Minimized/Maximized state of a window.
void gwinResize(GHandle gh, gCoord width, gCoord height)
Resize a window.
void gwinFillString(GHandle gh, gCoord x, gCoord y, const char *str)
Draw a text string with a filled background in the window.
void gwinMove(GHandle gh, gCoord x, gCoord y)
Move a window.
void gwinSetWindowManager(struct GWindowManager *gwm)
Set the window manager for the GWIN system.
gColor gwinGetPixelColor(GHandle gh, gCoord x, gCoord y)
Get the color of a pixel in the window.
void gwinSetMinMax(GHandle gh, GWindowMinMax minmax)
Minimize, Maximize or Restore a window.
void gwinDrawThickLine(GHandle gh, gCoord x0, gCoord y0, gCoord x1, gCoord y1, gCoord width, gBool round)
Draw a thick line in the window.
gBool gwinGetVisible(GHandle gh)
Gets the visibility of a window.
GWIN Graphic window subsystem header file.
GWIN 3D module header file.
GWIN GRAPH module header file.
GWIN image widget header file.
GWIN Widgets header file.
The structure to initialise a GWIN.
Definition: gwin.h:75
gCoord x
Definition: gwin.h:76
gCoord y
Definition: gwin.h:77
gBool show
Definition: gwin.h:80
gCoord width
Definition: gwin.h:78
gCoord height
Definition: gwin.h:79
A window object structure.
Definition: gwin.h:40
gColor bgcolor
Definition: gwin.h:52
GDisplay * display
Definition: gwin.h:46
gCoord x
Definition: gwin.h:47
gColor color
Definition: gwin.h:51
gCoord width
Definition: gwin.h:49
const struct gwinVMT * vmt
Definition: gwin.h:45
gU32 flags
Definition: gwin.h:53
gCoord y
Definition: gwin.h:48
gCoord height
Definition: gwin.h:50
The structure for an image.
Definition: gdisp_image.h:59
Type for a 2D point on the screen.
Definition: gdisp.h:51
A queue item.
Definition: gqueue.h:40
The Virtual Method Table for a GWIN window.
Definition: gwin_class.h:55