5 #ifndef __cviewcontainer__ 6 #define __cviewcontainer__ 10 #include "cdrawdefs.h" 11 #if VSTGUI_TOUCH_EVENT_HANDLING 12 #include "itouchevent.h" 19 extern IdStringPtr kMsgLooseFocus;
27 kMouseEnabled = 1 << 1,
28 kIncludeViewContainer = 1 << 2,
29 kIncludeInvisible = 1 << 3
32 explicit GetViewOptions (uint32_t options = kNone) : flags (options) {}
34 GetViewOptions& deep (
bool state =
true) { setBit (flags, kDeep, state);
return *
this; }
35 GetViewOptions& mouseEnabled (
bool state =
true) { setBit (flags, kMouseEnabled, state);
return *
this; }
36 GetViewOptions& includeViewContainer (
bool state =
true) { setBit (flags, kIncludeViewContainer, state);
return *
this; }
37 GetViewOptions& includeInvisible (
bool state =
true) { setBit (flags, kIncludeInvisible, state);
return *
this; }
39 bool getDeep ()
const {
return hasBit (flags, kDeep); }
40 bool getMouseEnabled ()
const {
return hasBit (flags, kMouseEnabled); }
41 bool getIncludeViewContainer ()
const {
return hasBit (flags, kIncludeViewContainer); }
42 bool getIncludeInvisible ()
const {
return hasBit (flags, kIncludeInvisible); }
55 using ViewList = std::list<SharedPointer<CView>>;
65 virtual bool addView (
CView* pView,
const CRect& mouseableArea,
bool mouseEnabled =
true);
68 virtual bool removeAll (
bool withForget =
true);
82 bool getAutosizingEnabled ()
const {
return hasViewFlag (kAutosizeSubviews); }
85 template<
class ViewClass,
class ContainerClass>
99 virtual void setBackgroundColorDrawStyle (CDrawStyle style);
100 CDrawStyle getBackgroundColorDrawStyle ()
const;
104 virtual bool invalidateDirtyViews ();
121 bool onWheel (
const CPoint& where,
const CMouseWheelAxis& axis,
const float& distance,
const CButtonState& buttons)
override;
125 #if VSTGUI_TOUCH_EVENT_HANDLING 126 virtual void onTouchEvent (ITouchEvent& event)
override;
127 virtual bool wantsMultiTouchEvents ()
const override {
return true; }
128 virtual void findSingleTouchEventTarget (ITouchEvent::Touch& event);
139 bool isDirty ()
const override;
155 using ChildViewConstIterator = ViewList::const_iterator;
156 using ChildViewConstReverseIterator = ViewList::const_reverse_iterator;
159 template<
bool reverse>
163 explicit Iterator<reverse> (
const CViewContainer* container) : children (container->getChildren ()) {
if (reverse) riterator = children.rbegin ();
else iterator = children.begin (); }
194 CView* operator* ()
const 197 return riterator != children.rend () ? *riterator :
nullptr;
198 return iterator != children.end () ? *iterator :
nullptr;
202 const ViewList& children;
203 ChildViewConstIterator iterator;
204 ChildViewConstReverseIterator riterator;
211 void dumpInfo ()
override;
212 virtual void dumpHierarchy ();
216 const CViewContainer* asViewContainer () const final {
return this; }
220 kAutosizeSubviews = 1 << (CView::kLastCViewFlag + 1)
224 void beforeDelete () override;
228 void setMouseDownView (CView* view);
229 CView* getMouseDownView () const;
231 const ViewList& getChildren () const;
234 std::unique_ptr<Impl> pImpl;
241 template<class ViewClass, class ContainerClass>
244 for (
auto& child : getChildren ())
246 auto vObj = child.cast<ViewClass> ();
249 result.push_back (vObj);
253 if (
auto container = child->asViewContainer ())
255 container->getChildViewsOfType<ViewClass, ContainerClass> (result);
259 return static_cast<uint32_t
> (result.size ());
ViewContainer Listener Interface.
Definition: iviewlistener.h:31
virtual bool isChild(CView *pView) const
check if pView is a child view of this container
Definition: cviewcontainer.cpp:501
void invalid() override
mark whole view as invalid
Definition: cviewcontainer.cpp:618
Container Class of CView objects.
Definition: cviewcontainer.h:52
Rect structure.
Definition: crect.h:17
bool removed(CView *parent) override
view is removed from parent view
Definition: cviewcontainer.cpp:1355
virtual bool hitTestSubViews(const CPoint &where, const CButtonState &buttons=-1)
Definition: cviewcontainer.cpp:829
virtual bool addView(CView *pView)
add a child view
Definition: cviewcontainer.cpp:376
virtual void drawBackgroundRect(CDrawContext *pContext, const CRect &_updateRect)
draw the background
Definition: cviewcontainer.cpp:656
Definition: cviewcontainer.h:22
virtual bool removeView(CView *pView, bool withForget=true)
remove a child view
Definition: cviewcontainer.cpp:472
A drawing context encapsulates the drawing context of the underlying OS.
Definition: cdrawcontext.h:29
bool onWheel(const CPoint &where, const float &distance, const CButtonState &buttons) override
called if a mouse wheel event is happening over this view
Definition: cviewcontainer.cpp:972
virtual uint32_t getNbViews() const
get the number of child views
Definition: cviewcontainer.cpp:544
virtual bool getViewsAt(const CPoint &where, ViewList &views, const GetViewOptions &options=GetViewOptions().deep()) const
get all views at point where, top->down
Definition: cviewcontainer.cpp:1262
virtual bool removeAll(bool withForget=true)
remove all child views
Definition: cviewcontainer.cpp:442
Base Object with reference counter.
Definition: vstguibase.h:276
bool hitTest(const CPoint &where, const CButtonState &buttons=-1) override
Definition: cviewcontainer.cpp:858
RGBA Color structure.
Definition: ccolor.h:15
virtual CViewContainer * getContainerAt(const CPoint &where, const GetViewOptions &options=GetViewOptions().deep()) const
get the container at point where
Definition: cviewcontainer.cpp:1306
CPoint & localToFrame(CPoint &point) const override
conversion from local view coordinates to frame coordinates
Definition: cviewcontainer.cpp:1346
virtual CColor getBackgroundColor() const
get the background color
Definition: cviewcontainer.cpp:315
bool attached(CView *parent) override
view is attached to a parent view
Definition: cviewcontainer.cpp:1367
bool onDrop(IDataPackage *drag, const CPoint &where) override
called if a drag is dropped onto this view
Definition: cviewcontainer.cpp:978
Definition: customcontrols.cpp:8
virtual const CPoint & getBackgroundOffset() const
get the offset of the background bitmap
Definition: cviewcontainer.cpp:327
virtual bool changeViewZOrder(CView *view, uint32_t newIndex)
change view z order position
Definition: cviewcontainer.cpp:569
virtual void setBackgroundOffset(const CPoint &p)
set the offset of the background bitmap
Definition: cviewcontainer.cpp:321
void drawRect(CDrawContext *pContext, const CRect &updateRect) override
Definition: cviewcontainer.cpp:696
virtual void setAutosizingEnabled(bool state)
enable or disable autosizing subviews. Per default this is enabled.
Definition: cviewcontainer.cpp:154
void setViewSize(const CRect &rect, bool invalid=true) override
Definition: cviewcontainer.cpp:164
void parentSizeChanged() override
notification that one of the views parent has changed its size
Definition: cviewcontainer.cpp:100
Base Class of all view objects.
Definition: cview.h:44
void onDragMove(IDataPackage *drag, const CPoint &where) override
called if a drag is moved inside this view
Definition: cviewcontainer.cpp:1031
virtual bool hasChildren() const
check if container has child views
Definition: cviewcontainer.cpp:535
interface for drag&drop and clipboard data
Definition: idatapackage.h:15
void looseFocus() override
called if view should loose focus
Definition: cviewcontainer.cpp:1124
CMouseEventResult onMouseMoved(CPoint &where, const CButtonState &buttons) override
called when a mouse move event occurs
Definition: cviewcontainer.cpp:920
bool sizeToFit() override
resize view to optimal size
Definition: cviewcontainer.cpp:262
virtual bool checkUpdateRect(CView *view, const CRect &rect)
Definition: cviewcontainer.cpp:818
CMouseEventResult onMouseDown(CPoint &where, const CButtonState &buttons) override
called when a mouse down event occurs
Definition: cviewcontainer.cpp:866
CPoint & frameToLocal(CPoint &point) const override
conversion from frame coordinates to local view coordinates
Definition: cviewcontainer.cpp:1337
Definition: cviewcontainer.h:160
void draw(CDrawContext *pContext) override
Definition: cviewcontainer.cpp:646
void onDragLeave(IDataPackage *drag, const CPoint &where) override
called if a drag is leaving this view
Definition: cviewcontainer.cpp:1019
uint32_t getChildViewsOfType(ContainerClass &result, bool deep=false) const
Definition: cviewcontainer.h:242
void takeFocus() override
called if view should take focus
Definition: cviewcontainer.cpp:1130
bool isDirty() const override
check if view is dirty
Definition: cviewcontainer.cpp:1193
CMouseEventResult onMouseCancel() override
called when mouse tracking should be canceled
Definition: cviewcontainer.cpp:941
void invalidRect(const CRect &rect) override
mark rect as invalid
Definition: cviewcontainer.cpp:628
virtual bool advanceNextFocusView(CView *oldFocus, bool reverse=false)
Definition: cviewcontainer.cpp:1141
virtual CRect getVisibleSize(const CRect &rect) const
Definition: cviewcontainer.cpp:246
Point structure.
Definition: cpoint.h:17
virtual void setBackgroundColor(const CColor &color)
set the background color (will only be drawn if this container is not set to transparent and does not...
Definition: cviewcontainer.cpp:305
CMouseEventResult onMouseUp(CPoint &where, const CButtonState &buttons) override
called when a mouse up event occurs
Definition: cviewcontainer.cpp:903
virtual CView * getViewAt(const CPoint &where, const GetViewOptions &options=GetViewOptions()) const
get the view at point where
Definition: cviewcontainer.cpp:1220
CViewContainer(const CRect &size)
Definition: cviewcontainer.cpp:53
virtual CView * getView(uint32_t index) const
get the child view at index
Definition: cviewcontainer.cpp:554
void onDragEnter(IDataPackage *drag, const CPoint &where) override
called if a drag is entering this view
Definition: cviewcontainer.cpp:1004
CMessageResult notify(CBaseObject *sender, IdStringPtr message) override
Definition: cviewcontainer.cpp:349