Some uiTab work.
This commit is contained in:
parent
a603386208
commit
6719275576
|
@ -1,25 +1,62 @@
|
|||
// 18 november 2015
|
||||
#include <vector>
|
||||
#include "uipriv_haiku.hpp"
|
||||
using namespace std;
|
||||
|
||||
struct tabPage {
|
||||
BTab *tab;
|
||||
BView *view;
|
||||
struct singleChild *child;
|
||||
};
|
||||
|
||||
struct uiTab {
|
||||
uiHaikuControl c;
|
||||
BTabView *tabview;
|
||||
vector<struct tabPage> *pages;
|
||||
};
|
||||
|
||||
uiHaikuDefineControl(
|
||||
static void onDestroy(uiTab *);
|
||||
|
||||
uiHaikuDefineControlWithOnDestroy(
|
||||
uiTab, // type name
|
||||
uiTabType, // type function
|
||||
tabview // handle
|
||||
tabview, // handle
|
||||
onDestroy(hthis); // on destroy
|
||||
)
|
||||
|
||||
void uiTabAppend(uiTab *t, const char *name, uiControl *c)
|
||||
static void onDestroy(uiTab *t)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void uiTabAppend(uiTab *t, const char *name, uiControl *c)
|
||||
{
|
||||
uiTabInsertAt(t, name, t->pages->size(), c);
|
||||
}
|
||||
|
||||
// see singlechild.cpp
|
||||
static void attach(void *attachTo, BLayoutItem *what)
|
||||
{
|
||||
BView *view = (BView *) attachTo;
|
||||
|
||||
// TODO refine the interface around this
|
||||
view->SetLayout((BLayout *) what);
|
||||
}
|
||||
|
||||
void uiTabInsertAt(uiTab *t, const char *name, uintmax_t before, uiControl *c)
|
||||
{
|
||||
// TODO
|
||||
struct tabPage p;
|
||||
|
||||
p.view = new BView(BRect(0, 0, 1, 1), NULL,
|
||||
B_FOLLOW_ALL_SIDES, 0);
|
||||
p.tab = new BTab(p.view);
|
||||
p.child = newSingleChild(c, uiControl(t), attach, p.view);
|
||||
|
||||
p.tab->SetLabel(name);
|
||||
|
||||
// TODO insert in the correct place
|
||||
t->tabview->AddTab(p.view, p.tab);
|
||||
t->pages->push_back(p);
|
||||
}
|
||||
|
||||
void uiTabDelete(uiTab *t, uintmax_t index)
|
||||
|
@ -51,6 +88,10 @@ uiTab *uiNewTab(void)
|
|||
t = (uiTab *) uiNewControl(uiTabType());
|
||||
|
||||
t->tabview = new BTabView(BRect(0, 0, 1, 1), NULL);
|
||||
// TODO scrollable
|
||||
t->tabview->SetTabWidth(B_WIDTH_FROM_LABEL);
|
||||
|
||||
t->pages = new vector<struct tabPage>();
|
||||
|
||||
uiHaikuFinishNewControl(t, uiTab);
|
||||
|
||||
|
|
Loading…
Reference in New Issue