Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 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_INPUT_METHOD_BASE_H_ | |
| 6 #define UI_BASE_IME_INPUT_METHOD_BASE_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/basictypes.h" | |
| 10 #include "base/compiler_specific.h" | |
| 11 #include "ui/base/ime/input_method.h" | |
| 12 #include "ui/base/ui_export.h" | |
| 13 | |
| 14 namespace gfx { | |
| 15 class Rect; | |
| 16 } // namespace gfx | |
| 17 | |
| 18 namespace ui { | |
| 19 | |
| 20 class TextInputClient; | |
| 21 | |
| 22 // A helper class providing functionalities shared among ui::InputMethod | |
| 23 // implementations. | |
| 24 class UI_EXPORT InputMethodBase : public InputMethod { | |
| 25 public: | |
| 26 InputMethodBase(); | |
| 27 virtual ~InputMethodBase(); | |
| 28 | |
| 29 // Overriden from InputMethod. | |
| 30 virtual void set_delegate(internal::InputMethodDelegate* delegate) OVERRIDE; | |
| 31 virtual void set_text_input_client(TextInputClient* client) OVERRIDE; | |
| 32 virtual TextInputClient* text_input_client() const OVERRIDE; | |
| 33 | |
| 34 // If a derived class overrides this method, it should call parent's | |
| 35 // implementation. | |
| 36 virtual void OnTextInputTypeChanged(gfx::NativeWindow window) OVERRIDE; | |
| 37 | |
| 38 virtual TextInputType GetTextInputType() const OVERRIDE; | |
| 39 | |
| 40 protected: | |
| 41 // Checks if the given |window| is focused. Returns true only if the window | |
| 42 // is inside the focused top-level window. | |
| 43 virtual bool IsWindowFocused(gfx::NativeWindow window) const = 0; | |
|
James Su
2011/11/21 08:23:36
Instead of introducing this method, I'd suggest to
Yusuke Sato
2011/11/22 11:09:30
Done.
| |
| 44 | |
| 45 // Derived class must call this function when ... | |
| 46 void ActiveWindowChanged(gfx::NativeWindow active); | |
|
James Su
2011/11/21 08:23:36
This method is not necessary. Instead, the owner s
Yusuke Sato
2011/11/22 11:09:30
Done.
| |
| 47 | |
| 48 // Checks if the focused text input client's text input type is | |
| 49 // TEXT_INPUT_TYPE_NONE. Also returns true if there is no focused text | |
| 50 // input client. | |
| 51 bool IsTextInputTypeNone() const; | |
| 52 | |
| 53 // Convenience method to call the focused text input client's | |
| 54 // OnInputMethodChanged() method. It'll only take effect if the current text | |
| 55 // input type is not TEXT_INPUT_TYPE_NONE. | |
| 56 void OnInputMethodChanged() const; | |
| 57 | |
| 58 // Convenience method to call delegate_->DispatchKeyEventPostIME(). | |
| 59 void DispatchKeyEventPostIME(gfx::NativeEvent native_key_event) const; | |
| 60 | |
| 61 private: | |
| 62 internal::InputMethodDelegate* delegate_; | |
| 63 TextInputClient* text_input_client_; | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(InputMethodBase); | |
| 66 }; | |
| 67 | |
| 68 } // namespace ui | |
| 69 | |
| 70 #endif // UI_BASE_IME_INPUT_METHOD_BASE_H_ | |
| OLD | NEW |