Home | History | Annotate | Download | only in linux
      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/strings/string16.h"
      9 #include "ui/base/ime/text_input_type.h"
     10 #include "ui/base/ui_base_export.h"
     11 
     12 namespace gfx {
     13 class Rect;
     14 }
     15 
     16 namespace ui {
     17 
     18 struct CompositionText;
     19 class KeyEvent;
     20 
     21 // An interface of input method context for input method frameworks on
     22 // GNU/Linux and likes.
     23 class UI_BASE_EXPORT LinuxInputMethodContext {
     24  public:
     25   virtual ~LinuxInputMethodContext() {}
     26 
     27   // Dispatches the key event to an underlying IME.  Returns true if the key
     28   // event is handled, otherwise false.  A client must set the text input type
     29   // before dispatching a key event.
     30   virtual bool DispatchKeyEvent(const ui::KeyEvent& key_event) = 0;
     31 
     32   // Resets the context.  A client needs to call OnTextInputTypeChanged() again
     33   // before calling DispatchKeyEvent().
     34   virtual void Reset() = 0;
     35 
     36   // Notifies the context that the text input type has changed.
     37   virtual void OnTextInputTypeChanged(TextInputType text_input_type) = 0;
     38 
     39   // Notifies the context that the caret bounds have changed.  |caret_bounds| is
     40   // relative to screen coordinates.
     41   virtual void OnCaretBoundsChanged(const gfx::Rect& caret_bounds) = 0;
     42 };
     43 
     44 // An interface of callback functions called from LinuxInputMethodContext.
     45 class UI_BASE_EXPORT LinuxInputMethodContextDelegate {
     46  public:
     47   virtual ~LinuxInputMethodContextDelegate() {}
     48 
     49   // Commits the |text| to the text input client.
     50   virtual void OnCommit(const base::string16& text) = 0;
     51 
     52   // Sets the composition text to the text input client.
     53   virtual void OnPreeditChanged(const CompositionText& composition_text) = 0;
     54 
     55   // Cleans up a composition session and makes sure that the composition text is
     56   // cleared.
     57   virtual void OnPreeditEnd() = 0;
     58 
     59   // Prepares things for a new composition session.
     60   virtual void OnPreeditStart() = 0;
     61 };
     62 
     63 }  // namespace ui
     64 
     65 #endif  // UI_BASE_IME_LINUX_LINUX_INPUT_METHOD_CONTEXT_H_
     66