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

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

Issue 6688049: New InputMethod api for Views. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add an OWNERS file. Created 9 years, 9 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
OLDNEW
(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 VIEWS_IME_INPUT_METHOD_BASE_H_
6 #define VIEWS_IME_INPUT_METHOD_BASE_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
11 #include "views/focus/focus_manager.h"
12 #include "views/ime/input_method.h"
13 #include "views/ime/input_method_delegate.h"
14 #include "views/ime/text_input_client.h"
15
16 namespace views {
17
18 class View;
19
20 // A helper class providing functionalities shared among InputMethod
21 // implementations.
22 class InputMethodBase : public InputMethod,
23 public FocusChangeListener {
24 public:
25 InputMethodBase();
26 virtual ~InputMethodBase();
27
28 // Overriden from InputMethod.
29 virtual void set_delegate(internal::InputMethodDelegate* delegate) OVERRIDE;
30
31 // If a derived class overrides this method, it should call parent's
32 // implementation first.
33 virtual void Init(Widget* widget) OVERRIDE;
34
35 // If a derived class overrides this method, it should call parent's
36 // implementation first, to make sure |widget_focused_| flag can be updated
37 // correctly.
38 virtual void OnFocusIn() OVERRIDE;
39
40 // If a derived class overrides this method, it should call parent's
41 // implementation first, to make sure |widget_focused_| flag can be updated
42 // correctly.
43 virtual void OnFocusOut() OVERRIDE;
44
45 // Overridden from FocusChangeListener. Derived classes shouldn't override
46 // this method. Override FocusedViewWillChange() and FocusedViewDidChange()
47 // instead.
48 virtual void FocusWillChange(View* focused_before, View* focused) OVERRIDE;
49
50 protected:
51 // Getters and setters of properties.
52 internal::InputMethodDelegate* delegate() const { return delegate_; }
53 Widget* widget() const { return widget_; }
54 View* focused_view() const { return focused_view_; }
55 bool widget_focused() const { return widget_focused_; }
56
57 // Checks if the given View is focused. Returns true only if the View and
58 // the Widget are both focused.
59 bool IsViewFocused(View* view) const;
60
61 // Gets the focused text input client. Returns NULL if the Widget is not
62 // focused, or there is no focused View or the focused View doesn't support
63 // text input.
64 TextInputClient* GetTextInputClient() const;
65
66 // Gets the text input type of the focused text input client. Returns
67 // ui::TEXT_INPUT_TYPE_NONE if there is no focused text input client.
68 ui::TextInputType GetTextInputType() const;
69
70 // Checks if the focused text input client's text input type is
71 // ui::TEXT_INPUT_TYPE_NONE. Also returns true if there is no focused text
72 // input client.
73 bool IsTextInputTypeNone() const;
74
75 // Convenience method to call the focused text input client's
76 // OnInputMethodChanged() method. It'll only take effect if the current text
77 // input type is not ui::TEXT_INPUT_TYPE_NONE.
78 void OnInputMethodChanged() const;
79
80 // Convenience method to call delegate_->DispatchKeyEventPostIME().
81 void DispatchKeyEventPostIME(const KeyEvent& key) const;
82
83 // Gets the current text input client's caret bounds in Widget's coordinates.
84 // Returns false if the current text input client doesn't support text input.
85 bool GetCaretBoundsInWidget(gfx::Rect* rect) const;
86
87 // Called just before changing the focused view. Should be overridden by
88 // derived classes. The default implementation does nothing.
89 virtual void FocusedViewWillChange();
90
91 // Called just after changing the focused view. Should be overridden by
92 // derived classes. The default implementation does nothing.
93 // Note: It's called just after changing the value of |focused_view_|. As it's
94 // called inside FocusChangeListener's FocusWillChange() method, which is
95 // called by the FocusManager before actually changing the focus, the derived
96 // class should not rely on the actual focus state of the |focused_view_|.
97 virtual void FocusedViewDidChange();
98
99 private:
100 internal::InputMethodDelegate* delegate_;
101 Widget* widget_;
102 View* focused_view_;
103
104 // Indicates if the top-level widget is focused or not.
105 bool widget_focused_;
106
107 DISALLOW_COPY_AND_ASSIGN(InputMethodBase);
108 };
109
110 } // namespace views
111
112 #endif // VIEWS_IME_INPUT_METHOD_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698