[Tizen] Fix build error for pepper-dali
[platform/core/uifw/dali-adaptor.git] / dali / internal / input / tizen-wayland / ecore-wl / imf-manager-impl-ecore-wl.h
1 #ifndef DALI_INTERNAL_INPUT_COMMON_IMF_MANAGER_IMPL_ECORE_WL_H
2 #define DALI_INTERNAL_INPUT_COMMON_IMF_MANAGER_IMPL_ECORE_WL_H
3
4 /*
5  * Copyright (c) 2018 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 <Ecore_IMF.h>
23 #include <Ecore.h>
24 #include <Ecore_Wayland.h>
25
26 #include <dali/public-api/common/vector-wrapper.h>
27 #include <dali/public-api/object/base-object.h>
28 #include <dali/integration-api/events/key-event-integ.h>
29
30 // INTERNAL INCLUDES
31 #include <dali/internal/input/common/imf-manager-impl.h>
32
33 namespace Dali
34 {
35
36 class RenderSurface;
37
38 namespace Internal
39 {
40
41 namespace Adaptor
42 {
43
44 class ImfManagerEcoreWl : public Dali::Internal::Adaptor::ImfManager
45 {
46 public:
47
48   /**
49    * Check whether the ImfManager is available.
50    * @return true if available, false otherwise
51    */
52   static bool IsAvailable();
53
54   /**
55    * Get the IMF manager instance, it creates the instance if it has not already been created.
56    * Internally, a check should be made using IsAvailable() before this is called as we do not want
57    * to create an instance if not needed by applications.
58    * @see IsAvailable()
59    */
60   static Dali::ImfManager Get();
61
62   /**
63    * Connect Callbacks required for IMF.
64    * If you don't connect imf callbacks, you can't get the key events.
65    * The events are PreeditChanged, Commit, DeleteSurrounding and PrivateCommand.
66    */
67   void ConnectCallbacks() override;
68
69   /**
70    * Disconnect Callbacks attached to imf context.
71    */
72   void DisconnectCallbacks() override;
73
74   /**
75    * @copydoc Dali::ImfManager::Finalize()
76    */
77   void Finalize() override;
78
79   /**
80    * @copydoc Dali::ImfManager::Activate()
81    */
82   void Activate() override;
83
84   /**
85    * @copydoc Dali::ImfManager::Deactivate()
86    */
87   void Deactivate() override;
88
89   /**
90    * @copydoc Dali::ImfManager::Reset()
91    */
92   void Reset() override;
93
94   /**
95    * @copydoc Dali::ImfManager::GetContext()
96    */
97   ImfContext* GetContext() override;
98
99   /**
100    * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
101    */
102   bool RestoreAfterFocusLost() const override;
103
104   /**
105    * @copydoc Dali::ImfManager::SetRestoreAfterFocusLost()
106    */
107   void SetRestoreAfterFocusLost( bool toggle ) override;
108
109   /**
110    * @copydoc Dali::ImfManager::PreEditChanged()
111    */
112   void PreEditChanged( void *data, Ecore_IMF_Context *imfContext, void *event_info );
113
114   /**
115    * @copydoc Dali::ImfManager::NotifyCursorPosition()
116    */
117   void CommitReceived( void *data, Ecore_IMF_Context *imfContext, void *event_info );
118
119   /**
120    * @copydoc Dali::ImfManager::NotifyCursorPosition()
121    */
122   Eina_Bool RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition );
123
124   /**
125    * @copydoc Dali::ImfManager::DeleteSurrounding()
126    */
127   void DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info );
128
129   /**
130    * @copydoc Dali::ImfManager::SendPrivateCommand()
131    */
132   void SendPrivateCommand( void* data, Ecore_IMF_Context* imfContext, void* event_info );
133
134   // Cursor related
135   /**
136    * @copydoc Dali::ImfManager::NotifyCursorPosition()
137    */
138   void NotifyCursorPosition() override;
139
140   /**
141    * @copydoc Dali::ImfManager::SetCursorPosition()
142    */
143   void SetCursorPosition( unsigned int cursorPosition ) override;
144
145   /**
146    * @copydoc Dali::ImfManager::GetCursorPosition()
147    */
148   unsigned int GetCursorPosition() const override;
149
150   /**
151    * @copydoc Dali::ImfManager::SetSurroundingText()
152    */
153   void SetSurroundingText( const std::string& text ) override;
154
155   /**
156    * @copydoc Dali::ImfManager::GetSurroundingText()
157    */
158   const std::string& GetSurroundingText() const override;
159
160   /**
161   * @copydoc Dali::ImfManager::NotifyTextInputMultiLine()
162   */
163   void NotifyTextInputMultiLine( bool multiLine ) override;
164
165   /**
166   * @copydoc Dali::ImfManager::GetTextDirection()
167   */
168   Dali::ImfManager::TextDirection GetTextDirection() override;
169
170   /**
171   * @copydoc Dali::ImfManager::GetInputMethodArea()
172   */
173   Dali::Rect<int> GetInputMethodArea() override;
174
175   /**
176   * @copydoc Dali::ImfManager::ApplyOptions()
177   */
178   void ApplyOptions( const InputMethodOptions& options ) override;
179
180   /**
181    * @copydoc Dali::ImfManager::SetInputPanelData()
182    */
183   void SetInputPanelData( const std::string& data ) override;
184
185   /**
186    * @copydoc Dali::ImfManager::GetInputPanelData()
187    */
188   void GetInputPanelData( std::string& data ) override;
189
190   /**
191    * @copydoc Dali::ImfManager::GetInputPanelState()
192    */
193   Dali::ImfManager::State GetInputPanelState() override;
194
195   /**
196    * @copydoc Dali::ImfManager::SetReturnKeyState()
197    */
198   void SetReturnKeyState( bool visible ) override;
199
200   /**
201    * @copydoc Dali::ImfManager::AutoEnableInputPanel()
202    */
203   void AutoEnableInputPanel( bool enabled ) override;
204
205   /**
206    * @copydoc Dali::ImfManager::ShowInputPanel()
207    */
208   void ShowInputPanel() override;
209
210   /**
211    * @copydoc Dali::ImfManager::HideInputPanel()
212    */
213   void HideInputPanel() override;
214
215   /**
216    * @copydoc Dali::ImfManager::GetKeyboardType()
217    */
218   Dali::ImfManager::KeyboardType GetKeyboardType() override;
219
220   /**
221    * @copydoc Dali::ImfManager::GetInputPanelLocale()
222    */
223   std::string GetInputPanelLocale() override;
224
225 protected:
226
227   /**
228    * Destructor.
229    */
230   virtual ~ImfManagerEcoreWl() override;
231
232 private:
233   /**
234    * Context created the first time and kept until deleted.
235    * @param[in] ecoreWlwin, The window is created by application.
236    */
237   void CreateContext( Ecore_Wl_Window *ecoreWlwin );
238
239   /**
240    * @copydoc Dali::ImfManager::DeleteContext()
241    */
242   void DeleteContext();
243
244 private:
245   // Undefined
246   explicit ImfManagerEcoreWl( Ecore_Wl_Window *ecoreWlwin );
247   explicit ImfManagerEcoreWl( const ImfManager& ) = delete;
248   ImfManagerEcoreWl& operator=( ImfManager& ) = delete;
249
250 private:
251   Ecore_IMF_Context* mIMFContext;
252   int mIMFCursorPosition;
253   std::string mSurroundingText;
254
255   bool mRestoreAfterFocusLost:1;             ///< Whether the keyboard needs to be restored (activated ) after focus regained.
256   bool mIdleCallbackConnected:1;             ///< Whether the idle callback is already connected.
257
258   std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
259   InputMethodOptions        mOptions;
260 };
261
262
263 } // namespace Adaptor
264
265 } // namespace Internal
266
267 } // namespace Dali
268
269 #endif // DALI_INTERNAL_INPUT_COMMON_IMF_MANAGER_IMPL_ECORE_WL_H