1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef UI_BASE_IME_LINUX_LINUX_INPUT_METHOD_CONTEXT_H_ 6 #define UI_BASE_IME_LINUX_LINUX_INPUT_METHOD_CONTEXT_H_ 7 8 #include "base/i18n/rtl.h" 9 #include "base/strings/string16.h" 10 #include "ui/base/ime/text_input_type.h" 11 #include "ui/base/ui_export.h" 12 13 namespace gfx { 14 class Rect; 15 } 16 17 namespace ui { 18 19 struct CompositionText; 20 class KeyEvent; 21 22 // An interface of input method context for input method frameworks on 23 // GNU/Linux and likes. 24 class UI_EXPORT LinuxInputMethodContext { 25 public: ~LinuxInputMethodContext()26 virtual ~LinuxInputMethodContext() {} 27 28 // Dispatches the key event to an underlying IME. Returns true if the key 29 // event is handled, otherwise false. A client must set the text input type 30 // before dispatching a key event. 31 virtual bool DispatchKeyEvent(const ui::KeyEvent& key_event) = 0; 32 33 // Resets the context. A client needs to call OnTextInputTypeChanged() again 34 // before calling DispatchKeyEvent(). 35 virtual void Reset() = 0; 36 37 // Returns the text direction of the current keyboard layout or input method. 38 virtual base::i18n::TextDirection GetInputTextDirection() const = 0; 39 40 // Notifies the context that the text input type has changed. 41 virtual void OnTextInputTypeChanged(TextInputType text_input_type) = 0; 42 43 // Notifies the context that the caret bounds have changed. |caret_bounds| is 44 // relative to screen coordinates. 45 virtual void OnCaretBoundsChanged(const gfx::Rect& caret_bounds) = 0; 46 }; 47 48 // An interface of callback functions called from LinuxInputMethodContext. 49 class UI_EXPORT LinuxInputMethodContextDelegate { 50 public: ~LinuxInputMethodContextDelegate()51 virtual ~LinuxInputMethodContextDelegate() {} 52 53 // Commits the |text| to the text input client. 54 virtual void OnCommit(const base::string16& text) = 0; 55 56 // Sets the composition text to the text input client. 57 virtual void OnPreeditChanged(const CompositionText& composition_text) = 0; 58 59 // Cleans up a composition session and makes sure that the composition text is 60 // cleared. 61 virtual void OnPreeditEnd() = 0; 62 63 // Prepares things for a new composition session. 64 virtual void OnPreeditStart() = 0; 65 }; 66 67 } // namespace ui 68 69 #endif // UI_BASE_IME_LINUX_LINUX_INPUT_METHOD_CONTEXT_H_ 70