summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--src/gui/itemshortcutcontainer.cpp6
-rw-r--r--src/gui/itemshortcutcontainer.h12
-rw-r--r--src/gui/itemshortcutwindow.cpp18
-rw-r--r--src/gui/itemshortcutwindow.h12
-rw-r--r--src/gui/scrollarea.cpp32
-rw-r--r--src/gui/scrollarea.h3
7 files changed, 29 insertions, 61 deletions
diff --git a/ChangeLog b/ChangeLog
index 6f2fe4e7..3017f5eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-04-12 Bjørn Lindeijer <bjorn@lindeijer.nl>
+
+ * src/gui/itemshortcutcontainer.h, src/gui/itemshortcutcontainer.cpp,
+ src/gui/itemshortcutwindow.cpp, src/gui/scrollarea.h,
+ src/gui/scrollarea.cpp, src/gui/itemshortcutwindow.h: Fixed display of
+ item shortcut container. gcn::Widget::setWidth is no longer virtual.
+
2008-04-11 David Athay <ko2fan@gmail.com>
* src/localplayer.cpp, src/beingmanager.h, src/gui/viewport.cpp,
diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp
index 0f7d1332..3c03d85a 100644
--- a/src/gui/itemshortcutcontainer.cpp
+++ b/src/gui/itemshortcutcontainer.cpp
@@ -40,6 +40,7 @@ ItemShortcutContainer::ItemShortcutContainer():
mItemMoved(NULL)
{
addMouseListener(this);
+ addWidgetListener(this);
ResourceManager *resman = ResourceManager::getInstance();
@@ -119,11 +120,8 @@ ItemShortcutContainer::draw(gcn::Graphics *graphics)
}
}
-void
-ItemShortcutContainer::setWidth(int width)
+void ItemShortcutContainer::widgetResized(const gcn::Event &event)
{
- gcn::Widget::setWidth(width);
-
mGridWidth = getWidth() / mBoxWidth;
if (mGridWidth < 1) {
mGridWidth = 1;
diff --git a/src/gui/itemshortcutcontainer.h b/src/gui/itemshortcutcontainer.h
index c69525e0..58f0aea7 100644
--- a/src/gui/itemshortcutcontainer.h
+++ b/src/gui/itemshortcutcontainer.h
@@ -26,6 +26,7 @@
#include <guichan/mouselistener.hpp>
#include <guichan/widget.hpp>
+#include <guichan/widgetlistener.hpp>
class Image;
class Item;
@@ -35,7 +36,9 @@ class Item;
*
* \ingroup GUI
*/
-class ItemShortcutContainer : public gcn::Widget, public gcn::MouseListener
+class ItemShortcutContainer : public gcn::Widget,
+ public gcn::WidgetListener,
+ public gcn::MouseListener
{
public:
/**
@@ -59,10 +62,10 @@ class ItemShortcutContainer : public gcn::Widget, public gcn::MouseListener
void draw(gcn::Graphics *graphics);
/**
- * Sets the width of the container. This is used to determine the new
- * height of the container.
+ * Invoked when a widget changes its size. This is used to determine
+ * the new height of the container.
*/
- void setWidth(int width);
+ void widgetResized(const gcn::Event &event);
/**
* Handles mouse when dragged.
@@ -79,7 +82,6 @@ class ItemShortcutContainer : public gcn::Widget, public gcn::MouseListener
*/
void mouseReleased(gcn::MouseEvent &event);
-
int getMaxItems()
{ return mMaxItems; }
diff --git a/src/gui/itemshortcutwindow.cpp b/src/gui/itemshortcutwindow.cpp
index efbbe266..3724516a 100644
--- a/src/gui/itemshortcutwindow.cpp
+++ b/src/gui/itemshortcutwindow.cpp
@@ -45,11 +45,12 @@ ItemShortcutWindow::ItemShortcutWindow()
setMaxWidth(mItems->getBoxWidth() * mItems->getMaxItems() + border);
setMaxHeight(mItems->getBoxHeight() * mItems->getMaxItems() + border);
- mInvenScroll = new ScrollArea(mItems);
- mInvenScroll->setPosition(SCROLL_PADDING, SCROLL_PADDING);
- mInvenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
+ mScrollArea = new ScrollArea(mItems);
+ mScrollArea->setPosition(SCROLL_PADDING, SCROLL_PADDING);
+ mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
+ mScrollArea->setOpaque(false);
- add(mInvenScroll);
+ add(mScrollArea);
loadWindowState();
}
@@ -57,12 +58,7 @@ ItemShortcutWindow::ItemShortcutWindow()
ItemShortcutWindow::~ItemShortcutWindow()
{
delete mItems;
- delete mInvenScroll;
-}
-
-void ItemShortcutWindow::logic()
-{
- Window::logic();
+ delete mScrollArea;
}
void ItemShortcutWindow::widgetResized(const gcn::Event &event)
@@ -71,7 +67,7 @@ void ItemShortcutWindow::widgetResized(const gcn::Event &event)
const gcn::Rectangle &area = getChildrenArea();
- mInvenScroll->setSize(
+ mScrollArea->setSize(
area.width - SCROLL_PADDING,
area.height - SCROLL_PADDING);
}
diff --git a/src/gui/itemshortcutwindow.h b/src/gui/itemshortcutwindow.h
index 51685e49..9742abdc 100644
--- a/src/gui/itemshortcutwindow.h
+++ b/src/gui/itemshortcutwindow.h
@@ -26,12 +26,11 @@
#include "window.h"
-#include "../guichanfwd.h"
-
class ItemShortcutContainer;
+class ScrollArea;
/**
- * Inventory dialog.
+ * A window around the ItemShortcutContainer.
*
* \ingroup Interface
*/
@@ -49,11 +48,6 @@ class ItemShortcutWindow : public Window
~ItemShortcutWindow();
/**
- * Logic (updates buttons and weight information).
- */
- void logic();
-
- /**
* Called whenever the widget changes size.
*/
void widgetResized(const gcn::Event &event);
@@ -61,7 +55,7 @@ class ItemShortcutWindow : public Window
private:
ItemShortcutContainer *mItems;
- gcn::ScrollArea *mInvenScroll;
+ ScrollArea *mScrollArea;
};
extern ItemShortcutWindow *itemShortcutWindow;
diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp
index 9c88f8e3..255aa2d8 100644
--- a/src/gui/scrollarea.cpp
+++ b/src/gui/scrollarea.cpp
@@ -165,14 +165,6 @@ void ScrollArea::logic()
void ScrollArea::draw(gcn::Graphics *graphics)
{
- checkPolicies();
-
- int alpha = getBaseColor().a;
- gcn::Color highlightColor = getBaseColor() + 0x303030;
- highlightColor.a = alpha;
- gcn::Color shadowColor = getBaseColor() - 0x303030;
- shadowColor.a = alpha;
-
if (mVBarVisible)
{
drawUpButton(graphics);
@@ -198,29 +190,7 @@ void ScrollArea::draw(gcn::Graphics *graphics)
mScrollbarWidth));
}
- gcn::Widget *content = getContent();
-
- if (content != NULL)
- {
- graphics->pushClipArea(getChildrenArea());
-
- if (content->getFrameSize() > 0)
- {
- gcn::Rectangle rec = content->getDimension();
- rec.x -= content->getFrameSize();
- rec.y -= content->getFrameSize();
- rec.width += 2 * content->getFrameSize();
- rec.height += 2 * content->getFrameSize();
- graphics->pushClipArea(rec);
- content->drawFrame(graphics);
- graphics->popClipArea();
- }
-
- graphics->pushClipArea(content->getDimension());
- content->draw(graphics);
- graphics->popClipArea();
- graphics->popClipArea();
- }
+ drawChildren(graphics);
}
void ScrollArea::drawFrame(gcn::Graphics *graphics)
diff --git a/src/gui/scrollarea.h b/src/gui/scrollarea.h
index 9fb7093d..dd1f946d 100644
--- a/src/gui/scrollarea.h
+++ b/src/gui/scrollarea.h
@@ -34,7 +34,8 @@ class ImageRect;
*
* \ingroup GUI
*/
-class ScrollArea : public gcn::ScrollArea {
+class ScrollArea : public gcn::ScrollArea
+{
public:
/**
* Constructor.