diff options
-rw-r--r-- | src/gui/buy.cpp | 1 | ||||
-rw-r--r-- | src/gui/buysell.cpp | 6 | ||||
-rw-r--r-- | src/gui/char_select.cpp | 4 | ||||
-rw-r--r-- | src/gui/char_server.cpp | 2 | ||||
-rw-r--r-- | src/gui/confirm_dialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/connection.cpp | 2 | ||||
-rw-r--r-- | src/gui/help.cpp | 2 | ||||
-rw-r--r-- | src/gui/itempopup.cpp | 2 | ||||
-rw-r--r-- | src/gui/login.cpp | 2 | ||||
-rw-r--r-- | src/gui/npc_text.cpp | 1 | ||||
-rw-r--r-- | src/gui/npcintegerdialog.cpp | 4 | ||||
-rw-r--r-- | src/gui/npclistdialog.cpp | 1 | ||||
-rw-r--r-- | src/gui/npcstringdialog.cpp | 4 | ||||
-rw-r--r-- | src/gui/ok_dialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/register.cpp | 2 | ||||
-rw-r--r-- | src/gui/sell.cpp | 1 | ||||
-rw-r--r-- | src/gui/setup.cpp | 2 | ||||
-rw-r--r-- | src/gui/skill.cpp | 2 | ||||
-rw-r--r-- | src/gui/speechbubble.cpp | 2 | ||||
-rw-r--r-- | src/gui/storagewindow.cpp | 1 | ||||
-rw-r--r-- | src/gui/updatewindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/window.cpp | 20 | ||||
-rw-r--r-- | src/gui/window.h | 10 |
23 files changed, 57 insertions, 20 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 3107c529..7e03c591 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -90,6 +90,7 @@ BuyDialog::BuyDialog(Network *network): Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); + center(); loadWindowState(); } diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp index 75c49b1f..e6dc7c1f 100644 --- a/src/gui/buysell.cpp +++ b/src/gui/buysell.cpp @@ -49,9 +49,11 @@ BuySellDialog::BuySellDialog(Network *network): } buyButton->requestFocus(); - loadWindowState(); - setContentSize(x, 2 * y + buyButton->getHeight()); + + center(); + setDefaultSize(); + loadWindowState(); } void BuySellDialog::logic() diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 6d5e082a..709988a3 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -127,7 +127,7 @@ CharSelectDialog::CharSelectDialog(Network *network, reflowLayout(250, 0); - setLocationRelativeTo(getParent()); + center(); setVisible(true); mSelectButton->requestFocus(); updatePlayerInfo(); @@ -306,7 +306,7 @@ CharCreateDialog::CharCreateDialog(Window *parent, int slot, Network *network, reflowLayout(225, 0); - setLocationRelativeTo(getParent()); + center(); setVisible(true); mNameField->requestFocus(); } diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp index 89bfa93a..22b0e7aa 100644 --- a/src/gui/char_server.cpp +++ b/src/gui/char_server.cpp @@ -85,7 +85,7 @@ ServerSelectDialog::ServerSelectDialog(LoginData *loginData, int nextState): // Select first server mServerList->setSelected(1); - setLocationRelativeTo(getParent()); + center(); setVisible(true); mOkButton->requestFocus(); } diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp index 0d41525a..a40593e3 100644 --- a/src/gui/confirm_dialog.cpp +++ b/src/gui/confirm_dialog.cpp @@ -85,7 +85,7 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg, if (getParent()) { - setLocationRelativeTo(getParent()); + center(); getParent()->moveToTop(this); } setVisible(true); diff --git a/src/gui/connection.cpp b/src/gui/connection.cpp index a69698e9..981100f9 100644 --- a/src/gui/connection.cpp +++ b/src/gui/connection.cpp @@ -56,7 +56,7 @@ ConnectionDialog::ConnectionDialog(): add(cancelButton); add(mProgressBar); - setLocationRelativeTo(getParent()); + center(); setVisible(true); } diff --git a/src/gui/help.cpp b/src/gui/help.cpp index 30c6a9c4..78b3c93a 100644 --- a/src/gui/help.cpp +++ b/src/gui/help.cpp @@ -58,7 +58,7 @@ HelpWindow::HelpWindow(): Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); - setLocationRelativeTo(getParent()); + center(); } void HelpWindow::action(const gcn::ActionEvent &event) diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 0e0dd9e6..efbee6b0 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -89,7 +89,7 @@ ItemPopup::ItemPopup(): add(mItemEffectScroll); add(mItemWeightScroll); - setLocationRelativeTo(getParent()); + center(); } ItemPopup::~ItemPopup() diff --git a/src/gui/login.cpp b/src/gui/login.cpp index e91f7616..414de40e 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -110,7 +110,7 @@ LoginDialog::LoginDialog(LoginData *loginData): place(3, 6, mOkButton); reflowLayout(250, 0); - setLocationRelativeTo(getParent()); + center(); setVisible(true); if (mUserField->getText().empty()) { diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 53c64a54..5bc654b8 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -61,6 +61,7 @@ NpcTextDialog::NpcTextDialog(Network *network): Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); + center(); loadWindowState(); } diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp index c1460f8d..643a7ef8 100644 --- a/src/gui/npcintegerdialog.cpp +++ b/src/gui/npcintegerdialog.cpp @@ -61,6 +61,10 @@ NpcIntegerDialog::NpcIntegerDialog(Network *network): place(2, 0, cancelButton); place(3, 0, okButton); reflowLayout(175, 0); + + center(); + setDefaultSize(); + loadWindowState(); } void NpcIntegerDialog::setRange(int min, int max) diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index 3960cb21..d280a982 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -66,6 +66,7 @@ NpcListDialog::NpcListDialog(Network *network): Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); + center(); loadWindowState(); } diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp index 4d170208..7ae2d5ed 100644 --- a/src/gui/npcstringdialog.cpp +++ b/src/gui/npcstringdialog.cpp @@ -47,6 +47,10 @@ NpcStringDialog::NpcStringDialog(Network *network): place(1, 1, cancelButton); place(2, 1, okButton); reflowLayout(175, 0); + + center(); + setDefaultSize(); + loadWindowState(); } std::string NpcStringDialog::getValue() diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp index 4f4f1117..f1a97b49 100644 --- a/src/gui/ok_dialog.cpp +++ b/src/gui/ok_dialog.cpp @@ -74,7 +74,7 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg, add(mTextArea); add(okButton); - setLocationRelativeTo(getParent()); + center(); setVisible(true); okButton->requestFocus(); } diff --git a/src/gui/register.cpp b/src/gui/register.cpp index c2190501..25c97713 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -130,7 +130,7 @@ RegisterDialog::RegisterDialog(LoginData *loginData): mServerField->addActionListener(this); mPortField->addActionListener(this); - setLocationRelativeTo(getParent()); + center(); setVisible(true); mUserField->requestFocus(); mUserField->setCaretPosition(mUserField->getText().length()); diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index 4cdabe68..e1b15bac 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -93,6 +93,7 @@ SellDialog::SellDialog(Network *network): Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); + center(); loadWindowState(); } diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 68bc3a4b..872596b0 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -101,7 +101,7 @@ Setup::Setup(): add(panel); - setLocationRelativeTo(getParent()); + center(); setInGame(false); } diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 6112f0e3..ed374a31 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -157,7 +157,7 @@ SkillDialog::SkillDialog(): Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); - setLocationRelativeTo(getParent()); + center(); loadWindowState(); } diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index 5f05971d..fb0d7684 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -58,7 +58,7 @@ SpeechBubble::SpeechBubble(): add(mCaption); add(mSpeechArea); - setLocationRelativeTo(getParent()); + center(); } void SpeechBubble::setCaption(const std::string &name, const gcn::Color *color) diff --git a/src/gui/storagewindow.cpp b/src/gui/storagewindow.cpp index 5981f121..663ad784 100644 --- a/src/gui/storagewindow.cpp +++ b/src/gui/storagewindow.cpp @@ -92,6 +92,7 @@ StorageWindow::StorageWindow(Network *network, int invSize): Layout &layout = getLayout(); layout.setRowHeight(0, mStoreButton->getHeight()); + center(); loadWindowState(); } diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index 6ec62337..df0a1f80 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -131,7 +131,7 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); - setLocationRelativeTo(getParent()); + center(); setVisible(true); mCancelButton->requestFocus(); diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 4bc0e4d0..d4665427 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -67,10 +67,9 @@ Window::Window(const std::string& caption, bool modal, Window *parent, const std mModal(modal), mCloseButton(false), mSticky(false), - mMinWinWidth(100), - mMinWinHeight(40), - mMaxWinWidth(INT_MAX), - mMaxWinHeight(INT_MAX), + mMinWinWidth(100), mDefaultWidth(100), mMaxWinWidth(INT_MAX), + mMinWinHeight(40), mDefaultHeight(40), mMaxWinHeight(INT_MAX), + mDefaultX(100), mDefaultY(100), mSkin(skin) { logger->log("Window::Window(\"%s\")", caption.c_str()); @@ -492,6 +491,14 @@ void Window::setDefaultSize(int defaultX, int defaultY, mDefaultHeight = defaultHeight; } +void Window::setDefaultSize() +{ + mDefaultX = getX(); + mDefaultY = getY(); + mDefaultWidth = getWidth(); + mDefaultHeight = getHeight(); +} + void Window::resetToDefaultSize(bool changePosition) { if (changePosition) setPosition(mDefaultX, mDefaultY); @@ -733,3 +740,8 @@ void Window::reflowLayout(int w, int h) mLayout = NULL; setContentSize(w, h); } + +void Window::center() +{ + setLocationRelativeTo(getParent()); +} diff --git a/src/gui/window.h b/src/gui/window.h index 9977aff4..95fe2174 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -240,6 +240,11 @@ class Window : public gcn::Window, gcn::WidgetListener int defaultWidth, int defaultHeight); /** + * Set the default win pos and size tot he current ones. + */ + void setDefaultSize(); + + /** * Reset the win pos and size to default. Don't forget to set defaults * first. */ @@ -275,6 +280,11 @@ class Window : public gcn::Window, gcn::WidgetListener */ ContainerPlacer getPlacer(int x, int y); + /** + * Positions the window in the center of it's parent. + */ + void center(); + protected: /** The window container windows add themselves to. */ static WindowContainer *windowContainer; |