1 #ifndef DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_WIN_H
\r
2 #define DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_WIN_H
\r
5 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
\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
11 * http://www.apache.org/licenses/LICENSE-2.0
\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
21 // EXTERNAL INCLUDES
\r
22 #include <dali/public-api/object/base-object.h>
\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
31 class RenderSurface;
\r
37 class InputMethodContextWin : public Dali::Internal::Adaptor::InputMethodContext, public Dali::ConnectionTracker
\r
41 * @brief Creates a new InputMethodContext handle
\r
43 * @param[in] actor The actor that uses the new InputMethodContext instance.
\r
44 * @return InputMethodContext pointer
\r
46 static InputMethodContextPtr New(Dali::Actor actor);
\r
50 * @param[in] win32Window, The window is created by application.
\r
52 explicit InputMethodContextWin(Dali::Actor actor);
\r
56 * @brief Initializes member data.
\r
58 void Initialize() override;
\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
65 void ConnectCallbacks() override;
\r
68 * Disconnect Callbacks attached to input method context.
\r
70 void DisconnectCallbacks() override;
\r
73 * @copydoc Dali::InputMethodContext::Finalize()
\r
75 void Finalize() override;
\r
78 * @copydoc Dali::InputMethodContext::Activate()
\r
80 void Activate() override;
\r
83 * @copydoc Dali::InputMethodContext::Deactivate()
\r
85 void Deactivate() override;
\r
88 * @copydoc Dali::InputMethodContext::Reset()
\r
90 void Reset() override;
\r
93 * @copydoc Dali::InputMethodContext::GetContext()
\r
95 ImfContext* GetContext() override;
\r
98 * @copydoc Dali::InputMethodContext::RestoreAfterFocusLost()
\r
100 bool RestoreAfterFocusLost() const override;
\r
103 * @copydoc Dali::InputMethodContext::SetRestoreAfterFocusLost()
\r
105 void SetRestoreAfterFocusLost(bool toggle) override;
\r
108 * @copydoc Dali::InputMethodContext::PreEditChanged()
\r
110 void PreEditChanged(void* data, ImfContext* imfContext, void* eventInfo) override;
\r
113 * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
\r
115 void CommitReceived(void* data, ImfContext* imfContext, void* eventInfo) override;
\r
118 * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
\r
120 bool RetrieveSurrounding(void* data, ImfContext* imfContext, char** text, int* cursorPosition) override;
\r
123 * @copydoc Dali::InputMethodContext::DeleteSurrounding()
\r
125 void DeleteSurrounding(void* data, ImfContext* imfContext, void* eventInfo) override;
\r
128 * @copydoc Dali::InputMethodContext::SendPrivateCommand()
\r
130 void SendPrivateCommand(void* data, ImfContext* imfContext, void* eventInfo) override
\r
135 * @copydoc Dali::InputMethodContext::SendCommitContent()
\r
137 void SendCommitContent(void* data, ImfContext* imfContext, void* eventInfo) override
\r
142 * @copydoc Dali::InputMethodContext::SendSelectionSet()
\r
144 void SendSelectionSet(void* data, ImfContext* imfContext, void* eventInfo) override
\r
150 * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
\r
152 void NotifyCursorPosition() override;
\r
155 * @copydoc Dali::InputMethodContext::SetCursorPosition()
\r
157 void SetCursorPosition(unsigned int cursorPosition) override;
\r
160 * @copydoc Dali::InputMethodContext::GetCursorPosition()
\r
162 unsigned int GetCursorPosition() const override;
\r
165 * @copydoc Dali::InputMethodContext::SetSurroundingText()
\r
167 void SetSurroundingText(const std::string& text) override;
\r
170 * @copydoc Dali::InputMethodContext::GetSurroundingText()
\r
172 const std::string& GetSurroundingText() const override;
\r
175 * @copydoc Dali::InputMethodContext::NotifyTextInputMultiLine()
\r
177 void NotifyTextInputMultiLine(bool multiLine) override;
\r
180 * @copydoc Dali::InputMethodContext::GetTextDirection()
\r
182 Dali::InputMethodContext::TextDirection GetTextDirection() override;
\r
185 * @copydoc Dali::InputMethodContext::GetInputMethodArea()
\r
187 Dali::Rect<int> GetInputMethodArea() override;
\r
190 * @copydoc Dali::InputMethodContext::ApplyOptions()
\r
192 void ApplyOptions(const InputMethodOptions& options) override;
\r
195 * @copydoc Dali::InputMethodContext::SetInputPanelData()
\r
197 void SetInputPanelData(const std::string& data) override;
\r
200 * @copydoc Dali::InputMethodContext::GetInputPanelData()
\r
202 void GetInputPanelData(std::string& data) override;
\r
205 * @copydoc Dali::InputMethodContext::GetInputPanelState()
\r
207 Dali::InputMethodContext::State GetInputPanelState() override;
\r
210 * @copydoc Dali::InputMethodContext::SetReturnKeyState()
\r
212 void SetReturnKeyState(bool visible) override;
\r
215 * @copydoc Dali::InputMethodContext::AutoEnableInputPanel()
\r
217 void AutoEnableInputPanel(bool enabled) override;
\r
220 * @copydoc Dali::InputMethodContext::ShowInputPanel()
\r
222 void ShowInputPanel() override;
\r
225 * @copydoc Dali::InputMethodContext::HideInputPanel()
\r
227 void HideInputPanel() override;
\r
230 * @copydoc Dali::InputMethodContext::GetKeyboardType()
\r
232 Dali::InputMethodContext::KeyboardType GetKeyboardType() override;
\r
235 * @copydoc Dali::InputMethodContext::GetInputPanelLocale()
\r
237 std::string GetInputPanelLocale() override;
\r
240 * @copydoc Dali::InputMethodContext::SetContentMIMETypes()
\r
242 void SetContentMIMETypes(const std::string& mimeTypes) override;
\r
245 * @copydoc Dali::InputMethodContext::FilterEventKey()
\r
247 bool FilterEventKey(const Dali::KeyEvent& keyEvent) override;
\r
250 * @copydoc Dali::InputMethodContext::SetInputPanelLanguage()
\r
252 void SetInputPanelLanguage(Dali::InputMethodContext::InputPanelLanguage language) override;
\r
255 * @copydoc Dali::InputMethodContext::GetInputPanelLanguage()
\r
257 Dali::InputMethodContext::InputPanelLanguage GetInputPanelLanguage() const override;
\r
260 * @copydoc Dali::InputMethodContext::SetInputPanelPosition()
\r
262 void SetInputPanelPosition(unsigned int x, unsigned int y) override;
\r
265 * @copydoc Dali::InputMethodContext::SetInputPanelPositionAlign()
\r
267 bool SetInputPanelPositionAlign(int x, int y, Dali::InputMethodContext::InputPanelAlign align) override;
\r
270 * @copydoc Dali::InputMethodContext::GetPreeditStyle()
\r
272 void GetPreeditStyle(Dali::InputMethodContext::PreEditAttributeDataContainer& attrs) const override;
\r
276 * Context created the first time and kept until deleted.
\r
277 * @param[in] win32Window, The window is created by application.
\r
279 void CreateContext(WinWindowHandle win32Window);
\r
282 * @copydoc Dali::InputMethodContext::DeleteContext()
\r
284 void DeleteContext();
\r
288 * @brief Process event key down, whether filter a key to isf.
\r
290 * @param[in] keyEvent The event key to be handled.
\r
291 * @return Whether the event key is handled.
\r
293 bool ProcessEventKeyDown(const Dali::KeyEvent& keyEvent);
\r
296 * @brief Process event key up, whether filter a key to isf.
\r
298 * @param[in] keyEvent The event key to be handled.
\r
299 * @return Whether the event key is handled.
\r
301 bool ProcessEventKeyUp(const Dali::KeyEvent& keyEvent);
\r
304 * Called when the binded actor is added to a window.
\r
306 void OnStaged(Dali::Actor actor);
\r
312 virtual ~InputMethodContextWin();
\r
315 // Undefined copy constructor
\r
316 InputMethodContextWin(const InputMethodContextWin& inputMethodContext) = delete;
\r
318 // Undefined assignment operator
\r
319 InputMethodContextWin& operator=(const InputMethodContextWin& inputMethodContext) = delete;
\r
322 WinWindowHandle mWin32Window;
\r
323 int mIMFCursorPosition;
\r
324 std::string mSurroundingText;
\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
330 Dali::InputMethodContext::PreEditAttributeDataContainer mPreeditAttrs; ///< Stores preedit attribute data
\r
333 } // namespace Adaptor
\r
335 } // namespace Internal
\r
337 } // namespace Dali
\r
339 #endif // DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_WIN_H
\r