From 24a0a80b056c98004faac3db38ab8e404d0da60c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Fri, 21 Nov 2008 00:14:05 +0000 Subject: [PATCH] Properly integrate the BTabView into a layout tree. Ie, the content will now resize with the tab view. There is probably a more elegant way overriding DoLayout(), but this should do for the time being. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28706 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/interface/TabView.h | 2 +- src/kits/interface/TabView.cpp | 46 +++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/headers/os/interface/TabView.h b/headers/os/interface/TabView.h index 7604d5b06d..ebb4c710e9 100644 --- a/headers/os/interface/TabView.h +++ b/headers/os/interface/TabView.h @@ -183,7 +183,7 @@ virtual void SetTabHeight(float height); BView *ViewForTab(int32 tabIndex) const; private: - void _InitObject(bool layouted = false); + void _InitObject(bool layouted, button_width width); virtual void _ReservedTabView1(); virtual void _ReservedTabView2(); diff --git a/src/kits/interface/TabView.cpp b/src/kits/interface/TabView.cpp index e0b08ac03a..70c487f5d2 100644 --- a/src/kits/interface/TabView.cpp +++ b/src/kits/interface/TabView.cpp @@ -5,6 +5,8 @@ * Authors: * Marc Flerackers (mflerackers@androme.be) * Jérôme Duval (korli@users.berlios.de) + * Stephan Aßmus + * Artur Wyszynski */ #include @@ -12,6 +14,7 @@ #include #include +#include #include #include #include @@ -344,14 +347,11 @@ BTab &BTab::operator=(const BTab &) // #pragma mark - + BTabView::BTabView(const char *name, button_width width, uint32 flags) : BView(name, flags) { - SetFont(be_bold_font); - - _InitObject(true); - - fTabWidthSetting = width; + _InitObject(true, width); } @@ -359,11 +359,7 @@ BTabView::BTabView(BRect frame, const char *name, button_width width, uint32 resizingMode, uint32 flags) : BView(frame, name, resizingMode, flags) { - SetFont(be_bold_font); - - _InitObject(); - - fTabWidthSetting = width; + _InitObject(false, width); } @@ -1130,11 +1126,13 @@ BTabView::ViewForTab(int32 tabIndex) const void -BTabView::_InitObject(bool layouted) +BTabView::_InitObject(bool layouted, button_width width) { + SetFont(be_bold_font); + fTabList = new BList; - fTabWidthSetting = B_WIDTH_AS_USUAL; + fTabWidthSetting = width; fSelection = 0; fFocus = -1; fTabOffset = 0.0f; @@ -1148,16 +1146,24 @@ BTabView::_InitObject(bool layouted) GetFontHeight(&fh); fTabHeight = fh.ascent + fh.descent + fh.leading + 8.0f; - BRect bounds = Bounds(); + if (layouted) { + BGroupLayout* layout = new(std::nothrow) BGroupLayout(B_HORIZONTAL); + if (layout) { + layout->SetInsets(3.0, 3.0 + TabHeight(), 3.0, 3.0); + SetLayout(layout); + } - bounds.top += TabHeight(); - bounds.InsetBy(3.0f, 3.0f); - - fContainerView = new BView(bounds, "view container", B_FOLLOW_ALL, - B_WILL_DRAW); - - if (layouted) + fContainerView = new BView("view container", B_WILL_DRAW); fContainerView->SetLayout(new(std::nothrow) BCardLayout()); + } else { + BRect bounds = Bounds(); + + bounds.top += TabHeight(); + bounds.InsetBy(3.0f, 3.0f); + + fContainerView = new BView(bounds, "view container", B_FOLLOW_ALL, + B_WILL_DRAW); + } fContainerView->SetViewColor(color); fContainerView->SetLowColor(color);