Add ICU message format support
[chromium-blink-merge.git] / ui / base / touch / touch_editing_controller.h
blob96eecc1c2a40f51c8884b5527303172e97269b8c
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
3 // found in the LICENSE file.
5 #ifndef UI_BASE_TOUCH_TOUCH_EDITING_CONTROLLER_H_
6 #define UI_BASE_TOUCH_TOUCH_EDITING_CONTROLLER_H_
8 #include "ui/base/models/simple_menu_model.h"
10 namespace gfx {
11 class Point;
12 class Rect;
15 namespace ui {
16 class SelectionBound;
18 // An interface implemented by widget that has text that can be selected/edited
19 // using touch.
20 class UI_BASE_EXPORT TouchEditable : public ui::SimpleMenuModel::Delegate {
21 public:
22 // TODO(mohsen): Consider switching from local coordinates to screen
23 // coordinates in this interface and see if it will simplify things.
25 // Select everything between start and end (points are in view's local
26 // coordinate system). |start| is the logical start and |end| is the logical
27 // end of selection. Visually, |start| may lie after |end|.
28 virtual void SelectRect(const gfx::Point& start, const gfx::Point& end) = 0;
30 // Move the caret to |point|. |point| is in local coordinates.
31 virtual void MoveCaretTo(const gfx::Point& point) = 0;
33 // Gets the end points of the current selection. The end points |anchor| and
34 // |focus| must be the cursor rect for the logical start and logical end of
35 // selection (in local coordinates):
36 // ____________________________________
37 // | textfield with |selected text| |
38 // ------------------------------------
39 // ^anchor ^focus
41 // Visually, anchor could be to the right of focus in the figure above - it
42 // depends on the selection direction.
43 virtual void GetSelectionEndPoints(ui::SelectionBound* anchor,
44 ui::SelectionBound* focus) = 0;
46 // Gets the bounds of the client view in its local coordinates.
47 virtual gfx::Rect GetBounds() = 0;
49 // Gets the NativeView hosting the client.
50 virtual gfx::NativeView GetNativeView() const = 0;
52 // Converts a point to/from screen coordinates from/to client view.
53 virtual void ConvertPointToScreen(gfx::Point* point) = 0;
54 virtual void ConvertPointFromScreen(gfx::Point* point) = 0;
56 // Returns true if the editable draws its own handles (hence, the
57 // TouchEditingControllerDeprecated need not draw handles).
58 virtual bool DrawsHandles() = 0;
60 // Tells the editable to open context menu.
61 virtual void OpenContextMenu(const gfx::Point& anchor) = 0;
63 // Tells the editable to end touch editing and destroy touch selection
64 // controller it owns.
65 virtual void DestroyTouchSelection() = 0;
67 protected:
68 ~TouchEditable() override {}
71 // This defines the callback interface for other code to be notified of changes
72 // in the state of a TouchEditable.
73 class UI_BASE_EXPORT TouchEditingControllerDeprecated {
74 public:
75 virtual ~TouchEditingControllerDeprecated() {}
77 // Creates a TouchEditingControllerDeprecated. Caller owns the returned
78 // object.
79 static TouchEditingControllerDeprecated* Create(
80 TouchEditable* client_view);
82 // Notifies the controller that the selection has changed.
83 virtual void SelectionChanged() = 0;
85 // Returns true if the user is currently dragging one of the handles.
86 virtual bool IsHandleDragInProgress() = 0;
88 // Hides visible handles. According to the value of |quick|, handles might
89 // fade out quickly or slowly.
90 virtual void HideHandles(bool quick) = 0;
93 class UI_BASE_EXPORT TouchEditingControllerFactory {
94 public:
95 static void SetInstance(TouchEditingControllerFactory* instance);
97 virtual TouchEditingControllerDeprecated* Create(TouchEditable* client_view)
98 = 0;
100 protected:
101 virtual ~TouchEditingControllerFactory() {}
104 } // namespace ui
106 #endif // UI_BASE_TOUCH_TOUCH_EDITING_CONTROLLER_H_