2017-08-23 09:24:23 +02:00
|
|
|
/**
|
|
|
|
* @file lv_kb.h
|
2018-06-19 09:49:58 +02:00
|
|
|
*
|
2017-08-23 09:24:23 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LV_KB_H
|
|
|
|
#define LV_KB_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
2018-07-07 12:21:36 +02:00
|
|
|
#ifdef LV_CONF_INCLUDE_SIMPLE
|
2018-07-07 11:53:22 +02:00
|
|
|
#include "lv_conf.h"
|
|
|
|
#else
|
2019-03-17 08:33:03 +01:00
|
|
|
#include "../../../lv_conf.h"
|
2018-07-07 11:53:22 +02:00
|
|
|
#endif
|
|
|
|
|
2019-03-07 00:05:16 +01:00
|
|
|
#if LV_USE_KB != 0
|
2017-08-23 09:24:23 +02:00
|
|
|
|
2018-01-19 15:40:22 +01:00
|
|
|
/*Testing of dependencies*/
|
2019-03-07 00:05:16 +01:00
|
|
|
#if LV_USE_BTNM == 0
|
|
|
|
#error "lv_kb: lv_btnm is required. Enable it in lv_conf.h (LV_USE_BTNM 1) "
|
2018-01-19 15:40:22 +01:00
|
|
|
#endif
|
|
|
|
|
2019-03-07 00:05:16 +01:00
|
|
|
#if LV_USE_TA == 0
|
|
|
|
#error "lv_kb: lv_ta is required. Enable it in lv_conf.h (LV_USE_TA 1) "
|
2018-01-19 15:40:22 +01:00
|
|
|
#endif
|
|
|
|
|
2017-11-30 11:35:33 +01:00
|
|
|
#include "../lv_core/lv_obj.h"
|
2017-08-23 09:24:23 +02:00
|
|
|
#include "lv_btnm.h"
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
|
|
|
|
2018-09-18 13:59:40 +02:00
|
|
|
enum {
|
2017-10-30 17:11:56 +01:00
|
|
|
LV_KB_MODE_TEXT,
|
2017-08-23 09:24:23 +02:00
|
|
|
LV_KB_MODE_NUM,
|
2018-09-18 13:59:40 +02:00
|
|
|
};
|
|
|
|
typedef uint8_t lv_kb_mode_t;
|
2017-08-23 09:24:23 +02:00
|
|
|
|
|
|
|
/*Data of keyboard*/
|
2019-04-04 07:15:40 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
lv_btnm_ext_t btnm; /*Ext. of ancestor*/
|
2017-08-23 09:24:23 +02:00
|
|
|
/*New data for this type */
|
2019-04-04 07:15:40 +02:00
|
|
|
lv_obj_t * ta; /*Pointer to the assigned text area*/
|
|
|
|
lv_kb_mode_t mode; /*Key map type*/
|
|
|
|
uint8_t
|
|
|
|
cursor_mng : 1; /*1: automatically show/hide cursor when a text area is assigned or left*/
|
2018-06-19 09:49:58 +02:00
|
|
|
} lv_kb_ext_t;
|
2017-08-23 09:24:23 +02:00
|
|
|
|
2018-09-18 13:59:40 +02:00
|
|
|
enum {
|
2017-11-15 15:50:33 +01:00
|
|
|
LV_KB_STYLE_BG,
|
|
|
|
LV_KB_STYLE_BTN_REL,
|
|
|
|
LV_KB_STYLE_BTN_PR,
|
|
|
|
LV_KB_STYLE_BTN_TGL_REL,
|
|
|
|
LV_KB_STYLE_BTN_TGL_PR,
|
|
|
|
LV_KB_STYLE_BTN_INA,
|
2018-09-18 13:59:40 +02:00
|
|
|
};
|
|
|
|
typedef uint8_t lv_kb_style_t;
|
|
|
|
|
2017-08-23 09:24:23 +02:00
|
|
|
/**********************
|
|
|
|
* GLOBAL PROTOTYPES
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a keyboard objects
|
|
|
|
* @param par pointer to an object, it will be the parent of the new keyboard
|
|
|
|
* @param copy pointer to a keyboard object, if not NULL then the new object will be copied from it
|
|
|
|
* @return pointer to the created keyboard
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy);
|
2017-08-23 09:24:23 +02:00
|
|
|
|
2017-11-10 15:01:40 +01:00
|
|
|
/*=====================
|
|
|
|
* Setter functions
|
|
|
|
*====================*/
|
2017-08-23 09:24:23 +02:00
|
|
|
|
2017-08-23 14:15:33 +02:00
|
|
|
/**
|
|
|
|
* Assign a Text Area to the Keyboard. The pressed characters will be put there.
|
|
|
|
* @param kb pointer to a Keyboard object
|
|
|
|
* @param ta pointer to a Text Area object to write there
|
|
|
|
*/
|
|
|
|
void lv_kb_set_ta(lv_obj_t * kb, lv_obj_t * ta);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a new a mode (text or number map)
|
|
|
|
* @param kb pointer to a Keyboard object
|
|
|
|
* @param mode the mode from 'lv_kb_mode_t'
|
|
|
|
*/
|
|
|
|
void lv_kb_set_mode(lv_obj_t * kb, lv_kb_mode_t mode);
|
|
|
|
|
|
|
|
/**
|
2017-11-10 15:01:40 +01:00
|
|
|
* Automatically hide or show the cursor of the current Text Area
|
2017-08-23 14:15:33 +02:00
|
|
|
* @param kb pointer to a Keyboard object
|
|
|
|
* @param en true: show cursor on the current text area, false: hide cursor
|
|
|
|
*/
|
2017-11-05 00:48:57 +01:00
|
|
|
void lv_kb_set_cursor_manage(lv_obj_t * kb, bool en);
|
2017-08-23 14:15:33 +02:00
|
|
|
|
2017-12-19 22:00:32 +01:00
|
|
|
/**
|
|
|
|
* Set a new map for the keyboard
|
|
|
|
* @param kb pointer to a Keyboard object
|
|
|
|
* @param map pointer to a string array to describe the map.
|
|
|
|
* See 'lv_btnm_set_map()' for more info.
|
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
static inline void lv_kb_set_map(lv_obj_t * kb, const char * map[])
|
2017-12-19 22:00:32 +01:00
|
|
|
{
|
|
|
|
lv_btnm_set_map(kb, map);
|
|
|
|
}
|
2017-08-23 14:15:33 +02:00
|
|
|
|
2019-04-03 15:47:36 +02:00
|
|
|
/**
|
|
|
|
* Set the button control map (hidden, disabled etc.) for the keyboard. The
|
|
|
|
* control map array will be copied and so may be deallocated after this
|
|
|
|
* function returns.
|
|
|
|
* @param kb pointer to a keyboard object
|
|
|
|
* @param ctrl_map pointer to an array of `lv_btn_ctrl_t` control bytes.
|
|
|
|
* See: `lv_btnm_set_ctrl_map` for more details.
|
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
static inline void lv_kb_set_ctrl_map(lv_obj_t * kb, const lv_btnm_ctrl_t * ctrl_map)
|
2019-04-03 15:47:36 +02:00
|
|
|
{
|
|
|
|
lv_btnm_set_ctrl_map(kb, ctrl_map);
|
|
|
|
}
|
|
|
|
|
2017-11-10 15:01:40 +01:00
|
|
|
/**
|
2017-11-15 15:50:33 +01:00
|
|
|
* Set a style of a keyboard
|
2017-11-10 15:01:40 +01:00
|
|
|
* @param kb pointer to a keyboard object
|
2017-11-15 15:50:33 +01:00
|
|
|
* @param type which style should be set
|
|
|
|
* @param style pointer to a style
|
2017-11-10 15:01:40 +01:00
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
void lv_kb_set_style(lv_obj_t * kb, lv_kb_style_t type, lv_style_t * style);
|
2017-11-10 15:01:40 +01:00
|
|
|
|
|
|
|
/*=====================
|
|
|
|
* Getter functions
|
|
|
|
*====================*/
|
|
|
|
|
2017-08-23 14:15:33 +02:00
|
|
|
/**
|
|
|
|
* Assign a Text Area to the Keyboard. The pressed characters will be put there.
|
|
|
|
* @param kb pointer to a Keyboard object
|
|
|
|
* @return pointer to the assigned Text Area object
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
lv_obj_t * lv_kb_get_ta(const lv_obj_t * kb);
|
2017-11-10 15:01:40 +01:00
|
|
|
|
2017-08-23 14:15:33 +02:00
|
|
|
/**
|
|
|
|
* Set a new a mode (text or number map)
|
|
|
|
* @param kb pointer to a Keyboard object
|
|
|
|
* @return the current mode from 'lv_kb_mode_t'
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
lv_kb_mode_t lv_kb_get_mode(const lv_obj_t * kb);
|
2017-08-23 14:15:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the current cursor manage mode.
|
|
|
|
* @param kb pointer to a Keyboard object
|
|
|
|
* @return true: show cursor on the current text area, false: hide cursor
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
bool lv_kb_get_cursor_manage(const lv_obj_t * kb);
|
2017-08-23 14:15:33 +02:00
|
|
|
|
2017-11-05 00:48:57 +01:00
|
|
|
/**
|
2017-11-15 15:50:33 +01:00
|
|
|
* Get a style of a keyboard
|
2017-11-05 00:48:57 +01:00
|
|
|
* @param kb pointer to a keyboard object
|
2017-11-15 15:50:33 +01:00
|
|
|
* @param type which style should be get
|
|
|
|
* @return style pointer to a style
|
2017-11-05 00:48:57 +01:00
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
lv_style_t * lv_kb_get_style(const lv_obj_t * kb, lv_kb_style_t type);
|
2017-11-05 00:48:57 +01:00
|
|
|
|
2019-03-27 00:48:35 +01:00
|
|
|
/*=====================
|
|
|
|
* Other functions
|
|
|
|
*====================*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default keyboard event to add characters to the Text area and change the map.
|
2019-04-04 07:15:40 +02:00
|
|
|
* If a custom `event_cb` is added to the keyboard this function be called from it to handle the
|
|
|
|
* button clicks
|
2019-03-27 00:48:35 +01:00
|
|
|
* @param kb pointer to a keyboard
|
|
|
|
* @param event the triggering event
|
|
|
|
*/
|
|
|
|
void lv_kb_def_event_cb(lv_obj_t * kb, lv_event_t event);
|
|
|
|
|
2017-08-23 09:24:23 +02:00
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
2019-04-04 07:15:40 +02:00
|
|
|
#endif /*LV_USE_KB*/
|
2017-08-23 09:24:23 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
|
|
|
#endif
|
|
|
|
|
2019-04-04 07:15:40 +02:00
|
|
|
#endif /*LV_KB_H*/
|