OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_TOUCHUI_TOUCH_SELECTION_CONTROLLER_H_ | 5 #ifndef UI_BASE_TOUCH_TOUCH_EDITING_CONTROLLER_H_ |
6 #define UI_VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_H_ | 6 #define UI_BASE_TOUCH_TOUCH_EDITING_CONTROLLER_H_ |
7 | 7 |
8 #include "ui/base/models/simple_menu_model.h" | 8 #include "ui/base/models/simple_menu_model.h" |
9 #include "ui/gfx/point.h" | 9 #include "ui/gfx/point.h" |
10 #include "ui/views/view.h" | 10 #include "ui/gfx/rect.h" |
11 | 11 |
12 namespace views { | 12 namespace ui { |
13 | 13 |
14 // An interface implemented by a View that has text that can be selected. | 14 // An interface implemented by widget that has text that can be selected/edited |
15 class VIEWS_EXPORT TouchSelectionClientView | 15 // using touch. |
16 : public View, | 16 class UI_EXPORT TouchEditable : public ui::SimpleMenuModel::Delegate { |
17 public ui::SimpleMenuModel::Delegate { | |
18 public: | 17 public: |
19 // Select everything between start and end (points are in view's local | 18 // Select everything between start and end (points are in view's local |
20 // coordinate system). |start| is the logical start and |end| is the logical | 19 // coordinate system). |start| is the logical start and |end| is the logical |
21 // end of selection. Visually, |start| may lie after |end|. | 20 // end of selection. Visually, |start| may lie after |end|. |
22 virtual void SelectRect(const gfx::Point& start, const gfx::Point& end) = 0; | 21 virtual void SelectRect(const gfx::Point& start, const gfx::Point& end) = 0; |
23 | 22 |
| 23 // Gets the bounds of the client view in parent's coordinates. |
| 24 virtual const gfx::Rect& GetBounds() = 0; |
| 25 |
| 26 // Gets the NativeView hosting the client. |
| 27 virtual gfx::NativeView GetNativeView() = 0; |
| 28 |
| 29 // Converts a point to/from screen coordinates from/to client view. |
| 30 virtual void ConvertPointToScreen(gfx::Point* point) = 0; |
| 31 virtual void ConvertPointFromScreen(gfx::Point* point) = 0; |
| 32 |
24 protected: | 33 protected: |
25 virtual ~TouchSelectionClientView() {} | 34 virtual ~TouchEditable() {} |
26 }; | 35 }; |
27 | 36 |
28 // This defines the callback interface for other code to be notified of changes | 37 // This defines the callback interface for other code to be notified of changes |
29 // in the state of a TouchSelectionClientView. | 38 // in the state of a TouchEditable. |
30 class VIEWS_EXPORT TouchSelectionController { | 39 class UI_EXPORT TouchSelectionController { |
31 public: | 40 public: |
32 virtual ~TouchSelectionController() {} | 41 virtual ~TouchSelectionController() {} |
33 | 42 |
34 // Creates a TouchSelectionController. Caller owns the returned object. | 43 // Creates a TouchSelectionController. Caller owns the returned object. |
35 static TouchSelectionController* create( | 44 static TouchSelectionController* create( |
36 TouchSelectionClientView* client_view); | 45 TouchEditable* client_view); |
37 | 46 |
38 // Notification that the text selection in TouchSelectionClientView has | 47 // Notification that the text selection in TouchEditable has |
39 // changed. p1 and p2 are lower corners of the start and end of selection: | 48 // changed. p1 and p2 are lower corners of the start and end of selection: |
40 // ____________________________________ | 49 // ____________________________________ |
41 // | textfield with |selected text| | | 50 // | textfield with |selected text| | |
42 // ------------------------------------ | 51 // ------------------------------------ |
43 // ^p1 ^p2 | 52 // ^p1 ^p2 |
44 // | 53 // |
45 // p1 is always the start and p2 is always the end of selection. Hence, | 54 // p1 is always the start and p2 is always the end of selection. Hence, |
46 // p1 could be to the right of p2 in the figure above. | 55 // p1 could be to the right of p2 in the figure above. |
47 virtual void SelectionChanged(const gfx::Point& p1, const gfx::Point& p2) = 0; | 56 virtual void SelectionChanged(const gfx::Point& p1, const gfx::Point& p2) = 0; |
48 | 57 |
49 // Notification that the TouchSelectionClientView has lost focus. | 58 // Notification that the TouchEditable has lost focus. |
50 virtual void ClientViewLostFocus() = 0; | 59 virtual void ClientViewLostFocus() = 0; |
51 }; | 60 }; |
52 | 61 |
53 } // namespace views | 62 } // namespace views |
54 | 63 |
55 #endif // UI_VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_H_ | 64 #endif // UI_BASE_TOUCH_TOUCH_EDITING_CONTROLLER_H_ |
OLD | NEW |