Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(782)

Side by Side Diff: ui/views/ime/input_method_base.h

Issue 12902029: Fix InputMethod Widget activation checks; cleanup, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/ime/input_method.h ('k') | ui/views/ime/input_method_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_VIEWS_IME_INPUT_METHOD_BASE_H_ 5 #ifndef UI_VIEWS_IME_INPUT_METHOD_BASE_H_
6 #define UI_VIEWS_IME_INPUT_METHOD_BASE_H_ 6 #define UI_VIEWS_IME_INPUT_METHOD_BASE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "ui/views/focus/focus_manager.h" 10 #include "ui/views/focus/focus_manager.h"
11 #include "ui/views/ime/input_method.h" 11 #include "ui/views/ime/input_method.h"
12 #include "ui/views/ime/input_method_delegate.h" 12 #include "ui/views/ime/input_method_delegate.h"
13 13
14 namespace gfx { 14 namespace gfx {
15 class Rect; 15 class Rect;
16 } 16 }
17 17
18 namespace ui { 18 namespace ui {
19 class KeyEvent; 19 class KeyEvent;
20 class TextInputClient;
21 } 20 }
22 21
23 namespace views { 22 namespace views {
24 23
25 class View; 24 // A helper that provides functionality shared by InputMethod implementations.
26 25 class VIEWS_EXPORT InputMethodBase : public InputMethod,
27 // A helper class providing functionalities shared among InputMethod
28 // implementations.
29 class VIEWS_EXPORT InputMethodBase : NON_EXPORTED_BASE(public InputMethod),
30 public FocusChangeListener { 26 public FocusChangeListener {
31 public: 27 public:
32 InputMethodBase(); 28 InputMethodBase();
33 virtual ~InputMethodBase(); 29 virtual ~InputMethodBase();
34 30
35 // Overridden from InputMethod. 31 // Overridden from InputMethod.
36 virtual void set_delegate(internal::InputMethodDelegate* delegate) OVERRIDE; 32 virtual void SetDelegate(internal::InputMethodDelegate* delegate) OVERRIDE;
37
38 // If a derived class overrides this method, it should call parent's
39 // implementation first.
40 virtual void Init(Widget* widget) OVERRIDE; 33 virtual void Init(Widget* widget) OVERRIDE;
41
42 // If a derived class overrides this method, it should call parent's
43 // implementation first, to make sure |widget_focused_| flag can be updated
44 // correctly.
45 virtual void OnFocus() OVERRIDE;
46
47 // If a derived class overrides this method, it should call parent's
48 // implementation first, to make sure |widget_focused_| flag can be updated
49 // correctly.
50 virtual void OnBlur() OVERRIDE;
51
52 // If a derived class overrides this method, it should call parent's
53 // implementation.
54 virtual void OnTextInputTypeChanged(View* view) OVERRIDE; 34 virtual void OnTextInputTypeChanged(View* view) OVERRIDE;
55
56 virtual ui::TextInputClient* GetTextInputClient() const OVERRIDE; 35 virtual ui::TextInputClient* GetTextInputClient() const OVERRIDE;
57 virtual ui::TextInputType GetTextInputType() const OVERRIDE; 36 virtual ui::TextInputType GetTextInputType() const OVERRIDE;
58 virtual bool IsMock() const OVERRIDE; 37 virtual bool IsMock() const OVERRIDE;
59 38
60 // Overridden from FocusChangeListener. 39 // Overridden from FocusChangeListener.
61 virtual void OnWillChangeFocus(View* focused_before, View* focused) OVERRIDE; 40 virtual void OnWillChangeFocus(View* focused_before, View* focused) OVERRIDE;
62 virtual void OnDidChangeFocus(View* focused_before, View* focused) OVERRIDE; 41 virtual void OnDidChangeFocus(View* focused_before, View* focused) OVERRIDE;
63 42
64 protected: 43 protected:
65 // Getters and setters of properties.
66 internal::InputMethodDelegate* delegate() const { return delegate_; } 44 internal::InputMethodDelegate* delegate() const { return delegate_; }
67 Widget* widget() const { return widget_; } 45 Widget* widget() const { return widget_; }
68 bool widget_focused() const { return widget_focused_; }
69 View* GetFocusedView() const; 46 View* GetFocusedView() const;
70 47
71 // Checks if the given View is focused. Returns true only if the View and 48 // Returns true only if the View is focused and its Widget is active.
72 // the Widget are both focused.
73 bool IsViewFocused(View* view) const; 49 bool IsViewFocused(View* view) const;
74 50
75 // Checks if the focused text input client's text input type is 51 // Returns true if there is no focused text input client or its type is none.
76 // ui::TEXT_INPUT_TYPE_NONE. Also returns true if there is no focused text
77 // input client.
78 bool IsTextInputTypeNone() const; 52 bool IsTextInputTypeNone() const;
79 53
80 // Convenience method to call the focused text input client's 54 // Calls the focused text input client's OnInputMethodChanged() method.
81 // OnInputMethodChanged() method. It'll only take effect if the current text 55 // This has no effect if the text input type is ui::TEXT_INPUT_TYPE_NONE.
82 // input type is not ui::TEXT_INPUT_TYPE_NONE.
83 void OnInputMethodChanged() const; 56 void OnInputMethodChanged() const;
84 57
85 // Convenience method to call delegate_->DispatchKeyEventPostIME(). 58 // Convenience method to call delegate_->DispatchKeyEventPostIME().
86 void DispatchKeyEventPostIME(const ui::KeyEvent& key) const; 59 void DispatchKeyEventPostIME(const ui::KeyEvent& key) const;
87 60
88 // Gets the current text input client's caret bounds in Widget's coordinates. 61 // Gets the current text input client's caret bounds in Widget's coordinates.
89 // Returns false if the current text input client doesn't support text input. 62 // Returns false if the current text input client doesn't support text input.
90 bool GetCaretBoundsInWidget(gfx::Rect* rect) const; 63 bool GetCaretBoundsInWidget(gfx::Rect* rect) const;
91 64
92 private: 65 private:
93 internal::InputMethodDelegate* delegate_; 66 internal::InputMethodDelegate* delegate_;
94 Widget* widget_; 67 Widget* widget_;
95 68
96 // Indicates if the top-level widget is focused or not.
97 bool widget_focused_;
98
99 DISALLOW_COPY_AND_ASSIGN(InputMethodBase); 69 DISALLOW_COPY_AND_ASSIGN(InputMethodBase);
100 }; 70 };
101 71
102 } // namespace views 72 } // namespace views
103 73
104 #endif // UI_VIEWS_IME_INPUT_METHOD_BASE_H_ 74 #endif // UI_VIEWS_IME_INPUT_METHOD_BASE_H_
OLDNEW
« no previous file with comments | « ui/views/ime/input_method.h ('k') | ui/views/ime/input_method_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698