| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 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 UI_VIEWS_SELECTION_CONTROLLER_DELEGATE_H_ |
| 6 #define UI_VIEWS_SELECTION_CONTROLLER_DELEGATE_H_ |
| 7 |
| 8 #include "ui/views/views_export.h" |
| 9 |
| 10 namespace ui { |
| 11 class MouseEvent; |
| 12 } |
| 13 |
| 14 namespace views { |
| 15 |
| 16 // An interface implemented/managed by a view which uses the |
| 17 // SelectionController. |
| 18 class VIEWS_EXPORT SelectionControllerDelegate { |
| 19 public: |
| 20 // Returns the associated RenderText instance to be used for selection. |
| 21 virtual gfx::RenderText* GetRenderTextForSelectionController() = 0; |
| 22 |
| 23 // Methods related to properties of the associated view. |
| 24 |
| 25 // Returns true if the associated text view is read only. |
| 26 virtual bool IsReadOnly() const = 0; |
| 27 // Returns whether there is a drag operation originating from the associated |
| 28 // view. |
| 29 virtual bool HasTextBeingDragged() const = 0; |
| 30 // Sets whether text is being dragged from the associated view. |
| 31 virtual void SetTextBeingDragged(bool value) = 0; |
| 32 // Returns the height of the associated view. |
| 33 virtual int GetViewHeight() const = 0; |
| 34 // Returns the width of the associated view. |
| 35 virtual int GetViewWidth() const = 0; |
| 36 // Returns the drag selection timer delay. This is the duration after which a |
| 37 // drag selection is updated when the event location is outside the text |
| 38 // bounds. |
| 39 virtual int GetDragSelectionDelay() const = 0; |
| 40 |
| 41 // Called before a pointer action which may change the associated view's |
| 42 // selection and/or text. Should not be called in succession and must always |
| 43 // be followed by an OnAfterPointerAction call. |
| 44 virtual void OnBeforePointerAction() = 0; |
| 45 // Called after a pointer action. |text_changed| and |selection_changed| can |
| 46 // be used by subclasses to make any necessary updates like redraw the text. |
| 47 // Must always be preceeded by an OnBeforePointerAction call. |
| 48 virtual void OnAfterPointerAction(bool text_changed, |
| 49 bool selection_changed) = 0; |
| 50 |
| 51 // Pastes the text from the selection clipboard at the current cursor |
| 52 // position. Always called within a pointer action for a non-readonly view. |
| 53 // Returns true if some text was pasted. |
| 54 virtual bool PasteSelectionClipboard() = 0; |
| 55 // Updates the selection clipboard with the currently selected text. Should |
| 56 // empty the selection clipboard if no text is currently selected. |
| 57 // NO-OP if the associated text view is obscured. Since this does not modify |
| 58 // the render text instance, it may be called outside of a pointer action. |
| 59 virtual void UpdateSelectionClipboard() = 0; |
| 60 |
| 61 protected: |
| 62 virtual ~SelectionControllerDelegate() {} |
| 63 }; |
| 64 |
| 65 } // namespace views |
| 66 |
| 67 #endif // UI_VIEWS_SELECTION_CONTROLLER_DELEGATE_H_ |
| OLD | NEW |