diff --git a/haiku/box.cpp b/haiku/box.cpp index 5c8b2017..26a61d64 100644 --- a/haiku/box.cpp +++ b/haiku/box.cpp @@ -127,6 +127,8 @@ static uiBox *finishNewBox(orientation o) b->layout = new BGroupLayout(o, 0); b->view = new BView(NULL, B_SUPPORTS_LAYOUT, b->layout); + // TODO is this really necessary? is it correct? + b->view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); b->vertical = o == B_VERTICAL; diff --git a/haiku/button.cpp b/haiku/button.cpp index 3c3b9350..a58cb781 100644 --- a/haiku/button.cpp +++ b/haiku/button.cpp @@ -3,29 +3,38 @@ struct uiButton { uiHaikuControl c; - BStringView *dummy; + BButton *button; + void (*onClicked)(uiButton *, void *); + void *onClickedData; }; uiHaikuDefineControl( uiButton, // type name uiButtonType, // type function - dummy // handle + button // handle ) +#define mButtonClicked 0x4E754E75 + +static void defaultOnClicked(uiButton *b, void *data) +{ + // do nothing +} + char *uiButtonText(uiButton *b) { - // TODO - return NULL; + return uiHaikuStrdupText(b->button->Label()); } void uiButtonSetText(uiButton *b, const char *text) { - // TODO + b->button->SetLabel(text); } void uiButtonOnClicked(uiButton *b, void (*f)(uiButton *b, void *data), void *data) { - // TODO + b->onClicked = f; + b->onClickedData = data; } uiButton *uiNewButton(const char *text) @@ -34,8 +43,10 @@ uiButton *uiNewButton(const char *text) b = (uiButton *) uiNewControl(uiButtonType()); - b->dummy = new BStringView(BRect(0, 0, 1, 1), NULL, - "TODO uiButton not implemented"); + b->button = new BButton(text, new BMessage(mButtonClicked)); + + // TODO hook up events + uiButtonOnClicked(b, defaultOnClicked, NULL); uiHaikuFinishNewControl(b, uiButton); diff --git a/haiku/tab.cpp b/haiku/tab.cpp index e5275b16..41b7b70b 100644 --- a/haiku/tab.cpp +++ b/haiku/tab.cpp @@ -49,6 +49,8 @@ void uiTabInsertAt(uiTab *t, const char *name, uintmax_t before, uiControl *c) p.view = new BView(BRect(0, 0, 1, 1), NULL, B_FOLLOW_ALL_SIDES, 0); + // TODO needed? + p.view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); p.tab = new BTab(p.view); p.child = newSingleChild(c, uiControl(t), attach, p.view);