2015-11-19 07:47:53 -06:00
|
|
|
// 18 november 2015
|
2015-11-19 15:57:15 -06:00
|
|
|
#include <vector>
|
2015-11-19 07:47:53 -06:00
|
|
|
#include "uipriv_haiku.hpp"
|
2015-11-19 15:57:15 -06:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
struct tabPage {
|
|
|
|
BTab *tab;
|
|
|
|
BView *view;
|
|
|
|
struct singleChild *child;
|
|
|
|
};
|
2015-11-19 07:47:53 -06:00
|
|
|
|
|
|
|
struct uiTab {
|
|
|
|
uiHaikuControl c;
|
2015-11-19 11:41:58 -06:00
|
|
|
BTabView *tabview;
|
2015-11-19 15:57:15 -06:00
|
|
|
vector<struct tabPage> *pages;
|
2015-11-19 07:47:53 -06:00
|
|
|
};
|
|
|
|
|
2015-11-19 15:57:15 -06:00
|
|
|
static void onDestroy(uiTab *);
|
|
|
|
|
|
|
|
uiHaikuDefineControlWithOnDestroy(
|
2015-11-19 07:47:53 -06:00
|
|
|
uiTab, // type name
|
|
|
|
uiTabType, // type function
|
2015-11-19 15:57:15 -06:00
|
|
|
tabview, // handle
|
|
|
|
onDestroy(hthis); // on destroy
|
2015-11-19 07:47:53 -06:00
|
|
|
)
|
|
|
|
|
2015-11-19 15:57:15 -06:00
|
|
|
static void onDestroy(uiTab *t)
|
2015-11-19 07:47:53 -06:00
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2015-11-19 15:57:15 -06:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2015-11-19 07:47:53 -06:00
|
|
|
void uiTabInsertAt(uiTab *t, const char *name, uintmax_t before, uiControl *c)
|
|
|
|
{
|
2015-11-19 15:57:15 -06:00
|
|
|
struct tabPage p;
|
|
|
|
|
2015-11-20 13:00:36 -06:00
|
|
|
p.view = new BView(NULL, B_SUPPORTS_LAYOUT);
|
2015-11-19 16:11:35 -06:00
|
|
|
// TODO needed?
|
|
|
|
p.view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
2015-11-19 15:57:15 -06:00
|
|
|
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);
|
2015-11-19 07:47:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void uiTabDelete(uiTab *t, uintmax_t index)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
uintmax_t uiTabNumPages(uiTab *t)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int uiTabMargined(uiTab *t, uintmax_t page)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiTabSetMargined(uiTab *t, uintmax_t page, int margined)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
uiTab *uiNewTab(void)
|
|
|
|
{
|
|
|
|
uiTab *t;
|
|
|
|
|
|
|
|
t = (uiTab *) uiNewControl(uiTabType());
|
|
|
|
|
2015-11-20 12:56:09 -06:00
|
|
|
t->tabview = new BTabView(NULL, B_WIDTH_FROM_LABEL);
|
2015-11-19 15:57:15 -06:00
|
|
|
// TODO scrollable
|
|
|
|
|
|
|
|
t->pages = new vector<struct tabPage>();
|
2015-11-19 07:47:53 -06:00
|
|
|
|
|
|
|
uiHaikuFinishNewControl(t, uiTab);
|
|
|
|
|
|
|
|
return t;
|
|
|
|
}
|