| 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 // Methods called to notify a mouse action which may change the associated |
| 42 // view's selection and/or text. |
| 43 |
| 44 // Should not be called in succession and must always be followed by an |
| 45 // OnAfterMouseAction call. |
| 46 virtual void OnBeforeMouseAction() = 0; |
| 47 // |text_changed| and |selection_changed| can be used by subclasses to make |
| 48 // any necessary updates like redraw the text. Must always be preceeded by an |
| 49 // OnBeforeMouseAction call. |
| 50 virtual void OnAfterMouseAction(bool text_changed, |
| 51 bool selection_changed) = 0; |
| 52 |
| 53 // Selection clipboard related methods. |
| 54 |
| 55 // Pastes the text from the selection clipboard at the current cursor |
| 56 // position. Always called within a mouse action for a non-readonly view. |
| 57 // Returns true if some text was pasted. |
| 58 virtual bool PasteSelectionClipboard() = 0; |
| 59 // Updates the selection clipboard with the currently selected text. Should |
| 60 // empty the selection clipboard if no text is currently selected. |
| 61 // NO-OP if the associated text view is obscured. Since this does not modify |
| 62 // the render text instance, it may not be called within a mouse action. |
| 63 virtual void UpdateSelectionClipboard() = 0; |
| 64 |
| 65 protected: |
| 66 virtual ~SelectionControllerDelegate() {} |
| 67 }; |
| 68 |
| 69 } // namespace views |
| 70 |
| 71 #endif // UI_VIEWS_SELECTION_CONTROLLER_DELEGATE_H_ |
| OLD | NEW |