µGFX  2.9
version 2.9
gwin_label.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_label.h
10  * @brief GWIN label widget header file
11  *
12  * @defgroup Label Label
13  * @ingroup Widgets
14  *
15  * @brief Simple label widget.
16  *
17  * @details Setting the dimensions of the widget to 0 will automatically
18  * set the labels dimensions to fit the entire text. Note that the
19  * dimensions of the label will change every time the text is changed
20  * through gwinSetText().
21  *
22  * @pre GFX_USE_GDISP must be set to GFXON in your gfxconf.h
23  * @pre GFX_USE_GWIN must be set to GFXON in your gfxconf.h
24  * @pre GDISP_NEED_TEXT must be set to GFXON in your gfxconf.h
25  * @pre GWIN_NEED_LABEL must be set to GFXON in your gfxconf.h
26  * @pre The fonts you want to use must be enabled in your gfxconf.h
27  *
28  * @{
29  */
30 
31 #ifndef _GWIN_LABEL_H
32 #define _GWIN_LABEL_H
33 
34 // This file is included within "src/gwin/gwin_widget.h"
35 
36 /**
37  * @brief The internal label flags
38  * @note Used only for writing a custom draw routine.
39  * @{
40  */
41 #define GLABEL_FLG_BORDER 0x01
42 /** @} */
43 
44 // An label window
45 typedef struct GLabelObject {
46  GWidgetObject w;
47 
48  #if GWIN_LABEL_ATTRIBUTE
49  gCoord tab;
50  const char* attr;
51  #endif
52 } GLabelObject;
53 
54 /**
55  * @brief Create a label widget.
56  * @details A label widget is a simple window which has a static text.
57  *
58  * @param[in] g The GDisplay to display this window on
59  * @param[in] widget The label structure to initialise. If this is NULL, the structure is dynamically allocated.
60  * @param[in] pInit The initialisation parameters to use.
61  *
62  * @return NULL if there is no resultat drawing area, otherwise the widget handle.
63  *
64  * @api
65  */
66 GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit);
67 #define gwinLabelCreate(w, pInit) gwinGLabelCreate(GDISP, w, pInit)
68 
69 /**
70  * @brief Border settings for the default rendering routine
71  *
72  * @param[in] gh The widget handle (must be a label handle)
73  * @param[in] border Shall a border be rendered?
74  *
75  * @api
76  */
77 void gwinLabelSetBorder(GHandle gh, gBool border);
78 
79 #if GWIN_LABEL_ATTRIBUTE || defined(__DOXYGEN__)
80  /**
81  * @brief Add an text attribute in front of the normal label text
82  * @details Often you want to display a text like this:
83  * Current IP: 192.168.1.42
84  * In that case, the actual IP will be variable, the text in front of it
85  * always remains the same. The static text is called the attribute and can be
86  * set using this function.
87  * Furthermore, the tab can be set in order to vertically align multiple labels.
88  * Please check out the website for further explanation, illustraions and usage
89  * examples.
90  *
91  * @note The attribute text is not copied into private memory and so it
92  * must be a constant string, not one allocated in a stack buffer.
93  * @note Use of this construct is discouraged. The appropriate way is to
94  * create two labels - one for the static text and one for the
95  * dynamic text.
96  *
97  * @param[in] gh The widget handle (must be a label handle)
98  * @param[in] tab The distance of the label text from the left widget edge
99  * @param[in] attr The attribute to be displayed
100  *
101  * @api
102  */
103  void gwinLabelSetAttribute(GHandle gh, gCoord tab, const char* attr);
104 #endif
105 
106 /**
107  * @defgroup Renderings_Label Renderings
108  *
109  * @brief Built-in rendering functions for the label widget.
110  *
111  * @details These function may be passed to @p gwinSetCustomDraw() to get different label drawing styles.
112  *
113  * @note In your custom label drawing function you may optionally call these
114  * standard functions and then draw your extra details on top.
115  * @note These custom drawing routines don't have to worry about setting clipping as the framework
116  * sets clipping to the object window prior to calling these routines.
117  *
118  * @{
119  */
120 
121 /**
122  * @brief Renders a label with the text justified based on the parameter.
123  *
124  * @param[in] gw The widget object (must be a label object)
125  * @param[in] param A parameter passed in from the user. Must be of type gJustify.
126  *
127  * @api
128  */
129 void gwinLabelDrawJustified(GWidgetObject *gw, void *param);
130 
131 /**
132  * @brief Renders a label with the text left jestified.
133  *
134  * @note This is the default rendering function.
135  *
136  * @param[in] gw The widget object (must be a label object)
137  * @param[in] param A parameter passed in from the user. Ignored by this function.
138  *
139  * @api
140  */
142 
143 /**
144  * @brief Renders a label with the text right jestified.
145  *
146  * @param[in] gw The widget object (must be a label object)
147  * @param[in] param A parameter passed in from the user. Ignored by this function.
148  *
149  * @api
150  */
152 
153 /**
154  * @brief Renders a label with the text center jestified.
155  *
156  * @param[in] gw The widget object (must be a label object)
157  * @param[in] param A parameter passed in from the user. Ignored by this function.
158  *
159  * @api
160  */
162 
163 /** @} */
164 
165 #endif // _GWIN_LABEL_H
166 /** @} */
gI16 gCoord
The type for a coordinate or length on the screen.
Definition: gdisp.h:39
GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit)
Create a label widget.
void gwinLabelSetAttribute(GHandle gh, gCoord tab, const char *attr)
Add an text attribute in front of the normal label text.
void gwinLabelSetBorder(GHandle gh, gBool border)
Border settings for the default rendering routine.
void gwinLabelDrawJustifiedLeft(GWidgetObject *gw, void *param)
Renders a label with the text left jestified.
void gwinLabelDrawJustified(GWidgetObject *gw, void *param)
Renders a label with the text justified based on the parameter.
void gwinLabelDrawJustifiedCenter(GWidgetObject *gw, void *param)
Renders a label with the text center jestified.
void gwinLabelDrawJustifiedRight(GWidgetObject *gw, void *param)
Renders a label with the text right jestified.
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