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
This commit is contained in:
Stephan Aßmus 2008-11-21 00:14:05 +00:00
parent 30ca128ee5
commit 24a0a80b05
2 changed files with 27 additions and 21 deletions

View File

@ -183,7 +183,7 @@ virtual void SetTabHeight(float height);
BView *ViewForTab(int32 tabIndex) const; BView *ViewForTab(int32 tabIndex) const;
private: private:
void _InitObject(bool layouted = false); void _InitObject(bool layouted, button_width width);
virtual void _ReservedTabView1(); virtual void _ReservedTabView1();
virtual void _ReservedTabView2(); virtual void _ReservedTabView2();

View File

@ -5,6 +5,8 @@
* Authors: * Authors:
* Marc Flerackers (mflerackers@androme.be) * Marc Flerackers (mflerackers@androme.be)
* Jérôme Duval (korli@users.berlios.de) * Jérôme Duval (korli@users.berlios.de)
* Stephan Aßmus <superstippi@gmx.de>
* Artur Wyszynski
*/ */
#include <TabView.h> #include <TabView.h>
@ -12,6 +14,7 @@
#include <string.h> #include <string.h>
#include <CardLayout.h> #include <CardLayout.h>
#include <GroupLayout.h>
#include <LayoutUtils.h> #include <LayoutUtils.h>
#include <List.h> #include <List.h>
#include <Message.h> #include <Message.h>
@ -344,14 +347,11 @@ BTab &BTab::operator=(const BTab &)
// #pragma mark - // #pragma mark -
BTabView::BTabView(const char *name, button_width width, uint32 flags) BTabView::BTabView(const char *name, button_width width, uint32 flags)
: BView(name, flags) : BView(name, flags)
{ {
SetFont(be_bold_font); _InitObject(true, width);
_InitObject(true);
fTabWidthSetting = width;
} }
@ -359,11 +359,7 @@ BTabView::BTabView(BRect frame, const char *name, button_width width,
uint32 resizingMode, uint32 flags) uint32 resizingMode, uint32 flags)
: BView(frame, name, resizingMode, flags) : BView(frame, name, resizingMode, flags)
{ {
SetFont(be_bold_font); _InitObject(false, width);
_InitObject();
fTabWidthSetting = width;
} }
@ -1130,11 +1126,13 @@ BTabView::ViewForTab(int32 tabIndex) const
void void
BTabView::_InitObject(bool layouted) BTabView::_InitObject(bool layouted, button_width width)
{ {
SetFont(be_bold_font);
fTabList = new BList; fTabList = new BList;
fTabWidthSetting = B_WIDTH_AS_USUAL; fTabWidthSetting = width;
fSelection = 0; fSelection = 0;
fFocus = -1; fFocus = -1;
fTabOffset = 0.0f; fTabOffset = 0.0f;
@ -1148,6 +1146,16 @@ BTabView::_InitObject(bool layouted)
GetFontHeight(&fh); GetFontHeight(&fh);
fTabHeight = fh.ascent + fh.descent + fh.leading + 8.0f; fTabHeight = fh.ascent + fh.descent + fh.leading + 8.0f;
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);
}
fContainerView = new BView("view container", B_WILL_DRAW);
fContainerView->SetLayout(new(std::nothrow) BCardLayout());
} else {
BRect bounds = Bounds(); BRect bounds = Bounds();
bounds.top += TabHeight(); bounds.top += TabHeight();
@ -1155,9 +1163,7 @@ BTabView::_InitObject(bool layouted)
fContainerView = new BView(bounds, "view container", B_FOLLOW_ALL, fContainerView = new BView(bounds, "view container", B_FOLLOW_ALL,
B_WILL_DRAW); B_WILL_DRAW);
}
if (layouted)
fContainerView->SetLayout(new(std::nothrow) BCardLayout());
fContainerView->SetViewColor(color); fContainerView->SetViewColor(color);
fContainerView->SetLowColor(color); fContainerView->SetLowColor(color);