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