3d0d3950219ee897443d640c2c0c737ec79c07fa
[platform/core/uifw/dali-adaptor.git] / dali / internal / input / windows / input-method-context-impl-win.h
1 #ifndef DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_WIN_H\r
2 #define DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_WIN_H\r
3 \r
4 /*\r
5  * Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
6  *\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  *\r
11  * http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  *\r
19  */\r
20 \r
21 // EXTERNAL INCLUDES\r
22 #include <dali/public-api/object/base-object.h>\r
23 \r
24 // INTERNAL INCLUDES\r
25 #include <dali/devel-api/adaptor-framework/input-method-context.h>\r
26 #include <dali/internal/input/common/input-method-context-impl.h>\r
27 #include <dali/internal/window-system/windows/platform-implement-win.h>\r
28 \r
29 namespace Dali\r
30 {\r
31 \r
32 class RenderSurface;\r
33 \r
34 namespace Internal\r
35 {\r
36 \r
37 namespace Adaptor\r
38 {\r
39 \r
40 class InputMethodContextWin : public Dali::Internal::Adaptor::InputMethodContext\r
41 {\r
42 public:\r
43   /**\r
44    * @brief Creates a new InputMethodContext handle\r
45    *\r
46    * @return InputMethodContext pointer\r
47    */\r
48   static InputMethodContextPtr New();\r
49 \r
50   /**\r
51    * Constructor\r
52    * @param[in] win32Window, The window is created by application.\r
53    */\r
54   explicit InputMethodContextWin( Win_Window_Handle win32Window );\r
55 \r
56 public:\r
57 \r
58   /**\r
59    * @brief Initializes member data.\r
60    */\r
61   void Initialize() override;\r
62 \r
63   /**\r
64    * Connect Callbacks required for InputMethodContext.\r
65    * If you don't connect InputMethodContext callbacks, you can't get the key events.\r
66    * The events are PreeditChanged, Commit and DeleteSurrounding.\r
67    */\r
68   void ConnectCallbacks() override;\r
69 \r
70   /**\r
71    * Disconnect Callbacks attached to input method context.\r
72    */\r
73   void DisconnectCallbacks() override;\r
74 \r
75   /**\r
76    * @copydoc Dali::InputMethodContext::Finalize()\r
77    */\r
78   void Finalize() override;\r
79 \r
80   /**\r
81    * @copydoc Dali::InputMethodContext::Activate()\r
82    */\r
83   void Activate() override;\r
84 \r
85   /**\r
86    * @copydoc Dali::InputMethodContext::Deactivate()\r
87    */\r
88   void Deactivate() override;\r
89 \r
90   /**\r
91    * @copydoc Dali::InputMethodContext::Reset()\r
92    */\r
93   void Reset() override;\r
94 \r
95   /**\r
96    * @copydoc Dali::InputMethodContext::GetContext()\r
97    */\r
98   ImfContext* GetContext() override;\r
99 \r
100   /**\r
101    * @copydoc Dali::InputMethodContext::RestoreAfterFocusLost()\r
102    */\r
103   bool RestoreAfterFocusLost() const override;\r
104 \r
105   /**\r
106    * @copydoc Dali::InputMethodContext::SetRestoreAfterFocusLost()\r
107    */\r
108   void SetRestoreAfterFocusLost( bool toggle ) override;\r
109 \r
110   /**\r
111    * @copydoc Dali::InputMethodContext::PreEditChanged()\r
112    */\r
113   void PreEditChanged( void* data, ImfContext* imfContext, void* event_info ) override;\r
114 \r
115   /**\r
116    * @copydoc Dali::InputMethodContext::NotifyCursorPosition()\r
117    */\r
118   void CommitReceived( void* data, ImfContext* imfContext, void* event_info ) override;\r
119 \r
120   /**\r
121    * @copydoc Dali::InputMethodContext::NotifyCursorPosition()\r
122    */\r
123   bool RetrieveSurrounding( void* data, ImfContext* imfContext, char** text, int* cursorPosition ) override;\r
124 \r
125   /**\r
126    * @copydoc Dali::InputMethodContext::DeleteSurrounding()\r
127    */\r
128   void DeleteSurrounding( void* data, ImfContext* imfContext, void* event_info ) override;\r
129 \r
130   /**\r
131    * @copydoc Dali::InputMethodContext::SendPrivateCommand()\r
132    */\r
133   void SendPrivateCommand( void* data, ImfContext* imfContext, void* event_info ) override\r
134   {}\r
135 \r
136   // Cursor related\r
137   /**\r
138    * @copydoc Dali::InputMethodContext::NotifyCursorPosition()\r
139    */\r
140   void NotifyCursorPosition() override;\r
141 \r
142   /**\r
143    * @copydoc Dali::InputMethodContext::SetCursorPosition()\r
144    */\r
145   void SetCursorPosition( unsigned int cursorPosition ) override;\r
146 \r
147   /**\r
148    * @copydoc Dali::InputMethodContext::GetCursorPosition()\r
149    */\r
150   unsigned int GetCursorPosition() const override;\r
151 \r
152   /**\r
153    * @copydoc Dali::InputMethodContext::SetSurroundingText()\r
154    */\r
155   void SetSurroundingText( const std::string& text ) override;\r
156 \r
157   /**\r
158    * @copydoc Dali::InputMethodContext::GetSurroundingText()\r
159    */\r
160   const std::string& GetSurroundingText() const override;\r
161 \r
162   /**\r
163   * @copydoc Dali::InputMethodContext::NotifyTextInputMultiLine()\r
164   */\r
165   void NotifyTextInputMultiLine( bool multiLine ) override;\r
166 \r
167   /**\r
168   * @copydoc Dali::InputMethodContext::GetTextDirection()\r
169   */\r
170   Dali::InputMethodContext::TextDirection GetTextDirection() override;\r
171 \r
172   /**\r
173   * @copydoc Dali::InputMethodContext::GetInputMethodArea()\r
174   */\r
175   Dali::Rect<int> GetInputMethodArea() override;\r
176 \r
177   /**\r
178   * @copydoc Dali::InputMethodContext::ApplyOptions()\r
179   */\r
180   void ApplyOptions( const InputMethodOptions& options ) override;\r
181 \r
182   /**\r
183    * @copydoc Dali::InputMethodContext::SetInputPanelData()\r
184    */\r
185   void SetInputPanelData( const std::string& data ) override;\r
186 \r
187   /**\r
188    * @copydoc Dali::InputMethodContext::GetInputPanelData()\r
189    */\r
190   void GetInputPanelData( std::string& data ) override;\r
191 \r
192   /**\r
193    * @copydoc Dali::InputMethodContext::GetInputPanelState()\r
194    */\r
195   Dali::InputMethodContext::State GetInputPanelState() override;\r
196 \r
197   /**\r
198    * @copydoc Dali::InputMethodContext::SetReturnKeyState()\r
199    */\r
200   void SetReturnKeyState( bool visible ) override;\r
201 \r
202   /**\r
203    * @copydoc Dali::InputMethodContext::AutoEnableInputPanel()\r
204    */\r
205   void AutoEnableInputPanel( bool enabled ) override;\r
206 \r
207   /**\r
208    * @copydoc Dali::InputMethodContext::ShowInputPanel()\r
209    */\r
210   void ShowInputPanel() override;\r
211 \r
212   /**\r
213    * @copydoc Dali::InputMethodContext::HideInputPanel()\r
214    */\r
215   void HideInputPanel() override;\r
216 \r
217   /**\r
218    * @copydoc Dali::InputMethodContext::GetKeyboardType()\r
219    */\r
220   Dali::InputMethodContext::KeyboardType GetKeyboardType() override;\r
221 \r
222   /**\r
223    * @copydoc Dali::InputMethodContext::GetInputPanelLocale()\r
224    */\r
225   std::string GetInputPanelLocale() override;\r
226 \r
227   /**\r
228    * @copydoc Dali::InputMethodContext::FilterEventKey()\r
229    */\r
230   bool FilterEventKey( const Dali::KeyEvent& keyEvent ) override;\r
231 \r
232 private:\r
233   /**\r
234    * Context created the first time and kept until deleted.\r
235    * @param[in] win32Window, The window is created by application.\r
236    */\r
237   void CreateContext( Win_Window_Handle win32Window );\r
238 \r
239   /**\r
240    * @copydoc Dali::InputMethodContext::DeleteContext()\r
241    */\r
242   void DeleteContext();\r
243 \r
244 private:\r
245 \r
246   /**\r
247    * @brief Process event key down, whether filter a key to isf.\r
248    *\r
249    * @param[in] keyEvent The event key to be handled.\r
250    * @return Whether the event key is handled.\r
251    */\r
252   bool ProcessEventKeyDown( const KeyEvent& keyEvent );\r
253 \r
254   /**\r
255    * @brief Process event key up, whether filter a key to isf.\r
256    *\r
257    * @param[in] keyEvent The event key to be handled.\r
258    * @return Whether the event key is handled.\r
259    */\r
260   bool ProcessEventKeyUp( const KeyEvent& keyEvent );\r
261 \r
262 public:\r
263 \r
264   /**\r
265    * Destructor.\r
266    */\r
267   virtual ~InputMethodContextWin();\r
268 \r
269 private:\r
270 \r
271   // Undefined copy constructor\r
272   InputMethodContextWin( const InputMethodContextWin& inputMethodContext) = delete;\r
273 \r
274   // Undefined assignment operator\r
275   InputMethodContextWin& operator=( const InputMethodContextWin& inputMethodContext ) = delete;\r
276 \r
277 private:\r
278   Win_Window_Handle mWin32Window;\r
279   int mIMFCursorPosition;\r
280   std::string mSurroundingText;\r
281 \r
282   bool mRestoreAfterFocusLost:1;             ///< Whether the keyboard needs to be restored (activated ) after focus regained.\r
283   bool mIdleCallbackConnected:1;             ///< Whether the idle callback is already connected.\r
284   InputMethodOptions        mOptions;\r
285 };\r
286 \r
287 } // namespace Adaptor\r
288 \r
289 } // namespace Internal\r
290 \r
291 } // namespace Dali\r
292 \r
293 #endif // DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_WIN_H\r