summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/login.cpp28
-rw-r--r--src/gui/minimap.cpp12
-rw-r--r--src/gui/window.cpp53
3 files changed, 53 insertions, 40 deletions
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index cd331322..ce13aaf0 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -117,11 +117,10 @@ LoginDialog::LoginDialog(LoginData *loginData):
setLocationRelativeTo(getParent());
setVisible(true);
- if (mUserField->getText().empty()) {
+ if (mUserField->getText().empty())
mUserField->requestFocus();
- } else {
+ else
mPassField->requestFocus();
- }
mOkButton->setEnabled(canSubmit());
}
@@ -156,14 +155,12 @@ void LoginDialog::action(const gcn::ActionEvent &event)
{
// Transfer these fields on to the register dialog
mLoginData->hostname = mServerField->getText();
+
if (isUShort(mPortField->getText()))
- {
mLoginData->port = getUShort(mPortField->getText());
- }
else
- {
mLoginData->port = 6901;
- }
+
mLoginData->username = mUserField->getText();
mLoginData->password = mPassField->getText();
@@ -196,14 +193,12 @@ bool LoginDialog::isUShort(const std::string &str)
strPtr != strEnd; ++strPtr)
{
if (*strPtr < '0' || *strPtr > '9')
- {
return false;
- }
+
l = l * 10 + (*strPtr - '0'); // *strPtr - '0' will never be negative
+
if (l > 65535)
- {
return false;
- }
}
return true;
}
@@ -279,9 +274,7 @@ void LoginDialog::DropDownList::save(const std::string &server,
++sPtr, ++pPtr)
{
if (*sPtr != server || *pPtr != port)
- {
saveEntry(*sPtr, *pPtr, position);
- }
}
}
@@ -293,26 +286,23 @@ int LoginDialog::DropDownList::getNumberOfElements()
std::string LoginDialog::DropDownList::getElementAt(int i)
{
if (i < 0 || i >= getNumberOfElements())
- {
return "";
- }
+
return getServerAt(i) + ":" + getPortAt(i);
}
std::string LoginDialog::DropDownList::getServerAt(int i)
{
if (i < 0 || i >= getNumberOfElements())
- {
return "";
- }
+
return mServers.at(i);
}
std::string LoginDialog::DropDownList::getPortAt(int i)
{
if (i < 0 || i >= getNumberOfElements())
- {
return "";
- }
+
return mPorts.at(i);
}
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 2a97b949..ecda29ce 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -80,18 +80,6 @@ void Minimap::setMapImage(Image *img)
mMapImage->getWidth() + offsetX : titleWidth);
setMaxHeight(mMapImage->getHeight() + offsetY);
- // Make sure the window is within the minimum and maximum boundaries
- // TODO: Shouldn't this be happening automatically within the Window
- // class?
- if (getMinWidth() > getWidth())
- setWidth(getMinWidth());
- else if (getMaxWidth() < getWidth())
- setWidth(getMaxWidth());
- if (getMinHeight() > getHeight())
- setHeight(getMinHeight());
- else if (getMaxHeight() < getHeight())
- setHeight(getMaxHeight());
-
setContentSize(getWidth() - offsetX, getHeight() - offsetY);
setDefaultSize(getX(), getY(), getWidth(), getHeight());
resetToDefaultSize();
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 8faf63a0..5253dd2e 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -193,8 +193,19 @@ void Window::draw(gcn::Graphics *graphics)
void Window::setContentSize(int width, int height)
{
- setSize(width + 2 * getPadding(),
- height + getPadding() + getTitleBarHeight());
+ width = width + 2 * getPadding();
+ height = height + getPadding() + getTitleBarHeight();
+
+ if (getMinWidth() > width)
+ width = getMinWidth();
+ else if (getMaxWidth() < width)
+ width = getMaxWidth();
+ if (getMinHeight() > height)
+ height = getMinHeight();
+ else if (getMaxHeight() < height)
+ height = getMaxHeight();
+
+ setSize(width, height);
}
void Window::setLocationRelativeTo(gcn::Widget *widget)
@@ -465,13 +476,19 @@ void Window::loadWindowState()
if (mGrip)
{
- const int width = (int) config.getValue(name + "WinWidth",
- mDefaultWidth);
- const int height = (int) config.getValue(name + "WinHeight",
- mDefaultHeight);
-
- setSize(width < getMinWidth() ? getMinWidth() : width,
- height < getMinHeight() ? getMinHeight() : height);
+ int width = (int) config.getValue(name + "WinWidth", mDefaultWidth);
+ int height = (int) config.getValue(name + "WinHeight", mDefaultHeight);
+
+ if (getMinWidth() > width)
+ width = getMinWidth();
+ else if (getMaxWidth() < width)
+ width = getMaxWidth();
+ if (getMinHeight() > height)
+ height = getMinHeight();
+ else if (getMaxHeight() < height)
+ height = getMaxHeight();
+
+ setSize(width, height);
}
else
{
@@ -490,6 +507,15 @@ void Window::saveWindowState()
if (mGrip)
{
+ if (getMinWidth() > getWidth())
+ setWidth(getMinWidth());
+ else if (getMaxWidth() < getWidth())
+ setWidth(getMaxWidth());
+ if (getMinHeight() > getHeight())
+ setHeight(getMinHeight());
+ else if (getMaxHeight() < getHeight())
+ setHeight(getMaxHeight());
+
config.setValue(mWindowName + "WinWidth", getWidth());
config.setValue(mWindowName + "WinHeight", getHeight());
}
@@ -499,6 +525,15 @@ void Window::saveWindowState()
void Window::setDefaultSize(int defaultX, int defaultY,
int defaultWidth, int defaultHeight)
{
+ if (getMinWidth() > defaultWidth)
+ defaultWidth = getMinWidth();
+ else if (getMaxWidth() < defaultWidth)
+ defaultWidth = getMaxWidth();
+ if (getMinHeight() > defaultHeight)
+ defaultHeight = getMinHeight();
+ else if (getMaxHeight() < defaultHeight)
+ defaultHeight = getMaxHeight();
+
mDefaultX = defaultX;
mDefaultY = defaultY;
mDefaultWidth = defaultWidth;