summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-08-10 20:28:23 -0600
committerJared Adams <jaxad0127@gmail.com>2009-08-10 20:28:23 -0600
commit9af6e761373f25b56e815f1f75b44473474cf280 (patch)
tree4393f9297c892fc1289c29eb4753462554b498df /src/gui/widgets
parent56865a2c98a589a1e530e296b1681e369e2ae48f (diff)
downloadmana-client-9af6e761373f25b56e815f1f75b44473474cf280.tar.gz
mana-client-9af6e761373f25b56e815f1f75b44473474cf280.tar.bz2
mana-client-9af6e761373f25b56e815f1f75b44473474cf280.tar.xz
mana-client-9af6e761373f25b56e815f1f75b44473474cf280.zip
Fix TabbedArea and ScrollArea to resize contents
Also remove that code from SkillDialog. I tried to do the same with ChatWindow, but it kept segfaulting. Will try again later.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/scrollarea.cpp5
-rw-r--r--src/gui/widgets/scrollarea.h5
-rw-r--r--src/gui/widgets/tabbedarea.cpp11
-rw-r--r--src/gui/widgets/tabbedarea.h5
4 files changed, 24 insertions, 2 deletions
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;
};