µGFX  2.9
version 2.9
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.io/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 GFXON in your gfxconf.h
22  * @pre GWIN_NEED_BUTTON must be set to GFXON 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  gCoord keyx, keyy;
61  gCoord keycx, keycy;
62  gU8 lastkeyrow, lastkeycol;
63  gU8 keyrow, keycol;
64  gU32 key;
66 
67 /**
68  * @brief Create a keyboard widget.
69  * @return NULL if there is no resultant drawing area, otherwise a window handle.
70  *
71  * @param[in] g The GDisplay to display this window on
72  * @param[in] gb The GKeyboardObject structure to initialise. If this is NULL the structure is dynamically allocated.
73  * @param[in] pInit The initialisation parameters
74  *
75  * @note The drawing color and the background color get set to the current defaults. If you haven't called
76  * @p gwinSetDefaultColor() or @p gwinSetDefaultBgColor() then these are GFX_WHITE and GFX_BLACK respectively.
77  * @note The font gets set to the current default font. If you haven't called @p gwinSetDefaultFont() then there
78  * is no default font and text drawing operations will no nothing.
79  * @note A keyboard remembers its normal drawing state. If there is a window manager then it is automatically
80  * redrawn if the window is moved or its visibility state is changed.
81  * @note A keyboard supports mouse input.
82  *
83  * @api
84  */
85 GHandle gwinGKeyboardCreate(GDisplay *g, GKeyboardObject *gb, const GWidgetInit *pInit);
86 #define gwinKeyboardCreate(gb, pInit) gwinGKeyboardCreate(GDISP, gb, pInit)
87 
88 /**
89  * @brief Get the keyboard event source for a GWIN virtual keyboard
90  * @return The event source handle or NULL if this is not a virtual keyboard
91  *
92  * @param[in] gh The GWIN virtual keyboard
93  *
94  * @note Normal GINPUT Keyboard events are returned by this event source.
95  */
97 
98 /**
99  * @brief Set the layout for the virtual keyboard
100  *
101  * @param[in] gh The GWIN virtual keyboard
102  * @param[in] layout The keyboard layout to use (described by gwin_keyboard_layout.h)
103  *
104  * @note Changing the layout resets the keyboard to key set 0 of the keyboard and cancels any
105  * pending shifts.
106  */
107 void gwinKeyboardSetLayout(GHandle gh, const struct GVKeyTable *layout);
108 
109 /**
110  * @defgroup Renderings_Keyboard Renderings
111  *
112  * @brief Built-in rendering functions for the keyboard widget.
113  *
114  * @details These function may be passed to @p gwinSetCustomDraw() to get different keyboard drawing styles.
115  *
116  * @note In your custom keyboard drawing function you may optionally call these
117  * standard functions and then draw your extra details on top.
118  * @note The built-in functions below ignore the param parameter.
119  * @note These custom drawing routines don't have to worry about setting clipping as the framework
120  * sets clipping to the object window prior to calling these routines.
121  *
122  * @{
123  */
124 
125 /**
126  * @brief The default rendering function for the keyboard widget
127  *
128  * @param[in] gw The widget object (must be a keyboard object)
129  * @param[in] param A parameter passed in from the user. Ignored by this function.
130  *
131  * @api
132  */
133 void gwinKeyboardDraw_Normal(GWidgetObject *gw, void *param);
134 
135 /** @} */
136 
137 #endif /* _GWIN_KEYBOARD_H */
138 /** @} */
gI16 gCoord
The type for a coordinate or length on the screen.
Definition: gdisp.h:39
void gwinKeyboardDraw_Normal(GWidgetObject *gw, void *param)
The default rendering function for the keyboard widget.
GHandle gwinGKeyboardCreate(GDisplay *g, GKeyboardObject *gb, const GWidgetInit *pInit)
Create a keyboard widget.
GEventGWin GEventGWinKeyboard
A Keyboard Event.
Definition: gwin_keyboard.h:40
void gwinKeyboardSetLayout(GHandle gh, const struct GVKeyTable *layout)
Set the layout for the virtual keyboard.
struct GKeyboardObject GKeyboardObject
The keyboard widget structure.
GSourceHandle gwinKeyboardGetEventSource(GHandle gh)
Get the keyboard event source for a GWIN virtual keyboard.
A Generic GWIN Event.
Definition: gwin_widget.h:149
The keyboard widget structure.
Definition: gwin_keyboard.h:56
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