summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-08-28 00:01:38 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-08-28 00:01:38 +0000
commit55786731e0517efdc123d4e8245b2aa94fa55cbe (patch)
tree17d64454f3daeb9f55241e8c9a95b5671f2da023 /src
parent76291862ce0e26040f251bc4764539d8ff6634a0 (diff)
downloadmana-55786731e0517efdc123d4e8245b2aa94fa55cbe.tar.gz
mana-55786731e0517efdc123d4e8245b2aa94fa55cbe.tar.bz2
mana-55786731e0517efdc123d4e8245b2aa94fa55cbe.tar.xz
mana-55786731e0517efdc123d4e8245b2aa94fa55cbe.zip
Made buy dialog resizable and added a WindowListener class for listening for
window resize and move events.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt21
-rw-r--r--src/Makefile.am21
-rw-r--r--src/engine.cpp10
-rw-r--r--src/gui/buy.cpp79
-rw-r--r--src/gui/buy.h8
-rw-r--r--src/gui/inventorywindow.cpp25
-rw-r--r--src/gui/inventorywindow.h19
-rw-r--r--src/gui/itemshortcutwindow.cpp32
-rw-r--r--src/gui/itemshortcutwindow.h14
-rw-r--r--src/gui/selectionlistener.h16
-rw-r--r--src/gui/status.h3
-rw-r--r--src/gui/window.cpp45
-rw-r--r--src/gui/window.h39
-rw-r--r--src/gui/windowlistener.h86
14 files changed, 284 insertions, 134 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ba4ae221..725dd5a6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -52,6 +52,8 @@ MARK_AS_ADVANCED(SDL_LIBRARY)
SET(SRCS
gui/widgets/resizegrip.cpp
gui/widgets/resizegrip.h
+ gui/box.h
+ gui/box.cpp
gui/browserbox.cpp
gui/browserbox.h
gui/buddywindow.cpp
@@ -88,8 +90,12 @@ SET(SRCS
gui/gccontainer.h
gui/gui.cpp
gui/gui.h
+ gui/hbox.h
+ gui/hbox.cpp
gui/help.cpp
gui/help.h
+ gui/inttextbox.cpp
+ gui/inttextbox.h
gui/inventorywindow.cpp
gui/inventorywindow.h
gui/itemcontainer.cpp
@@ -165,22 +171,17 @@ SET(SRCS
gui/textfield.h
gui/trade.cpp
gui/trade.h
+ gui/updatewindow.h
+ gui/updatewindow.cpp
+ gui/vbox.h
+ gui/vbox.cpp
gui/viewport.cpp
gui/viewport.h
gui/window.cpp
gui/window.h
gui/windowcontainer.cpp
gui/windowcontainer.h
- gui/inttextbox.h
- gui/inttextbox.cpp
- gui/box.h
- gui/box.cpp
- gui/vbox.h
- gui/vbox.cpp
- gui/hbox.h
- gui/hbox.cpp
- gui/updatewindow.h
- gui/updatewindow.cpp
+ gui/windowlistener.h
net/beinghandler.h
net/beinghandler.cpp
net/buysellhandler.h
diff --git a/src/Makefile.am b/src/Makefile.am
index d2e4d1c9..5f1ee760 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,8 @@
bin_PROGRAMS = tmw
tmw_SOURCES = gui/widgets/resizegrip.cpp \
gui/widgets/resizegrip.h \
+ gui/box.h \
+ gui/box.cpp \
gui/browserbox.cpp \
gui/browserbox.h \
gui/buddywindow.cpp \
@@ -37,8 +39,12 @@ tmw_SOURCES = gui/widgets/resizegrip.cpp \
gui/gccontainer.h \
gui/gui.cpp \
gui/gui.h \
+ gui/hbox.h \
+ gui/hbox.cpp \
gui/help.cpp \
gui/help.h \
+ gui/inttextbox.h \
+ gui/inttextbox.cpp \
gui/inventorywindow.cpp \
gui/inventorywindow.h \
gui/itemcontainer.cpp \
@@ -114,22 +120,17 @@ tmw_SOURCES = gui/widgets/resizegrip.cpp \
gui/textfield.h \
gui/trade.cpp \
gui/trade.h \
+ gui/updatewindow.h \
+ gui/updatewindow.cpp \
+ gui/vbox.h \
+ gui/vbox.cpp \
gui/viewport.cpp \
gui/viewport.h \
gui/window.cpp \
gui/window.h \
gui/windowcontainer.cpp \
gui/windowcontainer.h \
- gui/inttextbox.h \
- gui/inttextbox.cpp \
- gui/box.h \
- gui/box.cpp \
- gui/vbox.h \
- gui/vbox.cpp \
- gui/hbox.h \
- gui/hbox.cpp \
- gui/updatewindow.h \
- gui/updatewindow.cpp \
+ gui/windowlistener.h
net/beinghandler.h \
net/beinghandler.cpp \
net/buysellhandler.h \
diff --git a/src/engine.cpp b/src/engine.cpp
index 4a0f2f1f..4e37dc27 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -72,15 +72,11 @@ void Engine::changeMap(const std::string &mapPath)
particleEngine->clear();
// Store full map path in global var
- const std::string base = "maps/" + mapPath.substr(0, mapPath.rfind("."));
+ map_path = "maps/" + mapPath.substr(0, mapPath.rfind(".")) + ".tmx";
ResourceManager *resman = ResourceManager::getInstance();
- if (resman->exists(base + ".tmx"))
+ if (!resman->exists(map_path))
{
- map_path = base + ".tmx";
- }
- else
- {
- map_path = base + ".tmx.gz";
+ map_path += ".gz";
}
// Attempt to load the new map
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index ea477e07..3c7cbd51 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -43,6 +43,11 @@ BuyDialog::BuyDialog(Network *network):
Window("Buy"), mNetwork(network),
mMoney(0), mAmountItems(0), mMaxItems(0)
{
+ setResizable(true);
+ setMinWidth(260);
+ setMinHeight(230);
+ setDefaultSize(0, 0, 260, 230);
+
mShopItems = new ShopItems;
mShopItemList = new ShopListBox(mShopItems, mShopItems);
@@ -57,32 +62,15 @@ BuyDialog::BuyDialog(Network *network):
mItemDescLabel = new gcn::Label("Description:");
mItemEffectLabel = new gcn::Label("Effect:");
- setContentSize(260, 210);
- mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mScrollArea->setDimension(gcn::Rectangle(5, 5, 250, 110));
- mShopItemList->setDimension(gcn::Rectangle(5, 5, 238, 110));
-
- mSlider->setDimension(gcn::Rectangle(5, 120, 200, 10));
- mSlider->setEnabled(false);
-
- mQuantityLabel->setPosition(215, 120);
- mMoneyLabel->setPosition(5, 130);
-
- mIncreaseButton->setPosition(40, 186);
mIncreaseButton->setSize(20, 20);
- mIncreaseButton->setEnabled(false);
-
- mDecreaseButton->setPosition(10, 186);
mDecreaseButton->setSize(20, 20);
- mDecreaseButton->setEnabled(false);
+ mQuantityLabel->setWidth(60);
- mBuyButton->setPosition(180, 186);
+ mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
+ mIncreaseButton->setEnabled(false);
+ mDecreaseButton->setEnabled(false);
mBuyButton->setEnabled(false);
-
- mQuitButton->setPosition(212, 186);
-
- mItemEffectLabel->setDimension(gcn::Rectangle(5, 150, 240, 14));
- mItemDescLabel->setDimension(gcn::Rectangle(5, 169, 240, 14));
+ mSlider->setEnabled(false);
mShopItemList->setActionEventId("item");
mSlider->setActionEventId("slider");
@@ -101,6 +89,8 @@ BuyDialog::BuyDialog(Network *network):
add(mItemDescLabel);
add(mItemEffectLabel);
+ addWindowListener(this);
+ loadWindowState();
setLocationRelativeTo(getParent());
}
@@ -207,6 +197,49 @@ void BuyDialog::selectionChanged(const SelectionEvent &event)
mSlider->gcn::Slider::setScale(1, mMaxItems);
}
+void BuyDialog::windowResized(const WindowEvent &event)
+{
+ gcn::Rectangle area = getChildrenArea();
+ int width = area.width;
+ int height = area.height;
+
+ mDecreaseButton->setPosition(8, height - 8 - mDecreaseButton->getHeight());
+ mIncreaseButton->setPosition(
+ mDecreaseButton->getX() + mDecreaseButton->getWidth() + 5,
+ mDecreaseButton->getY());
+
+ mQuitButton->setPosition(
+ width - 8 - mQuitButton->getWidth(),
+ height - 8 - mQuitButton->getHeight());
+ mBuyButton->setPosition(
+ mQuitButton->getX() - 5 - mBuyButton->getWidth(),
+ mQuitButton->getY());
+
+ mItemDescLabel->setDimension(gcn::Rectangle(8,
+ mBuyButton->getY() - 5 - mItemDescLabel->getHeight(),
+ width - 16,
+ mItemDescLabel->getHeight()));
+ mItemEffectLabel->setDimension(gcn::Rectangle(8,
+ mItemDescLabel->getY() - 5 - mItemEffectLabel->getHeight(),
+ width - 16,
+ mItemEffectLabel->getHeight()));
+ mMoneyLabel->setDimension(gcn::Rectangle(8,
+ mItemEffectLabel->getY() - 5 - mMoneyLabel->getHeight(),
+ width - 16,
+ mMoneyLabel->getHeight()));
+
+ mQuantityLabel->setPosition(
+ width - mQuantityLabel->getWidth() - 8,
+ mMoneyLabel->getY() - 5 - mQuantityLabel->getHeight());
+ mSlider->setDimension(gcn::Rectangle(8,
+ mQuantityLabel->getY(),
+ mQuantityLabel->getX() - 8 - 8,
+ 10));
+
+ mScrollArea->setDimension(gcn::Rectangle(8, 8, width - 16,
+ mSlider->getY() - 5 - 8));
+}
+
void
BuyDialog::updateButtonsAndLabels()
{
@@ -247,8 +280,6 @@ BuyDialog::updateButtonsAndLabels()
// Update quantity and money labels
mQuantityLabel->setCaption(
toString(mAmountItems) + " / " + toString(mMaxItems));
- mQuantityLabel->adjustSize();
mMoneyLabel->setCaption("Price: " + toString(price) + " GP / "
+ toString(mMoney - price) + " GP" );
- mMoneyLabel->adjustSize();
}
diff --git a/src/gui/buy.h b/src/gui/buy.h
index 8f1893dc..d8016216 100644
--- a/src/gui/buy.h
+++ b/src/gui/buy.h
@@ -41,7 +41,8 @@ class ListBox;
*
* \ingroup Interface
*/
-class BuyDialog : public Window, public gcn::ActionListener, SelectionListener
+class BuyDialog : public Window, public gcn::ActionListener, SelectionListener,
+ WindowListener
{
public:
/**
@@ -99,6 +100,11 @@ class BuyDialog : public Window, public gcn::ActionListener, SelectionListener
void
updateButtonsAndLabels();
+ /**
+ * Called whenever the window is resized.
+ */
+ void windowResized(const WindowEvent &event);
+
private:
Network *mNetwork;
gcn::Button *mBuyButton;
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index da391a7b..6e5ae84a 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -82,6 +82,7 @@ InventoryWindow::InventoryWindow():
mUseButton->setSize(48, mUseButton->getHeight());
+ addWindowListener(this);
loadWindowState();
}
@@ -175,17 +176,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
}
}
-void InventoryWindow::mouseDragged(gcn::MouseEvent &event)
-{
- int tmpWidth = getWidth(), tmpHeight = getHeight();
- Window::mouseDragged(event);
- if (getWidth() != tmpWidth || getHeight() != tmpHeight)
- {
- updateWidgets();
- }
-}
-
-void InventoryWindow::updateWidgets()
+void InventoryWindow::windowResized(const WindowEvent &event)
{
gcn::Rectangle area = getChildrenArea();
int width = area.width;
@@ -235,15 +226,3 @@ Item* InventoryWindow::getItem()
{
return mItems->getItem();
}
-
-void InventoryWindow::loadWindowState()
-{
- Window::loadWindowState();
- updateWidgets();
-}
-
-void InventoryWindow::resetToDefaultSize()
-{
- Window::resetToDefaultSize();
- updateWidgets();
-}
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index 5ee89fef..14e1f25f 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -26,8 +26,9 @@
#include <guichan/actionlistener.hpp>
-#include "window.h"
#include "selectionlistener.h"
+#include "window.h"
+#include "windowlistener.h"
#include "../guichanfwd.h"
@@ -39,7 +40,8 @@ class ItemContainer;
*
* \ingroup Interface
*/
-class InventoryWindow : public Window, gcn::ActionListener, SelectionListener
+class InventoryWindow : public Window, gcn::ActionListener, SelectionListener,
+ WindowListener
{
public:
/**
@@ -59,14 +61,8 @@ class InventoryWindow : public Window, gcn::ActionListener, SelectionListener
void mouseClicked(gcn::MouseEvent &event);
- void mouseDragged(gcn::MouseEvent &event);
-
Item* getItem();
- void loadWindowState();
-
- void resetToDefaultSize();
-
/**
* Updates labels to currently selected item.
*
@@ -74,11 +70,14 @@ class InventoryWindow : public Window, gcn::ActionListener, SelectionListener
*/
void selectionChanged(const SelectionEvent &event);
+ /**
+ * Called whenever the window is resized.
+ */
+ void windowResized(const WindowEvent &event);
+
private:
void updateButtons(); /**< Updates button states. */
- void updateWidgets(); /**< Updates widgets size/position. */
-
ItemContainer *mItems;
gcn::Button *mUseButton, *mDropButton;
diff --git a/src/gui/itemshortcutwindow.cpp b/src/gui/itemshortcutwindow.cpp
index 2ee2cfde..efac9353 100644
--- a/src/gui/itemshortcutwindow.cpp
+++ b/src/gui/itemshortcutwindow.cpp
@@ -38,7 +38,7 @@ ItemShortcutWindow::ItemShortcutWindow()
mItems = new ItemShortcutContainer();
- int border = (SCROLL_PADDING * 2) + (getPadding() * 2);
+ int border = SCROLL_PADDING * 2 + getPadding() * 2;
setMinWidth(mItems->getBoxWidth() + border);
setMinHeight(mItems->getBoxHeight() + border);
setMaxWidth(mItems->getBoxWidth() * mItems->getMaxItems() + border);
@@ -50,6 +50,7 @@ ItemShortcutWindow::ItemShortcutWindow()
add(mInvenScroll);
+ addWindowListener(this);
loadWindowState();
}
@@ -64,32 +65,11 @@ void ItemShortcutWindow::logic()
Window::logic();
}
-void ItemShortcutWindow::mouseDragged(gcn::MouseEvent &event)
-{
- const int tWidth = getWidth(), tHeight = getHeight();
- Window::mouseDragged(event);
- if (getWidth() != tWidth || getHeight() != tHeight)
- {
- updateWidgets();
- }
-}
-
-void ItemShortcutWindow::updateWidgets()
+void ItemShortcutWindow::windowResized(const WindowEvent &event)
{
const gcn::Rectangle area = getChildrenArea();
- mInvenScroll->setSize(area.width - SCROLL_PADDING,
- area.height - SCROLL_PADDING);
-}
-
-void ItemShortcutWindow::loadWindowState()
-{
- Window::loadWindowState();
- updateWidgets();
-}
-
-void ItemShortcutWindow::resetToDefaultSize()
-{
- Window::resetToDefaultSize();
- updateWidgets();
+ mInvenScroll->setSize(
+ area.width - SCROLL_PADDING,
+ area.height - SCROLL_PADDING);
}
diff --git a/src/gui/itemshortcutwindow.h b/src/gui/itemshortcutwindow.h
index 16a06b55..83bc348d 100644
--- a/src/gui/itemshortcutwindow.h
+++ b/src/gui/itemshortcutwindow.h
@@ -24,6 +24,7 @@
#define _TMW_ITEMSHORTCUTWINDOW_H
#include "window.h"
+#include "windowlistener.h"
#include "../guichanfwd.h"
@@ -34,7 +35,7 @@ class ItemShortcutContainer;
*
* \ingroup Interface
*/
-class ItemShortcutWindow : public Window
+class ItemShortcutWindow : public Window, WindowListener
{
public:
/**
@@ -52,15 +53,12 @@ class ItemShortcutWindow : public Window
*/
void logic();
- void mouseDragged(gcn::MouseEvent &event);
-
- void loadWindowState();
-
- void resetToDefaultSize();
+ /**
+ * Called whenever the window is resized.
+ */
+ void windowResized(const WindowEvent &event);
private:
- void updateWidgets(); /**< Updates widgets size/position. */
-
ItemShortcutContainer *mItems;
gcn::ScrollArea *mInvenScroll;
diff --git a/src/gui/selectionlistener.h b/src/gui/selectionlistener.h
index b39672b5..917a4871 100644
--- a/src/gui/selectionlistener.h
+++ b/src/gui/selectionlistener.h
@@ -25,33 +25,23 @@
#define _TMW_SELECTIONLISTENER_H__
#include <guichan/widget.hpp>
+#include <guichan/event.hpp>
/**
* An event that characterizes a change in the current selection.
*
* \ingroup GUI
*/
-class SelectionEvent
+class SelectionEvent : public gcn::Event
{
public:
/**
* Constructor.
*/
SelectionEvent(gcn::Widget *source):
- mSource(source)
+ gcn::Event(source)
{
}
-
- /**
- * The widget from which the event originated.
- */
- gcn::Widget* getSource() const
- {
- return mSource;
- }
-
- private:
- gcn::Widget *mSource;
};
/**
diff --git a/src/gui/status.h b/src/gui/status.h
index de530bc9..10773e10 100644
--- a/src/gui/status.h
+++ b/src/gui/status.h
@@ -41,7 +41,8 @@ class ProgressBar;
*
* \ingroup Interface
*/
-class StatusWindow : public Window, public gcn::ActionListener {
+class StatusWindow : public Window, public gcn::ActionListener
+{
public:
/**
* Constructor.
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 8cacd23e..650016cb 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -220,6 +220,8 @@ void Window::setWidth(int width)
{
mGrip->setX(getWidth() - mGrip->getWidth() - getChildrenArea().x);
}
+
+ fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_RESIZED));
}
void Window::setHeight(int height)
@@ -230,6 +232,8 @@ void Window::setHeight(int height)
{
mGrip->setY(getHeight() - mGrip->getHeight() - getChildrenArea().y);
}
+
+ fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_RESIZED));
}
void Window::setDimension(const gcn::Rectangle &dimension)
@@ -241,9 +245,30 @@ void Window::setDimension(const gcn::Rectangle &dimension)
mGrip->setX(getWidth() - mGrip->getWidth() - getChildrenArea().x);
mGrip->setY(getHeight() - mGrip->getHeight() - getChildrenArea().y);
}
+
+ fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_RESIZED));
+ fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_MOVED));
+}
+
+void Window::setPosition(int x, int y)
+{
+ gcn::Window::setPosition(x, y);
+ fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_MOVED));
+}
+
+void Window::setX(int x)
+{
+ gcn::Window::setX(x);
+ fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_MOVED));
+}
+
+void Window::setY(int y)
+{
+ gcn::Window::setY(y);
+ fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_MOVED));
}
-void Window::setLocationRelativeTo(gcn::Widget* widget)
+void Window::setLocationRelativeTo(gcn::Widget *widget)
{
int wx, wy;
int x, y;
@@ -561,3 +586,21 @@ int Window::getResizeHandles(gcn::MouseEvent &event)
return resizeHandles;
}
+
+void Window::fireWindowEvent(const WindowEvent &event)
+{
+ WindowListeners::iterator i_end = mListeners.end();
+ WindowListeners::iterator i = mListeners.begin();
+
+ switch (event.getType())
+ {
+ case WindowEvent::WINDOW_MOVED:
+ for (; i != i_end; ++i)
+ { (*i)->windowMoved(event); }
+ break;
+ case WindowEvent::WINDOW_RESIZED:
+ for (; i != i_end; ++i)
+ { (*i)->windowResized(event); }
+ break;
+ }
+}
diff --git a/src/gui/window.h b/src/gui/window.h
index 625d7541..b83aa78b 100644
--- a/src/gui/window.h
+++ b/src/gui/window.h
@@ -28,6 +28,8 @@
#include "../guichanfwd.h"
+#include "windowlistener.h"
+
class ConfigListener;
class GCContainer;
class ImageRect;
@@ -115,6 +117,21 @@ class Window : public gcn::Window
void setDimension(const gcn::Rectangle &dimension);
/**
+ * Sets the position of this window.
+ */
+ void setPosition(int x, int y);
+
+ /**
+ * Sets the window x coordinate.
+ */
+ void setX(int x);
+
+ /**
+ * Sets the window y coordinate.
+ */
+ void setY(int y);
+
+ /**
* Sets the location relative to the given widget.
*/
void setLocationRelativeTo(gcn::Widget *widget);
@@ -255,6 +272,20 @@ class Window : public gcn::Window
*/
virtual void resetToDefaultSize();
+ /**
+ * Adds a listener to the list that's notified when the window is
+ * moved or resized.
+ */
+ void addWindowListener(WindowListener *listener)
+ { mListeners.push_back(listener); }
+
+ /**
+ * Removes a listener from the list that's notified when the window is
+ * moved or resized.
+ */
+ void removeWindowListener(WindowListener *listener)
+ { mListeners.remove(listener); }
+
enum ResizeHandles
{
TOP = 0x01,
@@ -310,6 +341,14 @@ class Window : public gcn::Window
* where two borders are moved at the same time.
*/
static const int resizeBorderWidth = 10;
+
+ private:
+ /**
+ * Sends out a window event to the list of selection listeners.
+ */
+ void fireWindowEvent(const WindowEvent &event);
+
+ WindowListeners mListeners;
};
#endif
diff --git a/src/gui/windowlistener.h b/src/gui/windowlistener.h
new file mode 100644
index 00000000..08aab71d
--- /dev/null
+++ b/src/gui/windowlistener.h
@@ -0,0 +1,86 @@
+/*
+ * The Mana World
+ * Copyright 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#ifndef _TMW_WINDOW_LISTENER_H_
+#define _TMW_WINDOW_LISTENER_H_
+
+#include <guichan/widgets/window.hpp>
+#include <guichan/event.hpp>
+
+/**
+ * An event that characterizes a window move or resize.
+ *
+ * \ingroup GUI
+ */
+class WindowEvent : public gcn::Event
+{
+ public:
+ /**
+ * Constructor.
+ */
+ WindowEvent(gcn::Window *source, int type):
+ gcn::Event(source)
+ {
+ mType = type;
+ }
+
+ /**
+ * Returns the event type.
+ */
+ int getType() const
+ { return mType; }
+
+ enum WindowEventType
+ {
+ WINDOW_MOVED,
+ WINDOW_RESIZED
+ };
+};
+
+/**
+ * The listener that's notified when a window is moved or resized.
+ *
+ * \ingroup GUI
+ */
+class WindowListener
+{
+ public:
+ /**
+ * Virtual destructor.
+ */
+ virtual ~WindowListener() {}
+
+ /**
+ * Called whenever the window is moved.
+ */
+ virtual void windowMoved(const WindowEvent &event) {}
+
+ /**
+ * Called whenever the window is resized.
+ */
+ virtual void windowResized(const WindowEvent &event) {}
+};
+
+typedef std::list<WindowListener*> WindowListeners;
+
+#endif