µGFX  2.9
version 2.9
gwin_textedit.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_textedit.h
10  * @brief GWIN textedit widget header file
11  *
12  * @defgroup TextEdit TextEdit
13  * @ingroup Widgets
14  *
15  * @brief Widget that accepts text input.
16  *
17  * @note Due to the modularity of the @p GINPUT module, the text input can either come from a real physical
18  * keyboard or from a vritual on-screen keyboard such as the @p KeyboardWidget.
19  *
20  * @pre GFX_USE_GDISP must be set to GFXON in your gfxconf.h
21  * @pre GFX_USE_GWIN must be set to GFXON in your gfxconf.h
22  * @pre GDISP_NEED_TEXT must be set to GFXON in your gfxconf.h
23  * @pre GWIN_NEED_TEXTEDIT must be set to GFXON in your gfxconf.h
24  * @pre The fonts you want to use must be enabled in your gfxconf.h
25  *
26  * @{
27  */
28 
29 #ifndef _GWIN_TEXTEDIT_H
30 #define _GWIN_TEXTEDIT_H
31 
32 // This file is included within "src/gwin/gwin_widget.h"
33 
34 // A TextEdit widget
35 typedef struct GTexteditObject {
36  GWidgetObject w;
37 
38  char* textBuffer;
39  gMemSize maxSize;
40  gU16 cursorPos;
41 } GTexteditObject;
42 
43 /**
44  * @brief Create a TextEdit widget
45  * @details A TextEdit widget is a rectangular box which allows the user to input data through a keyboard.
46  * The keyboard can either be a physical one or a virtual on-screen keyboard as the keyboard driver
47  * is abstracted through the GINPUT module.
48  *
49  * @param[in] g The GDisplay on which the textedit should be displayed
50  * @param[in] wt The TextEdit structure to initialise. If this is NULL, the structure is dynamically allocated.
51  * @param[in] pInit The initialisation parameters to use.
52  * @param[in] maxSize The maximum number of characters the TextEdit widget can hold. (0 means unlimited).
53  *
54  * @return NULL if there is no resultant drawing area, otherwise the widget handle.
55  *
56  * @note If the initial text set is larger than maxSize then the text is truncated at maxSize characters.
57  * @api
58  */
59 GHandle gwinGTexteditCreate(GDisplay* g, GTexteditObject* wt, GWidgetInit* pInit, gMemSize maxSize);
60 #define gwinTexteditCreate(wt, pInit, maxSize) gwinGTexteditCreate(GDISP, wt, pInit, maxSize)
61 
62 /**
63  * @brief Send a special key to the textedit such as GKEY_LEFT, GKEY_RIGHT, GKEY_HOME, GKEY_END
64  *
65  * @param[in] gh The window handle (must be a textedit window)
66  * @param[in] key The special key to send.
67  * @pre Requires GINPUT_NEED_KEYBOARD or GWIN_NEED_KEYBOARD to be on
68  * @api
69  */
71 
72 /**
73  * @brief Send a normal utf8 character to the textedit
74  *
75  * @param[in] gh The window handle (must be a textedit window)
76  * @param[in] pkey The pointer to the utf8 character to send.
77  * @param[in] len The length of the utf8 character in bytes.
78  * @note This must ONLY be called with a single utf8 character at a time. Don't attempt to
79  * send a string of characters in the one call.
80  * @note Characters are interpreted as if they came directly from a keyboard ie a backspace
81  * character will perform the backspace operation, a tab will send the focus to the next
82  * control etc.
83  * @pre Requires GINPUT_NEED_KEYBOARD or GWIN_NEED_KEYBOARD to be on
84  * @api
85  */
86 void gwinTextEditSendKey(GHandle gh, char *pkey, unsigned len);
87 
88 /**
89  * @defgroup Renderings_Textedit Renderings
90  *
91  * @brief Built-in rendering functions for the textedit widget.
92  *
93  * @details These function may be passed to @p gwinSetCustomDraw() to get different textedit drawing styles.
94  *
95  * @note In your custom textedit drawing function you may optionally call these
96  * standard functions and then draw your extra details on top.
97  * @note These custom drawing routines don't have to worry about setting clipping as the framework
98  * sets clipping to the object window prior to calling these routines.
99  *
100  * @{
101  */
102 
103 /**
104  * @brief The default rendering function for the textedit widget.
105  *
106  * @param[in] gw The widget object (must be a button textedit).
107  * @param[in] param A parameter passed in from the user. Ignored by this function.
108  *
109  * @api
110  */
111 void gwinTexteditDefaultDraw(GWidgetObject* gw, void* param);
112 
113 /** @} */
114 
115 #endif // _GWIN_TEXTEDIT_H
116 /** @} */
void gwinTexteditDefaultDraw(GWidgetObject *gw, void *param)
The default rendering function for the textedit widget.
void gwinTextEditSendKey(GHandle gh, char *pkey, unsigned len)
Send a normal utf8 character to the textedit.
void gwinTextEditSendSpecialKey(GHandle gh, gU8 key)
Send a special key to the textedit such as GKEY_LEFT, GKEY_RIGHT, GKEY_HOME, GKEY_END.
GHandle gwinGTexteditCreate(GDisplay *g, GTexteditObject *wt, GWidgetInit *pInit, gMemSize maxSize)
Create a TextEdit widget.
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