summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-07-30 14:33:28 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-07-30 14:33:28 +0000
commitaff167beefadc32add4b44626cc2f1cbef800c7b (patch)
tree43796105cc107ec55742e88562e064d8031d3b23 /src/gui
parent18b73fdadd715d356416a95c31a25b3293fa2596 (diff)
downloadmana-aff167beefadc32add4b44626cc2f1cbef800c7b.tar.gz
mana-aff167beefadc32add4b44626cc2f1cbef800c7b.tar.bz2
mana-aff167beefadc32add4b44626cc2f1cbef800c7b.tar.xz
mana-aff167beefadc32add4b44626cc2f1cbef800c7b.zip
Updated TMW to be compatible with Guichan 0.5.0 (merged from guichan-0.5.0
branch).
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/box.h27
-rw-r--r--src/gui/buddywindow.cpp2
-rw-r--r--src/gui/buddywindow.h2
-rw-r--r--src/gui/buy.cpp2
-rw-r--r--src/gui/buy.h2
-rw-r--r--src/gui/buysell.cpp2
-rw-r--r--src/gui/buysell.h2
-rw-r--r--src/gui/char_select.cpp10
-rw-r--r--src/gui/char_select.h6
-rw-r--r--src/gui/chat.cpp27
-rw-r--r--src/gui/chat.h2
-rw-r--r--src/gui/confirm_dialog.cpp4
-rw-r--r--src/gui/confirm_dialog.h2
-rw-r--r--src/gui/connection.cpp2
-rw-r--r--src/gui/debugwindow.cpp2
-rw-r--r--src/gui/debugwindow.h2
-rw-r--r--src/gui/gui.cpp10
-rw-r--r--src/gui/help.cpp2
-rw-r--r--src/gui/help.h2
-rw-r--r--src/gui/inventorywindow.cpp7
-rw-r--r--src/gui/inventorywindow.h2
-rw-r--r--src/gui/item_amount.cpp2
-rw-r--r--src/gui/item_amount.h2
-rw-r--r--src/gui/login.cpp4
-rw-r--r--src/gui/login.h4
-rw-r--r--src/gui/menuwindow.cpp8
-rw-r--r--src/gui/ministatus.cpp2
-rw-r--r--src/gui/newskill.cpp2
-rw-r--r--src/gui/newskill.h2
-rw-r--r--src/gui/npc_text.cpp2
-rw-r--r--src/gui/npc_text.h2
-rw-r--r--src/gui/npclistdialog.cpp2
-rw-r--r--src/gui/npclistdialog.h2
-rw-r--r--src/gui/ok_dialog.cpp4
-rw-r--r--src/gui/ok_dialog.h2
-rw-r--r--src/gui/register.cpp2
-rw-r--r--src/gui/register.h2
-rw-r--r--src/gui/scrollarea.cpp37
-rw-r--r--src/gui/sell.cpp2
-rw-r--r--src/gui/sell.h2
-rw-r--r--src/gui/setup.cpp2
-rw-r--r--src/gui/setup.h2
-rw-r--r--src/gui/setup_audio.cpp2
-rw-r--r--src/gui/setup_audio.h2
-rw-r--r--src/gui/setup_joystick.cpp2
-rw-r--r--src/gui/setup_joystick.h2
-rw-r--r--src/gui/setup_video.cpp2
-rw-r--r--src/gui/setup_video.h2
-rw-r--r--src/gui/skill.cpp2
-rw-r--r--src/gui/skill.h2
-rw-r--r--src/gui/status.cpp2
-rw-r--r--src/gui/status.h2
-rw-r--r--src/gui/tabbedcontainer.cpp2
-rw-r--r--src/gui/tabbedcontainer.h4
-rw-r--r--src/gui/textfield.cpp2
-rw-r--r--src/gui/trade.cpp2
-rw-r--r--src/gui/trade.h2
-rw-r--r--src/gui/updatewindow.cpp6
-rw-r--r--src/gui/updatewindow.h2
-rw-r--r--src/gui/vbox.cpp18
-rw-r--r--src/gui/window.cpp34
61 files changed, 150 insertions, 150 deletions
diff --git a/src/gui/box.h b/src/gui/box.h
index dccbfc78..ed1a7163 100644
--- a/src/gui/box.h
+++ b/src/gui/box.h
@@ -31,27 +31,30 @@
class Box : public gcn::Container
{
+ public:
+ /**
+ * Returns padding.
+ */
+ unsigned int getPadding();
+
+ /**
+ * Sets padding between widgets.
+ */
+ void setPadding(unsigned int);
+
protected:
Box();
virtual ~Box();
- /*
- * Spacing between client widgets
+ /**
+ * Spacing between client widgets.
*/
unsigned int padding;
virtual void draw(gcn::Graphics *) = 0;
- public:
- /*
- * Returns padding
- */
- unsigned int getPadding();
-
- /*
- * Sets padding between widgets
- */
- void setPadding(unsigned int);
+ typedef std::list<gcn::Widget*> Widgets;
+ typedef Widgets::iterator WidgetIterator;
};
#endif
diff --git a/src/gui/buddywindow.cpp b/src/gui/buddywindow.cpp
index 19a2f1e0..145f0ad2 100644
--- a/src/gui/buddywindow.cpp
+++ b/src/gui/buddywindow.cpp
@@ -61,7 +61,7 @@ BuddyWindow::BuddyWindow():
add(cancel);
}
-void BuddyWindow::action(const std::string& eventId)
+void BuddyWindow::action(const std::string &eventId, gcn::Widget *widget)
{
if (eventId == "Talk") {
int selected = mListbox->getSelected();
diff --git a/src/gui/buddywindow.h b/src/gui/buddywindow.h
index 6eeb7999..8764d008 100644
--- a/src/gui/buddywindow.h
+++ b/src/gui/buddywindow.h
@@ -48,7 +48,7 @@ class BuddyWindow : public Window, public gcn::ActionListener
/**
* Performs action.
*/
- void action(const std::string &actionId);
+ void action(const std::string& eventId, gcn::Widget* widget);
private:
BuddyList *mBuddyList;
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index e96cc04f..e7bfef58 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -148,7 +148,7 @@ void BuyDialog::addItem(short id, int price)
mItemList->adjustSize();
}
-void BuyDialog::action(const std::string& eventId)
+void BuyDialog::action(const std::string &eventId, gcn::Widget *widget)
{
int selectedItem = mItemList->getSelected();
diff --git a/src/gui/buy.h b/src/gui/buy.h
index 0349be4a..b09b648b 100644
--- a/src/gui/buy.h
+++ b/src/gui/buy.h
@@ -71,7 +71,7 @@ class BuyDialog : public Window, public gcn::ActionListener
/**
* Called when receiving actions from the widgets.
*/
- void action(const std::string& eventId);
+ void action(const std::string& eventId, gcn::Widget* widget);
/**
* Returns the number of items in the shop inventory.
diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp
index 6e338f08..ac0dcc84 100644
--- a/src/gui/buysell.cpp
+++ b/src/gui/buysell.cpp
@@ -50,7 +50,7 @@ BuySellDialog::BuySellDialog():
setLocationRelativeTo(getParent());
}
-void BuySellDialog::action(const std::string& eventId)
+void BuySellDialog::action(const std::string &eventId, gcn::Widget *widget)
{
if (eventId == "Buy") {
current_npc->buy();
diff --git a/src/gui/buysell.h b/src/gui/buysell.h
index 2d3c7bd3..7a90a869 100644
--- a/src/gui/buysell.h
+++ b/src/gui/buysell.h
@@ -47,7 +47,7 @@ class BuySellDialog : public Window, public gcn::ActionListener
/**
* Called when receiving actions from the widgets.
*/
- void action(const std::string& eventId);
+ void action(const std::string& eventId, gcn::Widget* widget);
};
#endif
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index e8aa84e0..934988f4 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -48,7 +48,7 @@ class CharDeleteConfirm : public ConfirmDialog
{
public:
CharDeleteConfirm(CharSelectDialog *master);
- void action(const std::string &eventId);
+ void action(const std::string &eventId, gcn::Widget *widget);
private:
CharSelectDialog *master;
};
@@ -60,13 +60,13 @@ CharDeleteConfirm::CharDeleteConfirm(CharSelectDialog *m):
{
}
-void CharDeleteConfirm::action(const std::string &eventId)
+void CharDeleteConfirm::action(const std::string &eventId, gcn::Widget *widget)
{
//ConfirmDialog::action(eventId);
if (eventId == "yes") {
master->attemptCharDelete();
}
- ConfirmDialog::action(eventId);
+ ConfirmDialog::action(eventId, widget);
}
CharSelectDialog::CharSelectDialog(Network *network,
@@ -126,7 +126,7 @@ CharSelectDialog::CharSelectDialog(Network *network,
updatePlayerInfo();
}
-void CharSelectDialog::action(const std::string& eventId)
+void CharSelectDialog::action(const std::string &eventId, gcn::Widget *widget)
{
if (eventId == "ok" && n_character > 0)
{
@@ -284,7 +284,7 @@ CharCreateDialog::CharCreateDialog(Window *parent, int slot, Network *network,
setLocationRelativeTo(getParent());
}
-void CharCreateDialog::action(const std::string& eventId)
+void CharCreateDialog::action(const std::string &eventId, gcn::Widget *widget)
{
if (eventId == "create") {
if (getName().length() >= 4) {
diff --git a/src/gui/char_select.h b/src/gui/char_select.h
index 8fc7cd01..20105516 100644
--- a/src/gui/char_select.h
+++ b/src/gui/char_select.h
@@ -29,6 +29,8 @@
#include "../guichanfwd.h"
#include "../lockedarray.h"
+#include <guichan/actionlistener.hpp>
+
class LocalPlayer;
class Network;
class PlayerBox;
@@ -49,7 +51,7 @@ class CharSelectDialog : public Window, public gcn::ActionListener
LockedArray<LocalPlayer*> *charInfo,
unsigned char sex);
- void action(const std::string& eventId);
+ void action(const std::string& eventId, gcn::Widget* widget);
void updatePlayerInfo();
@@ -101,7 +103,7 @@ class CharCreateDialog : public Window, public gcn::ActionListener
CharCreateDialog(Window *parent, int slot, Network *network,
unsigned char sex);
- void action(const std::string& eventId);
+ void action(const std::string& eventId, gcn::Widget* widget);
std::string getName();
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 870582df..133e5e3a 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -85,18 +85,17 @@ ChatWindow::~ChatWindow()
void
ChatWindow::logic()
{
- mChatInput->setPosition(
- mChatInput->getBorderSize(),
- getContent()->getHeight() - mChatInput->getHeight() -
- mChatInput->getBorderSize());
- mChatInput->setWidth(
- getContent()->getWidth() - 2 * mChatInput->getBorderSize());
-
- mScrollArea->setWidth(
- getContent()->getWidth() - 2 * mScrollArea->getBorderSize());
- mScrollArea->setHeight(
- getContent()->getHeight() - 2 * mScrollArea->getBorderSize() -
- mChatInput->getHeight() - 5);
+ // todo: only do this when the size changes (updateWidgets?)
+
+ const gcn::Rectangle area = getChildrenArea();
+
+ mChatInput->setPosition(mChatInput->getBorderSize(),
+ 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->getHeight() - 5);
mScrollArea->logic();
}
@@ -189,7 +188,7 @@ ChatWindow::chatLog(CHATSKILL act)
}
void
-ChatWindow::action(const std::string& eventId)
+ChatWindow::action(const std::string &eventId, gcn::Widget *widget)
{
if (eventId == "chatinput")
{
@@ -246,7 +245,7 @@ ChatWindow::requestChatFocus()
bool
ChatWindow::isFocused()
{
- return mChatInput->hasFocus();
+ return mChatInput->isFocused();
}
void
diff --git a/src/gui/chat.h b/src/gui/chat.h
index 80e57a84..addfb6b5 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -145,7 +145,7 @@ class ChatWindow : public Window, public gcn::ActionListener,
/**
* Performs action.
*/
- void action(const std::string &actionId);
+ void action(const std::string& actionId, gcn::Widget* widget);
/**
* Request focus for typing chat message.
diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp
index 2d574157..ed2f8680 100644
--- a/src/gui/confirm_dialog.cpp
+++ b/src/gui/confirm_dialog.cpp
@@ -64,13 +64,13 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
yesButton->requestFocus();
}
-void ConfirmDialog::action(const std::string &eventId)
+void ConfirmDialog::action(const std::string &eventId, gcn::Widget *widget)
{
// Proxy button events to our listeners
ActionListenerIterator i;
for (i = mActionListeners.begin(); i != mActionListeners.end(); ++i)
{
- (*i)->action(eventId);
+ (*i)->action(eventId, widget);
}
// Can we receive anything else anyway?
diff --git a/src/gui/confirm_dialog.h b/src/gui/confirm_dialog.h
index 3a05494f..1c206b03 100644
--- a/src/gui/confirm_dialog.h
+++ b/src/gui/confirm_dialog.h
@@ -47,7 +47,7 @@ class ConfirmDialog : public Window, public gcn::ActionListener {
/**
* Called when receiving actions from the widgets.
*/
- void action(const std::string& eventId);
+ void action(const std::string& eventId, gcn::Widget* widget);
};
#endif
diff --git a/src/gui/connection.cpp b/src/gui/connection.cpp
index 4bd619ea..f7fdaca6 100644
--- a/src/gui/connection.cpp
+++ b/src/gui/connection.cpp
@@ -35,7 +35,7 @@
namespace {
struct ConnectionActionListener : public gcn::ActionListener
{
- void action(const std::string& eventId) { state = EXIT_STATE; }
+ void action(const std::string &eventId, gcn::Widget *widget) { state = EXIT_STATE; }
} listener;
}
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index 66681a8b..d467d4d3 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -98,7 +98,7 @@ DebugWindow::logic()
}
void
-DebugWindow::action(const std::string& eventId)
+DebugWindow::action(const std::string &eventId, gcn::Widget *widget)
{
if (eventId == "close")
{
diff --git a/src/gui/debugwindow.h b/src/gui/debugwindow.h
index 80524ffa..61ef44e6 100644
--- a/src/gui/debugwindow.h
+++ b/src/gui/debugwindow.h
@@ -53,7 +53,7 @@ class DebugWindow : public Window, public gcn::ActionListener
/**
* Performs action.
*/
- void action(const std::string &actionId);
+ void action(const std::string& eventId, gcn::Widget* widget);
private:
gcn::Label *mMusicFileLabel, *mMapFileLabel;
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index cb79e54b..c980389f 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -28,7 +28,7 @@
#include <guichan/imagefont.hpp>
#ifdef USE_OPENGL
-#include <guichan/opengl/openglimageloader.hpp>
+#include "../resources/openglsdlimageloader.h"
#endif
#include <guichan/sdl/sdlinput.hpp>
@@ -92,16 +92,14 @@ Gui::Gui(Graphics *graphics):
{
// Set graphics
setGraphics(graphics);
+
+ // Set image loader
#ifdef USE_OPENGL
if (config.getValue("opengl", 0)) {
-
- // Set image loader
- mHostImageLoader = new SDLImageLoader();
- mImageLoader = new gcn::OpenGLImageLoader(mHostImageLoader);
+ mImageLoader = new OpenGLSDLImageLoader();
} else
#endif
{
- // Set image loader
mImageLoader = new SDLImageLoader();
}
diff --git a/src/gui/help.cpp b/src/gui/help.cpp
index dfb814db..e7429b29 100644
--- a/src/gui/help.cpp
+++ b/src/gui/help.cpp
@@ -54,7 +54,7 @@ HelpWindow::HelpWindow():
setLocationRelativeTo(getParent());
}
-void HelpWindow::action(const std::string& eventId)
+void HelpWindow::action(const std::string &eventId, gcn::Widget *widget)
{
if (eventId == "close")
{
diff --git a/src/gui/help.h b/src/gui/help.h
index 44c3d6fc..539ab31b 100644
--- a/src/gui/help.h
+++ b/src/gui/help.h
@@ -48,7 +48,7 @@ class HelpWindow : public Window, public LinkHandler,
/**
* Called when receiving actions from the widgets.
*/
- void action(const std::string& eventId);
+ void action(const std::string& eventId, gcn::Widget* widget);
/**
* Handles link action.
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 8f672bc9..063e8836 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -95,7 +95,7 @@ void InventoryWindow::logic()
mWeightLabel->adjustSize();
}
-void InventoryWindow::action(const std::string &eventId)
+void InventoryWindow::action(const std::string &eventId, gcn::Widget *widget)
{
Item *item = mItems->getItem();
@@ -168,8 +168,9 @@ void InventoryWindow::mouseMotion(int mx, int my)
void InventoryWindow::updateWidgets()
{
- int width = getContent()->getWidth();
- int height = getContent()->getHeight();
+ gcn::Rectangle area = getChildrenArea();
+ int width = area.width;
+ int height = area.height;
int columns = width / 24;
if (columns < 1)
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index 179e5314..da7a7ef2 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -54,7 +54,7 @@ class InventoryWindow : public Window, gcn::ActionListener
/**
* Called when receiving actions from the widgets.
*/
- void action(const std::string& eventId);
+ void action(const std::string& eventId, gcn::Widget* widget);
void mouseClick(int x, int y, int button, int count);
diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp
index b1b01c3f..30c899a8 100644
--- a/src/gui/item_amount.cpp
+++ b/src/gui/item_amount.cpp
@@ -94,7 +94,7 @@ void ItemAmountWindow::resetAmount()
mItemAmountTextBox->setInt(1);
}
-void ItemAmountWindow::action(const std::string& eventId)
+void ItemAmountWindow::action(const std::string &eventId, gcn::Widget *widget)
{
int amount = mItemAmountTextBox->getInt();
diff --git a/src/gui/item_amount.h b/src/gui/item_amount.h
index ad1e18d6..a2a17575 100644
--- a/src/gui/item_amount.h
+++ b/src/gui/item_amount.h
@@ -54,7 +54,7 @@ class ItemAmountWindow : public Window, public gcn::ActionListener
/**
* Called when receiving actions from widget.
*/
- void action(const std::string& eventId);
+ void action(const std::string& eventId, gcn::Widget* widget);
/**
* Sets default amount value.
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index c0dd9245..2f646bd1 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -43,7 +43,7 @@ WrongDataNoticeListener::setTarget(gcn::TextField *textField)
}
void
-WrongDataNoticeListener::action(const std::string &eventId)
+WrongDataNoticeListener::action(const std::string &eventId, gcn::Widget *widget)
{
if (eventId == "ok")
{
@@ -128,7 +128,7 @@ LoginDialog::~LoginDialog()
}
void
-LoginDialog::action(const std::string& eventId)
+LoginDialog::action(const std::string &eventId, gcn::Widget *widget)
{
if (eventId == "ok")
{
diff --git a/src/gui/login.h b/src/gui/login.h
index 39548950..7218dca8 100644
--- a/src/gui/login.h
+++ b/src/gui/login.h
@@ -38,7 +38,7 @@ class LoginData;
class WrongDataNoticeListener : public gcn::ActionListener {
public:
void setTarget(gcn::TextField *textField);
- void action(const std::string &eventId);
+ void action(const std::string& eventId, gcn::Widget* widget);
private:
gcn::TextField *mTarget;
};
@@ -65,7 +65,7 @@ class LoginDialog : public Window, public gcn::ActionListener {
/**
* Called when receiving actions from the widgets.
*/
- void action(const std::string& eventId);
+ void action(const std::string& eventId, gcn::Widget* widget);
private:
gcn::TextField *mUserField;
diff --git a/src/gui/menuwindow.cpp b/src/gui/menuwindow.cpp
index 503f7ba8..a1b342f0 100644
--- a/src/gui/menuwindow.cpp
+++ b/src/gui/menuwindow.cpp
@@ -39,7 +39,7 @@ namespace {
/**
* Called when receiving actions from widget.
*/
- void action(const std::string& eventId);
+ void action(const std::string &eventId, gcn::Widget *widget);
} listener;
}
@@ -69,13 +69,13 @@ MenuWindow::MenuWindow():
setDefaultSize((windowContainer->getWidth() - x - 2), 0, x, (y + h));
}
-void MenuWindow::draw(gcn::Graphics *g)
+void MenuWindow::draw(gcn::Graphics *graphics)
{
- Window::drawContent(g);
+ drawChildren(graphics);
}
-void MenuWindowListener::action(const std::string& eventId)
+void MenuWindowListener::action(const std::string &eventId, gcn::Widget *widget)
{
Window *window = NULL;
if (eventId == "Status")
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index be089b68..53849550 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -96,5 +96,5 @@ void MiniStatusWindow::update()
void MiniStatusWindow::draw(gcn::Graphics *graphics)
{
update();
- Window::drawContent(graphics);
+ drawChildren(graphics);
}
diff --git a/src/gui/newskill.cpp b/src/gui/newskill.cpp
index 498186ba..7f5de543 100644
--- a/src/gui/newskill.cpp
+++ b/src/gui/newskill.cpp
@@ -121,7 +121,7 @@ NewSkillDialog::NewSkillDialog():
setLocationRelativeTo(getParent());
}
-void NewSkillDialog::action(const std::string& eventId)
+void NewSkillDialog::action(const std::string &eventId, gcn::Widget *widget)
{
int osp = startPoint;
if (eventId == "close")
diff --git a/src/gui/newskill.h b/src/gui/newskill.h
index 764019f5..224574bd 100644
--- a/src/gui/newskill.h
+++ b/src/gui/newskill.h
@@ -55,7 +55,7 @@ class NewSkillDialog : public Window, public gcn::ActionListener
NewSkillDialog();
// action listener
- void action(const std::string&);
+ void action(const std::string& eventId, gcn::Widget* widget);
private:
void resetNSD(); // updates the values in the dialog box
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index 1a6bb5ce..5b7ca439 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -67,7 +67,7 @@ NpcTextDialog::addText(const std::string &text)
}
void
-NpcTextDialog::action(const std::string& eventId)
+NpcTextDialog::action(const std::string &eventId, gcn::Widget *widget)
{
if (eventId == "ok")
{
diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h
index a1d75aab..3ce1215d 100644
--- a/src/gui/npc_text.h
+++ b/src/gui/npc_text.h
@@ -49,7 +49,7 @@ class NpcTextDialog : public Window, public gcn::ActionListener
* Called when receiving actions from the widgets.
*/
void
- action(const std::string &eventId);
+ action(const std::string& eventId, gcn::Widget* widget);
/**
* Sets the text shows in the dialog.
diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp
index 2d12986d..d1c3ddcb 100644
--- a/src/gui/npclistdialog.cpp
+++ b/src/gui/npclistdialog.cpp
@@ -91,7 +91,7 @@ NpcListDialog::reset()
}
void
-NpcListDialog::action(const std::string& eventId)
+NpcListDialog::action(const std::string &eventId, gcn::Widget *widget)
{
int choice = 0;
diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h
index 7d649450..03b76681 100644
--- a/src/gui/npclistdialog.h
+++ b/src/gui/npclistdialog.h
@@ -54,7 +54,7 @@ class NpcListDialog : public Window, public gcn::ActionListener,
* Called when receiving actions from the widgets.
*/
void
- action(const std::string& eventId);
+ action(const std::string& eventId, gcn::Widget* widget);
/**
* Returns the number of items in the choices list.
diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp
index 2f3f21c5..906fd61f 100644
--- a/src/gui/ok_dialog.cpp
+++ b/src/gui/ok_dialog.cpp
@@ -54,13 +54,13 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg,
okButton->requestFocus();
}
-void OkDialog::action(const std::string &eventId)
+void OkDialog::action(const std::string &eventId, gcn::Widget *widget)
{
// Proxy button events to our listeners
ActionListenerIterator i;
for (i = mActionListeners.begin(); i != mActionListeners.end(); ++i)
{
- (*i)->action(eventId);
+ (*i)->action(eventId, widget);
}
// Can we receive anything else anyway?
diff --git a/src/gui/ok_dialog.h b/src/gui/ok_dialog.h
index eb0da2c0..06f703cc 100644
--- a/src/gui/ok_dialog.h
+++ b/src/gui/ok_dialog.h
@@ -46,7 +46,7 @@ class OkDialog : public Window, public gcn::ActionListener {
/**
* Called when receiving actions from the widgets.
*/
- void action(const std::string& eventId);
+ void action(const std::string& eventId, gcn::Widget* widget);
};
#endif
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index b99568a8..38136b87 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -116,7 +116,7 @@ RegisterDialog::~RegisterDialog()
}
void
-RegisterDialog::action(const std::string& eventId)
+RegisterDialog::action(const std::string &eventId, gcn::Widget *widget)
{
if (eventId == "cancel")
{
diff --git a/src/gui/register.h b/src/gui/register.h
index b46eb1ce..5d3f6cd5 100644
--- a/src/gui/register.h
+++ b/src/gui/register.h
@@ -56,7 +56,7 @@ class RegisterDialog : public Window, public gcn::ActionListener {
/**
* Called when receiving actions from the widgets.
*/
- void action(const std::string& eventId);
+ void action(const std::string& eventId, gcn::Widget* widget);
// Made them public to have the possibility to request focus
// from external functions.
diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp
index 3703ead8..18a1dfb4 100644
--- a/src/gui/scrollarea.cpp
+++ b/src/gui/scrollarea.cpp
@@ -55,7 +55,7 @@ ScrollArea::~ScrollArea()
{
// Garbage collection
if (mGC) {
- delete mContent;
+ delete getContent();
}
instances--;
@@ -144,20 +144,21 @@ void ScrollArea::init()
void ScrollArea::logic()
{
gcn::ScrollArea::logic();
+ gcn::Widget *content = getContent();
// When no scrollbar in a certain direction, adapt content size to match
// the content dimension exactly.
- if (mContent != NULL)
+ if (content != NULL)
{
if (getHorizontalScrollPolicy() == gcn::ScrollArea::SHOW_NEVER)
{
- mContent->setWidth(getContentDimension().width -
- 2 * mContent->getBorderSize());
+ content->setWidth(getChildrenArea().width -
+ 2 * content->getBorderSize());
}
if (getVerticalScrollPolicy() == gcn::ScrollArea::SHOW_NEVER)
{
- mContent->setHeight(getContentDimension().height -
- 2 * mContent->getBorderSize());
+ content->setHeight(getChildrenArea().height -
+ 2 * content->getBorderSize());
}
}
}
@@ -197,24 +198,26 @@ void ScrollArea::draw(gcn::Graphics *graphics)
mScrollbarWidth));
}
- if (mContent)
+ gcn::Widget *content = getContent();
+
+ if (content != NULL)
{
- graphics->pushClipArea(getContentDimension());
+ graphics->pushClipArea(getChildrenArea());
- if (mContent->getBorderSize() > 0)
+ if (content->getBorderSize() > 0)
{
- gcn::Rectangle rec = mContent->getDimension();
- rec.x -= mContent->getBorderSize();
- rec.y -= mContent->getBorderSize();
- rec.width += 2 * mContent->getBorderSize();
- rec.height += 2 * mContent->getBorderSize();
+ gcn::Rectangle rec = content->getDimension();
+ rec.x -= content->getBorderSize();
+ rec.y -= content->getBorderSize();
+ rec.width += 2 * content->getBorderSize();
+ rec.height += 2 * content->getBorderSize();
graphics->pushClipArea(rec);
- mContent->drawBorder(graphics);
+ content->drawBorder(graphics);
graphics->popClipArea();
}
- graphics->pushClipArea(mContent->getDimension());
- mContent->draw(graphics);
+ graphics->pushClipArea(content->getDimension());
+ content->draw(graphics);
graphics->popClipArea();
graphics->popClipArea();
}
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 0b7abf6f..e820d42f 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -152,7 +152,7 @@ void SellDialog::addItem(Item *item, int price)
mItemList->adjustSize();
}
-void SellDialog::action(const std::string& eventId)
+void SellDialog::action(const std::string &eventId, gcn::Widget *widget)
{
int selectedItem = mItemList->getSelected();
diff --git a/src/gui/sell.h b/src/gui/sell.h
index 59bc58c2..423fea26 100644
--- a/src/gui/sell.h
+++ b/src/gui/sell.h
@@ -68,7 +68,7 @@ class SellDialog : public Window, public gcn::ActionListener
/**
* Called when receiving actions from the widgets.
*/
- void action(const std::string& eventId);
+ void action(const std::string& eventId, gcn::Widget* widget);
/**
* Mouse callback
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index e0e0e81b..6af9119b 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -85,7 +85,7 @@ Setup::~Setup()
for_each(mTabs.begin(), mTabs.end(), make_dtor(mTabs));
}
-void Setup::action(const std::string &event)
+void Setup::action(const std::string& event, gcn::Widget *widget)
{
if (event == "Apply")
{
diff --git a/src/gui/setup.h b/src/gui/setup.h
index 611633c5..6601ce3d 100644
--- a/src/gui/setup.h
+++ b/src/gui/setup.h
@@ -54,7 +54,7 @@ class Setup : public Window, public gcn::ActionListener
* Event handling method.
*/
void
- action(const std::string& eventId);
+ action(const std::string& eventId, gcn::Widget* widget);
private:
std::list<SetupTab*> mTabs;
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index 6f884e2f..db88ff64 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -108,7 +108,7 @@ void Setup_Audio::cancel()
config.setValue("musicVolume", mMusicVolume);
}
-void Setup_Audio::action(const std::string &event)
+void Setup_Audio::action(const std::string& event, gcn::Widget *widget)
{
if (event == "sfx")
{
diff --git a/src/gui/setup_audio.h b/src/gui/setup_audio.h
index 706d6a50..f09f62da 100644
--- a/src/gui/setup_audio.h
+++ b/src/gui/setup_audio.h
@@ -38,7 +38,7 @@ class Setup_Audio : public SetupTab, public gcn::ActionListener
void apply();
void cancel();
- void action(const std::string&);
+ void action(const std::string& eventId, gcn::Widget* widget);
private:
int mMusicVolume, mSfxVolume;
diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp
index fdf50980..36b0ee20 100644
--- a/src/gui/setup_joystick.cpp
+++ b/src/gui/setup_joystick.cpp
@@ -44,7 +44,7 @@ Setup_Joystick::Setup_Joystick():
add(mCalibrateButton);
}
-void Setup_Joystick::action(const std::string &event)
+void Setup_Joystick::action(const std::string &event, gcn::Widget *widget)
{
if (!joystick) {
return;
diff --git a/src/gui/setup_joystick.h b/src/gui/setup_joystick.h
index 2abe9678..da773c8f 100644
--- a/src/gui/setup_joystick.h
+++ b/src/gui/setup_joystick.h
@@ -38,7 +38,7 @@ class Setup_Joystick : public SetupTab, public gcn::ActionListener
void apply() {}
void cancel() {}
- void action(const std::string&);
+ void action(const std::string& eventId, gcn::Widget* widget);
private:
gcn::Label *mCalibrateLabel;
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 05543092..9eb94520 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -237,7 +237,7 @@ void Setup_Video::cancel()
config.setValue("opengl", mOpenGLEnabled ? 1 : 0);
}
-void Setup_Video::action(const std::string &event)
+void Setup_Video::action(const std::string &event, gcn::Widget *widget)
{
if (event == "guialpha")
{
diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h
index b021ead4..d0a10925 100644
--- a/src/gui/setup_video.h
+++ b/src/gui/setup_video.h
@@ -41,7 +41,7 @@ class Setup_Video : public SetupTab, public gcn::ActionListener,
void apply();
void cancel();
- void action(const std::string&);
+ void action(const std::string &eventId, gcn::Widget *widget);
/** Called when key is pressed */
void keyPress(const gcn::Key& key);
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp
index 604a19cc..4f552fd7 100644
--- a/src/gui/skill.cpp
+++ b/src/gui/skill.cpp
@@ -103,7 +103,7 @@ SkillDialog::~SkillDialog()
cleanList();
}
-void SkillDialog::action(const std::string& eventId)
+void SkillDialog::action(const std::string &eventId, gcn::Widget *widget)
{
if (eventId == "inc")
{
diff --git a/src/gui/skill.h b/src/gui/skill.h
index fe80347d..5555fec4 100644
--- a/src/gui/skill.h
+++ b/src/gui/skill.h
@@ -57,7 +57,7 @@ class SkillDialog : public Window, public gcn::ActionListener,
*/
~SkillDialog();
- void action(const std::string&);
+ void action(const std::string& eventId, gcn::Widget* widget);
void update();
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index 7d6cabac..bf109460 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -361,7 +361,7 @@ void StatusWindow::draw(gcn::Graphics *g)
Window::draw(g);
}
-void StatusWindow::action(const std::string& eventId)
+void StatusWindow::action(const std::string &eventId, gcn::Widget *widget)
{
// Stats Part
if (eventId.length() == 3)
diff --git a/src/gui/status.h b/src/gui/status.h
index 52ece323..6b963d24 100644
--- a/src/gui/status.h
+++ b/src/gui/status.h
@@ -51,7 +51,7 @@ class StatusWindow : public Window, public gcn::ActionListener {
/**
* Called when receiving actions from widget.
*/
- void action(const std::string& eventId);
+ void action(const std::string& eventId, gcn::Widget* widget);
/**
* Draw this window
diff --git a/src/gui/tabbedcontainer.cpp b/src/gui/tabbedcontainer.cpp
index f1927c6f..e3d2527b 100644
--- a/src/gui/tabbedcontainer.cpp
+++ b/src/gui/tabbedcontainer.cpp
@@ -78,7 +78,7 @@ void TabbedContainer::logic()
Container::logic();
}
-void TabbedContainer::action(const std::string &event)
+void TabbedContainer::action(const std::string &event, gcn::Widget *widget)
{
std::stringstream ss(event);
int tabNo;
diff --git a/src/gui/tabbedcontainer.h b/src/gui/tabbedcontainer.h
index 24c8c425..453d8374 100644
--- a/src/gui/tabbedcontainer.h
+++ b/src/gui/tabbedcontainer.h
@@ -43,7 +43,7 @@ class TabbedContainer : public gcn::Container, public gcn::ActionListener
void logic();
- void action(const std::string &event);
+ void action(const std::string &event, gcn::Widget *widget);
void setOpaque(bool opaque);
@@ -53,7 +53,7 @@ class TabbedContainer : public gcn::Container, public gcn::ActionListener
Widgets mTabs; // The actual tabs at the top
Widgets mContents; // The contents of the tabs
- Widget *mActiveContent;
+ gcn::Widget *mActiveContent;
};
#endif
diff --git a/src/gui/textfield.cpp b/src/gui/textfield.cpp
index aa9d04fd..2e083d5a 100644
--- a/src/gui/textfield.cpp
+++ b/src/gui/textfield.cpp
@@ -82,7 +82,7 @@ TextField::~TextField()
void TextField::draw(gcn::Graphics *graphics)
{
- if (hasFocus()) {
+ if (isFocused()) {
drawCaret(graphics,
getFont()->getWidth(mText.substr(0, mCaretPosition)) -
mXScroll);
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index 4efdb06c..73193c88 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -258,7 +258,7 @@ void TradeWindow::mouseClick(int x, int y, int button, int count)
mItemDescriptionLabel->adjustSize();
}
-void TradeWindow::action(const std::string &eventId)
+void TradeWindow::action(const std::string &eventId, gcn::Widget *widget)
{
Item *item = inventoryWindow->getItem();
diff --git a/src/gui/trade.h b/src/gui/trade.h
index 8bf4b86d..eb3c0f97 100644
--- a/src/gui/trade.h
+++ b/src/gui/trade.h
@@ -110,7 +110,7 @@ class TradeWindow : public Window, gcn::ActionListener
/**
* Called when receiving actions from the widgets.
*/
- void action(const std::string& eventId);
+ void action(const std::string& eventId, gcn::Widget* widget);
private:
Network *mNetwork;
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 3f5fe7bb..9188b6de 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -107,7 +107,7 @@ UpdaterWindow::~UpdaterWindow()
}
// Remove possibly leftover temporary download
- remove((mBasePath + "/updates/download.temp").c_str());
+ ::remove((mBasePath + "/updates/download.temp").c_str());
delete[] mCurlError;
}
@@ -129,7 +129,7 @@ void UpdaterWindow::enable()
mPlayButton->requestFocus();
}
-void UpdaterWindow::action(const std::string& eventId)
+void UpdaterWindow::action(const std::string &eventId, gcn::Widget *widget)
{
if (eventId == "cancel")
{
@@ -299,7 +299,7 @@ int UpdaterWindow::downloadThread(void *ptr)
// Any existing file with this name is deleted first, otherwise the
// rename will fail on Windows.
- remove(newName.c_str());
+ ::remove(newName.c_str());
rename(outFilename.c_str(), newName.c_str());
}
}
diff --git a/src/gui/updatewindow.h b/src/gui/updatewindow.h
index 5f049e18..8a168be8 100644
--- a/src/gui/updatewindow.h
+++ b/src/gui/updatewindow.h
@@ -79,7 +79,7 @@ class UpdaterWindow : public Window, public gcn::ActionListener
*/
void loadNews();
- void action(const std::string& eventId);
+ void action(const std::string& eventId, gcn::Widget* widget);
/**
* Add a row to the message field.
diff --git a/src/gui/vbox.cpp b/src/gui/vbox.cpp
index d79fbba2..eb838ead 100644
--- a/src/gui/vbox.cpp
+++ b/src/gui/vbox.cpp
@@ -25,17 +25,21 @@
void VBox::draw(gcn::Graphics *graphics)
{
- int widgetCount = mWidgets.size();
- int childWidth = getWidth();
- if (widgetCount == 0)
- return;
- int childHeight = getHeight() / widgetCount;
+ if (mWidgets.size() == 0)
+ {
+ return;
+ }
+ int childWidth = getWidth();
+ int childHeight = getHeight() / mWidgets.size();
int i = 0;
- for (WidgetIterator w = mWidgets.begin(); w != mWidgets.end(); w++) {
- (*w)->setPosition(0, childHeight * i - padding);
+
+ for (WidgetIterator w = mWidgets.begin(); w != mWidgets.end(); w++)
+ {
+ (*w)->setPosition(0, childHeight * i - padding);
(*w)->setSize(childWidth, childHeight);
i++;
}
+
gcn::Container::draw(graphics);
}
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 974a1d73..9a07111f 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):
// Add chrome
mChrome = new GCContainer();
mChrome->setOpaque(false);
- setContent(mChrome);
+ gcn::Window::add(mChrome);
// Add this window to the window container
windowContainer->add(this);
@@ -180,7 +180,7 @@ void Window::draw(gcn::Graphics* graphics)
graphics->drawText(getCaption(), 7, 5, gcn::Graphics::LEFT);
}
- drawContent(graphics);
+ drawChildren(graphics);
}
void Window::setContentWidth(int width)
@@ -195,7 +195,7 @@ void Window::setContentHeight(int height)
resizeToContent();
}
-void Window::setLocationRelativeTo(gcn::Widget* widget)
+void Window::setLocationRelativeTo(gcn::Widget *widget)
{
int wx, wy;
int x, y;
@@ -267,7 +267,7 @@ void Window::mousePress(int x, int y, int button)
// border, and is a candidate for a resize.
if (isResizable() && button == 1 &&
getGripDimension().isPointInRect(x, y) &&
- !getContentDimension().isPointInRect(x, y) &&
+ !getChildrenArea().isPointInRect(x, y) &&
hasMouse() &&
!(mMouseDrag && y > (int)getPadding()))
{
@@ -374,11 +374,8 @@ void Window::mouseMotion(int x, int y)
// Set the new window and content dimensions
setDimension(newDim);
-
- if (mContent != NULL && mMouseResize)
- {
- mContent->setDimension(getContentDimension());
- }
+ const gcn::Rectangle area = getChildrenArea();
+ mChrome->setSize(area.width, area.height);
}
}
@@ -406,18 +403,16 @@ Window::loadWindowState()
{
const std::string &name = mWindowName;
- setPosition((int)config.getValue(name + "WinX", getX()),
- (int)config.getValue(name + "WinY", getY()));
+ setPosition((int) config.getValue(name + "WinX", getX()),
+ (int) config.getValue(name + "WinY", getY()));
if (mResizable)
{
- setWidth((int)config.getValue(name + "WinWidth", getWidth()));
- setHeight((int)config.getValue(name + "WinHeight", getHeight()));
+ setSize((int) config.getValue(name + "WinWidth", getWidth()),
+ (int) config.getValue(name + "WinHeight", getHeight()));
- if (mContent != NULL)
- {
- mContent->setDimension(getContentDimension());
- }
+ const gcn::Rectangle area = getChildrenArea();
+ mChrome->setSize(area.width, area.height);
}
}
@@ -437,9 +432,4 @@ void Window::resetToDefaultSize()
{
setPosition(mDefaultX, mDefaultY);
setContentSize(mDefaultWidth, mDefaultHeight);
-
- if (mContent != NULL)
- {
- mContent->setDimension(getContentDimension());
- }
}