µGFX  2.9
version 2.9
gwin_checkbox.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_checkbox.h
10  * @brief GWIN Graphic window subsystem header file.
11  *
12  * @defgroup Checkbox Checkbox
13  * @ingroup Widgets
14  *
15  * @brief CheckBox widget.
16  *
17  * @details GWIN allows it to easily create a group of checkbox buttons.
18  *
19  * @pre GFX_USE_GWIN must be set to GFXON in your gfxconf.h
20  * @pre GWIN_NEED_CHECKBOX must be set to GFXON in your gfxconf.h
21  * @{
22  */
23 
24 #ifndef _GWIN_CHECKBOX_H
25 #define _GWIN_CHECKBOX_H
26 
27 /* This file is included within "src/gwin/gwin_widget.h" */
28 
29 /*===========================================================================*/
30 /* Driver constants. */
31 /*===========================================================================*/
32 
33 #define GEVENT_GWIN_CHECKBOX (GEVENT_GWIN_CTRL_FIRST+2)
34 
35 /*===========================================================================*/
36 /* Type definitions */
37 /*===========================================================================*/
38 
39 typedef struct GEventGWinCheckbox {
40  GEventType type; // The type of this event (GEVENT_GWIN_CHECKBOX)
41  GHandle gwin; // The checkbox that has been depressed (actually triggered on release)
42  #if GWIN_WIDGET_TAGS
43  WidgetTag tag; // The checkbox tag
44  #endif
45  gBool isChecked; // Is the checkbox currently checked or unchecked?
46 } GEventGWinCheckbox;
47 
48 /**
49  * @brief The internal checkbox flags
50  * @note Used only for writing a custom draw routine.
51  * @{
52  */
53 #define GCHECKBOX_FLG_CHECKED 0x01
54 /** @} */
55 
56 /* A Checkbox window */
57 typedef struct GCheckboxObject {
58  GWidgetObject w;
59  #if GINPUT_NEED_TOGGLE
60  gU16 toggle;
61  #endif
62 } GCheckboxObject;
63 
64 /**
65  * @brief Create a checkbox window.
66  * @return NULL if there is no resultant drawing area, otherwise a window handle.
67  *
68  * @param[in] g The GDisplay to display this window on
69  * @param[in] gb The GCheckboxObject structure to initialise. If this is NULL, the structure is dynamically allocated.
70  * @param[in] pInit The initialization parameters to use
71  *
72  * @note The drawing color and the background color get set to the current defaults. If you haven't called
73  * @p gwinSetDefaultColor() or @p gwinSetDefaultBgColor() then these are GFX_WHITE and GFX_BLACK respectively.
74  * @note The font gets set to the current default font. If you haven't called @p gwinSetDefaultFont() then there
75  * is no default font and text drawing operations will no nothing.
76  * @note A checkbox remembers its normal drawing state. If there is a window manager then it is automatically
77  * redrawn if the window is moved or its visibility state is changed.
78  * @note A checkbox supports mouse and a toggle input.
79  * @note When assigning a toggle, only one toggle is supported. If you try to assign more than one toggle it will
80  * forget the previous toggle. When assigning a toggle the role parameter must be 0.
81  *
82  * @api
83  */
84 GHandle gwinGCheckboxCreate(GDisplay *g, GCheckboxObject *gb, const GWidgetInit *pInit);
85 #define gwinCheckboxCreate(gb, pInit) gwinGCheckboxCreate(GDISP, gb, pInit)
86 
87 /**
88  * @brief Set the state of a checkbox
89  *
90  * @param[in] gh The window handle (must be a checkbox window)
91  * @param[in] isChecked gTrue to set the check, gFalse to uncheck.
92  *
93  * @api
94  */
95 void gwinCheckboxCheck(GHandle gh, gBool isChecked);
96 
97 /**
98  * @brief Get the state of a checkbox
99  * @return gTrue if the checkbox is currently checked
100  *
101  * @param[in] gh The window handle (must be a checkbox window)
102  *
103  * @api
104  */
106 
107 /**
108  * @defgroup Renderings_Checkbox Renderings
109  *
110  * @brief Built-in rendering functions for the checkbox widget.
111  *
112  * @details These function may be passed to @p gwinSetCustomDraw() to get different checkbox drawing styles.
113  *
114  * @note In your custom checkbox drawing function you may optionally call these
115  * standard functions and then draw your extra details on top.
116  * @note These custom drawing routines don't have to worry about setting clipping as the framework
117  * sets clipping to the object window prior to calling these routines.
118  *
119  * @{
120  */
121 
122 /**
123  * @brief Renders a square checkbox where the text is on the right side of the checkbox.
124  *
125  * @param[in] gw The widget (must be a checkbox)
126  * @param[in] param A parameter passed in from the user. Ignored by this function.
127  *
128  * @api
129  */
130 void gwinCheckboxDraw_CheckOnLeft(GWidgetObject *gw, void *param);
131 
132 /**
133  * @brief Renders a square checkbox where the text is on the left side of the checkbox.
134  *
135  * @param[in] gw The widget (must be a checkbox)
136  * @param[in] param A parameter passed in from the user. Ignored by this function.
137  *
138  * @api
139  */
140 void gwinCheckboxDraw_CheckOnRight(GWidgetObject *gw, void *param);
141 
142 /**
143  * @brief Renders a checkbox in form of a rectangular button with the text inside of it.
144  *
145  * @details This behaves like a button that can be toggled.
146  *
147  * @param[in] gw The widget (must be a checkbox)
148  * @param[in] param A parameter passed in from the user. Ignored by this function.
149  *
150  * @api
151  */
152 void gwinCheckboxDraw_Button(GWidgetObject *gw, void *param);
153 /** @} */
154 
155 #endif /* _GWIN_CHECKBOX_H */
156 /** @} */
157 
GHandle gwinGCheckboxCreate(GDisplay *g, GCheckboxObject *gb, const GWidgetInit *pInit)
Create a checkbox window.
gBool gwinCheckboxIsChecked(GHandle gh)
Get the state of a checkbox.
void gwinCheckboxCheck(GHandle gh, gBool isChecked)
Set the state of a checkbox.
void gwinCheckboxDraw_CheckOnRight(GWidgetObject *gw, void *param)
Renders a square checkbox where the text is on the left side of the checkbox.
void gwinCheckboxDraw_Button(GWidgetObject *gw, void *param)
Renders a checkbox in form of a rectangular button with the text inside of it.
void gwinCheckboxDraw_CheckOnLeft(GWidgetObject *gw, void *param)
Renders a square checkbox where the text is on the right side of the checkbox.
gU16 WidgetTag
Defines a the type of a tag on a widget.
Definition: gwin_widget.h:81
The structure to initialise a widget.
Definition: gwin_widget.h:97
The GWIN Widget structure.
Definition: gwin_widget.h:118
A window object structure.
Definition: gwin.h:40