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/events.h" | |
12 #include "ui/base/ime/input_method.h" | |
13 #include "ui/base/ui_export.h" | |
14 | |
15 namespace gfx { | |
16 class Rect; | |
17 } // namespace gfx | |
18 | |
19 namespace ui { | |
20 | |
21 class TextInputClient; | |
22 | |
23 // A helper class providing functionalities shared among ui::InputMethod | |
24 // implementations. | |
25 class UI_EXPORT InputMethodBase : public InputMethod { | |
26 public: | |
27 InputMethodBase(); | |
28 virtual ~InputMethodBase(); | |
29 | |
30 // Overriden from InputMethod. | |
31 virtual void set_delegate(internal::InputMethodDelegate* delegate) OVERRIDE; | |
32 virtual void Init(const base::NativeWindow& system_toplevel_window) OVERRIDE; | |
33 // If a derived class overrides OnFocus()/OnBlur(), it should call parent's | |
34 // implementation first, to make sure |system_toplevel_window_focused_| flag | |
35 // can be updated correctly. | |
36 virtual void OnFocus() OVERRIDE; | |
37 virtual void OnBlur() OVERRIDE; | |
38 virtual void SetFocusedTextInputClient(TextInputClient* client) OVERRIDE; | |
39 virtual TextInputClient* GetTextInputClient() const OVERRIDE; | |
40 | |
41 // If a derived class overrides this method, it should call parent's | |
42 // implementation. | |
43 virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE; | |
44 | |
45 virtual TextInputType GetTextInputType() const OVERRIDE; | |
46 | |
47 protected: | |
48 // Returns true if |client| is currently focused. | |
49 bool IsTextInputClientFocused(const TextInputClient* client); | |
50 | |
51 // Checks if the focused text input client's text input type is | |
52 // TEXT_INPUT_TYPE_NONE. Also returns true if there is no focused text | |
53 // input client. | |
54 bool IsTextInputTypeNone() const; | |
55 | |
56 // Convenience method to call the focused text input client's | |
57 // OnInputMethodChanged() method. It'll only take effect if the current text | |
58 // input type is not TEXT_INPUT_TYPE_NONE. | |
59 void OnInputMethodChanged() const; | |
60 | |
61 // Convenience method to call delegate_->DispatchKeyEventPostIME(). | |
62 void DispatchKeyEventPostIME(const base::NativeEvent& native_event) const; | |
63 | |
64 // Convenience method to call delegate_->DispatchFabricatedKeyEventPostIME(). | |
65 void DispatchFabricatedKeyEventPostIME( | |
66 EventType type, KeyboardCode key_code, int flags) const; | |
67 | |
68 bool system_toplevel_window_focused() const; | |
James Su
2011/11/29 04:25:53
this method can be inlined?
Yusuke Sato
2011/11/29 09:06:36
Done.
| |
69 | |
70 private: | |
71 internal::InputMethodDelegate* delegate_; | |
72 TextInputClient* text_input_client_; | |
73 | |
74 bool system_toplevel_window_focused_; | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(InputMethodBase); | |
77 }; | |
78 | |
79 } // namespace ui | |
80 | |
81 #endif // UI_BASE_IME_INPUT_METHOD_BASE_H_ | |
OLD | NEW |