From 0b3aafe2859d9ea1c4009eed8a87f69c41cbc14b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 14 Oct 2012 17:22:07 +0300 Subject: Dont use guichan tab and tabbedarea anymore. It have some methods and widget connections what cant be changed by overloading. --- src/gui/widgets/tab.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) (limited to 'src/gui/widgets/tab.cpp') 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; +} -- cgit v1.2.3-70-g09d2