[Tizen] Add codes for Dali Windows Backend
[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 <Ecore_IMF.h>\r
23 //#include <Ecore_X.h>\r
24 \r
25 #include <dali/public-api/object/base-object.h>\r
26 \r
27 // INTERNAL INCLUDES\r
28 #include <dali/devel-api/adaptor-framework/input-method-context.h>\r
29 #include <dali/internal/input/common/input-method-context-impl.h>\r
30 \r
31 typedef unsigned int   Ecore_X_Window;\r
32 \r
33 namespace Dali\r
34 {\r
35 \r
36 class RenderSurface;\r
37 \r
38 namespace Internal\r
39 {\r
40 \r
41 namespace Adaptor\r
42 {\r
43 \r
44 class InputMethodContextWin : public Dali::Internal::Adaptor::InputMethodContext\r
45 {\r
46 public:\r
47   /**\r
48    * @brief Creates a new InputMethodContext handle\r
49    *\r
50    * @return InputMethodContext pointer\r
51    */\r
52   static InputMethodContextPtr New();\r
53 \r
54   /**\r
55    * Constructor\r
56    * @param[in] ecoreXwin, The window is created by application.\r
57    */\r
58   explicit InputMethodContextWin( Ecore_X_Window ecoreXwin );\r
59 \r
60 public:\r
61 \r
62   /**\r
63    * @brief Initializes member data.\r
64    */\r
65   void Initialize() override;\r
66 \r
67   /**\r
68    * Connect Callbacks required for InputMethodContext.\r
69    * If you don't connect InputMethodContext callbacks, you can't get the key events.\r
70    * The events are PreeditChanged, Commit and DeleteSurrounding.\r
71    */\r
72   void ConnectCallbacks() override;\r
73 \r
74   /**\r
75    * Disconnect Callbacks attached to input method context.\r
76    */\r
77   void DisconnectCallbacks() override;\r
78 \r
79   /**\r
80    * @copydoc Dali::InputMethodContext::Finalize()\r
81    */\r
82   void Finalize() override;\r
83 \r
84   /**\r
85    * @copydoc Dali::InputMethodContext::Activate()\r
86    */\r
87   void Activate() override;\r
88 \r
89   /**\r
90    * @copydoc Dali::InputMethodContext::Deactivate()\r
91    */\r
92   void Deactivate() override;\r
93 \r
94   /**\r
95    * @copydoc Dali::InputMethodContext::Reset()\r
96    */\r
97   void Reset() override;\r
98 \r
99   /**\r
100    * @copydoc Dali::InputMethodContext::GetContext()\r
101    */\r
102   ImfContext* GetContext() override;\r
103 \r
104   /**\r
105    * @copydoc Dali::InputMethodContext::RestoreAfterFocusLost()\r
106    */\r
107   bool RestoreAfterFocusLost() const override;\r
108 \r
109   /**\r
110    * @copydoc Dali::InputMethodContext::SetRestoreAfterFocusLost()\r
111    */\r
112   void SetRestoreAfterFocusLost( bool toggle ) override;\r
113 \r
114   /**\r
115    * @copydoc Dali::InputMethodContext::PreEditChanged()\r
116    */\r
117   void PreEditChanged( void* data, ImfContext* imfContext, void* event_info ) override;\r
118 \r
119   /**\r
120    * @copydoc Dali::InputMethodContext::NotifyCursorPosition()\r
121    */\r
122   void CommitReceived( void* data, ImfContext* imfContext, void* event_info ) override;\r
123 \r
124   /**\r
125    * @copydoc Dali::InputMethodContext::NotifyCursorPosition()\r
126    */\r
127   bool RetrieveSurrounding( void* data, ImfContext* imfContext, char** text, int* cursorPosition ) override;\r
128 \r
129   /**\r
130    * @copydoc Dali::InputMethodContext::DeleteSurrounding()\r
131    */\r
132   void DeleteSurrounding( void* data, ImfContext* imfContext, void* event_info ) override;\r
133 \r
134   /**\r
135    * @copydoc Dali::InputMethodContext::SendPrivateCommand()\r
136    */\r
137   void SendPrivateCommand( void* data, ImfContext* imfContext, void* event_info ) override\r
138   {}\r
139 \r
140   // Cursor related\r
141   /**\r
142    * @copydoc Dali::InputMethodContext::NotifyCursorPosition()\r
143    */\r
144   void NotifyCursorPosition() override;\r
145 \r
146   /**\r
147    * @copydoc Dali::InputMethodContext::SetCursorPosition()\r
148    */\r
149   void SetCursorPosition( unsigned int cursorPosition ) override;\r
150 \r
151   /**\r
152    * @copydoc Dali::InputMethodContext::GetCursorPosition()\r
153    */\r
154   unsigned int GetCursorPosition() const override;\r
155 \r
156   /**\r
157    * @copydoc Dali::InputMethodContext::SetSurroundingText()\r
158    */\r
159   void SetSurroundingText( const std::string& text ) override;\r
160 \r
161   /**\r
162    * @copydoc Dali::InputMethodContext::GetSurroundingText()\r
163    */\r
164   const std::string& GetSurroundingText() const override;\r
165 \r
166   /**\r
167   * @copydoc Dali::InputMethodContext::NotifyTextInputMultiLine()\r
168   */\r
169   void NotifyTextInputMultiLine( bool multiLine ) override;\r
170 \r
171   /**\r
172   * @copydoc Dali::InputMethodContext::GetTextDirection()\r
173   */\r
174   Dali::InputMethodContext::TextDirection GetTextDirection() override;\r
175 \r
176   /**\r
177   * @copydoc Dali::InputMethodContext::GetInputMethodArea()\r
178   */\r
179   Dali::Rect<int> GetInputMethodArea() override;\r
180 \r
181   /**\r
182   * @copydoc Dali::InputMethodContext::ApplyOptions()\r
183   */\r
184   void ApplyOptions( const InputMethodOptions& options ) override;\r
185 \r
186   /**\r
187    * @copydoc Dali::InputMethodContext::SetInputPanelData()\r
188    */\r
189   void SetInputPanelData( const std::string& data ) override;\r
190 \r
191   /**\r
192    * @copydoc Dali::InputMethodContext::GetInputPanelData()\r
193    */\r
194   void GetInputPanelData( std::string& data ) override;\r
195 \r
196   /**\r
197    * @copydoc Dali::InputMethodContext::GetInputPanelState()\r
198    */\r
199   Dali::InputMethodContext::State GetInputPanelState() override;\r
200 \r
201   /**\r
202    * @copydoc Dali::InputMethodContext::SetReturnKeyState()\r
203    */\r
204   void SetReturnKeyState( bool visible ) override;\r
205 \r
206   /**\r
207    * @copydoc Dali::InputMethodContext::AutoEnableInputPanel()\r
208    */\r
209   void AutoEnableInputPanel( bool enabled ) override;\r
210 \r
211   /**\r
212    * @copydoc Dali::InputMethodContext::ShowInputPanel()\r
213    */\r
214   void ShowInputPanel() override;\r
215 \r
216   /**\r
217    * @copydoc Dali::InputMethodContext::HideInputPanel()\r
218    */\r
219   void HideInputPanel() override;\r
220 \r
221   /**\r
222    * @copydoc Dali::InputMethodContext::GetKeyboardType()\r
223    */\r
224   Dali::InputMethodContext::KeyboardType GetKeyboardType() override;\r
225 \r
226   /**\r
227    * @copydoc Dali::InputMethodContext::GetInputPanelLocale()\r
228    */\r
229   std::string GetInputPanelLocale() override;\r
230 \r
231   /**\r
232    * @copydoc Dali::InputMethodContext::FilterEventKey()\r
233    */\r
234   bool FilterEventKey( const Dali::KeyEvent& keyEvent ) override;\r
235 \r
236 private:\r
237   /**\r
238    * Context created the first time and kept until deleted.\r
239    * @param[in] ecoreXwin, The window is created by application.\r
240    */\r
241   void CreateContext( Ecore_X_Window ecoreXwin );\r
242 \r
243   /**\r
244    * @copydoc Dali::InputMethodContext::DeleteContext()\r
245    */\r
246   void DeleteContext();\r
247 \r
248 private:\r
249 \r
250   /**\r
251    * @brief Process event key down, whether filter a key to isf.\r
252    *\r
253    * @param[in] keyEvent The event key to be handled.\r
254    * @return Whether the event key is handled.\r
255    */\r
256   bool ProcessEventKeyDown( const KeyEvent& keyEvent );\r
257 \r
258   /**\r
259    * @brief Process event key up, whether filter a key to isf.\r
260    *\r
261    * @param[in] keyEvent The event key to be handled.\r
262    * @return Whether the event key is handled.\r
263    */\r
264   bool ProcessEventKeyUp( const KeyEvent& keyEvent );\r
265 \r
266   ///**\r
267   //* Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.\r
268   //* This function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Modifiers enums.\r
269   //* @param[in] ecoreModifier the Ecore_Event_Modifier input.\r
270   //* @return the Ecore_IMF_Keyboard_Modifiers output.\r
271   //*/\r
272   //Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier( unsigned int ecoreModifier );\r
273 \r
274   ///**\r
275   // * EcoreInputModifierToEcoreIMFLock function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Locks enums.\r
276   // * @param[in] modifier the Ecore_Event_Modifier input.\r
277   // * @return the Ecore_IMF_Keyboard_Locks output.\r
278   // */\r
279   //Ecore_IMF_Keyboard_Locks EcoreInputModifierToEcoreIMFLock( unsigned int modifier );\r
280 \r
281 public:\r
282 \r
283   /**\r
284    * Destructor.\r
285    */\r
286   virtual ~InputMethodContextWin();\r
287 \r
288 private:\r
289 \r
290   // Undefined copy constructor\r
291   InputMethodContextWin( const InputMethodContextWin& inputMethodContext) = delete;\r
292 \r
293   // Undefined assignment operator\r
294   InputMethodContextWin& operator=( const InputMethodContextWin& inputMethodContext ) = delete;\r
295 \r
296 private:\r
297   //Ecore_IMF_Context* mIMFContext;\r
298   Ecore_X_Window mEcoreXwin;\r
299   int mIMFCursorPosition;\r
300   std::string mSurroundingText;\r
301 \r
302   bool mRestoreAfterFocusLost:1;             ///< Whether the keyboard needs to be restored (activated ) after focus regained.\r
303   bool mIdleCallbackConnected:1;             ///< Whether the idle callback is already connected.\r
304   InputMethodOptions        mOptions;\r
305 };\r
306 \r
307 } // namespace Adaptor\r
308 \r
309 } // namespace Internal\r
310 \r
311 } // namespace Dali\r
312 \r
313 #endif // __DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_X_H\r