version 2.8
gwin_keyboard.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.org/license.html
6  */
7 
8 /**
9  * @file src/gwin/gwin_keyboard.h
10  * @brief GWIN Graphic window subsystem header file.
11  *
12  * @defgroup VirtualKeyboard VirtualKeyboard
13  * @ingroup Widgets
14  *
15  * @brief Keyboard widget. Used to provide a virtual on-screen keyboard.
16  *
17  * @details GWIN allows it to easily create buttons with different styles
18  * and check for different meta states such as: PRESSED, CLICKED,
19  * RELEASED etc.
20  *
21  * @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
22  * @pre GWIN_NEED_BUTTON must be set to TRUE in your gfxconf.h
23  * @{
24  */
25 
26 #ifndef _GWIN_KEYBOARD_H
27 #define _GWIN_KEYBOARD_H
28 
29 /* This file is included within "src/gwin/gwin_widget.h" */
30 
31 /**
32  * @brief The Event Type for a Button Event
33  */
34 #define GEVENT_GWIN_KEYBOARD (GEVENT_GWIN_CTRL_FIRST+6)
35 
36 /**
37  * @brief A Keyboard Event
38  * @note There are currently no GEventGWinButton listening flags - use 0 as the flags to @p gwinAttachListener()
39  */
41 
42 /**
43  * @brief The internal keyboard flags and other defines
44  * @note Used only for writing a custom draw routine.
45  * @{
46  */
47 #define GKEYBOARD_FLG_REVERTSET 0x01
48 #define GKEYBOARD_FLG_QUICKUPDATE 0x02
49 #define GKEY_BAD_ROWCOL 255
50 /** @} */
51 
52 /**
53  * @brief The keyboard widget structure
54  * @note Do not use the members directly - treat it as a black-box.
55  */
56 typedef struct GKeyboardObject {
57  GWidgetObject w;
58  const struct GVKeyTable *keytable;
59  const char **keyset;
60  coord_t keyx, keyy;
61  coord_t keycx, keycy;
62  uint8_t lastkeyrow, lastkeycol;
63  uint8_t keyrow, keycol;
64  uint32_t key;
66 
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70 
71 /**
72  * @brief Create a keyboard widget.
73  * @return NULL if there is no resultant drawing area, otherwise a window handle.
74  *
75  * @param[in] g The GDisplay to display this window on
76  * @param[in] gb The GKeyboardObject structure to initialise. If this is NULL the structure is dynamically allocated.
77  * @param[in] pInit The initialisation parameters
78  *
79  * @note The drawing color and the background color get set to the current defaults. If you haven't called
80  * @p gwinSetDefaultColor() or @p gwinSetDefaultBgColor() then these are White and Black respectively.
81  * @note The font gets set to the current default font. If you haven't called @p gwinSetDefaultFont() then there
82  * is no default font and text drawing operations will no nothing.
83  * @note A keyboard remembers its normal drawing state. If there is a window manager then it is automatically
84  * redrawn if the window is moved or its visibility state is changed.
85  * @note A keyboard supports mouse input.
86  *
87  * @api
88  */
89 GHandle gwinGKeyboardCreate(GDisplay *g, GKeyboardObject *gb, const GWidgetInit *pInit);
90 #define gwinKeyboardCreate(gb, pInit) gwinGKeyboardCreate(GDISP, gb, pInit)
91 
92 /**
93  * @brief Get the keyboard event source for a GWIN virtual keyboard
94  * @return The event source handle or NULL if this is not a virtual keyboard
95  *
96  * @param[in] gh The GWIN virtual keyboard
97  *
98  * @note Normal GINPUT Keyboard events are returned by this event source.
99  */
100 GSourceHandle gwinKeyboardGetEventSource(GHandle gh);
101 
102 /**
103  * @brief Set the layout for the virtual keyboard
104  *
105  * @param[in] gh The GWIN virtual keyboard
106  * @param[in] layout The keyboard layout to use (described by gwin_keyboard_layout.h)
107  *
108  * @note Changing the layout resets the keyboard to key set 0 of the keyboard and cancels any
109  * pending shifts.
110  */
111 void gwinKeyboardSetLayout(GHandle gh, const struct GVKeyTable *layout);
112 
113 /**
114  * @defgroup Renderings_Keyboard Renderings
115  *
116  * @brief Built-in rendering functions for the keyboard widget.
117  *
118  * @details These function may be passed to @p gwinSetCustomDraw() to get different keyboard drawing styles.
119  *
120  * @note In your custom keyboard drawing function you may optionally call these
121  * standard functions and then draw your extra details on top.
122  * @note The built-in functions below ignore the param parameter.
123  * @note These custom drawing routines don't have to worry about setting clipping as the framework
124  * sets clipping to the object window prior to calling these routines.
125  *
126  * @{
127  */
128 
129 /**
130  * @brief The default rendering function for the keyboard widget
131  *
132  * @param[in] gw The widget object (must be a keyboard object)
133  * @param[in] param A parameter passed in from the user. Ignored by this function.
134  *
135  * @api
136  */
137 void gwinKeyboardDraw_Normal(GWidgetObject *gw, void *param);
138 
139 /** @} */
140 
141 #ifdef __cplusplus
142 }
143 #endif
144 
145 #endif /* _GWIN_KEYBOARD_H */
146 /** @} */
int16_t coord_t
The type for a coordinate or length on the screen.
Definition: gdisp.h:39
The structure to initialise a widget.
Definition: gwin_widget.h:97
GHandle gwinGKeyboardCreate(GDisplay *g, GKeyboardObject *gb, const GWidgetInit *pInit)
Create a keyboard widget.
GSourceHandle gwinKeyboardGetEventSource(GHandle gh)
Get the keyboard event source for a GWIN virtual keyboard.
The GWIN Widget structure.
Definition: gwin_widget.h:118
The keyboard widget structure.
Definition: gwin_keyboard.h:56
GEventGWin GEventGWinKeyboard
A Keyboard Event.
Definition: gwin_keyboard.h:40
void gwinKeyboardDraw_Normal(GWidgetObject *gw, void *param)
The default rendering function for the keyboard widget.
A window object structure.
Definition: gwin.h:40
void gwinKeyboardSetLayout(GHandle gh, const struct GVKeyTable *layout)
Set the layout for the virtual keyboard.
struct GKeyboardObject GKeyboardObject
The keyboard widget structure.
A Generic GWIN Event.
Definition: gwin_widget.h:149