summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-03-09 01:23:14 -0600
committerIra Rice <irarice@gmail.com>2009-03-09 01:23:14 -0600
commit40883938ceb60b0999f9b693dadbe2239e83f139 (patch)
tree594edf50f129f6e6a09b8f139495fdc4bf587684 /src/gui
parent5fa3f62d0d6d9cbffeef0f6a2497aae023dbadcf (diff)
downloadmana-client-40883938ceb60b0999f9b693dadbe2239e83f139.tar.gz
mana-client-40883938ceb60b0999f9b693dadbe2239e83f139.tar.bz2
mana-client-40883938ceb60b0999f9b693dadbe2239e83f139.tar.xz
mana-client-40883938ceb60b0999f9b693dadbe2239e83f139.zip
Got rid of an ugly and unified interface breaking cancel button in favor
of adding overridable close functionality to the Window class. Now, if you need a close button, but need to do something different, or in addition to the Window close functionality, you can override it and do that action. Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/storagewindow.cpp9
-rw-r--r--src/gui/storagewindow.h2
-rw-r--r--src/gui/window.cpp7
-rw-r--r--src/gui/window.h2
4 files changed, 11 insertions, 9 deletions
diff --git a/src/gui/storagewindow.cpp b/src/gui/storagewindow.cpp
index 856f9166..d3bc7ef8 100644
--- a/src/gui/storagewindow.cpp
+++ b/src/gui/storagewindow.cpp
@@ -59,11 +59,11 @@ StorageWindow::StorageWindow(Network *network, int invSize):
{
setWindowName("Storage");
setResizable(true);
+ setCloseButton(true);
// If you adjust these defaults, don't forget to adjust the trade window's.
setDefaultSize(115, 25, 375, 300);
- mCancelButton = new Button(_("Close"), "close", this);
mStoreButton = new Button(_("Store"), "store", this);
mRetrieveButton = new Button(_("Retrieve"), "retrieve", this);
@@ -85,7 +85,6 @@ StorageWindow::StorageWindow(Network *network, int invSize):
place(0, 0, mSlotsLabel).setPadding(3);
place(1, 0, mSlotsBar, 3);
place(0, 1, mInvenScroll, 4, 4);
- place(0, 5, mCancelButton);
place(2, 5, mStoreButton);
place(3, 5, mRetrieveButton);
@@ -121,11 +120,7 @@ void StorageWindow::logic()
void StorageWindow::action(const gcn::ActionEvent &event)
{
- if (event.getId() == "close")
- {
- close();
- }
- else if (event.getId() == "store")
+ if (event.getId() == "store")
{
Item *item = inventoryWindow->getSelectedItem();
diff --git a/src/gui/storagewindow.h b/src/gui/storagewindow.h
index 23142ac1..86451bfe 100644
--- a/src/gui/storagewindow.h
+++ b/src/gui/storagewindow.h
@@ -88,7 +88,7 @@ class StorageWindow : public Window, gcn::ActionListener, gcn::SelectionListener
std::string mSlots;
std::string mUsedSlots;
- gcn::Button *mCancelButton, *mStoreButton, *mRetrieveButton;
+ gcn::Button *mStoreButton, *mRetrieveButton;
gcn::ScrollArea *mInvenScroll;
gcn::Label *mSlotsLabel;
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 0869368d..2b422f86 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -328,7 +328,7 @@ void Window::mousePressed(gcn::MouseEvent &event)
if (closeButtonRect.isPointInRect(x, y))
{
- setVisible(false);
+ close();
}
}
@@ -337,6 +337,11 @@ void Window::mousePressed(gcn::MouseEvent &event)
}
}
+void Window::close()
+{
+ setVisible(false);
+}
+
void Window::mouseReleased(gcn::MouseEvent &event)
{
if (mGrip && mouseResize)
diff --git a/src/gui/window.h b/src/gui/window.h
index a4f56e05..3a92ac17 100644
--- a/src/gui/window.h
+++ b/src/gui/window.h
@@ -276,6 +276,8 @@ class Window : public gcn::Window, gcn::WidgetListener
*/
ContainerPlacer getPlacer(int x, int y);
+ virtual void close();
+
protected:
/** The window container windows add themselves to. */
static WindowContainer *windowContainer;