ASPiK SDK
uiselection.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 __uiselection__
6 #define __uiselection__
7 
8 #if VSTGUI_LIVE_EDITING
9 
10 #include "../../lib/cview.h"
11 #include "../../lib/idependency.h"
12 #include <list>
13 #include <string>
14 
15 namespace VSTGUI {
16 class UIViewFactory;
17 class IUIDescription;
18 class OutputStream;
19 class InputStream;
20 
21 using UISelectionViewList = std::list<SharedPointer<CView>>;
22 //----------------------------------------------------------------------------------------------------
23 class UISelection : public CBaseObject, protected UISelectionViewList, public IDependency
24 //----------------------------------------------------------------------------------------------------
25 {
26 public:
27  using UISelectionViewList::const_iterator;
28  using UISelectionViewList::const_reverse_iterator;
29  using UISelectionViewList::begin;
30  using UISelectionViewList::end;
31  using UISelectionViewList::rbegin;
32  using UISelectionViewList::rend;
33 
34  enum {
35  kMultiSelectionStyle,
36  kSingleSelectionStyle
37  };
38 
39  UISelection (int32_t style = kMultiSelectionStyle);
40  ~UISelection () override;
41 
42  void setStyle (int32_t style);
43 
44  void add (CView* view);
45  void remove (CView* view);
46  void setExclusive (CView* view);
47  void empty ();
48 
49  CView* first () const;
50 
51  bool contains (CView* view) const;
52  bool containsParent (CView* view) const;
53 
54  int32_t total () const;
55  CRect getBounds () const;
56  static CRect getGlobalViewCoordinates (CView* view);
57 
58  void moveBy (const CPoint& p);
59  void invalidRects () const;
60 
61  void setDragOffset (const CPoint& p) { dragOffset = p; }
62  const CPoint& getDragOffset () const { return dragOffset; }
63 
64  static IdStringPtr kMsgSelectionWillChange;
65  static IdStringPtr kMsgSelectionChanged;
66  static IdStringPtr kMsgSelectionViewWillChange;
67  static IdStringPtr kMsgSelectionViewChanged;
68 
69  bool store (OutputStream& stream, IUIDescription* uiDescription);
70  bool restore (InputStream& stream, IUIDescription* uiDescription);
71 protected:
72 
73  std::list<CBaseObject*> dependencies;
74  int32_t style;
75 
76  CPoint dragOffset;
77 };
78 
79 } // namespace
80 
81 #endif // VSTGUI_LIVE_EDITING
82 
83 #endif // __uiselection__
Definition: customcontrols.cpp:8