summaryrefslogtreecommitdiff
path: root/src/gui/tabbedcontainer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/tabbedcontainer.cpp')
-rw-r--r--src/gui/tabbedcontainer.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/gui/tabbedcontainer.cpp b/src/gui/tabbedcontainer.cpp
index fba4e846..8e95aa7c 100644
--- a/src/gui/tabbedcontainer.cpp
+++ b/src/gui/tabbedcontainer.cpp
@@ -21,18 +21,23 @@
#include <algorithm>
-#include "tabbedcontainer.h"
-
#include "button.h"
+#include "tabbedcontainer.h"
-#include "../utils/tostring.h"
#include "../utils/dtor.h"
+#include "../utils/tostring.h"
-#define TABWIDTH 60
-#define TABHEIGHT 20
-
-TabbedContainer::TabbedContainer():
- mActiveContent(0)
+TabbedContainer::TabbedContainer(int width, int padX, int buttonHeight,
+ int height, int padY, int buttonsPerRow):
+ mActiveContent(0),
+ mWidth(width),
+ mPadX(padX),
+ mButtonHeight(buttonHeight),
+ mHeight(height),
+ mPadY(padY),
+ mButtonsPerRow(buttonsPerRow),
+
+ mButtonWidth((width - (buttonsPerRow - 1) * padX) / buttonsPerRow - padX)
{
}
@@ -50,13 +55,14 @@ void TabbedContainer::addTab(gcn::Widget *widget, const std::string &caption)
Button *tab = new Button(caption, toString(tabNumber), this);
- tab->setSize(TABWIDTH, TABHEIGHT);
- add(tab, TABWIDTH * tabNumber, 0);
+ tab->setSize(mButtonWidth, mButtonHeight);
+ add(tab, (mButtonWidth + mPadX) * (tabNumber % mButtonsPerRow),
+ (mButtonHeight + mPadY) * (tabNumber / mButtonsPerRow));
mTabs[caption] = tab;
mContents.push_back(widget);
- widget->setPosition(0, TABHEIGHT);
+ widget->setPosition(0, mHeight);
// If this is the first tab in this container, make it visible
if (!mActiveContent) {
@@ -81,7 +87,7 @@ void TabbedContainer::logic()
if (mActiveContent) {
mActiveContent->setSize(
getWidth() - 2 * mActiveContent->getFrameSize(),
- getHeight() - TABHEIGHT - 2 * mActiveContent->getFrameSize());
+ getHeight() - mHeight - 2 * mActiveContent->getFrameSize());
}
Container::logic();