ASPiK SDK
ctabview.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 __ctabview__
6 #define __ctabview__
7 
8 #include "vstguifwd.h"
9 #include "cviewcontainer.h"
10 #include "cfont.h"
11 #include "ccolor.h"
12 #include "controls/icontrollistener.h"
13 
14 namespace VSTGUI {
15 
16 class CTabChildView;
17 
18 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
23 {
24 public:
25  enum TabPosition {
26  kPositionLeft = 0,
27  kPositionRight,
28  kPositionTop,
29  kPositionBottom
30  };
31 
32  enum TabAlignment {
33  kAlignCenter = 0,
34  kAlignLeft,
35  kAlignRight,
36  kAlignTop = kAlignLeft,
37  kAlignBottom = kAlignRight
38  };
39 
40  CTabView (const CRect& size, CBitmap* tabBitmap, CBitmap* background = nullptr, TabPosition tabPosition = kPositionTop, int32_t style = 0);
41  CTabView (const CRect& size, const CRect& tabSize, CBitmap* background = nullptr, TabPosition tabPosition = kPositionTop, int32_t style = 0);
42 
43  //-----------------------------------------------------------------------------
45  //-----------------------------------------------------------------------------
47  virtual bool addTab (CView* view, UTF8StringPtr name = nullptr, CBitmap* tabBitmap = nullptr);
48  virtual bool addTab (CView* view, CControl* button);
49  virtual bool removeTab (CView* view);
50  virtual bool removeAllTabs ();
51  virtual bool selectTab (int32_t index);
52  virtual int32_t getCurrentSelectedTab () const { return currentTab; }
53 
54  virtual CRect& getTabViewSize (CRect& rect) const;
55 
56  virtual void setTabFontStyle (const CFontRef font, CCoord fontSize = 12, CColor selectedColor = kBlackCColor, CColor deselectedColor = kWhiteCColor);
57 
58  virtual void alignTabs (TabAlignment alignment = kAlignCenter);
59 
60  virtual void setTabViewInsets (const CPoint& inset);
62 
63  void drawBackgroundRect (CDrawContext *pContext, const CRect& _updateRect) override;
64  void valueChanged (CControl *pControl) override;
65  void setViewSize (const CRect &rect, bool invalid = true) override;
66  void setAutosizeFlags (int32_t flags) override;
67 //-----------------------------------------------------------------------------
68  CLASS_METHODS (CTabView, CViewContainer)
69 protected:
70  ~CTabView () noexcept override;
71  void setCurrentChild (CTabChildView* childView);
72 
73  int32_t numberOfChilds;
74  int32_t currentTab;
75  TabPosition tabPosition;
76  int32_t style;
77  CRect tabSize;
78  CPoint tabViewInset;
79  CBitmap* tabBitmap;
80  CTabChildView* firstChild;
81  CTabChildView* lastChild;
82  CTabChildView* currentChild;
83 };
84 
85 } // namespace
86 
87 #endif
void invalid() override
mark whole view as invalid
Definition: cviewcontainer.cpp:618
void drawBackgroundRect(CDrawContext *pContext, const CRect &_updateRect) override
draw the background
Definition: ctabview.cpp:357
Container Class of CView objects.
Definition: cviewcontainer.h:52
font class
Definition: cfont.h:31
Rect structure.
Definition: crect.h:17
virtual bool removeTab(CView *view)
remove a tab
Definition: ctabview.cpp:257
a tab view
Definition: ctabview.h:19
void setViewSize(const CRect &rect, bool invalid=true) override
set views size
Definition: ctabview.cpp:471
A drawing context encapsulates the drawing context of the underlying OS.
Definition: cdrawcontext.h:29
RGBA Color structure.
Definition: ccolor.h:15
virtual void setTabFontStyle(const CFontRef font, CCoord fontSize=12, CColor selectedColor=kBlackCColor, CColor deselectedColor=kWhiteCColor)
call this after the tabs are added. Tabs added after this call will have the default font style...
Definition: ctabview.cpp:406
void setAutosizeFlags(int32_t flags) override
set autosize flags
Definition: ctabview.cpp:153
virtual void alignTabs(TabAlignment alignment=kAlignCenter)
call this after you have added all tabs to align them according to alignment
Definition: ctabview.cpp:425
Encapsulates various platform depended kinds of bitmaps.
Definition: cbitmap.h:21
Definition: customcontrols.cpp:8
virtual bool selectTab(int32_t index)
select tab at index
Definition: ctabview.cpp:309
base class of all VSTGUI controls
Definition: ccontrol.h:76
virtual int32_t getCurrentSelectedTab() const
get current index of selected tab
Definition: ctabview.h:52
Base Class of all view objects.
Definition: cview.h:44
virtual CRect & getTabViewSize(CRect &rect) const
the size of one tab
Definition: ctabview.cpp:386
virtual bool removeAllTabs()
remove all tabs
Definition: ctabview.cpp:291
Point structure.
Definition: cpoint.h:17
Definition: icontrollistener.h:14
virtual bool addTab(CView *view, UTF8StringPtr name=nullptr, CBitmap *tabBitmap=nullptr)
add a tab
Definition: ctabview.cpp:159