OLD | NEW |
| (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_TOUCHUI_TOUCH_SELECTION_CONTROLLER_H_ | |
6 #define VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_H_ | |
7 #pragma once | |
8 | |
9 #include "ui/base/models/simple_menu_model.h" | |
10 #include "ui/gfx/point.h" | |
11 #include "views/view.h" | |
12 | |
13 namespace views { | |
14 | |
15 // An interface implemented by a View that has text that can be selected. | |
16 class VIEWS_EXPORT TouchSelectionClientView | |
17 : public View, | |
18 public ui::SimpleMenuModel::Delegate { | |
19 public: | |
20 // Select everything between start and end (points are in view's local | |
21 // coordinate system). |start| is the logical start and |end| is the logical | |
22 // end of selection. Visually, |start| may lie after |end|. | |
23 virtual void SelectRect(const gfx::Point& start, const gfx::Point& end) = 0; | |
24 | |
25 protected: | |
26 virtual ~TouchSelectionClientView() {} | |
27 }; | |
28 | |
29 // This defines the callback interface for other code to be notified of changes | |
30 // in the state of a TouchSelectionClientView. | |
31 class VIEWS_EXPORT TouchSelectionController { | |
32 public: | |
33 virtual ~TouchSelectionController() {} | |
34 | |
35 // Creates a TouchSelectionController. Caller owns the returned object. | |
36 static TouchSelectionController* create( | |
37 TouchSelectionClientView* client_view); | |
38 | |
39 // Notification that the text selection in TouchSelectionClientView has | |
40 // changed. p1 and p2 are lower corners of the start and end of selection: | |
41 // ____________________________________ | |
42 // | textfield with |selected text| | | |
43 // ------------------------------------ | |
44 // ^p1 ^p2 | |
45 // | |
46 // p1 is always the start and p2 is always the end of selection. Hence, | |
47 // p1 could be to the right of p2 in the figure above. | |
48 virtual void SelectionChanged(const gfx::Point& p1, const gfx::Point& p2) = 0; | |
49 | |
50 // Notification that the TouchSelectionClientView has lost focus. | |
51 virtual void ClientViewLostFocus() = 0; | |
52 }; | |
53 | |
54 } // namespace views | |
55 | |
56 #endif // VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_H_ | |
OLD | NEW |