Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/libs/lvgl/lv_objx/lv_kb.h
1476 views
1
/*
2
* Copyright (c) 2019-2020 CTCaer
3
*
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms and conditions of the GNU General Public License,
6
* version 2, as published by the Free Software Foundation.
7
*
8
* This program is distributed in the hope it will be useful, but WITHOUT
9
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11
* more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15
*/
16
17
/**
18
* @file lv_kb.h
19
*
20
*/
21
22
#ifndef LV_KB_H
23
#define LV_KB_H
24
25
#ifdef __cplusplus
26
extern "C" {
27
#endif
28
29
/*********************
30
* INCLUDES
31
*********************/
32
#ifdef LV_CONF_INCLUDE_SIMPLE
33
#include "lv_conf.h"
34
#else
35
#include "../../lv_conf.h"
36
#endif
37
38
#if USE_LV_KB != 0
39
40
/*Testing of dependencies*/
41
#if USE_LV_BTNM == 0
42
#error "lv_kb: lv_btnm is required. Enable it in lv_conf.h (USE_LV_BTNM 1) "
43
#endif
44
45
#if USE_LV_TA == 0
46
#error "lv_kb: lv_ta is required. Enable it in lv_conf.h (USE_LV_TA 1) "
47
#endif
48
49
#include "../lv_core/lv_obj.h"
50
#include "lv_btnm.h"
51
52
/*********************
53
* DEFINES
54
*********************/
55
56
/**********************
57
* TYPEDEFS
58
**********************/
59
60
enum {
61
LV_KB_MODE_TEXT,
62
LV_KB_MODE_NUM,
63
LV_KB_MODE_HEX
64
};
65
typedef uint8_t lv_kb_mode_t;
66
67
/*Data of keyboard*/
68
typedef struct {
69
lv_btnm_ext_t btnm; /*Ext. of ancestor*/
70
/*New data for this type */
71
lv_obj_t *ta; /*Pointer to the assigned text area*/
72
lv_kb_mode_t mode; /*Key map type*/
73
uint8_t cursor_mng :1; /*1: automatically show/hide cursor when a text area is assigned or left*/
74
lv_action_t ok_action; /*Called when the "Ok" button is clicked*/
75
lv_action_t hide_action; /*Called when the "Hide" button is clicked*/
76
} lv_kb_ext_t;
77
78
enum {
79
LV_KB_STYLE_BG,
80
LV_KB_STYLE_BTN_REL,
81
LV_KB_STYLE_BTN_PR,
82
LV_KB_STYLE_BTN_TGL_REL,
83
LV_KB_STYLE_BTN_TGL_PR,
84
LV_KB_STYLE_BTN_INA,
85
};
86
typedef uint8_t lv_kb_style_t;
87
88
89
/**********************
90
* GLOBAL PROTOTYPES
91
**********************/
92
93
/**
94
* Create a keyboard objects
95
* @param par pointer to an object, it will be the parent of the new keyboard
96
* @param copy pointer to a keyboard object, if not NULL then the new object will be copied from it
97
* @return pointer to the created keyboard
98
*/
99
lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy);
100
101
/*=====================
102
* Setter functions
103
*====================*/
104
105
/**
106
* Assign a Text Area to the Keyboard. The pressed characters will be put there.
107
* @param kb pointer to a Keyboard object
108
* @param ta pointer to a Text Area object to write there
109
*/
110
void lv_kb_set_ta(lv_obj_t * kb, lv_obj_t * ta);
111
112
/**
113
* Set a new a mode (text or number map)
114
* @param kb pointer to a Keyboard object
115
* @param mode the mode from 'lv_kb_mode_t'
116
*/
117
void lv_kb_set_mode(lv_obj_t * kb, lv_kb_mode_t mode);
118
119
/**
120
* Automatically hide or show the cursor of the current Text Area
121
* @param kb pointer to a Keyboard object
122
* @param en true: show cursor on the current text area, false: hide cursor
123
*/
124
void lv_kb_set_cursor_manage(lv_obj_t * kb, bool en);
125
126
/**
127
* Set call back to call when the "Ok" button is pressed
128
* @param kb pointer to Keyboard object
129
* @param action a callback with 'lv_action_t' type
130
*/
131
void lv_kb_set_ok_action(lv_obj_t * kb, lv_action_t action);
132
133
/**
134
* Set call back to call when the "Hide" button is pressed
135
* @param kb pointer to Keyboard object
136
* @param action a callback with 'lv_action_t' type
137
*/
138
void lv_kb_set_hide_action(lv_obj_t * kb, lv_action_t action);
139
140
/**
141
* Set a new map for the keyboard
142
* @param kb pointer to a Keyboard object
143
* @param map pointer to a string array to describe the map.
144
* See 'lv_btnm_set_map()' for more info.
145
*/
146
static inline void lv_kb_set_map(lv_obj_t *kb, const char ** map)
147
{
148
lv_btnm_set_map(kb, map);
149
}
150
151
/**
152
* Set a style of a keyboard
153
* @param kb pointer to a keyboard object
154
* @param type which style should be set
155
* @param style pointer to a style
156
*/
157
void lv_kb_set_style(lv_obj_t *kb, lv_kb_style_t type, lv_style_t *style);
158
159
/*=====================
160
* Getter functions
161
*====================*/
162
163
/**
164
* Assign a Text Area to the Keyboard. The pressed characters will be put there.
165
* @param kb pointer to a Keyboard object
166
* @return pointer to the assigned Text Area object
167
*/
168
lv_obj_t * lv_kb_get_ta(const lv_obj_t * kb);
169
170
/**
171
* Set a new a mode (text or number map)
172
* @param kb pointer to a Keyboard object
173
* @return the current mode from 'lv_kb_mode_t'
174
*/
175
lv_kb_mode_t lv_kb_get_mode(const lv_obj_t * kb);
176
177
/**
178
* Get the current cursor manage mode.
179
* @param kb pointer to a Keyboard object
180
* @return true: show cursor on the current text area, false: hide cursor
181
*/
182
bool lv_kb_get_cursor_manage(const lv_obj_t * kb);
183
184
/**
185
* Get the callback to call when the "Ok" button is pressed
186
* @param kb pointer to Keyboard object
187
* @return the ok callback
188
*/
189
lv_action_t lv_kb_get_ok_action(const lv_obj_t * kb);
190
191
/**
192
* Get the callback to call when the "Hide" button is pressed
193
* @param kb pointer to Keyboard object
194
* @return the close callback
195
*/
196
lv_action_t lv_kb_get_hide_action(const lv_obj_t * kb);
197
198
/**
199
* Get a style of a keyboard
200
* @param kb pointer to a keyboard object
201
* @param type which style should be get
202
* @return style pointer to a style
203
*/
204
lv_style_t * lv_kb_get_style(const lv_obj_t *kb, lv_kb_style_t type);
205
206
/**********************
207
* MACROS
208
**********************/
209
210
#endif /*USE_LV_KB*/
211
212
#ifdef __cplusplus
213
} /* extern "C" */
214
#endif
215
216
#endif /*LV_KB_H*/
217
218