[dali_2.3.37] Merge branch 'devel/master'
[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) 2022 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 class RenderSurface;\r
32 \r
33 namespace Internal\r
34 {\r
35 namespace Adaptor\r
36 {\r
37 class InputMethodContextWin : public Dali::Internal::Adaptor::InputMethodContext, public Dali::ConnectionTracker\r
38 {\r
39 public:\r
40   /**\r
41    * @brief Creates a new InputMethodContext handle\r
42    *\r
43    * @param[in] actor The actor that uses the new InputMethodContext instance.\r
44    * @return InputMethodContext pointer\r
45    */\r
46   static InputMethodContextPtr New(Dali::Actor actor);\r
47 \r
48   /**\r
49    * Constructor\r
50    * @param[in] win32Window, The window is created by application.\r
51    */\r
52   explicit InputMethodContextWin(Dali::Actor actor);\r
53 \r
54 public:\r
55   /**\r
56    * @brief Initializes member data.\r
57    */\r
58   void Initialize() override;\r
59 \r
60   /**\r
61    * Connect Callbacks required for InputMethodContext.\r
62    * If you don't connect InputMethodContext callbacks, you can't get the key events.\r
63    * The events are PreeditChanged, Commit and DeleteSurrounding.\r
64    */\r
65   void ConnectCallbacks() override;\r
66 \r
67   /**\r
68    * Disconnect Callbacks attached to input method context.\r
69    */\r
70   void DisconnectCallbacks() override;\r
71 \r
72   /**\r
73    * @copydoc Dali::InputMethodContext::Finalize()\r
74    */\r
75   void Finalize() override;\r
76 \r
77   /**\r
78    * @copydoc Dali::InputMethodContext::Activate()\r
79    */\r
80   void Activate() override;\r
81 \r
82   /**\r
83    * @copydoc Dali::InputMethodContext::Deactivate()\r
84    */\r
85   void Deactivate() override;\r
86 \r
87   /**\r
88    * @copydoc Dali::InputMethodContext::Reset()\r
89    */\r
90   void Reset() override;\r
91 \r
92   /**\r
93    * @copydoc Dali::InputMethodContext::GetContext()\r
94    */\r
95   ImfContext* GetContext() override;\r
96 \r
97   /**\r
98    * @copydoc Dali::InputMethodContext::RestoreAfterFocusLost()\r
99    */\r
100   bool RestoreAfterFocusLost() const override;\r
101 \r
102   /**\r
103    * @copydoc Dali::InputMethodContext::SetRestoreAfterFocusLost()\r
104    */\r
105   void SetRestoreAfterFocusLost(bool toggle) override;\r
106 \r
107   /**\r
108    * @copydoc Dali::InputMethodContext::PreEditChanged()\r
109    */\r
110   void PreEditChanged(void* data, ImfContext* imfContext, void* eventInfo) override;\r
111 \r
112   /**\r
113    * @copydoc Dali::InputMethodContext::NotifyCursorPosition()\r
114    */\r
115   void CommitReceived(void* data, ImfContext* imfContext, void* eventInfo) override;\r
116 \r
117   /**\r
118    * @copydoc Dali::InputMethodContext::NotifyCursorPosition()\r
119    */\r
120   bool RetrieveSurrounding(void* data, ImfContext* imfContext, char** text, int* cursorPosition) override;\r
121 \r
122   /**\r
123    * @copydoc Dali::InputMethodContext::DeleteSurrounding()\r
124    */\r
125   void DeleteSurrounding(void* data, ImfContext* imfContext, void* eventInfo) override;\r
126 \r
127   /**\r
128    * @copydoc Dali::InputMethodContext::SendPrivateCommand()\r
129    */\r
130   void SendPrivateCommand(void* data, ImfContext* imfContext, void* eventInfo) override\r
131   {\r
132   }\r
133 \r
134   /**\r
135    * @copydoc Dali::InputMethodContext::SendCommitContent()\r
136    */\r
137   void SendCommitContent(void* data, ImfContext* imfContext, void* eventInfo) override\r
138   {\r
139   }\r
140 \r
141   /**\r
142    * @copydoc Dali::InputMethodContext::SendSelectionSet()\r
143    */\r
144   void SendSelectionSet(void* data, ImfContext* imfContext, void* eventInfo) override\r
145   {\r
146   }\r
147 \r
148   // Cursor related\r
149   /**\r
150    * @copydoc Dali::InputMethodContext::NotifyCursorPosition()\r
151    */\r
152   void NotifyCursorPosition() override;\r
153 \r
154   /**\r
155    * @copydoc Dali::InputMethodContext::SetCursorPosition()\r
156    */\r
157   void SetCursorPosition(unsigned int cursorPosition) override;\r
158 \r
159   /**\r
160    * @copydoc Dali::InputMethodContext::GetCursorPosition()\r
161    */\r
162   unsigned int GetCursorPosition() const override;\r
163 \r
164   /**\r
165    * @copydoc Dali::InputMethodContext::SetSurroundingText()\r
166    */\r
167   void SetSurroundingText(const std::string& text) override;\r
168 \r
169   /**\r
170    * @copydoc Dali::InputMethodContext::GetSurroundingText()\r
171    */\r
172   const std::string& GetSurroundingText() const override;\r
173 \r
174   /**\r
175   * @copydoc Dali::InputMethodContext::NotifyTextInputMultiLine()\r
176   */\r
177   void NotifyTextInputMultiLine(bool multiLine) override;\r
178 \r
179   /**\r
180   * @copydoc Dali::InputMethodContext::GetTextDirection()\r
181   */\r
182   Dali::InputMethodContext::TextDirection GetTextDirection() override;\r
183 \r
184   /**\r
185   * @copydoc Dali::InputMethodContext::GetInputMethodArea()\r
186   */\r
187   Dali::Rect<int> GetInputMethodArea() override;\r
188 \r
189   /**\r
190   * @copydoc Dali::InputMethodContext::ApplyOptions()\r
191   */\r
192   void ApplyOptions(const InputMethodOptions& options) override;\r
193 \r
194   /**\r
195    * @copydoc Dali::InputMethodContext::SetInputPanelData()\r
196    */\r
197   void SetInputPanelData(const std::string& data) override;\r
198 \r
199   /**\r
200    * @copydoc Dali::InputMethodContext::GetInputPanelData()\r
201    */\r
202   void GetInputPanelData(std::string& data) override;\r
203 \r
204   /**\r
205    * @copydoc Dali::InputMethodContext::GetInputPanelState()\r
206    */\r
207   Dali::InputMethodContext::State GetInputPanelState() override;\r
208 \r
209   /**\r
210    * @copydoc Dali::InputMethodContext::SetReturnKeyState()\r
211    */\r
212   void SetReturnKeyState(bool visible) override;\r
213 \r
214   /**\r
215    * @copydoc Dali::InputMethodContext::AutoEnableInputPanel()\r
216    */\r
217   void AutoEnableInputPanel(bool enabled) override;\r
218 \r
219   /**\r
220    * @copydoc Dali::InputMethodContext::ShowInputPanel()\r
221    */\r
222   void ShowInputPanel() override;\r
223 \r
224   /**\r
225    * @copydoc Dali::InputMethodContext::HideInputPanel()\r
226    */\r
227   void HideInputPanel() override;\r
228 \r
229   /**\r
230    * @copydoc Dali::InputMethodContext::GetKeyboardType()\r
231    */\r
232   Dali::InputMethodContext::KeyboardType GetKeyboardType() override;\r
233 \r
234   /**\r
235    * @copydoc Dali::InputMethodContext::GetInputPanelLocale()\r
236    */\r
237   std::string GetInputPanelLocale() override;\r
238 \r
239   /**\r
240    * @copydoc Dali::InputMethodContext::SetContentMIMETypes()\r
241    */\r
242   void SetContentMIMETypes(const std::string& mimeTypes) override;\r
243 \r
244   /**\r
245    * @copydoc Dali::InputMethodContext::FilterEventKey()\r
246    */\r
247   bool FilterEventKey(const Dali::KeyEvent& keyEvent) override;\r
248 \r
249   /**\r
250    * @copydoc Dali::InputMethodContext::SetInputPanelLanguage()\r
251    */\r
252   void SetInputPanelLanguage(Dali::InputMethodContext::InputPanelLanguage language) override;\r
253 \r
254   /**\r
255    * @copydoc Dali::InputMethodContext::GetInputPanelLanguage()\r
256    */\r
257   Dali::InputMethodContext::InputPanelLanguage GetInputPanelLanguage() const override;\r
258 \r
259   /**\r
260    * @copydoc Dali::InputMethodContext::SetInputPanelPosition()\r
261    */\r
262   void SetInputPanelPosition(unsigned int x, unsigned int y) override;\r
263 \r
264   /**\r
265    * @copydoc Dali::InputMethodContext::SetInputPanelPositionAlign()\r
266    */\r
267   bool SetInputPanelPositionAlign(int x, int y, Dali::InputMethodContext::InputPanelAlign align) override;\r
268 \r
269   /**\r
270    * @copydoc Dali::InputMethodContext::GetPreeditStyle()\r
271    */\r
272   void GetPreeditStyle(Dali::InputMethodContext::PreEditAttributeDataContainer& attrs) const override;\r
273 \r
274 private:\r
275   /**\r
276    * Context created the first time and kept until deleted.\r
277    * @param[in] win32Window, The window is created by application.\r
278    */\r
279   void CreateContext(WinWindowHandle win32Window);\r
280 \r
281   /**\r
282    * @copydoc Dali::InputMethodContext::DeleteContext()\r
283    */\r
284   void DeleteContext();\r
285 \r
286 private:\r
287   /**\r
288    * @brief Process event key down, whether filter a key to isf.\r
289    *\r
290    * @param[in] keyEvent The event key to be handled.\r
291    * @return Whether the event key is handled.\r
292    */\r
293   bool ProcessEventKeyDown(const Dali::KeyEvent& keyEvent);\r
294 \r
295   /**\r
296    * @brief Process event key up, whether filter a key to isf.\r
297    *\r
298    * @param[in] keyEvent The event key to be handled.\r
299    * @return Whether the event key is handled.\r
300    */\r
301   bool ProcessEventKeyUp(const Dali::KeyEvent& keyEvent);\r
302 \r
303   /**\r
304    * Called when the binded actor is added to a window.\r
305    */\r
306   void OnStaged(Dali::Actor actor);\r
307 \r
308 public:\r
309   /**\r
310    * Destructor.\r
311    */\r
312   virtual ~InputMethodContextWin();\r
313 \r
314 private:\r
315   // Undefined copy constructor\r
316   InputMethodContextWin(const InputMethodContextWin& inputMethodContext) = delete;\r
317 \r
318   // Undefined assignment operator\r
319   InputMethodContextWin& operator=(const InputMethodContextWin& inputMethodContext) = delete;\r
320 \r
321 private:\r
322   WinWindowHandle mWin32Window;\r
323   int             mIMFCursorPosition;\r
324   std::string     mSurroundingText;\r
325 \r
326   bool               mRestoreAfterFocusLost : 1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.\r
327   bool               mIdleCallbackConnected : 1; ///< Whether the idle callback is already connected.\r
328   InputMethodOptions mOptions;\r
329 \r
330   Dali::InputMethodContext::PreEditAttributeDataContainer mPreeditAttrs; ///< Stores preedit attribute data\r
331 };\r
332 \r
333 } // namespace Adaptor\r
334 \r
335 } // namespace Internal\r
336 \r
337 } // namespace Dali\r
338 \r
339 #endif // DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_WIN_H\r