ff83e50151876d1127161249305fd65b5811dbcd
[platform/core/uifw/dali-adaptor.git] / dali / internal / input / generic / input-method-context-impl-generic.h
1 #ifndef __DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_GENERIC_H
2 #define __DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_GENERIC_H
3
4 /*
5  * Copyright (c) 2021 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/object/base-object.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/devel-api/adaptor-framework/input-method-context.h>
26 #include <dali/internal/input/common/input-method-context-impl.h>
27
28 namespace Dali
29 {
30 namespace Internal
31 {
32 namespace Adaptor
33 {
34 /**
35  * @brief Satisfies input API requirements for platforms without input method context support
36  */
37 class InputMethodContextGeneric : public Dali::Internal::Adaptor::InputMethodContext
38 {
39 public:
40   /**
41    * @brief Creates a new InputMethodContext handle
42    *
43    * @param[in] actor The actor that uses the new InputMethodContext instance.
44    * @return InputMethodContext pointer
45    */
46   static InputMethodContextPtr New(Dali::Actor actor);
47
48   /**
49    * Constructor
50    * @param[in] actor The actor that uses the new InputMethodContext instance.
51    */
52   explicit InputMethodContextGeneric(Dali::Actor actor);
53
54 public:
55   /**
56    * @brief Initializes member data.
57    */
58   void Initialize() override;
59
60   /**
61    * Connect Callbacks required for InputMethodContext.
62    * If you don't connect InputMethodContext callbacks, you can't get the key events.
63    * The events are PreeditChanged, Commit and DeleteSurrounding.
64    */
65   void ConnectCallbacks() override;
66
67   /**
68    * Disconnect Callbacks attached to input method context.
69    */
70   void DisconnectCallbacks() override;
71
72   /**
73    * @copydoc Dali::InputMethodContext::Finalize()
74    */
75   void Finalize() override;
76
77   /**
78    * @copydoc Dali::InputMethodContext::Activate()
79    */
80   void Activate() override;
81
82   /**
83    * @copydoc Dali::InputMethodContext::Deactivate()
84    */
85   void Deactivate() override;
86
87   /**
88    * @copydoc Dali::InputMethodContext::Reset()
89    */
90   void Reset() override;
91
92   /**
93    * @copydoc Dali::InputMethodContext::GetContext()
94    */
95   ImfContext* GetContext() override;
96
97   /**
98    * @copydoc Dali::InputMethodContext::RestoreAfterFocusLost()
99    */
100   bool RestoreAfterFocusLost() const override;
101
102   /**
103    * @copydoc Dali::InputMethodContext::SetRestoreAfterFocusLost()
104    */
105   void SetRestoreAfterFocusLost(bool toggle) override;
106
107   /**
108    * @copydoc Dali::InputMethodContext::PreEditChanged()
109    */
110   void PreEditChanged(void* data, ImfContext* imfContext, void* eventInfo) override;
111
112   /**
113    * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
114    */
115   void CommitReceived(void* data, ImfContext* imfContext, void* eventInfo) override;
116
117   /**
118    * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
119    */
120   bool RetrieveSurrounding(void* data, ImfContext* imfContext, char** text, int* cursorPosition) override;
121
122   /**
123    * @copydoc Dali::InputMethodContext::DeleteSurrounding()
124    */
125   void DeleteSurrounding(void* data, ImfContext* imfContext, void* eventInfo) override;
126
127   /**
128    * @copydoc Dali::InputMethodContext::SendPrivateCommand()
129    */
130   void SendPrivateCommand(void* data, ImfContext* imfContext, void* eventInfo) override;
131
132   /**
133    * @copydoc Dali::InputMethodContext::SendCommitContent()
134    */
135   void SendCommitContent(void* data, ImfContext* imfContext, void* eventInfo) override;
136
137   // Cursor related
138   /**
139    * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
140    */
141   void NotifyCursorPosition() override;
142
143   /**
144    * @copydoc Dali::InputMethodContext::SetCursorPosition()
145    */
146   void SetCursorPosition(unsigned int cursorPosition) override;
147
148   /**
149    * @copydoc Dali::InputMethodContext::GetCursorPosition()
150    */
151   unsigned int GetCursorPosition() const override;
152
153   /**
154    * @copydoc Dali::InputMethodContext::SetSurroundingText()
155    */
156   void SetSurroundingText(const std::string& text) override;
157
158   /**
159    * @copydoc Dali::InputMethodContext::GetSurroundingText()
160    */
161   const std::string& GetSurroundingText() const override;
162
163   /**
164   * @copydoc Dali::InputMethodContext::NotifyTextInputMultiLine()
165   */
166   void NotifyTextInputMultiLine(bool multiLine) override;
167
168   /**
169   * @copydoc Dali::InputMethodContext::GetTextDirection()
170   */
171   Dali::InputMethodContext::TextDirection GetTextDirection() override;
172
173   /**
174   * @copydoc Dali::InputMethodContext::GetInputMethodArea()
175   */
176   Dali::Rect<int> GetInputMethodArea() override;
177
178   /**
179   * @copydoc Dali::InputMethodContext::ApplyOptions()
180   */
181   void ApplyOptions(const InputMethodOptions& options) override;
182
183   /**
184    * @copydoc Dali::InputMethodContext::SetInputPanelData()
185    */
186   void SetInputPanelData(const std::string& data) override;
187
188   /**
189    * @copydoc Dali::InputMethodContext::GetInputPanelData()
190    */
191   void GetInputPanelData(std::string& data) override;
192
193   /**
194    * @copydoc Dali::InputMethodContext::GetInputPanelState()
195    */
196   Dali::InputMethodContext::State GetInputPanelState() override;
197
198   /**
199    * @copydoc Dali::InputMethodContext::SetReturnKeyState()
200    */
201   void SetReturnKeyState(bool visible) override;
202
203   /**
204    * @copydoc Dali::InputMethodContext::AutoEnableInputPanel()
205    */
206   void AutoEnableInputPanel(bool enabled) override;
207
208   /**
209    * @copydoc Dali::InputMethodContext::ShowInputPanel()
210    */
211   void ShowInputPanel() override;
212
213   /**
214    * @copydoc Dali::InputMethodContext::HideInputPanel()
215    */
216   void HideInputPanel() override;
217
218   /**
219    * @copydoc Dali::InputMethodContext::GetKeyboardType()
220    */
221   Dali::InputMethodContext::KeyboardType GetKeyboardType() override;
222
223   /**
224    * @copydoc Dali::InputMethodContext::GetInputPanelLocale()
225    */
226   std::string GetInputPanelLocale() override;
227
228   /**
229    * @copydoc Dali::InputMethodContext::SetContentMIMETypes()
230    */
231   void SetContentMIMETypes(const std::string& mimeTypes) override;
232
233   /**
234    * @copydoc Dali::InputMethodContext::FilterEventKey()
235    */
236   bool FilterEventKey(const Dali::KeyEvent& keyEvent) override;
237
238   /**
239    * @copydoc Dali::InputMethodContext::AllowTextPrediction()
240    */
241   void AllowTextPrediction(bool prediction) override;
242
243   /**
244    * @copydoc Dali::InputMethodContext::IsTextPredictionAllowed()
245    */
246   bool IsTextPredictionAllowed() const override;
247
248   /**
249    * @copydoc Dali::InputMethodContext::SetInputPanelLanguage()
250    */
251   void SetInputPanelLanguage(Dali::InputMethodContext::InputPanelLanguage language) override;
252
253   /**
254    * @copydoc Dali::InputMethodContext::GetInputPanelLanguage()
255    */
256   Dali::InputMethodContext::InputPanelLanguage GetInputPanelLanguage() const override;
257
258   /**
259    * @copydoc Dali::InputMethodContext::SetInputPanelPosition()
260    */
261   void SetInputPanelPosition(unsigned int x, unsigned int y) override;
262
263   /**
264    * @copydoc Dali::InputMethodContext::GetPreeditStyle()
265    */
266   void GetPreeditStyle(Dali::InputMethodContext::PreEditAttributeDataContainer& attrs) const override;
267
268 public:
269   /**
270    * Destructor.
271    */
272   virtual ~InputMethodContextGeneric();
273
274 private:
275   // Undefined copy constructor
276   InputMethodContextGeneric(const InputMethodContextGeneric& inputMethodContext) = delete;
277
278   // Undefined assignment operator
279   InputMethodContextGeneric& operator=(const InputMethodContextGeneric& inputMethodContext) = delete;
280 };
281
282 } // namespace Adaptor
283
284 } // namespace Internal
285
286 } // namespace Dali
287
288 #endif // __DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_GENERIC_H