summaryrefslogtreecommitdiff
path: root/src/gui/widgets/tab.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-10-14 17:22:07 +0300
committerAndrei Karas <akaras@inbox.ru>2012-10-14 17:22:07 +0300
commit0b3aafe2859d9ea1c4009eed8a87f69c41cbc14b (patch)
tree5489a0ab504f34e7dcc7c273f274b52c76269206 /src/gui/widgets/tab.cpp
parentc23959e3c40e97f9c1aeb9eabc52131b6fa68f2a (diff)
downloadmanaverse-0b3aafe2859d9ea1c4009eed8a87f69c41cbc14b.tar.gz
manaverse-0b3aafe2859d9ea1c4009eed8a87f69c41cbc14b.tar.bz2
manaverse-0b3aafe2859d9ea1c4009eed8a87f69c41cbc14b.tar.xz
manaverse-0b3aafe2859d9ea1c4009eed8a87f69c41cbc14b.zip
Dont use guichan tab and tabbedarea anymore.
It have some methods and widget connections what cant be changed by overloading.
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;
+}