Chromium Code Reviews| Index: ui/base/ime/input_method_base.h |
| diff --git a/ui/base/ime/input_method_base.h b/ui/base/ime/input_method_base.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9c86caf5d4d96f8722b936d19e4ba51d7f2364c9 |
| --- /dev/null |
| +++ b/ui/base/ime/input_method_base.h |
| @@ -0,0 +1,88 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UI_BASE_IME_INPUT_METHOD_BASE_H_ |
| +#define UI_BASE_IME_INPUT_METHOD_BASE_H_ |
| +#pragma once |
| + |
| +#include "base/basictypes.h" |
| +#include "base/compiler_specific.h" |
| +#include "ui/base/events.h" |
| +#include "ui/base/ime/input_method.h" |
| +#include "ui/base/ui_export.h" |
| + |
| +namespace gfx { |
| +class Rect; |
| +} // namespace gfx |
| + |
| +namespace ui { |
| + |
| +class TextInputClient; |
| + |
| +// A helper class providing functionalities shared among ui::InputMethod |
| +// implementations. |
| +class UI_EXPORT InputMethodBase : public InputMethod { |
| + public: |
| + InputMethodBase(); |
| + virtual ~InputMethodBase(); |
| + |
| + // Overriden from InputMethod. |
| + virtual void set_delegate(internal::InputMethodDelegate* delegate) OVERRIDE; |
| + virtual void Init(bool focused) OVERRIDE; |
| + // If a derived class overrides OnFocus()/OnBlur(), it should call parent's |
| + // implementation first, to make sure |system_toplevel_window_focused_| flag |
| + // can be updated correctly. |
| + virtual void OnFocus() OVERRIDE; |
| + virtual void OnBlur() OVERRIDE; |
| + virtual void SetFocusedTextInputClient(TextInputClient* client) OVERRIDE; |
| + virtual TextInputClient* GetTextInputClient() const OVERRIDE; |
| + |
| + // If a derived class overrides this method, it should call parent's |
| + // implementation. |
| + virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE; |
| + |
| + virtual TextInputType GetTextInputType() const OVERRIDE; |
| + |
| + protected: |
| + virtual void OnWillChangeFocusedClient( |
| + TextInputClient* focused_before, TextInputClient* focused) {} |
|
sky
2011/12/05 15:15:29
nit: when you wrap, each param on its own line.
Yusuke Sato
2011/12/05 22:55:14
Done.
|
| + virtual void OnDidChangeFocusedClient( |
| + TextInputClient* focused_before, TextInputClient* focused) {} |
| + |
| + // Returns true if |client| is currently focused. |
| + bool IsTextInputClientFocused(const TextInputClient* client); |
| + |
| + // Checks if the focused text input client's text input type is |
| + // TEXT_INPUT_TYPE_NONE. Also returns true if there is no focused text |
| + // input client. |
| + bool IsTextInputTypeNone() const; |
| + |
| + // Convenience method to call the focused text input client's |
| + // OnInputMethodChanged() method. It'll only take effect if the current text |
| + // input type is not TEXT_INPUT_TYPE_NONE. |
| + void OnInputMethodChanged() const; |
| + |
| + // Convenience method to call delegate_->DispatchKeyEventPostIME(). |
| + void DispatchKeyEventPostIME(const base::NativeEvent& native_event) const; |
| + |
| + // Convenience method to call delegate_->DispatchFabricatedKeyEventPostIME(). |
| + void DispatchFabricatedKeyEventPostIME( |
| + EventType type, KeyboardCode key_code, int flags) const; |
| + |
| + bool system_toplevel_window_focused() const { |
| + return system_toplevel_window_focused_; |
| + } |
| + |
| + private: |
| + internal::InputMethodDelegate* delegate_; |
| + TextInputClient* text_input_client_; |
| + |
| + bool system_toplevel_window_focused_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(InputMethodBase); |
| +}; |
| + |
| +} // namespace ui |
| + |
| +#endif // UI_BASE_IME_INPUT_METHOD_BASE_H_ |