summaryrefslogtreecommitdiff
path: root/src/gui/window.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-03-10 08:29:49 -0600
committerIra Rice <irarice@gmail.com>2009-03-10 08:29:49 -0600
commit67ea3716f8b01484527ead747c0cc6af3ac0cd76 (patch)
tree2d9656ab21c09fe0bd6562c8cb9e73ed57205643 /src/gui/window.cpp
parent443a10db52e909c4c2a33543795ec8837547e973 (diff)
downloadmana-67ea3716f8b01484527ead747c0cc6af3ac0cd76.tar.gz
mana-67ea3716f8b01484527ead747c0cc6af3ac0cd76.tar.bz2
mana-67ea3716f8b01484527ead747c0cc6af3ac0cd76.tar.xz
mana-67ea3716f8b01484527ead747c0cc6af3ac0cd76.zip
Moved enforcement of minimum widths and heights to the Window class.
This was needed in the Minimap class, but not migrated out to the Window class until now. Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui/window.cpp')
-rw-r--r--src/gui/window.cpp53
1 files changed, 44 insertions, 9 deletions
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;