Add new APIs for text input
[platform/core/uifw/libscl-ui-nui.git] / capi / include / cscl-ui-nui.h
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __SCL_CSHARP_NUI_H__
18 #define __SCL_CSHARP_NUI_H__
19
20 #include <tizen.h>
21 #include <cscl-ui-controller.h>
22
23 #define MAX_FONT_NAME_LEN 32
24 #define DEGREE_TO_SCLROTATION(degree) \
25     (degree == 90 ? ROTATION_90_CW : \
26     (degree == 180 ? ROTATION_180 : \
27     (degree == 270 ? ROTATION_90_CCW : \
28     ROTATION_0)))
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 typedef enum _LabelAlignment {
35     LABEL_ALIGN_LEFT_TOP = 0,
36     LABEL_ALIGN_CENTER_TOP,
37     LABEL_ALIGN_RIGHT_TOP,
38     LABEL_ALIGN_LEFT_MIDDLE,
39     LABEL_ALIGN_CENTER_MIDDLE,
40     LABEL_ALIGN_RIGHT_MIDDLE,
41     LABEL_ALIGN_LEFT_BOTTOM,
42     LABEL_ALIGN_CENTER_BOTTOM,
43     LABEL_ALIGN_RIGHT_BOTTOM,
44     MAX_LABEL_ALIGNMENT
45 } LabelAlignment;
46
47 typedef enum _WindowType {
48     WINDOW_KEYPAD,
49     WINDOW_MAGNIFIER,
50     WINDOW_DIM,
51     WINDOW_POPUP,
52     WINDOW_AUTO_POPUP,
53 }WindowType;
54
55 /* graphics backend */
56 typedef void (*scl_nui_draw_text_cb)(const char *font_name, short font_size, bool is_italic, bool is_bold, int r, int g, int b, int a,
57                                      const char *str, int pos_x, int pos_y, int w, int h,
58                                      LabelAlignment align, int padding_x, int padding_y, int inner_width, int inner_height, WindowType type, void* user_data);
59
60 typedef void (*scl_nui_draw_image_cb)(const char *image_path, int dest_x, int dest_y, int dest_weight, int dest_height, int src_x, int src_y, int src_width, int src_height, WindowType type, void* user_data);
61 typedef void (*scl_nui_draw_rectangle_cb)(int pos_x, int pos_y, int width, int height, bool fill, int fill_color_r, int fill_color_g, int fill_color_b, int fill_color_a, SCLWindowType type, void* user_data);
62
63 /* window backend */
64 typedef void (*scl_nui_update_window_cb)(SCLWindowType type, int x, int y, int width, int height, void* user_data);
65 typedef int (*scl_nui_key_click_event_cb)(const char *key_value, unsigned long key_event, int key_type, int key_modifier);
66 typedef int (*scl_nui_drag_state_changed_cb)(const char *key_value, unsigned long key_event, int key_type, int event_type, int current_x, int current_y);
67 typedef int (*scl_nui_event_notification_cb)(SCLUINotiType noti_type, SclNotiDesc *etc_info);
68 typedef void (*scl_nui_update_window_position_cb)(SCLWindowType type, int pos_x, int pos_y, int rot_x, int rot_y, void* user_data);
69
70 int scl_nui_init(const char *entry_filepath);
71 int scl_nui_fini();
72 int scl_nui_show();
73 int scl_nui_hide();
74
75 int scl_nui_get_input_mode(const char **input_mode);
76 int scl_nui_set_input_mode(const char *input_mode);
77 int scl_nui_set_update_pending(bool pend);
78 int scl_nui_set_rotation(int degree);
79
80 int scl_nui_set_draw_text_cb(scl_nui_draw_text_cb callback, void *user_data);
81 int scl_nui_set_draw_image_cb(scl_nui_draw_image_cb callback, void *user_data);
82 int scl_nui_set_draw_rectangle_cb(scl_nui_draw_rectangle_cb callback, void *user_data);
83
84 int scl_nui_set_cur_sublayout(const char *sub_layout_name);
85 int scl_nui_set_string_substitution(const char *original, const char *substitute);
86 int scl_nui_unset_string_substitution(const char *original);
87
88 int scl_nui_set_update_window_cb(scl_nui_update_window_cb callback, void *user_data);
89
90 int scl_nui_set_key_click_event_cb(scl_nui_key_click_event_cb callback);
91 int scl_nui_set_drag_state_changed_cb(scl_nui_drag_state_changed_cb callback);
92 int scl_nui_set_event_notification_cb(scl_nui_event_notification_cb callback);
93 int scl_nui_set_update_window_position_cb(scl_nui_update_window_position_cb callback, void *user_data);
94
95 int scl_nui_enable_magnifier(bool enabled);
96 int scl_nui_enable_sound(bool enabled);
97 int scl_nui_enable_vibration(bool enabled);
98 int scl_nui_set_private_key(const char* custom_id, char* label, char* imagelabel[SCL_BUTTON_STATE_MAX], char* imagebg[SCL_BUTTON_STATE_MAX], unsigned long key_event, char *key_value, bool redraw);
99 int scl_nui_unset_private_key(const char* custom_id);
100 int scl_nui_enable_button(const char* custom_id, bool enabled);
101 int scl_nui_get_shift_state(unsigned int *state);
102 int scl_nui_set_shift_state(unsigned int state);
103 int scl_nui_set_autocapital_shift_state(bool state);
104 int scl_nui_disable_input_event(bool disable);
105
106 #ifdef __cplusplus
107 }
108 #endif
109
110 #endif /* __SCL_CSHARP_NUI_H__ */