OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ | 5 #ifndef UI_VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ |
6 #define UI_VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ | 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ |
7 | 7 |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "ui/base/events/event_constants.h" | 10 #include "ui/base/events/event_constants.h" |
11 #include "ui/base/ime/text_input_client.h" | 11 #include "ui/base/ime/text_input_client.h" |
12 #include "ui/base/models/simple_menu_model.h" | 12 #include "ui/base/models/simple_menu_model.h" |
| 13 #include "ui/base/touch/touch_editing_controller.h" |
13 #include "ui/gfx/font.h" | 14 #include "ui/gfx/font.h" |
14 #include "ui/views/border.h" | 15 #include "ui/views/border.h" |
15 #include "ui/views/context_menu_controller.h" | 16 #include "ui/views/context_menu_controller.h" |
16 #include "ui/views/controls/textfield/native_textfield_wrapper.h" | 17 #include "ui/views/controls/textfield/native_textfield_wrapper.h" |
17 #include "ui/views/controls/textfield/textfield_views_model.h" | 18 #include "ui/views/controls/textfield/textfield_views_model.h" |
18 #include "ui/views/drag_controller.h" | 19 #include "ui/views/drag_controller.h" |
19 #include "ui/views/touchui/touch_selection_controller.h" | |
20 #include "ui/views/view.h" | 20 #include "ui/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 } |
29 | 29 |
30 namespace views { | 30 namespace views { |
31 | 31 |
32 class FocusableBorder; | 32 class FocusableBorder; |
33 class MenuModelAdapter; | 33 class MenuModelAdapter; |
34 class MenuRunner; | 34 class MenuRunner; |
35 | 35 |
36 // A views/skia only implementation of NativeTextfieldWrapper. | 36 // A views/skia only implementation of NativeTextfieldWrapper. |
37 // No platform specific code is used. | 37 // No platform specific code is used. |
38 // Following features are not yet supported. | 38 // Following features are not yet supported. |
39 // * BIDI/Complex script. | 39 // * BIDI/Complex script. |
40 // * Support surrogate pair, or maybe we should just use UTF32 internally. | 40 // * Support surrogate pair, or maybe we should just use UTF32 internally. |
41 // * X selection (only if we want to support). | 41 // * X selection (only if we want to support). |
42 // Once completed, this will replace Textfield, NativeTextfieldWin and | 42 // Once completed, this will replace Textfield, NativeTextfieldWin and |
43 // NativeTextfieldGtk. | 43 // NativeTextfieldGtk. |
44 class VIEWS_EXPORT NativeTextfieldViews : public TouchSelectionClientView, | 44 class VIEWS_EXPORT NativeTextfieldViews : public View, |
| 45 public ui::TouchEditable, |
45 public ContextMenuController, | 46 public ContextMenuController, |
46 public DragController, | 47 public DragController, |
47 public NativeTextfieldWrapper, | 48 public NativeTextfieldWrapper, |
48 public ui::TextInputClient, | 49 public ui::TextInputClient, |
49 public TextfieldViewsModel::Delegate { | 50 public TextfieldViewsModel::Delegate { |
50 public: | 51 public: |
51 // Interval over which the cursor/caret blinks. This represents the full | 52 // Interval over which the cursor/caret blinks. This represents the full |
52 // cycle; the caret is shown for half of this time and hidden for the other | 53 // cycle; the caret is shown for half of this time and hidden for the other |
53 // half. | 54 // half. |
54 static const int kCursorBlinkCycleMs; | 55 static const int kCursorBlinkCycleMs; |
(...skipping 14 matching lines...) Expand all Loading... |
69 virtual bool CanDrop(const ui::OSExchangeData& data) OVERRIDE; | 70 virtual bool CanDrop(const ui::OSExchangeData& data) OVERRIDE; |
70 virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE; | 71 virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE; |
71 virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE; | 72 virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE; |
72 virtual void OnDragDone() OVERRIDE; | 73 virtual void OnDragDone() OVERRIDE; |
73 virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE; | 74 virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE; |
74 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 75 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
75 virtual void OnFocus() OVERRIDE; | 76 virtual void OnFocus() OVERRIDE; |
76 virtual void OnBlur() OVERRIDE; | 77 virtual void OnBlur() OVERRIDE; |
77 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE; | 78 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE; |
78 | 79 |
79 // TouchSelectionClientView overrides: | 80 // ui::TouchEditable overrides: |
80 virtual void SelectRect(const gfx::Point& start, | 81 virtual void SelectRect(const gfx::Point& start, |
81 const gfx::Point& end) OVERRIDE; | 82 const gfx::Point& end) OVERRIDE; |
| 83 virtual const gfx::Rect& GetBounds() OVERRIDE; |
| 84 virtual gfx::NativeView GetNativeView() OVERRIDE; |
| 85 virtual void ConvertPointToScreen(gfx::Point* point) OVERRIDE; |
| 86 virtual void ConvertPointFromScreen(gfx::Point* point) OVERRIDE; |
82 | 87 |
83 // ContextMenuController overrides: | 88 // ContextMenuController overrides: |
84 virtual void ShowContextMenuForView(View* source, | 89 virtual void ShowContextMenuForView(View* source, |
85 const gfx::Point& point) OVERRIDE; | 90 const gfx::Point& point) OVERRIDE; |
86 | 91 |
87 // Overridden from DragController: | 92 // Overridden from DragController: |
88 virtual void WriteDragDataForView(View* sender, | 93 virtual void WriteDragDataForView(View* sender, |
89 const gfx::Point& press_pt, | 94 const gfx::Point& press_pt, |
90 ui::OSExchangeData* data) OVERRIDE; | 95 ui::OSExchangeData* data) OVERRIDE; |
91 virtual int GetDragOperationsForView(View* sender, | 96 virtual int GetDragOperationsForView(View* sender, |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 // State variables used to track double and triple clicks. | 298 // State variables used to track double and triple clicks. |
294 size_t aggregated_clicks_; | 299 size_t aggregated_clicks_; |
295 base::TimeDelta last_click_time_; | 300 base::TimeDelta last_click_time_; |
296 gfx::Point last_click_location_; | 301 gfx::Point last_click_location_; |
297 | 302 |
298 // Context menu and its content list for the textfield. | 303 // Context menu and its content list for the textfield. |
299 scoped_ptr<ui::SimpleMenuModel> context_menu_contents_; | 304 scoped_ptr<ui::SimpleMenuModel> context_menu_contents_; |
300 scoped_ptr<views::MenuModelAdapter> context_menu_delegate_; | 305 scoped_ptr<views::MenuModelAdapter> context_menu_delegate_; |
301 scoped_ptr<views::MenuRunner> context_menu_runner_; | 306 scoped_ptr<views::MenuRunner> context_menu_runner_; |
302 | 307 |
303 scoped_ptr<TouchSelectionController> touch_selection_controller_; | 308 scoped_ptr<ui::TouchSelectionController> touch_selection_controller_; |
304 | 309 |
305 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldViews); | 310 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldViews); |
306 }; | 311 }; |
307 | 312 |
308 } // namespace views | 313 } // namespace views |
309 | 314 |
310 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ | 315 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ |
OLD | NEW |