summaryrefslogtreecommitdiff
path: root/src/gui/widgets/tab.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets/tab.cpp')
-rw-r--r--src/gui/widgets/tab.cpp59
1 files changed, 58 insertions, 1 deletions
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index e002c03fe..ab7d5683e 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -31,6 +31,7 @@
#include "gui/palette.h"
#include "gui/theme.h"
+#include "gui/widgets/label.h"
#include "gui/widgets/tabbedarea.h"
#include "utils/dtor.h"
@@ -62,8 +63,14 @@ static std::string const data[TAB_COUNT] =
ImageRect Tab::tabImg[TAB_COUNT];
Tab::Tab() :
- gcn::Tab(),
+ gcn::BasicContainer(),
+ gcn::MouseListener(),
gcn::WidgetListener(),
+
+ mLabel(new Label),
+ mHasMouse(false),
+ mTabbedArea(nullptr),
+
mTabColor(&Theme::getThemeColor(Theme::TAB)),
mTabHighlightedColor(&Theme::getThemeColor(Theme::TAB_HIGHLIGHTED)),
mTabSelectedColor(&Theme::getThemeColor(Theme::TAB_SELECTED)),
@@ -85,12 +92,20 @@ Tab::~Tab()
for (int mode = 0; mode < TAB_COUNT; mode ++)
theme->unloadRect(tabImg[mode]);
}
+
+ delete mLabel;
+ mLabel = nullptr;
+
delete mVertexes;
mVertexes = nullptr;
}
void Tab::init()
{
+ mLabel->setPosition(4, 4);
+ add(mLabel);
+
+ addMouseListener(this);
setFocusable(false);
setFrameSize(0);
mFlash = 0;
@@ -209,3 +224,45 @@ void Tab::setLabelFont(gcn::Font *const font)
mLabel->adjustSize();
adjustSize();
}
+
+
+void Tab::adjustSize()
+{
+ setSize(mLabel->getWidth() + 8,
+ mLabel->getHeight() + 8);
+
+ if (mTabbedArea)
+ mTabbedArea->adjustTabPositions();
+}
+
+void Tab::setTabbedArea(TabbedArea* tabbedArea)
+{
+ mTabbedArea = tabbedArea;
+}
+
+TabbedArea* Tab::getTabbedArea()
+{
+ return mTabbedArea;
+}
+
+void Tab::setCaption(const std::string &caption)
+{
+ mLabel->setCaption(caption);
+ mLabel->adjustSize();
+ adjustSize();
+}
+
+const std::string &Tab::getCaption() const
+{
+ return mLabel->getCaption();
+}
+
+void Tab::mouseEntered(gcn::MouseEvent& mouseEvent A_UNUSED)
+{
+ mHasMouse = true;
+}
+
+void Tab::mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED)
+{
+ mHasMouse = false;
+}