ASPiK SDK
uieditview.h
1 // This file is part of VSTGUI. It is subject to the license terms
2 // in the LICENSE file found in the top-level directory of this
3 // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
4 
5 #ifndef __uieditview__
6 #define __uieditview__
7 
8 #include "../../lib/cviewcontainer.h"
9 
10 #if VSTGUI_LIVE_EDITING
11 
12 #include "../../lib/cbitmap.h"
13 #include "../../lib/ccolor.h"
14 
15 namespace VSTGUI {
16 class UIUndoManager;
17 class UISelection;
18 class UIDescription;
19 class IUIDescription;
20 class UICrossLines;
21 class ViewSizeChangeOperation;
22 class UIGrid;
23 namespace UIEditViewInternal {
24  class UIHighlightView;
25 } // namespace UIEditViewInternal
26 
27 //----------------------------------------------------------------------------------------------------
28 class UIEditView : public CViewContainer
29 {
30 public:
31  UIEditView (const CRect& size, UIDescription* uidescription);
32  ~UIEditView () override;
33 
34  void enableEditing (bool state);
35  void enableAutosizing (bool state);
36  void setScale (double scale);
37 
38  void setEditView (CView* view);
39  CView* getEditView () const;
40 
41  void doKeyMove (const CPoint& delta);
42  void doKeySize (const CPoint& delta);
43 
44  void setUndoManager (UIUndoManager* manager);
45  UIUndoManager* getUndoManager ();
46 
47  void setSelection (UISelection* selection);
48  UISelection* getSelection ();
49 
50  void setGrid (UIGrid* grid);
51 
52  void setupColors (const IUIDescription* description);
53 
54  static IdStringPtr kMsgAttached;
55  static IdStringPtr kMsgRemoved;
56 protected:
57  enum MouseEditMode {
58  kNoEditing,
59  kDragEditing,
60  kSizeEditing
61  };
62 
63  enum MouseSizeMode {
64  kSizeModeNone = 0,
65  kSizeModeBottomRight,
66  kSizeModeBottomLeft,
67  kSizeModeTopRight,
68  kSizeModeTopLeft,
69  kSizeModeLeft,
70  kSizeModeRight,
71  kSizeModeTop,
72  kSizeModeBottom
73  };
74 
75  void invalidSelection ();
76  MouseSizeMode selectionHitTest (const CPoint& where, CView** resultView);
77  bool hitTestSubViews (const CPoint& where, const CButtonState& buttons = -1) override;
78  CMouseEventResult onMouseDown (CPoint &where, const CButtonState& buttons) override;
79  CMouseEventResult onMouseUp (CPoint &where, const CButtonState& buttons) override;
80  CMouseEventResult onMouseMoved (CPoint &where, const CButtonState& buttons) override;
81  CMouseEventResult onMouseExited (CPoint& where, const CButtonState& buttons) override;
82  CMessageResult notify (CBaseObject* sender, IdStringPtr message) override;
83 
84  void doDragEditingMove (CPoint& where);
85  void doSizeEditingMove (CPoint& where);
86 
87  CBitmap* createBitmapFromSelection (UISelection* selection);
88  void startDrag (CPoint& where);
89  UISelection* getSelectionOutOfDrag (IDataPackage* drag);
90  bool onDrop (IDataPackage* drag, const CPoint& where) override;
91  void onDragEnter (IDataPackage* drag, const CPoint& where) override;
92  void onDragLeave (IDataPackage* drag, const CPoint& where) override;
93  void onDragMove (IDataPackage* drag, const CPoint& where) override;
94 
95  void draw (CDrawContext *pContext) override;
96  void drawRect (CDrawContext *pContext, const CRect& updateRect) override;
97  CView* getViewAt (const CPoint& p, const GetViewOptions& options = GetViewOptions ()) const override;
98  CViewContainer* getContainerAt (const CPoint& p, const GetViewOptions& options = GetViewOptions ().deep ()) const override;
99  bool advanceNextFocusView (CView* oldFocus, bool reverse) override;
100  bool onWheel (const CPoint &where, const CMouseWheelAxis &axis, const float &distance, const CButtonState &buttons) override;
101 
102  void looseFocus () override;
103  void takeFocus () override;
104  bool removed (CView* parent) override;
105  bool attached (CView* parent) override;
106 
107  bool editing {true};
108  bool autosizing {true};
109  MouseEditMode mouseEditMode {kNoEditing};
110  MouseSizeMode mouseSizeMode {kSizeModeNone};
111  CPoint mouseStartPoint;
112 
113  SharedPointer<UIUndoManager> undoManger;
114  SharedPointer<UISelection> selection;
115  UISelection* dragSelection {nullptr};
116  UIDescription* description {nullptr};
117  SharedPointer<UIGrid> grid;
118 
119  UIEditViewInternal::UIHighlightView* highlightView {nullptr};
120  CLayeredViewContainer* overlayView {nullptr};
121  UICrossLines* lines {nullptr};
122  ViewSizeChangeOperation* moveSizeOperation {nullptr};
123  CVSTGUITimer* editTimer {nullptr};
124 
125  CColor crosslineForegroundColor;
126  CColor crosslineBackgroundColor;
127  CColor viewHighlightColor;
128  CColor viewSelectionColor;
129 };
130 
131 } // namespace
132 
133 #endif // VSTGUI_LIVE_EDITING
134 
135 #endif // __uieditview__
Definition: customcontrols.cpp:8