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

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: Rebase. 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 virtual TextInputClient* GetTextInputClient() const OVERRIDE;
46 virtual ui::TextInputType GetTextInputType() const OVERRIDE;
47
48 // Overridden from FocusChangeListener. Derived classes shouldn't override
49 // this method. Override FocusedViewWillChange() and FocusedViewDidChange()
50 // instead.
51 virtual void FocusWillChange(View* focused_before, View* focused) OVERRIDE;
52
53 protected:
54 // Getters and setters of properties.
55 internal::InputMethodDelegate* delegate() const { return delegate_; }
56 Widget* widget() const { return widget_; }
57 View* focused_view() const { return focused_view_; }
58 bool widget_focused() const { return widget_focused_; }
59
60 // Checks if the given View is focused. Returns true only if the View and
61 // the Widget are both focused.
62 bool IsViewFocused(View* view) const;
63
64 // Checks if the focused text input client's text input type is
65 // ui::TEXT_INPUT_TYPE_NONE. Also returns true if there is no focused text
66 // input client.
67 bool IsTextInputTypeNone() const;
68
69 // Convenience method to call the focused text input client's
70 // OnInputMethodChanged() method. It'll only take effect if the current text
71 // input type is not ui::TEXT_INPUT_TYPE_NONE.
72 void OnInputMethodChanged() const;
73
74 // Convenience method to call delegate_->DispatchKeyEventPostIME().
75 void DispatchKeyEventPostIME(const KeyEvent& key) const;
76
77 // Gets the current text input client's caret bounds in Widget's coordinates.
78 // Returns false if the current text input client doesn't support text input.
79 bool GetCaretBoundsInWidget(gfx::Rect* rect) const;
80
81 // Called just before changing the focused view. Should be overridden by
82 // derived classes. The default implementation does nothing.
83 virtual void FocusedViewWillChange();
84
85 // Called just after changing the focused view. Should be overridden by
86 // derived classes. The default implementation does nothing.
87 // Note: It's called just after changing the value of |focused_view_|. As it's
88 // called inside FocusChangeListener's FocusWillChange() method, which is
89 // called by the FocusManager before actually changing the focus, the derived
90 // class should not rely on the actual focus state of the |focused_view_|.
91 virtual void FocusedViewDidChange();
92
93 private:
94 internal::InputMethodDelegate* delegate_;
95 Widget* widget_;
96 View* focused_view_;
97
98 // Indicates if the top-level widget is focused or not.
99 bool widget_focused_;
100
101 DISALLOW_COPY_AND_ASSIGN(InputMethodBase);
102 };
103
104 } // namespace views
105
106 #endif // VIEWS_IME_INPUT_METHOD_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698