µGFX  2.9
version 2.9
gwin_tabset.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_tabset.h
10  * @brief GWIN Graphic window subsystem header file.
11  *
12  * @defgroup Tabset Tabset
13  * @ingroup Containers
14  *
15  * @brief Tabwidget to implement different "Tabs" or "Pages". Used to structure menus.
16  *
17  * @details A tabset is a set of tabs that control visibility of a number of pages of widgets.
18  * Note: Although the tabset is implemented as a container - you don't put your controls
19  * directly on the tabset. Instead you create a page and put your widgets on the page.
20  *
21  * @pre GFX_USE_GWIN must be set to GFXON in your gfxconf.h
22  * @pre GWIN_NEED_TABSET must be set to GFXON in your gfxconf.h
23  * @{
24  */
25 
26 #ifndef _GWIN_TABSET_H
27 #define _GWIN_TABSET_H
28 
29 /* This file is included from src/gwin/gwin_container.h */
30 
31 /**
32  * @brief The Event Type for a Tabset Event
33  */
34 #define GEVENT_GWIN_TABSET (GEVENT_GWIN_CTRL_FIRST+5)
35 
36 /**
37  * @brief A Tabset Event
38  * @note There are currently no GEventGWinTabset listening flags - use 0 as the flags to @p gwinAttachListener()
39  */
40 typedef struct GEventGWinTabset {
41  GEventType type; // The type of this event (GEVENT_GWIN_TABSET)
42  GHandle gwin; // The tabset window handle
43  #if GWIN_NEED_WIDGET && GWIN_WIDGET_TAGS
44  WidgetTag tag; // The tag of the tabset
45  #endif
46  // Above are the generic widget event elements, below the tabset specific elements
47  GHandle ghPage; // The tabpage window handle that has been selected
48  int nPage; // The page number (0 to n-1) that has been selected
50 
51 /**
52  * @brief Flags for gwinTabsetCreate()
53  * @{
54  */
55 #define GWIN_TABSET_BORDER 0x00000001 // Should the tab pages have a border?
56 /** @} */
57 
58 typedef struct GTabsetObject {
60  gCoord border_top;
61  } GTabsetObject;
62 
63 /**
64  * @brief Create a tabset widget
65  *
66  * @details This widget provides a set of tabs.
67  *
68  * @param[in] g The GDisplay to display this window on
69  * @param[in] fo The GTabsetObject structure to initialize. If this is NULL the structure is dynamically allocated.
70  * @param[in] pInit The initialization parameters
71  * @param[in] flags Some flags, see notes.
72  *
73  * @note Possible flags are: GWIN_TABSET_BORDER
74  *
75  * @return NULL if there is no resulting widget. A valid GHandle otherwise.
76  *
77  * @api
78  */
79 GHandle gwinGTabsetCreate(GDisplay *g, GTabsetObject *fo, GWidgetInit *pInit, gU32 flags);
80 #define gwinTabsetCreate(fo, pInit, flags) gwinGTabsetCreate(GDISP, fo, pInit, flags);
81 
82 /**
83  * @brief Add a tab-page to the tabset
84  * @returns The GHandle of the tab-page container.
85  *
86  * @param[in] gh The tabset handle
87  * @param[in] title The text to set. This must be a constant string unless useAlloc is set.
88  * @param[in] useAlloc If gTrue the string specified will be copied into dynamically allocated memory.
89  *
90  * @api
91  */
92 GHandle gwinTabsetAddTab(GHandle gh, const char *title, gBool useAlloc);
93 
94 /**
95  * @brief Delete a tab-page.
96  * @details Any widgets on the page will also be destroyed
97  *
98  * @param[in] gh The tab-page handle
99  *
100  * @note The index position of all tabs after this tab in the tabset are automatically renumbered.
101  *
102  * @api
103  */
104 #define gwinTabsetDeleteTab(gh) gwinDestroy(gh)
105 
106 /**
107  * @brief Count the number of tabs in the tabset
108  * @returns The number of tabs or zero if none exist.
109  *
110  * @param[in] gh The tabset handle
111  *
112  * @api
113  */
115 
116 /**
117  * @brief Get the GHandle of a tab based on its position
118  * @returns The GHandle of the tab-page container or NULL if that tab-page doesn't exist.
119  *
120  * @param[in] gh The tabset handle
121  * @param[in] index The tab-page handle to return (0 to number of pages - 1)
122  *
123  * @api
124  */
126 
127 /**
128  * @brief Get the GHandle of a tab based on its title
129  * @returns The GHandle of the tab-page container or NULL if that tab-page doesn't exist.
130  *
131  * @param[in] gh The tabset handle
132  * @param[in] title The title to search for
133  *
134  * @api
135  */
136 GHandle gwinTabsetGetTabByTitle(GHandle gh, const char *title);
137 
138 /**
139  * @brief Set the title of a tab-page.
140  *
141  * @param[in] gh The tab-page handle (NB: Use the page handle NOT the tabset handle)
142  * @param[in] title The text to set. This must be a constant string unless useAlloc is set.
143  * @param[in] useAlloc If gTrue the string specified will be copied into dynamically allocated memory.
144  *
145  * @note This function should be used to change the text associated with a tab-page
146  * rather than @p gwinSetText().
147  *
148  * @api
149  */
150 void gwinTabsetSetTitle(GHandle gh, const char *title, gBool useAlloc);
151 
152 /**
153  * @brief Get the title of a tab-page.
154  * @return The title of the tab.
155  *
156  * @param[in] gh The tab-page handle (NB: Use the page handle NOT the tabset handle)
157  *
158  * @api
159  */
160 #define gwinTabsetGetTitle(gh) gwinGetText(gh)
161 
162 /**
163  * @brief Set the active tab in a tabset.
164  *
165  * @param[in] gh The tab-page handle (NB: Use the page handle NOT the tabset handle)
166  *
167  * @api
168  */
170 
171 /**
172  * @defgroup Renderings_Tabset Renderings
173  *
174  * @brief Built-in rendering functions for the tabset widget.
175  *
176  * @details These function may be passed to @p gwinSetCustomDraw() to get different tabset drawing styles.
177  *
178  * @note In your custom tabset drawing function you may optionally call these
179  * standard functions and then draw your extra details on top.
180  * @note These custom drawing routines don't have to worry about setting clipping as the framework
181  * sets clipping to the object window prior to calling these routines.
182  *
183  * @{
184  */
185 
186 /**
187  * @brief The default rendering function for the tabset widget.
188  *
189  * @details Fills the client area with the background color.
190  *
191  * @param[in] gw The widget object (must be a container object).
192  * @param[in] param A parameter passed in from the user. Ignored by this function.
193  *
194  * @api
195  */
196 void gwinTabsetDraw_Std(GWidgetObject *gw, void *param);
197 
198 /**
199  * @brief Renders the tabset but leaves the client area transparent.
200  *
201  * @details Will not fill the client area at all.
202  *
203  * @param[in] gw The widget object (must be a container object).
204  * @param[in] param A parameter passed in from the user. Ignored by this function.
205  *
206  * @api
207  */
209 
210 #if GDISP_NEED_IMAGE || defined(__DOXYGEN__)
211  /**
212  * @brief Renders the tabset and uses the specified image for the client area.
213  *
214  * @details The image will be tiled throghout the client area. Therefore, to archive the best looking result the
215  * supplied image needs to be of the same size as the client area size of the tabset widget (inner size).
216  *
217  * @param[in] gw The widget object (must be a tabset object).
218  * @param[in] param A parameter passed in from the user. Must be an image handle. See note below.
219  *
220  * @note The image must be already opened before calling @p gwinSetCustomDraw(). The handle is passed as the parameter
221  * to this function.
222  *
223  * @pre GDISP_NEED_IMAGE must be set to GFXON
224  *
225  * @api
226  */
227  void gwinTabsetDraw_Image(GWidgetObject *gw, void *param);
228 #endif /* GDISP_NEED_IMAGE */
229 /** @} */
230 
231 #endif /* _GWIN_TABSET_H */
232 /** @} */
233 
gI16 gCoord
The type for a coordinate or length on the screen.
Definition: gdisp.h:39
void gwinTabsetDraw_Transparent(GWidgetObject *gw, void *param)
Renders the tabset but leaves the client area transparent.
void gwinTabsetDraw_Std(GWidgetObject *gw, void *param)
The default rendering function for the tabset widget.
void gwinTabsetDraw_Image(GWidgetObject *gw, void *param)
Renders the tabset and uses the specified image for the client area.
struct GEventGWinTabset GEventGWinTabset
A Tabset Event.
GHandle gwinGTabsetCreate(GDisplay *g, GTabsetObject *fo, GWidgetInit *pInit, gU32 flags)
Create a tabset widget.
GHandle gwinTabsetAddTab(GHandle gh, const char *title, gBool useAlloc)
Add a tab-page to the tabset.
void gwinTabsetSetTab(GHandle gh)
Set the active tab in a tabset.
int gwinTabsetCountTabs(GHandle gh)
Count the number of tabs in the tabset.
GHandle gwinTabsetGetTabByTitle(GHandle gh, const char *title)
Get the GHandle of a tab based on its title.
void gwinTabsetSetTitle(GHandle gh, const char *title, gBool useAlloc)
Set the title of a tab-page.
GHandle gwinTabsetGetTabByIndex(GHandle gh, int index)
Get the GHandle of a tab based on its position.
gU16 WidgetTag
Defines a the type of a tag on a widget.
Definition: gwin_widget.h:81
A Tabset Event.
Definition: gwin_tabset.h:40
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