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 virtual void OnFocus() OVERRIDE; | |
34 virtual void OnBlur() OVERRIDE; | |
35 virtual void SetFocusedTextInputClient(TextInputClient* client) OVERRIDE; | |
36 virtual TextInputClient* GetTextInputClient() const OVERRIDE; | |
37 | |
38 // If a derived class overrides this method, it should call parent's | |
39 // implementation. | |
40 virtual void OnTextInputTypeChanged(const TextInputClient* window) OVERRIDE; | |
James Su
2011/11/24 03:57:03
const TextInputClient* client
Yusuke Sato
2011/11/28 06:29:40
Done.
| |
41 | |
42 virtual TextInputType GetTextInputType() const OVERRIDE; | |
43 | |
44 protected: | |
45 // Checks if the focused text input client's text input type is | |
46 // TEXT_INPUT_TYPE_NONE. Also returns true if there is no focused text | |
47 // input client. | |
48 bool IsTextInputTypeNone() const; | |
49 | |
James Su
2011/11/24 03:57:03
It's probably worth to have a utility method IsTex
Yusuke Sato
2011/11/28 06:29:40
Done.
| |
50 // Convenience method to call the focused text input client's | |
51 // OnInputMethodChanged() method. It'll only take effect if the current text | |
52 // input type is not TEXT_INPUT_TYPE_NONE. | |
53 void OnInputMethodChanged() const; | |
54 | |
55 // Convenience method to call delegate_->DispatchKeyEventPostIME(). | |
56 void DispatchKeyEventPostIME(const base::NativeEvent& native_event) const; | |
57 | |
58 // Convenience method to call delegate_->DispatchFabricatedKeyEventPostIME(). | |
59 void DispatchFabricatedKeyEventPostIME( | |
60 EventType type, KeyboardCode key_code, int flags) const; | |
61 | |
62 bool system_toplevel_window_focused() const; | |
63 | |
64 private: | |
65 internal::InputMethodDelegate* delegate_; | |
66 TextInputClient* text_input_client_; | |
67 | |
68 bool system_toplevel_window_focused_; | |
69 | |
70 DISALLOW_COPY_AND_ASSIGN(InputMethodBase); | |
71 }; | |
72 | |
73 } // namespace ui | |
74 | |
75 #endif // UI_BASE_IME_INPUT_METHOD_BASE_H_ | |
OLD | NEW |