-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathYabStackView.cpp
More file actions
50 lines (42 loc) · 982 Bytes
/
YabStackView.cpp
File metadata and controls
50 lines (42 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// #include <string.h>
#include "YabStackView.h"
YabStackView::YabStackView(BRect frame, const char *name, int32 number_of_views, uint32 resizingMode, uint32 flags, const BFont *labelFont) : BView(frame, name, resizingMode, flags)
{
myViews = new BView*[number_of_views];
// init
for(int i=0; i < number_of_views; i++)
{
myViews[i] = NULL;
}
myCurrent = 0;
myBounds = Bounds();
myNumOfViews = number_of_views;
}
YabStackView::~YabStackView()
{
delete[] myViews;
}
void YabStackView::AddViews(BView** stackedViews)
{
for(int32 i = 0; i < myNumOfViews; i++)
{
myViews[i] = stackedViews[i];
if(i != myCurrent) myViews[i]->Hide();
AddChild(myViews[i]);
}
}
void YabStackView::SelectView(int32 index)
{
if(index != myCurrent && index >= 0 && index < myNumOfViews)
{
Invalidate(myBounds);
myViews[myCurrent]->Hide();
myCurrent = index;
Invalidate(myBounds);
myViews[myCurrent]->Show();
}
}
int32 YabStackView::CurrentView()
{
return myCurrent;
}