Merge remote-tracking branch 'origin/tizen' into devel/new_mesh
[platform/core/uifw/dali-adaptor.git] / adaptors / devel-api / adaptor-framework / virtual-keyboard.h
1 #ifndef __DALI_VIRTUAL_KEYBOARD_H__
2 #define __DALI_VIRTUAL_KEYBOARD_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/signals/dali-signal.h>
23 #include <dali/public-api/math/rect.h>
24
25 namespace Dali
26 {
27
28 /**
29  * @brief This namespace is provided for application developers to be able to show and hide the on-screen keyboard.
30  *
31  * Key events are sent to the actor in focus. Focus is set through the actor Public API.
32  */
33 namespace VirtualKeyboard
34 {
35
36 // Types
37
38 typedef Signal< void () > VoidSignalType;
39 typedef Signal< void (bool) > StatusSignalType;
40
41 // Enumerations
42
43 /**
44  * @brief The direction of text.
45  */
46 enum TextDirection
47 {
48   LeftToRight,
49   RightToLeft,
50 };
51
52 /**
53  * @brief The meaning of the return key.
54  */
55 enum ReturnKeyType
56 {
57   DEFAULT,
58   DONE,
59   GO,
60   JOIN,
61   LOGIN,
62   NEXT,
63   SEARCH,
64   SEND,
65   SIGNIN
66 };
67
68 // Functions
69 /**
70  * @brief Show the virtual keyboard.
71  */
72 DALI_IMPORT_API void Show();
73
74 /**
75  * @brief Hide the virtual keyboard.
76  */
77 DALI_IMPORT_API void Hide();
78
79 /**
80  * @brief Returns whether the virtual keyboard is visible or not.
81  * @return true if visible, false otherwise.
82  */
83 DALI_IMPORT_API bool IsVisible();
84
85 /**
86  * @brief Set the specific return key into the virtual keyboard.
87  * @param[in] type the kind of return key types.
88  */
89 DALI_IMPORT_API void SetReturnKeyType( ReturnKeyType type );
90
91 /**
92  * @brief Retrieve the current return key type.
93  * @return the type of retun key.
94  */
95 DALI_IMPORT_API ReturnKeyType GetReturnKeyType();
96
97 /**
98  * @brief Enable/disable prediction (predictive text).
99  *
100  * By default prediction text is enabled.
101  * @param[in] enable true or false to enable or disable
102  * Prediction can not be changed while the keyboard is visible. It must be set in advance of showing keyboard.
103  */
104 DALI_IMPORT_API void EnablePrediction(const bool enable);
105
106 /**
107  * @brief Returns whether prediction is enabled in the virtual keyboard
108  * @return true if predictive text enabled, false otherwise.
109  */
110 DALI_IMPORT_API bool IsPredictionEnabled();
111
112 /**
113  * @brief Provides size and position of keyboard.
114  *
115  * Position is relative to whether keyboard is visible or not.
116  * If keyboard is not visible then position will be off the screen.
117  * If keyboard is not being shown when this method is called the keyboard is partially setup (IMFContext) to get
118  * the values then taken down.  So ideally GetSizeAndPosition() should be called after Show().
119  * @return rect which is keyboard panel x, y, width, height
120  */
121 DALI_IMPORT_API Dali::Rect<int> GetSizeAndPosition();
122
123 /**
124  * @brief Rotates the keyboard orientation to the given angle.
125  *
126  * A value of 0 indicates the portrait orientation.
127  * Other valid values are 90, 180, 270.
128  * @param angle the angle is in degrees.
129  */
130 DALI_IMPORT_API void RotateTo(int angle);
131
132 /**
133  * @brief Returns text direction of the keyboard's current input language.
134  * @return The direction of the text.
135  */
136 DALI_IMPORT_API TextDirection GetTextDirection();
137
138 /**
139  * @brief Connect to this signal to be notified when the virtual keyboard is shown or hidden.
140  *
141  * A callback of the following type may be connected:
142  * @code
143  *   void YourCallbackName(bool keyboardShown);
144  * @endcode
145  * If the parameter keyboardShown is true, then the keyboard has just shown, if it is false, then it
146  * has just been hidden.
147  * @return The signal to connect to.
148  */
149 DALI_IMPORT_API StatusSignalType& StatusChangedSignal();
150
151 /**
152  * @brief Connect to this signal to be notified when the virtual keyboard is resized.
153  *
154  * A callback of the following type may be connected:
155  * @code
156  *   void YourCallbackName();
157  * @endcode
158  * User can get changed size by using GetSizeAndPosition() in the callback
159  * @return The signal to connect to.
160  */
161 DALI_IMPORT_API VoidSignalType& ResizedSignal();
162
163 /**
164  * @brief Connect to this signal to be notified when the virtual keyboard's language is changed.
165  *
166  * A callback of the following type may be connected:
167  * @code
168  *   void YourCallbackName();
169  * @endcode
170  * User can get the text direction of the language by calling GetTextDirection() in the callback.
171  * @return The signal to connect to.
172  */
173 DALI_IMPORT_API VoidSignalType& LanguageChangedSignal();
174
175 } // namespace VirtualKeyboard
176
177 } // namespace Dali
178
179 #endif // __DALI_VIRTUAL_KEYBOARD_H__