OLD | NEW |
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 VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ | 5 #ifndef VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ |
6 #define VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ | 6 #define VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
11 #include "ui/base/ime/text_input_client.h" | |
12 #include "ui/base/models/simple_menu_model.h" | 11 #include "ui/base/models/simple_menu_model.h" |
13 #include "ui/gfx/font.h" | 12 #include "ui/gfx/font.h" |
14 #include "views/border.h" | 13 #include "views/border.h" |
15 #include "views/context_menu_controller.h" | 14 #include "views/context_menu_controller.h" |
16 #include "views/controls/textfield/native_textfield_wrapper.h" | 15 #include "views/controls/textfield/native_textfield_wrapper.h" |
17 #include "views/controls/textfield/textfield_views_model.h" | 16 #include "views/controls/textfield/textfield_views_model.h" |
18 #include "views/drag_controller.h" | 17 #include "views/drag_controller.h" |
| 18 #include "views/ime/text_input_client.h" |
19 #include "views/touchui/touch_selection_controller.h" | 19 #include "views/touchui/touch_selection_controller.h" |
20 #include "views/view.h" | 20 #include "views/view.h" |
21 | 21 |
22 namespace base { | 22 namespace base { |
23 class Time; | 23 class Time; |
24 } | 24 } |
25 | 25 |
26 namespace gfx { | 26 namespace gfx { |
27 class Canvas; | 27 class Canvas; |
28 } | 28 } |
(...skipping 10 matching lines...) Expand all Loading... |
39 // Following features are not yet supported. | 39 // Following features are not yet supported. |
40 // * BIDI/Complex script. | 40 // * BIDI/Complex script. |
41 // * Support surrogate pair, or maybe we should just use UTF32 internally. | 41 // * Support surrogate pair, or maybe we should just use UTF32 internally. |
42 // * X selection (only if we want to support). | 42 // * X selection (only if we want to support). |
43 // Once completed, this will replace Textfield, NativeTextfieldWin and | 43 // Once completed, this will replace Textfield, NativeTextfieldWin and |
44 // NativeTextfieldGtk. | 44 // NativeTextfieldGtk. |
45 class VIEWS_EXPORT NativeTextfieldViews : public TouchSelectionClientView, | 45 class VIEWS_EXPORT NativeTextfieldViews : public TouchSelectionClientView, |
46 public ContextMenuController, | 46 public ContextMenuController, |
47 public DragController, | 47 public DragController, |
48 public NativeTextfieldWrapper, | 48 public NativeTextfieldWrapper, |
49 public ui::TextInputClient, | 49 public TextInputClient, |
50 public TextfieldViewsModel::Delegate { | 50 public TextfieldViewsModel::Delegate { |
51 public: | 51 public: |
52 explicit NativeTextfieldViews(Textfield* parent); | 52 explicit NativeTextfieldViews(Textfield* parent); |
53 virtual ~NativeTextfieldViews(); | 53 virtual ~NativeTextfieldViews(); |
54 | 54 |
55 // View overrides: | 55 // View overrides: |
56 virtual gfx::NativeCursor GetCursor(const MouseEvent& event) OVERRIDE; | 56 virtual gfx::NativeCursor GetCursor(const MouseEvent& event) OVERRIDE; |
57 virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; | 57 virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; |
58 virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; | 58 virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; |
59 virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; | 59 virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 virtual bool IsIMEComposing() const OVERRIDE; | 112 virtual bool IsIMEComposing() const OVERRIDE; |
113 virtual void GetSelectedRange(ui::Range* range) const OVERRIDE; | 113 virtual void GetSelectedRange(ui::Range* range) const OVERRIDE; |
114 virtual void SelectRange(const ui::Range& range) OVERRIDE; | 114 virtual void SelectRange(const ui::Range& range) OVERRIDE; |
115 virtual void GetSelectionModel(gfx::SelectionModel* sel) const OVERRIDE; | 115 virtual void GetSelectionModel(gfx::SelectionModel* sel) const OVERRIDE; |
116 virtual void SelectSelectionModel(const gfx::SelectionModel& sel) OVERRIDE; | 116 virtual void SelectSelectionModel(const gfx::SelectionModel& sel) OVERRIDE; |
117 virtual size_t GetCursorPosition() const OVERRIDE; | 117 virtual size_t GetCursorPosition() const OVERRIDE; |
118 virtual bool HandleKeyPressed(const KeyEvent& e) OVERRIDE; | 118 virtual bool HandleKeyPressed(const KeyEvent& e) OVERRIDE; |
119 virtual bool HandleKeyReleased(const KeyEvent& e) OVERRIDE; | 119 virtual bool HandleKeyReleased(const KeyEvent& e) OVERRIDE; |
120 virtual void HandleFocus() OVERRIDE; | 120 virtual void HandleFocus() OVERRIDE; |
121 virtual void HandleBlur() OVERRIDE; | 121 virtual void HandleBlur() OVERRIDE; |
122 virtual ui::TextInputClient* GetTextInputClient() OVERRIDE; | 122 virtual TextInputClient* GetTextInputClient() OVERRIDE; |
123 virtual void ApplyStyleRange(const gfx::StyleRange& style) OVERRIDE; | 123 virtual void ApplyStyleRange(const gfx::StyleRange& style) OVERRIDE; |
124 virtual void ApplyDefaultStyle() OVERRIDE; | 124 virtual void ApplyDefaultStyle() OVERRIDE; |
125 virtual void ClearEditHistory() OVERRIDE; | 125 virtual void ClearEditHistory() OVERRIDE; |
126 | 126 |
127 // ui::SimpleMenuModel::Delegate overrides | 127 // ui::SimpleMenuModel::Delegate overrides |
128 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 128 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
129 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 129 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
130 virtual bool GetAcceleratorForCommandId( | 130 virtual bool GetAcceleratorForCommandId( |
131 int command_id, | 131 int command_id, |
132 ui::Accelerator* accelerator) OVERRIDE; | 132 ui::Accelerator* accelerator) OVERRIDE; |
133 virtual void ExecuteCommand(int command_id) OVERRIDE; | 133 virtual void ExecuteCommand(int command_id) OVERRIDE; |
134 | 134 |
135 // class name of internal | 135 // class name of internal |
136 static const char kViewClassName[]; | 136 static const char kViewClassName[]; |
137 | 137 |
138 protected: | 138 protected: |
139 // View override. | 139 // View override. |
140 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; | 140 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; |
141 | 141 |
142 private: | 142 private: |
143 friend class NativeTextfieldViewsTest; | 143 friend class NativeTextfieldViewsTest; |
144 friend class TouchSelectionControllerImplTest; | 144 friend class TouchSelectionControllerImplTest; |
145 | 145 |
146 // Overridden from ui::TextInputClient: | 146 // Overridden from TextInputClient: |
147 virtual void SetCompositionText( | 147 virtual void SetCompositionText( |
148 const ui::CompositionText& composition) OVERRIDE; | 148 const ui::CompositionText& composition) OVERRIDE; |
149 virtual void ConfirmCompositionText() OVERRIDE; | 149 virtual void ConfirmCompositionText() OVERRIDE; |
150 virtual void ClearCompositionText() OVERRIDE; | 150 virtual void ClearCompositionText() OVERRIDE; |
151 virtual void InsertText(const string16& text) OVERRIDE; | 151 virtual void InsertText(const string16& text) OVERRIDE; |
152 virtual void InsertChar(char16 ch, int flags) OVERRIDE; | 152 virtual void InsertChar(char16 ch, int flags) OVERRIDE; |
153 virtual ui::TextInputType GetTextInputType() const OVERRIDE; | 153 virtual ui::TextInputType GetTextInputType() const OVERRIDE; |
154 virtual gfx::Rect GetCaretBounds() OVERRIDE; | 154 virtual gfx::Rect GetCaretBounds() OVERRIDE; |
155 virtual bool HasCompositionText() OVERRIDE; | 155 virtual bool HasCompositionText() OVERRIDE; |
156 virtual bool GetTextRange(ui::Range* range) OVERRIDE; | 156 virtual bool GetTextRange(ui::Range* range) OVERRIDE; |
157 virtual bool GetCompositionTextRange(ui::Range* range) OVERRIDE; | 157 virtual bool GetCompositionTextRange(ui::Range* range) OVERRIDE; |
158 virtual bool GetSelectionRange(ui::Range* range) OVERRIDE; | 158 virtual bool GetSelectionRange(ui::Range* range) OVERRIDE; |
159 virtual bool SetSelectionRange(const ui::Range& range) OVERRIDE; | 159 virtual bool SetSelectionRange(const ui::Range& range) OVERRIDE; |
160 virtual bool DeleteRange(const ui::Range& range) OVERRIDE; | 160 virtual bool DeleteRange(const ui::Range& range) OVERRIDE; |
161 virtual bool GetTextFromRange(const ui::Range& range, | 161 virtual bool GetTextFromRange(const ui::Range& range, |
162 string16* text) OVERRIDE; | 162 string16* text) OVERRIDE; |
163 virtual void OnInputMethodChanged() OVERRIDE; | 163 virtual void OnInputMethodChanged() OVERRIDE; |
164 virtual bool ChangeTextDirectionAndLayoutAlignment( | 164 virtual bool ChangeTextDirectionAndLayoutAlignment( |
165 base::i18n::TextDirection direction) OVERRIDE; | 165 base::i18n::TextDirection direction) OVERRIDE; |
| 166 virtual View* GetOwnerViewOfTextInputClient() OVERRIDE; |
166 | 167 |
167 // Overridden from TextfieldViewsModel::Delegate: | 168 // Overridden from TextfieldViewsModel::Delegate: |
168 virtual void OnCompositionTextConfirmedOrCleared() OVERRIDE; | 169 virtual void OnCompositionTextConfirmedOrCleared() OVERRIDE; |
169 | 170 |
170 // Returns the TextfieldViewsModel's text/cursor/selection rendering model. | 171 // Returns the TextfieldViewsModel's text/cursor/selection rendering model. |
171 gfx::RenderText* GetRenderText() const; | 172 gfx::RenderText* GetRenderText() const; |
172 | 173 |
173 // A callback function to periodically update the cursor state. | 174 // A callback function to periodically update the cursor state. |
174 void UpdateCursor(); | 175 void UpdateCursor(); |
175 | 176 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 scoped_ptr<views::MenuRunner> context_menu_runner_; | 253 scoped_ptr<views::MenuRunner> context_menu_runner_; |
253 | 254 |
254 scoped_ptr<TouchSelectionController> touch_selection_controller_; | 255 scoped_ptr<TouchSelectionController> touch_selection_controller_; |
255 | 256 |
256 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldViews); | 257 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldViews); |
257 }; | 258 }; |
258 | 259 |
259 } // namespace views | 260 } // namespace views |
260 | 261 |
261 #endif // VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ | 262 #endif // VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ |
OLD | NEW |