diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/skilldialog.cpp | 22 | ||||
-rw-r--r-- | src/gui/skilldialog.h | 8 | ||||
-rw-r--r-- | src/gui/widgets/scrollarea.cpp | 5 | ||||
-rw-r--r-- | src/gui/widgets/scrollarea.h | 5 | ||||
-rw-r--r-- | src/gui/widgets/tabbedarea.cpp | 11 | ||||
-rw-r--r-- | src/gui/widgets/tabbedarea.h | 5 |
6 files changed, 24 insertions, 32 deletions
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index a0bfaf53..01b6e5ae 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -122,25 +122,6 @@ void SkillDialog::action(const gcn::ActionEvent &event) } } -void SkillDialog::adjustTabSize() -{ - gcn::Widget *content = mTabs->getCurrentWidget(); - if (content) { - int width = mTabs->getWidth() - 2 * content->getFrameSize() - 2 * mTabs->getFrameSize(); - int height = mTabs->getContainerHeight() - 2 * content->getFrameSize(); - content->setSize(width, height); - content->setVisible(true); - content->logic(); - } -} - -void SkillDialog::widgetResized(const gcn::Event &event) -{ - Window::widgetResized(event); - - adjustTabSize(); -} - void SkillDialog::logic() { Window::logic(); @@ -148,7 +129,6 @@ void SkillDialog::logic() Tab *tab = dynamic_cast<Tab*>(mTabs->getSelectedTab()); if (tab != mCurrentTab) { mCurrentTab = tab; - adjustTabSize(); } } @@ -248,8 +228,6 @@ void SkillDialog::loadSkills(const std::string &file) } } } - - adjustTabSize(); update(); } diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h index 6ad28be4..8fa7443d 100644 --- a/src/gui/skilldialog.h +++ b/src/gui/skilldialog.h @@ -54,12 +54,6 @@ class SkillDialog : public Window, public gcn::ActionListener */ void action(const gcn::ActionEvent &event); - /** - * Called when the widget changes size. Used for adapting the size of - * the tabbed area. - */ - void widgetResized(const gcn::Event &event); - void logic(); /** @@ -77,8 +71,6 @@ class SkillDialog : public Window, public gcn::ActionListener void setModifiable(int id, bool modifiable); private: - void adjustTabSize(); - typedef std::map<int, SkillInfo*> SkillMap; SkillMap mSkills; Tab *mCurrentTab; diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 52322b05..6cf27bb6 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -42,6 +42,7 @@ ScrollArea::ScrollArea(): mY(0), mOpaque(true) { + addWidgetListener(this); init(); } @@ -346,3 +347,7 @@ void ScrollArea::mouseExited(gcn::MouseEvent& event) mHasMouse = false; } +void ScrollArea::widgetResized(const gcn::Event &event) +{ + getContent()->setSize(getWidth() - 2 * getFrameSize(), getHeight() - 2 * getFrameSize()); +} diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 8fd92b5f..69e99b1f 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -23,6 +23,7 @@ #define SCROLLAREA_H #include <guichan/widgets/scrollarea.hpp> +#include <guichan/widgetlistener.hpp> class Image; class ImageRect; @@ -36,7 +37,7 @@ class ImageRect; * * \ingroup GUI */ -class ScrollArea : public gcn::ScrollArea +class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener { public: /** @@ -98,6 +99,8 @@ class ScrollArea : public gcn::ScrollArea */ void mouseExited(gcn::MouseEvent& event); + void widgetResized(const gcn::Event &event); + protected: enum BUTTON_DIR { UP, diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index bb5ae9a4..2de812ed 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -27,6 +27,7 @@ TabbedArea::TabbedArea() : gcn::TabbedArea() { mWidgetContainer->setOpaque(false); + addWidgetListener(this); } int TabbedArea::getNumberOfTabs() const @@ -152,3 +153,13 @@ void TabbedArea::setSelectedTab(gcn::Tab *tab) if (newTab) newTab->setCurrent(); } + +void TabbedArea::widgetResized(const gcn::Event &event) +{ + int width = getWidth() - 2 * getFrameSize(); + int height = getHeight() - 2 * getFrameSize() - mTabContainer->getHeight(); + mWidgetContainer->setSize(width, height); + gcn::Widget *w = getCurrentWidget(); + if (w) + w->setSize(width, height); +} diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index 29ba2f76..1b61b102 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -23,6 +23,7 @@ #define TABBEDAREA_H #include <guichan/widget.hpp> +#include <guichan/widgetlistener.hpp> #include <guichan/widgets/container.hpp> #include <guichan/widgets/tabbedarea.hpp> @@ -33,7 +34,7 @@ class Tab; /** * A tabbed area, the same as the guichan tabbed area in 0.8, but extended */ -class TabbedArea : public gcn::TabbedArea +class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener { public: /** @@ -97,6 +98,8 @@ class TabbedArea : public gcn::TabbedArea void setSelectedTab(gcn::Tab *tab); + void widgetResized(const gcn::Event &event); + private: typedef std::vector< std::pair<gcn::Tab*, gcn::Widget*> > TabContainer; }; |