summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog43
-rw-r--r--INSTALL2
-rw-r--r--NEWS2
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/gui/button.cpp2
-rw-r--r--src/gui/buy.cpp16
-rw-r--r--src/gui/buy.h14
-rw-r--r--src/gui/char_server.cpp2
-rw-r--r--src/gui/chat.cpp12
-rw-r--r--src/gui/checkbox.cpp6
-rw-r--r--src/gui/checkbox.h2
-rw-r--r--src/gui/inventorywindow.cpp17
-rw-r--r--src/gui/inventorywindow.h15
-rw-r--r--src/gui/itemcontainer.cpp15
-rw-r--r--src/gui/itemcontainer.h13
-rw-r--r--src/gui/itemshortcutwindow.cpp9
-rw-r--r--src/gui/itemshortcutwindow.h7
-rw-r--r--src/gui/listbox.cpp21
-rw-r--r--src/gui/listbox.h31
-rw-r--r--src/gui/login.cpp2
-rw-r--r--src/gui/playerbox.cpp8
-rw-r--r--src/gui/playerbox.h2
-rw-r--r--src/gui/radiobutton.cpp2
-rw-r--r--src/gui/register.cpp2
-rw-r--r--src/gui/scrollarea.cpp24
-rw-r--r--src/gui/scrollarea.h2
-rw-r--r--src/gui/selectionlistener.h68
-rw-r--r--src/gui/sell.cpp7
-rw-r--r--src/gui/sell.h12
-rw-r--r--src/gui/setup_audio.cpp4
-rw-r--r--src/gui/setup_joystick.cpp6
-rw-r--r--src/gui/setup_video.cpp18
-rw-r--r--src/gui/shoplistbox.cpp10
-rw-r--r--src/gui/shoplistbox.h25
-rw-r--r--src/gui/slider.cpp2
-rw-r--r--src/gui/tabbedcontainer.cpp4
-rw-r--r--src/gui/textbox.cpp4
-rw-r--r--src/gui/textfield.cpp6
-rw-r--r--src/gui/textfield.h2
-rw-r--r--src/gui/trade.cpp2
-rw-r--r--src/gui/trade.h6
-rw-r--r--src/gui/window.cpp105
-rw-r--r--src/gui/window.h77
-rw-r--r--src/gui/windowlistener.h86
45 files changed, 190 insertions, 529 deletions
diff --git a/ChangeLog b/ChangeLog
index da2fde63..4d77242d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -147,12 +147,43 @@
outdoor map by MerlinX420. Fixed some map bugs in snake dungeon.
* data/items.xml: Added chicken leg meta information.
+2008-01-28 Bjørn Lindeijer <bjorn@lindeijer.nl>
+
+ * src/gui/sell.cpp, src/gui/window.cpp, src/gui/inventorywindow.h,
+ src/gui/buy.h, src/gui/itemshortcutwindow.cpp,
+ src/gui/inventorywindow.cpp, src/gui/buy.cpp, src/gui/sell.h,
+ src/gui/window.h, src/gui/windowlistener.h,
+ src/gui/itemshortcutwindow.h, src/CMakeLists.txt, src/Makefile.am:
+ Used the gcn::WidgetListener instead of our WindowListener.
+
2008-01-26 Bjørn Lindeijer <bjorn@lindeijer.nl>
* src/gui/trade.h, src/game.h, src/being.h: Fixed a GCC 4.3 compile
error and constified the usage of auto_ptr, since that's the way in
which we are using them.
+2008-01-23 Bjørn Lindeijer <bjorn@lindeijer.nl>
+
+ * src/gui/char_server.cpp, src/gui/window.cpp, src/gui/checkbox.h,
+ src/gui/playerbox.h, src/gui/button.cpp, src/gui/chat.cpp,
+ src/gui/slider.cpp, src/gui/tabbedcontainer.cpp, src/gui/textfield.h,
+ src/gui/shoplistbox.cpp, src/gui/register.cpp,
+ src/gui/radiobutton.cpp, src/gui/textbox.cpp, src/gui/login.cpp,
+ src/gui/setup_audio.cpp, src/gui/setup_video.cpp,
+ src/gui/textfield.cpp, src/gui/playerbox.cpp,
+ src/gui/setup_joystick.cpp, src/gui/scrollarea.h,
+ src/gui/windowlistener.h, src/gui/checkbox.cpp,
+ src/gui/scrollarea.cpp: Compile against Guichan 0.8.0. Some issues
+ with ShopListBox left and not trying to use their new TabbedArea,
+ SelectionListener and WidgetListener yet. Also needs more testing.
+ * src/gui/trade.cpp, src/gui/sell.cpp, src/gui/inventorywindow.h,
+ src/gui/selectionlistener.h, src/gui/itemcontainer.h,
+ src/gui/shoplistbox.cpp, src/gui/shoplistbox.h, src/gui/listbox.h,
+ src/gui/buy.h, src/gui/inventorywindow.cpp, src/gui/buy.cpp,
+ src/gui/itemcontainer.cpp, src/gui/sell.h, src/gui/trade.h,
+ src/gui/listbox.cpp, src/CMakeLists.txt, src/Makefile.am: Used the
+ gcn::SelectionListener instead of our own.
+
2008-01-19 Philipp Sehmisch <tmw@crushnet.org>
* data/maps/new_10-1.tmx, data/maps/new_11-1.tmx: Map fixes by 5t3v3 at
@@ -239,12 +270,12 @@
* src/particleemitter.cpp, src/particleemitter.h: Particle images
are now reference-counted properly.
- * src/resources/spritedef.cpp: Error placeholder is now used when attempting
- to load a sprite definition file that doesn't exist.
- * src/monster.cpp, src/player.cpp: Avoided attempts to load "data/graphics/"
- when a monster or equipment piece has no sprite.
- * data/graphics/particles/cookingfire.particle.xml: Removed some particle
- properties that did nothing because they were misspelled.
+ * src/resources/spritedef.cpp: Error placeholder is now used when
+ attempting to load a sprite definition file that doesn't exist.
+ * src/monster.cpp, src/player.cpp: Avoided attempts to load
+ "data/graphics/" when a monster or equipment piece has no sprite.
+ * data/graphics/particles/cookingfire.particle.xml: Removed some
+ particle properties that did nothing because they were misspelled.
2007-12-22 Bjørn Lindeijer <bjorn@lindeijer.nl>
diff --git a/INSTALL b/INSTALL
index cfb5aba9..81c2d148 100644
--- a/INSTALL
+++ b/INSTALL
@@ -20,7 +20,7 @@ and some libraries. The required libraries are:
* SDL_mixer http://www.libsdl.org/projects/SDL_mixer/
* SDL_image http://www.libsdl.org/projects/SDL_image/
* SDL_net http://www.libsdl.org/projects/SDL_net/
-* Guichan 0.7.x http://guichan.sourceforge.net/
+* Guichan 0.8.x http://guichan.sourceforge.net/
* libxml2 http://www.xmlsoft.org/
* physfs 1.0.x http://icculus.org/physfs/
* zlib 1.2.x http://www.gzip.org/zlib/
diff --git a/NEWS b/NEWS
index ebdae676..51a181d0 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+0.0.24.1 (7 April 2008)
+
0.0.24 (24 December 2007)
- Added female specific hair styles
- Added user-definable key settings
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 74665423..793d135f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -134,7 +134,6 @@ SET(SRCS
gui/register.h
gui/scrollarea.cpp
gui/scrollarea.h
- gui/selectionlistener.h
gui/sell.cpp
gui/sell.h
gui/setup_audio.cpp
@@ -176,7 +175,6 @@ SET(SRCS
gui/window.h
gui/windowcontainer.cpp
gui/windowcontainer.h
- gui/windowlistener.h
net/beinghandler.h
net/beinghandler.cpp
net/buysellhandler.h
diff --git a/src/Makefile.am b/src/Makefile.am
index b2bfa32f..329dbd78 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -84,7 +84,6 @@ tmw_SOURCES = gui/widgets/resizegrip.cpp \
gui/register.h \
gui/scrollarea.cpp \
gui/scrollarea.h \
- gui/selectionlistener.h \
gui/sell.cpp \
gui/sell.h \
gui/setup_audio.cpp \
@@ -126,7 +125,6 @@ tmw_SOURCES = gui/widgets/resizegrip.cpp \
gui/window.h \
gui/windowcontainer.cpp \
gui/windowcontainer.h \
- gui/windowlistener.h \
net/beinghandler.h \
net/beinghandler.cpp \
net/buysellhandler.h \
diff --git a/src/gui/button.cpp b/src/gui/button.cpp
index e47f90f8..c6bc4ccb 100644
--- a/src/gui/button.cpp
+++ b/src/gui/button.cpp
@@ -82,7 +82,7 @@ Button::Button(const std::string& caption, const std::string &actionEventId,
void Button::init()
{
- setBorderSize(0);
+ setFrameSize(0);
if (mInstances == 0)
{
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index 3516129b..17e5dba7 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -90,7 +90,6 @@ BuyDialog::BuyDialog(Network *network):
add(mItemDescLabel);
add(mItemEffectLabel);
- addWindowListener(this);
loadWindowState();
setLocationRelativeTo(getParent());
}
@@ -184,9 +183,8 @@ void BuyDialog::action(const gcn::ActionEvent &event)
}
}
-void BuyDialog::selectionChanged(const SelectionEvent &event)
+void BuyDialog::valueChanged(const gcn::SelectionEvent &event)
{
-
// Reset amount of items and update labels
mAmountItems = 1;
mSlider->setValue(1);
@@ -195,11 +193,13 @@ void BuyDialog::selectionChanged(const SelectionEvent &event)
mSlider->gcn::Slider::setScale(1, mMaxItems);
}
-void BuyDialog::windowResized(const WindowEvent &event)
+void BuyDialog::widgetResized(const gcn::Event &event)
{
- gcn::Rectangle area = getChildrenArea();
- int width = area.width;
- int height = area.height;
+ Window::widgetResized(event);
+
+ const gcn::Rectangle &area = getChildrenArea();
+ const int width = area.width;
+ const int height = area.height;
mDecreaseButton->setPosition(8, height - 8 - mDecreaseButton->getHeight());
mIncreaseButton->setPosition(
@@ -241,7 +241,7 @@ void BuyDialog::windowResized(const WindowEvent &event)
void
BuyDialog::updateButtonsAndLabels()
{
- int selectedItem = mShopItemList->getSelected();
+ const int selectedItem = mShopItemList->getSelected();
int price = 0;
if (selectedItem > -1)
diff --git a/src/gui/buy.h b/src/gui/buy.h
index 5ee7ab95..3a9ea3c5 100644
--- a/src/gui/buy.h
+++ b/src/gui/buy.h
@@ -25,9 +25,9 @@
#define _TMW_BUY_H
#include <guichan/actionlistener.hpp>
+#include <guichan/selectionlistener.hpp>
#include "window.h"
-#include "selectionlistener.h"
#include "../guichanfwd.h"
@@ -41,8 +41,8 @@ class ListBox;
*
* \ingroup Interface
*/
-class BuyDialog : public Window, public gcn::ActionListener, SelectionListener,
- WindowListener
+class BuyDialog : public Window, public gcn::ActionListener,
+ gcn::SelectionListener
{
public:
/**
@@ -84,10 +84,8 @@ class BuyDialog : public Window, public gcn::ActionListener, SelectionListener,
/**
* Updates the labels according to the selected item.
- *
- * @see SelectionListener::selectionChanged
*/
- void selectionChanged(const SelectionEvent &event);
+ void valueChanged(const gcn::SelectionEvent &event);
/**
* Returns the name of item number i in the shop inventory.
@@ -101,9 +99,9 @@ class BuyDialog : public Window, public gcn::ActionListener, SelectionListener,
updateButtonsAndLabels();
/**
- * Called whenever the window is resized.
+ * Called whenever the widget changes size.
*/
- void windowResized(const WindowEvent &event);
+ void widgetResized(const gcn::Event &event);
private:
Network *mNetwork;
diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp
index a5fda25f..638c05a6 100644
--- a/src/gui/char_server.cpp
+++ b/src/gui/char_server.cpp
@@ -69,7 +69,7 @@ ServerSelectDialog::ServerSelectDialog(LoginData *loginData):
mScrollArea->setDimension(gcn::Rectangle(
5, 5, 200 - 2 * 5,
100 - 3 * 5 - mCancelButton->getHeight() -
- mScrollArea->getBorderSize()));
+ mScrollArea->getFrameSize()));
mServerList->setActionEventId("ok");
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index effb58d2..8fe1a67a 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -64,7 +64,7 @@ ChatWindow::ChatWindow(Network *network):
mTextOutput->setMaxRow((int) config.getValue("ChatLogLength", 0));
mScrollArea = new ScrollArea(mTextOutput);
mScrollArea->setPosition(
- mScrollArea->getBorderSize(), mScrollArea->getBorderSize());
+ mScrollArea->getFrameSize(), mScrollArea->getFrameSize());
mScrollArea->setScrollPolicy(
gcn::ScrollArea::SHOW_NEVER, gcn::ScrollArea::SHOW_ALWAYS);
mScrollArea->setOpaque(false);
@@ -84,12 +84,12 @@ ChatWindow::logic()
const gcn::Rectangle area = getChildrenArea();
- mChatInput->setPosition(mChatInput->getBorderSize(),
+ mChatInput->setPosition(mChatInput->getFrameSize(),
area.height - mChatInput->getHeight() -
- mChatInput->getBorderSize());
- mChatInput->setWidth(area.width - 2 * mChatInput->getBorderSize());
- mScrollArea->setWidth(area.width - 2 * mScrollArea->getBorderSize());
- mScrollArea->setHeight(area.height - 2 * mScrollArea->getBorderSize() -
+ mChatInput->getFrameSize());
+ mChatInput->setWidth(area.width - 2 * mChatInput->getFrameSize());
+ mScrollArea->setWidth(area.width - 2 * mScrollArea->getFrameSize());
+ mScrollArea->setHeight(area.height - 2 * mScrollArea->getFrameSize() -
mChatInput->getHeight() - 5);
mScrollArea->logic();
}
diff --git a/src/gui/checkbox.cpp b/src/gui/checkbox.cpp
index fab4780c..5b300d33 100644
--- a/src/gui/checkbox.cpp
+++ b/src/gui/checkbox.cpp
@@ -34,8 +34,8 @@ Image *CheckBox::checkBoxChecked;
Image *CheckBox::checkBoxDisabled;
Image *CheckBox::checkBoxDisabledChecked;
-CheckBox::CheckBox(const std::string& caption, bool marked):
- gcn::CheckBox(caption, marked)
+CheckBox::CheckBox(const std::string& caption, bool selected):
+ gcn::CheckBox(caption, selected)
{
if (instances == 0)
{
@@ -68,7 +68,7 @@ void CheckBox::drawBox(gcn::Graphics* graphics)
{
Image *box;
- if (mMarked) {
+ if (isSelected()) {
if (isEnabled()) {
box = checkBoxChecked;
} else {
diff --git a/src/gui/checkbox.h b/src/gui/checkbox.h
index 468a7f38..262e63ae 100644
--- a/src/gui/checkbox.h
+++ b/src/gui/checkbox.h
@@ -40,7 +40,7 @@ class CheckBox : public gcn::CheckBox {
/**
* Constructor.
*/
- CheckBox(const std::string& caption, bool marked = false);
+ CheckBox(const std::string& caption, bool selected = false);
/**
* Destructor.
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 83dadbc9..7062720d 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -81,7 +81,6 @@ InventoryWindow::InventoryWindow():
mUseButton->setSize(60, mUseButton->getHeight());
- addWindowListener(this);
loadWindowState();
}
@@ -132,7 +131,7 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
}
}
-void InventoryWindow::selectionChanged(const SelectionEvent &event)
+void InventoryWindow::valueChanged(const gcn::SelectionEvent &event)
{
Item *item = mItems->getItem();
@@ -169,17 +168,19 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
/* Convert relative to the window coordinates to absolute screen
* coordinates.
*/
- int mx = event.getX() + getX();
- int my = event.getY() + getY();
+ const int mx = event.getX() + getX();
+ const int my = event.getY() + getY();
viewport->showPopup(mx, my, item);
}
}
-void InventoryWindow::windowResized(const WindowEvent &event)
+void InventoryWindow::widgetResized(const gcn::Event &event)
{
- gcn::Rectangle area = getChildrenArea();
- int width = area.width;
- int height = area.height;
+ Window::widgetResized(event);
+
+ const gcn::Rectangle &area = getChildrenArea();
+ const int width = area.width;
+ const int height = area.height;
int columns = width / 24;
if (columns < 1)
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index 14e1f25f..1a6e01af 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -25,10 +25,9 @@
#define _TMW_INVENTORYWINDOW_H
#include <guichan/actionlistener.hpp>
+#include <guichan/selectionlistener.hpp>
-#include "selectionlistener.h"
#include "window.h"
-#include "windowlistener.h"
#include "../guichanfwd.h"
@@ -40,8 +39,8 @@ class ItemContainer;
*
* \ingroup Interface
*/
-class InventoryWindow : public Window, gcn::ActionListener, SelectionListener,
- WindowListener
+class InventoryWindow : public Window, gcn::ActionListener,
+ gcn::SelectionListener
{
public:
/**
@@ -65,15 +64,13 @@ class InventoryWindow : public Window, gcn::ActionListener, SelectionListener,
/**
* Updates labels to currently selected item.
- *
- * @see SelectionListener::selectionChanged.
*/
- void selectionChanged(const SelectionEvent &event);
+ void valueChanged(const gcn::SelectionEvent &event);
/**
- * Called whenever the window is resized.
+ * Called whenever the widget changes size.
*/
- void windowResized(const WindowEvent &event);
+ void widgetResized(const gcn::Event &event);
private:
void updateButtons(); /**< Updates button states. */
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index 74d1abd1..c73d25f3 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -24,8 +24,7 @@
#include "itemcontainer.h"
#include <guichan/mouseinput.hpp>
-
-#include "selectionlistener.h"
+#include <guichan/selectionlistener.hpp>
#include "../graphics.h"
#include "../inventory.h"
@@ -167,20 +166,20 @@ ItemContainer::setSelectedItem(Item *item)
if (mSelectedItem != item)
{
mSelectedItem = item;
- fireSelectionChangedEvent();
+ distributeValueChangedEvent();
}
}
void
-ItemContainer::fireSelectionChangedEvent()
+ItemContainer::distributeValueChangedEvent()
{
- SelectionEvent event(this);
- SelectionListeners::iterator i_end = mListeners.end();
- SelectionListeners::iterator i;
+ gcn::SelectionEvent event(this);
+ std::list<gcn::SelectionListener*>::iterator i_end = mListeners.end();
+ std::list<gcn::SelectionListener*>::iterator i;
for (i = mListeners.begin(); i != i_end; ++i)
{
- (*i)->selectionChanged(event);
+ (*i)->valueChanged(event);
}
}
diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h
index 8c548fcd..58b19179 100644
--- a/src/gui/itemcontainer.h
+++ b/src/gui/itemcontainer.h
@@ -32,7 +32,10 @@
class Image;
class Inventory;
class Item;
-class SelectionListener;
+
+namespace gcn {
+ class SelectionListener;
+}
/**
* An item container. Used to show items in inventory and trade dialog.
@@ -87,7 +90,7 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener
* Adds a listener to the list that's notified each time a change to
* the selection occurs.
*/
- void addSelectionListener(SelectionListener *listener)
+ void addSelectionListener(gcn::SelectionListener *listener)
{
mListeners.push_back(listener);
}
@@ -96,7 +99,7 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener
* Removes a listener from the list that's notified each time a change
* to the selection occurs.
*/
- void removeSelectionListener(SelectionListener *listener)
+ void removeSelectionListener(gcn::SelectionListener *listener)
{
mListeners.remove(listener);
}
@@ -110,7 +113,7 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener
/**
* Sends out selection events to the list of selection listeners.
*/
- void fireSelectionChangedEvent();
+ void distributeValueChangedEvent();
Inventory *mInventory;
Image *mSelImg;
@@ -118,7 +121,7 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener
int mMaxItems;
- std::list<SelectionListener*> mListeners;
+ std::list<gcn::SelectionListener*> mListeners;
};
#endif
diff --git a/src/gui/itemshortcutwindow.cpp b/src/gui/itemshortcutwindow.cpp
index 51f9f91e..efbbe266 100644
--- a/src/gui/itemshortcutwindow.cpp
+++ b/src/gui/itemshortcutwindow.cpp
@@ -39,7 +39,7 @@ ItemShortcutWindow::ItemShortcutWindow()
mItems = new ItemShortcutContainer();
- int border = SCROLL_PADDING * 2 + getPadding() * 2;
+ const int border = SCROLL_PADDING * 2 + getPadding() * 2;
setMinWidth(mItems->getBoxWidth() + border);
setMinHeight(mItems->getBoxHeight() + border);
setMaxWidth(mItems->getBoxWidth() * mItems->getMaxItems() + border);
@@ -51,7 +51,6 @@ ItemShortcutWindow::ItemShortcutWindow()
add(mInvenScroll);
- addWindowListener(this);
loadWindowState();
}
@@ -66,9 +65,11 @@ void ItemShortcutWindow::logic()
Window::logic();
}
-void ItemShortcutWindow::windowResized(const WindowEvent &event)
+void ItemShortcutWindow::widgetResized(const gcn::Event &event)
{
- const gcn::Rectangle area = getChildrenArea();
+ Window::widgetResized(event);
+
+ const gcn::Rectangle &area = getChildrenArea();
mInvenScroll->setSize(
area.width - SCROLL_PADDING,
diff --git a/src/gui/itemshortcutwindow.h b/src/gui/itemshortcutwindow.h
index 1dde8686..51685e49 100644
--- a/src/gui/itemshortcutwindow.h
+++ b/src/gui/itemshortcutwindow.h
@@ -25,7 +25,6 @@
#define _TMW_ITEMSHORTCUTWINDOW_H
#include "window.h"
-#include "windowlistener.h"
#include "../guichanfwd.h"
@@ -36,7 +35,7 @@ class ItemShortcutContainer;
*
* \ingroup Interface
*/
-class ItemShortcutWindow : public Window, WindowListener
+class ItemShortcutWindow : public Window
{
public:
/**
@@ -55,9 +54,9 @@ class ItemShortcutWindow : public Window, WindowListener
void logic();
/**
- * Called whenever the window is resized.
+ * Called whenever the widget changes size.
*/
- void windowResized(const WindowEvent &event);
+ void widgetResized(const gcn::Event &event);
private:
ItemShortcutContainer *mItems;
diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp
index 94e8b38c..634afa07 100644
--- a/src/gui/listbox.cpp
+++ b/src/gui/listbox.cpp
@@ -23,8 +23,6 @@
#include "listbox.h"
-#include "selectionlistener.h"
-
#include <guichan/font.hpp>
#include <guichan/graphics.hpp>
#include <guichan/listmodel.hpp>
@@ -62,28 +60,9 @@ void ListBox::draw(gcn::Graphics *graphics)
}
void
-ListBox::setSelected(int selected)
-{
- gcn::ListBox::setSelected(selected);
- fireSelectionChangedEvent();
-}
-
-void
ListBox::mouseDragged(gcn::MouseEvent &event)
{
// Pretend mouse is pressed continuously while dragged. Causes list
// selection to be updated as is default in many GUIs.
mousePressed(event);
}
-
-void ListBox::fireSelectionChangedEvent()
-{
- SelectionEvent event(this);
- SelectionListeners::iterator i_end = mListeners.end();
- SelectionListeners::iterator i;
-
- for (i = mListeners.begin(); i != i_end; ++i)
- {
- (*i)->selectionChanged(event);
- }
-}
diff --git a/src/gui/listbox.h b/src/gui/listbox.h
index 1d480eb1..b226a11e 100644
--- a/src/gui/listbox.h
+++ b/src/gui/listbox.h
@@ -49,37 +49,6 @@ class ListBox : public gcn::ListBox
void draw(gcn::Graphics *graphics);
void mouseDragged(gcn::MouseEvent &event);
-
- /**
- * Adds a listener to the list that's notified each time a change to
- * the selection occurs.
- */
- void addSelectionListener(SelectionListener *listener)
- {
- mListeners.push_back(listener);
- }
-
- /**
- * Removes a listener from the list that's notified each time a change
- * to the selection occurs.
- */
- void removeSelectionListener(SelectionListener *listener)
- {
- mListeners.remove(listener);
- }
-
- /**
- * Sets the index of the selected element.
- */
- virtual void setSelected(int selected);
-
- protected:
- /**
- * Sends out selection events to the list of selection listeners.
- */
- void fireSelectionChangedEvent();
-
- std::list<SelectionListener*> mListeners;
};
#endif
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index 2c13f204..d85f4e83 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -124,7 +124,7 @@ LoginDialog::action(const gcn::ActionEvent &event)
mLoginData->hostname = mServerField->getText();
mLoginData->username = mUserField->getText();
mLoginData->password = mPassField->getText();
- mLoginData->remember = mKeepCheck->isMarked();
+ mLoginData->remember = mKeepCheck->isSelected();
mLoginData->registerLogin = false;
mOkButton->setEnabled(false);
diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp
index 8e5f1827..2c633b72 100644
--- a/src/gui/playerbox.cpp
+++ b/src/gui/playerbox.cpp
@@ -39,7 +39,7 @@ ImageRect PlayerBox::background;
PlayerBox::PlayerBox(const Player *player):
mPlayer(player)
{
- setBorderSize(2);
+ setFrameSize(2);
if (instances == 0)
{
@@ -83,7 +83,7 @@ PlayerBox::draw(gcn::Graphics *graphics)
{
// Draw character
int x, y, bs;
- bs = getBorderSize();
+ bs = getFrameSize();
x = getWidth() / 2 - 16 + bs;
y = getHeight() / 2 + bs;
mPlayer->draw(static_cast<Graphics*>(graphics), x, y);
@@ -91,10 +91,10 @@ PlayerBox::draw(gcn::Graphics *graphics)
}
void
-PlayerBox::drawBorder(gcn::Graphics *graphics)
+PlayerBox::drawFrame(gcn::Graphics *graphics)
{
int w, h, bs;
- bs = getBorderSize();
+ bs = getFrameSize();
w = getWidth() + bs * 2;
h = getHeight() + bs * 2;
diff --git a/src/gui/playerbox.h b/src/gui/playerbox.h
index 6bba1b51..c226e750 100644
--- a/src/gui/playerbox.h
+++ b/src/gui/playerbox.h
@@ -64,7 +64,7 @@ class PlayerBox : public gcn::ScrollArea
/**
* Draws the background and border of the scroll area.
*/
- void drawBorder(gcn::Graphics *graphics);
+ void drawFrame(gcn::Graphics *graphics);
private:
const Player *mPlayer; /**< The character used for display */
diff --git a/src/gui/radiobutton.cpp b/src/gui/radiobutton.cpp
index e318116a..0ac4dea8 100644
--- a/src/gui/radiobutton.cpp
+++ b/src/gui/radiobutton.cpp
@@ -67,7 +67,7 @@ void RadioButton::drawBox(gcn::Graphics* graphics)
{
Image *box = NULL;
- if (mMarked) {
+ if (isSelected()) {
if (isEnabled()) {
box = radioChecked;
} else {
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index b42a7af8..9496da93 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -235,7 +235,7 @@ RegisterDialog::action(const gcn::ActionEvent &event)
mLoginData->port = (short) config.getValue("port", 0);
mLoginData->username = mUserField->getText();
mLoginData->password = mPasswordField->getText();
- mLoginData->username += mFemaleButton->isMarked() ? "_F" : "_M";
+ mLoginData->username += mFemaleButton->isSelected() ? "_F" : "_M";
mLoginData->registerLogin = true;
state = ACCOUNT_STATE;
diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp
index cd83b565..9c88f8e3 100644
--- a/src/gui/scrollarea.cpp
+++ b/src/gui/scrollarea.cpp
@@ -153,12 +153,12 @@ void ScrollArea::logic()
if (getHorizontalScrollPolicy() == gcn::ScrollArea::SHOW_NEVER)
{
content->setWidth(getChildrenArea().width -
- 2 * content->getBorderSize());
+ 2 * content->getFrameSize());
}
if (getVerticalScrollPolicy() == gcn::ScrollArea::SHOW_NEVER)
{
content->setHeight(getChildrenArea().height -
- 2 * content->getBorderSize());
+ 2 * content->getFrameSize());
}
}
}
@@ -204,15 +204,15 @@ void ScrollArea::draw(gcn::Graphics *graphics)
{
graphics->pushClipArea(getChildrenArea());
- if (content->getBorderSize() > 0)
+ if (content->getFrameSize() > 0)
{
gcn::Rectangle rec = content->getDimension();
- rec.x -= content->getBorderSize();
- rec.y -= content->getBorderSize();
- rec.width += 2 * content->getBorderSize();
- rec.height += 2 * content->getBorderSize();
+ rec.x -= content->getFrameSize();
+ rec.y -= content->getFrameSize();
+ rec.width += 2 * content->getFrameSize();
+ rec.height += 2 * content->getFrameSize();
graphics->pushClipArea(rec);
- content->drawBorder(graphics);
+ content->drawFrame(graphics);
graphics->popClipArea();
}
@@ -223,9 +223,9 @@ void ScrollArea::draw(gcn::Graphics *graphics)
}
}
-void ScrollArea::drawBorder(gcn::Graphics *graphics)
+void ScrollArea::drawFrame(gcn::Graphics *graphics)
{
- int bs = getBorderSize();
+ int bs = getFrameSize();
int w = getWidth() + bs * 2;
int h = getHeight() + bs * 2;
@@ -240,10 +240,10 @@ void ScrollArea::setOpaque(bool opaque)
mOpaque = opaque;
if (mOpaque) {
- setBorderSize(2);
+ setFrameSize(2);
}
else {
- setBorderSize(0);
+ setFrameSize(0);
}
}
diff --git a/src/gui/scrollarea.h b/src/gui/scrollarea.h
index 504842cc..9fb7093d 100644
--- a/src/gui/scrollarea.h
+++ b/src/gui/scrollarea.h
@@ -65,7 +65,7 @@ class ScrollArea : public gcn::ScrollArea {
/**
* Draws the background and border of the scroll area.
*/
- void drawBorder(gcn::Graphics *graphics);
+ void drawFrame(gcn::Graphics *graphics);
/**
* Sets whether the widget should draw its background or not.
diff --git a/src/gui/selectionlistener.h b/src/gui/selectionlistener.h
deleted file mode 100644
index 917a4871..00000000
--- a/src/gui/selectionlistener.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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_SELECTIONLISTENER_H__
-#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 : public gcn::Event
-{
- public:
- /**
- * Constructor.
- */
- SelectionEvent(gcn::Widget *source):
- gcn::Event(source)
- {
- }
-};
-
-/**
- * The listener that's notified when a selection value changes.
- *
- * \ingroup GUI
- */
-class SelectionListener
-{
- public:
- /**
- * Virtual destructor.
- */
- virtual ~SelectionListener() {}
-
- /**
- * Called whenever the value of the selection changes.
- */
- virtual void selectionChanged(const SelectionEvent &event) = 0;
-};
-
-typedef std::list<SelectionListener*> SelectionListeners;
-
-#endif
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 63e7d704..ce971cb0 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -97,7 +97,6 @@ SellDialog::SellDialog(Network *network):
add(mSellButton);
add(mQuitButton);
- addWindowListener(this);
loadWindowState();
setLocationRelativeTo(getParent());
}
@@ -204,7 +203,7 @@ void SellDialog::action(const gcn::ActionEvent &event)
}
}
-void SellDialog::selectionChanged(const SelectionEvent &event)
+void SellDialog::valueChanged(const gcn::SelectionEvent &event)
{
// Reset amount of items and update labels
mAmountItems = 1;
@@ -214,8 +213,10 @@ void SellDialog::selectionChanged(const SelectionEvent &event)
mSlider->gcn::Slider::setScale(1, mMaxItems);
}
-void SellDialog::windowResized(const WindowEvent &event)
+void SellDialog::widgetResized(const gcn::Event &event)
{
+ Window::widgetResized(event);
+
gcn::Rectangle area = getChildrenArea();
int width = area.width;
int height = area.height;
diff --git a/src/gui/sell.h b/src/gui/sell.h
index d5c70c45..c56337ef 100644
--- a/src/gui/sell.h
+++ b/src/gui/sell.h
@@ -25,10 +25,9 @@
#define _TMW_SELL_H
#include <guichan/actionlistener.hpp>
+#include <guichan/selectionlistener.hpp>
#include "window.h"
-#include "selectionlistener.h"
-#include "windowlistener.h"
#include "../guichanfwd.h"
@@ -42,8 +41,7 @@ class ShopListBox;
*
* \ingroup Interface
*/
-class SellDialog : public Window, gcn::ActionListener, SelectionListener,
- WindowListener
+class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener
{
public:
/**
@@ -78,12 +76,12 @@ class SellDialog : public Window, gcn::ActionListener, SelectionListener,
*
* @see SelectionListener::selectionChanged
*/
- void selectionChanged(const SelectionEvent &event);
+ void valueChanged(const gcn::SelectionEvent &event);
/**
- * Called whenever the window is resized.
+ * Called whenever the widget changes size.
*/
- void windowResized(const WindowEvent &event);
+ void widgetResized(const gcn::Event &event);
/**
* Gives Player's Money amount
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index e5aadf80..4227b5ca 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -70,7 +70,7 @@ Setup_Audio::Setup_Audio():
void Setup_Audio::apply()
{
- if (mSoundCheckBox->isMarked())
+ if (mSoundCheckBox->isSelected())
{
config.setValue("sound", 1);
try {
@@ -95,7 +95,7 @@ void Setup_Audio::apply()
void Setup_Audio::cancel()
{
- mSoundCheckBox->setMarked(mSoundEnabled);
+ mSoundCheckBox->setSelected(mSoundEnabled);
sound.setSfxVolume(mSfxVolume);
mSfxSlider->setValue(mSfxVolume);
diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp
index 56f411d7..a501298e 100644
--- a/src/gui/setup_joystick.cpp
+++ b/src/gui/setup_joystick.cpp
@@ -43,7 +43,7 @@ Setup_Joystick::Setup_Joystick():
mCalibrateButton->setPosition(10, 30 + mCalibrateLabel->getHeight());
mOriginalJoystickEnabled = (int)config.getValue("joystickEnabled", 0) != 0;
- mJoystickEnabled->setMarked(mOriginalJoystickEnabled);
+ mJoystickEnabled->setSelected(mOriginalJoystickEnabled);
mJoystickEnabled->addActionListener(this);
@@ -60,7 +60,7 @@ void Setup_Joystick::action(const gcn::ActionEvent &event)
if (event.getSource() == mJoystickEnabled)
{
- joystick->setEnabled(mJoystickEnabled->isMarked());
+ joystick->setEnabled(mJoystickEnabled->isSelected());
}
else
{
@@ -83,7 +83,7 @@ void Setup_Joystick::cancel()
{
joystick->setEnabled(mOriginalJoystickEnabled);
}
- mJoystickEnabled->setMarked(mOriginalJoystickEnabled);
+ mJoystickEnabled->setSelected(mOriginalJoystickEnabled);
}
void Setup_Joystick::apply()
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index cd1507a7..d0c3d5e3 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -156,7 +156,7 @@ Setup_Video::Setup_Video():
mFpsField->setEnabled(mFps > 0);
mFpsSlider->setValue(mFps);
mFpsSlider->setEnabled(mFps > 0);
- mFpsCheckBox->setMarked(mFps > 0);
+ mFpsCheckBox->setSelected(mFps > 0);
mCustomCursorCheckBox->setActionEventId("customcursor");
mAlphaSlider->setActionEventId("guialpha");
@@ -244,7 +244,7 @@ Setup_Video::~Setup_Video()
void Setup_Video::apply()
{
// Full screen changes
- bool fullscreen = mFsCheckBox->isMarked();
+ bool fullscreen = mFsCheckBox->isSelected();
if (fullscreen != (config.getValue("screen", 0) == 1))
{
// checks for opengl usage
@@ -271,9 +271,9 @@ void Setup_Video::apply()
}
// OpenGL change
- if (mOpenGLCheckBox->isMarked() != mOpenGLEnabled)
+ if (mOpenGLCheckBox->isSelected() != mOpenGLEnabled)
{
- config.setValue("opengl", mOpenGLCheckBox->isMarked() ? 1 : 0);
+ config.setValue("opengl", mOpenGLCheckBox->isSelected() ? 1 : 0);
// OpenGL can currently only be changed by restarting, notify user.
new OkDialog("Changing OpenGL",
@@ -314,9 +314,9 @@ Setup_Video::updateSlider(gcn::Slider *slider, gcn::TextField *field,
void Setup_Video::cancel()
{
- mFsCheckBox->setMarked(mFullScreenEnabled);
- mOpenGLCheckBox->setMarked(mOpenGLEnabled);
- mCustomCursorCheckBox->setMarked(mCustomCursorEnabled);
+ mFsCheckBox->setSelected(mFullScreenEnabled);
+ mOpenGLCheckBox->setSelected(mOpenGLEnabled);
+ mCustomCursorCheckBox->setSelected(mCustomCursorEnabled);
mAlphaSlider->setValue(mOpacity);
mOverlayDetailSlider->setValue(mOverlayDetail);
@@ -340,7 +340,7 @@ void Setup_Video::action(const gcn::ActionEvent &event)
else if (event.getId() == "customcursor")
{
config.setValue("customcursor",
- mCustomCursorCheckBox->isMarked() ? 1 : 0);
+ mCustomCursorCheckBox->isSelected() ? 1 : 0);
}
else if (event.getId() == "fpslimitslider")
{
@@ -378,7 +378,7 @@ void Setup_Video::action(const gcn::ActionEvent &event)
}
else if (event.getId() == "fpslimitcheckbox")
{
- if (mFpsCheckBox->isMarked())
+ if (mFpsCheckBox->isSelected())
{
mFps = (int) mFpsSlider->getValue();
}
diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp
index 4c590e66..026c4aef 100644
--- a/src/gui/shoplistbox.cpp
+++ b/src/gui/shoplistbox.cpp
@@ -23,8 +23,6 @@
#include "shoplistbox.h"
-#include "selectionlistener.h"
-
#include <guichan/font.hpp>
#include <guichan/graphics.hpp>
#include <guichan/listmodel.hpp>
@@ -101,6 +99,9 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
}
}
+/* TODO:
+ * This method is no longer virtual, needed to be able to change row height...
+ *
void ShopListBox::setSelected(int selected)
{
if (!mListModel)
@@ -123,15 +124,16 @@ void ShopListBox::setSelected(int selected)
}
}
- fireSelectionChangedEvent();
+ distributeValueChangedEvent();
}
+*/
void ShopListBox::mousePressed(gcn::MouseEvent &event)
{
if (event.getButton() == gcn::MouseEvent::LEFT)
{
setSelected(event.getY() / mRowHeight);
- generateAction();
+ distributeActionEvent();
}
}
diff --git a/src/gui/shoplistbox.h b/src/gui/shoplistbox.h
index 1cfb183b..aeceab1b 100644
--- a/src/gui/shoplistbox.h
+++ b/src/gui/shoplistbox.h
@@ -27,8 +27,6 @@
#include "listbox.h"
#include "shop.h"
-class SelectionListener;
-
/**
* A list box, meant to be used inside a scroll area. Same as the Guichan list
* box except this one doesn't have a background, instead completely relying
@@ -57,29 +55,6 @@ class ShopListBox : public ListBox
void mousePressed(gcn::MouseEvent &event);
/**
- * Adds a listener to the list that's notified each time a change to
- * the selection occurs.
- */
- void addSelectionListener(SelectionListener *listener)
- {
- mListeners.push_back(listener);
- }
-
- /**
- * Removes a listener from the list that's notified each time a change
- * to the selection occurs.
- */
- void removeSelectionListener(SelectionListener *listener)
- {
- mListeners.remove(listener);
- }
-
- /**
- * Sets the index of the selected element.
- */
- void setSelected(int selected);
-
- /**
* gives information about the current player's money
*/
void setPlayersMoney(int money);
diff --git a/src/gui/slider.cpp b/src/gui/slider.cpp
index f0170a1b..c94c7bfb 100644
--- a/src/gui/slider.cpp
+++ b/src/gui/slider.cpp
@@ -64,7 +64,7 @@ Slider::~Slider()
void Slider::init()
{
int x, y, w, h,o1,o2;
- setBorderSize(0);
+ setFrameSize(0);
// Load resources
if (mInstances == 0)
diff --git a/src/gui/tabbedcontainer.cpp b/src/gui/tabbedcontainer.cpp
index 8fb2f598..d6267e65 100644
--- a/src/gui/tabbedcontainer.cpp
+++ b/src/gui/tabbedcontainer.cpp
@@ -82,8 +82,8 @@ void TabbedContainer::logic()
{
if (mActiveContent) {
mActiveContent->setSize(
- getWidth() - 2 * mActiveContent->getBorderSize(),
- getHeight() - TABHEIGHT - 2 * mActiveContent->getBorderSize());
+ getWidth() - 2 * mActiveContent->getFrameSize(),
+ getHeight() - TABHEIGHT - 2 * mActiveContent->getFrameSize());
}
Container::logic();
diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp
index 329813e5..84c8ad4b 100644
--- a/src/gui/textbox.cpp
+++ b/src/gui/textbox.cpp
@@ -32,14 +32,14 @@ TextBox::TextBox():
gcn::TextBox()
{
setOpaque(false);
- setBorderSize(0);
+ setFrameSize(0);
}
TextBox::TextBox(const std::string& text):
gcn::TextBox(text)
{
setOpaque(false);
- setBorderSize(0);
+ setFrameSize(0);
}
void TextBox::setText(const std::string &text)
diff --git a/src/gui/textfield.cpp b/src/gui/textfield.cpp
index 5b875da3..8db720cf 100644
--- a/src/gui/textfield.cpp
+++ b/src/gui/textfield.cpp
@@ -40,7 +40,7 @@ ImageRect TextField::skin;
TextField::TextField(const std::string& text):
gcn::TextField(text)
{
- setBorderSize(2);
+ setFrameSize(2);
if (instances == 0)
{
@@ -93,10 +93,10 @@ void TextField::draw(gcn::Graphics *graphics)
graphics->drawText(mText, 1 - mXScroll, 1);
}
-void TextField::drawBorder(gcn::Graphics *graphics)
+void TextField::drawFrame(gcn::Graphics *graphics)
{
int w, h, bs;
- bs = getBorderSize();
+ bs = getFrameSize();
w = getWidth() + bs * 2;
h = getHeight() + bs * 2;
diff --git a/src/gui/textfield.h b/src/gui/textfield.h
index 4748830c..bc47d501 100644
--- a/src/gui/textfield.h
+++ b/src/gui/textfield.h
@@ -53,7 +53,7 @@ class TextField : public gcn::TextField {
/**
* Draws the background and border.
*/
- void drawBorder(gcn::Graphics *graphics);
+ void drawFrame(gcn::Graphics *graphics);
private:
static int instances;
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index 744afe1e..383d6582 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -225,7 +225,7 @@ void TradeWindow::tradeItem(Item *item, int quantity)
outMsg.writeInt32(quantity);
}
-void TradeWindow::selectionChanged(const SelectionEvent &event)
+void TradeWindow::valueChanged(const gcn::SelectionEvent &event)
{
Item *item;
diff --git a/src/gui/trade.h b/src/gui/trade.h
index 49deb899..7adf9575 100644
--- a/src/gui/trade.h
+++ b/src/gui/trade.h
@@ -27,9 +27,9 @@
#include <memory>
#include <guichan/actionlistener.hpp>
+#include <guichan/selectionlistener.hpp>
#include "window.h"
-#include "selectionlistener.h"
#include "../guichanfwd.h"
@@ -44,7 +44,7 @@ class ScrollArea;
*
* \ingroup Interface
*/
-class TradeWindow : public Window, gcn::ActionListener, SelectionListener
+class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener
{
public:
/**
@@ -107,7 +107,7 @@ class TradeWindow : public Window, gcn::ActionListener, SelectionListener
* Updates the labels and makes sure only one item is selected in
* either my inventory or partner inventory.
*/
- void selectionChanged(const SelectionEvent &event);
+ void valueChanged(const gcn::SelectionEvent &event);
/**
* Called when receiving actions from the widgets.
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index b7ff79f7..9bef5d68 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -105,7 +105,7 @@ Window::Window(const std::string& caption, bool modal, Window *parent):
instances++;
- setBorderSize(0);
+ setFrameSize(0);
setPadding(3);
setTitleBarHeight(20);
@@ -125,6 +125,8 @@ Window::Window(const std::string& caption, bool modal, Window *parent):
// Windows are invisible by default
setVisible(false);
+
+ addWidgetListener(this);
}
Window::~Window()
@@ -196,18 +198,6 @@ void Window::draw(gcn::Graphics *graphics)
drawChildren(graphics);
}
-void Window::setContentWidth(int width)
-{
- mChrome->setWidth(width);
- setWidth(width + 2 * getPadding());
-}
-
-void Window::setContentHeight(int height)
-{
- mChrome->setHeight(height);
- setHeight(height + getPadding() + getTitleBarHeight());
-}
-
void Window::setContentSize(int width, int height)
{
mChrome->setSize(width, height);
@@ -215,61 +205,6 @@ void Window::setContentSize(int width, int height)
height + getPadding() + getTitleBarHeight());
}
-void Window::setSize(int width, int height)
-{
- if (width == mDimension.width && height == mDimension.height) return;
-
- // No call to ancestor! Infinite loop otherwise.
- mDimension.width = width;
- mDimension.height = height;
-
- if (mGrip)
- {
- gcn::Rectangle const &area = getChildrenArea();
- mGrip->setPosition(width - mGrip->getWidth() - area.x,
- height - mGrip->getHeight() - area.y);
- }
-
- fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_RESIZED));
-}
-
-void Window::setWidth(int width)
-{
- setSize(width, mDimension.height);
-}
-
-void Window::setHeight(int height)
-{
- setSize(mDimension.width, height);
-}
-
-void Window::setPosition(int x, int y)
-{
- if (x == mDimension.x && y == mDimension.y) return;
-
- // No call to ancestor!
- mDimension.x = x;
- mDimension.y = y;
-
- fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_MOVED));
-}
-
-void Window::setDimension(const gcn::Rectangle &dimension)
-{
- setPosition(dimension.x, dimension.y);
- setSize(dimension.width, dimension.height);
-}
-
-void Window::setX(int x)
-{
- setPosition(x, mDimension.y);
-}
-
-void Window::setY(int y)
-{
- setPosition(mDimension.x, y);
-}
-
void Window::setLocationRelativeTo(gcn::Widget *widget)
{
int wx, wy;
@@ -320,6 +255,16 @@ void Window::setResizable(bool r)
}
}
+void Window::widgetResized(const gcn::Event &event)
+{
+ if (mGrip)
+ {
+ gcn::Rectangle const &area = getChildrenArea();
+ mGrip->setPosition(getWidth() - mGrip->getWidth() - area.x,
+ getHeight() - mGrip->getHeight() - area.y);
+ }
+}
+
void Window::setCloseButton(bool flag)
{
mCloseButton = flag;
@@ -406,7 +351,7 @@ void Window::mouseReleased(gcn::MouseEvent &event)
}
// This should be the responsibility of Guichan (and is from 0.8.0 on)
- mIsMoving = false;
+ mMoved = false;
}
void Window::mouseExited(gcn::MouseEvent &event)
@@ -448,7 +393,7 @@ void Window::mouseDragged(gcn::MouseEvent &event)
gcn::Window::mouseDragged(event);
// Keep guichan window inside screen when it may be moved
- if (isMovable() && mIsMoving)
+ if (isMovable() && mMoved)
{
int newX = std::max(0, getX());
int newY = std::max(0, getY());
@@ -457,7 +402,7 @@ void Window::mouseDragged(gcn::MouseEvent &event)
setPosition(newX, newY);
}
- if (mouseResize && !mIsMoving)
+ if (mouseResize && !mMoved)
{
const int dx = event.getX() - mDragOffsetX;
const int dy = event.getY() - mDragOffsetY;
@@ -589,21 +534,3 @@ 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 18f97cec..9ca435a9 100644
--- a/src/gui/window.h
+++ b/src/gui/window.h
@@ -25,11 +25,10 @@
#define _TMW_WINDOW_H__
#include <guichan/widgets/window.hpp>
+#include <guichan/widgetlistener.hpp>
#include "../guichanfwd.h"
-#include "windowlistener.h"
-
class ConfigListener;
class GCContainer;
class ImageRect;
@@ -43,7 +42,7 @@ class Image;
*
* \ingroup GUI
*/
-class Window : public gcn::Window
+class Window : public gcn::Window, gcn::WidgetListener
{
public:
friend class WindowConfigListener;
@@ -87,56 +86,11 @@ class Window : public gcn::Window
void add(gcn::Widget *w, int x, int y, bool delChild = true);
/**
- * Sets the width of the window contents.
- */
- void setContentWidth(int width);
-
- /**
- * Sets the height of the window contents.
- */
- void setContentHeight(int height);
-
- /**
* Sets the size of this window.
*/
void setContentSize(int width, int height);
/**
- * Sets the size of this window.
- */
- void setSize(int width, int height);
-
- /**
- * Sets the width of this window.
- */
- void setWidth(int width);
-
- /**
- * Sets the height of this window.
- */
- void setHeight(int height);
-
- /**
- * Sets the position and size of this 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);
@@ -147,6 +101,11 @@ class Window : public gcn::Window
void setResizable(bool resize);
/**
+ * Called whenever the widget changes size.
+ */
+ void widgetResized(const gcn::Event &event);
+
+ /**
* Sets whether or not the window has a close button.
*/
void setCloseButton(bool flag);
@@ -276,20 +235,6 @@ 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,
@@ -344,14 +289,6 @@ 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
deleted file mode 100644
index 24f6a7b8..00000000
--- a/src/gui/windowlistener.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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 &) {}
-
- /**
- * Called whenever the window is resized.
- */
- virtual void windowResized(const WindowEvent &) {}
-};
-
-typedef std::list<WindowListener*> WindowListeners;
-
-#endif