summaryrefslogtreecommitdiff
path: root/src/gui/window.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-03-10 11:50:27 -0600
committerIra Rice <irarice@gmail.com>2009-03-10 11:50:27 -0600
commit58ee835c3763e7bf088fa6c7e31dda1d687589cc (patch)
tree2eb06f7ee3fa05af68fb536284497a9967222ad9 /src/gui/window.cpp
parent5bbf8219bffbb587cf9a23561734c917bb23f42f (diff)
downloadmana-client-58ee835c3763e7bf088fa6c7e31dda1d687589cc.tar.gz
mana-client-58ee835c3763e7bf088fa6c7e31dda1d687589cc.tar.bz2
mana-client-58ee835c3763e7bf088fa6c7e31dda1d687589cc.tar.xz
mana-client-58ee835c3763e7bf088fa6c7e31dda1d687589cc.zip
Extended window layout to take relative positions, as well as offsets to
that position. This makes it so that when resolutions are changed, the default locations stay relative to the window's position, and not the 800x600 screen resolution. Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui/window.cpp')
-rw-r--r--src/gui/window.cpp99
1 files changed, 99 insertions, 0 deletions
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 5253dd2e..f1316b4c 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -220,6 +220,53 @@ void Window::setLocationRelativeTo(gcn::Widget *widget)
getY() + (wy + (widget->getHeight() - getHeight()) / 2 - y));
}
+void Window::setLocationRelativeTo(ImageRect::ImagePosition position)
+{
+ int x = 0, y = 0;
+
+ if (position == ImageRect::UPPER_LEFT)
+ {
+ }
+ else if (position == ImageRect::UPPER_CENTER)
+ {
+ x = (windowContainer->getWidth() - getWidth()) / 2;
+ }
+ else if (position == ImageRect::UPPER_RIGHT)
+ {
+ x = windowContainer->getWidth() - getWidth();
+ }
+ else if (position == ImageRect::LEFT)
+ {
+ y = (windowContainer->getHeight() - getHeight()) / 2;
+ }
+ else if (position == ImageRect::CENTER)
+ {
+ x = (windowContainer->getWidth() - getWidth()) / 2;
+ y = (windowContainer->getHeight() - getHeight()) / 2;
+ }
+ else if (position == ImageRect::RIGHT)
+ {
+ x = windowContainer->getWidth() - getWidth();
+ y = (windowContainer->getHeight() - getHeight()) / 2;
+ }
+ else if (position == ImageRect::LOWER_LEFT)
+ {
+ y = windowContainer->getHeight() - getHeight();
+ }
+ else if (position == ImageRect::LOWER_CENTER)
+ {
+ x = (windowContainer->getWidth() - getWidth()) / 2;
+ y = windowContainer->getHeight() - getHeight();
+ }
+ else if (position == ImageRect::LOWER_RIGHT)
+ {
+ x = windowContainer->getWidth() - getWidth();
+ y = windowContainer->getHeight() - getHeight();
+ }
+
+ setPosition(x, y);
+}
+
void Window::setMinWidth(unsigned int width)
{
mMinWinWidth = width;
@@ -540,6 +587,58 @@ void Window::setDefaultSize(int defaultX, int defaultY,
mDefaultHeight = defaultHeight;
}
+void Window::setDefaultSize(int defaultWidth, int defaultHeight,
+ ImageRect::ImagePosition position,
+ int offsetX, int offsetY)
+{
+ int x = 0, y = 0;
+
+ if (position == ImageRect::UPPER_LEFT)
+ {
+ }
+ else if (position == ImageRect::UPPER_CENTER)
+ {
+ x = (windowContainer->getWidth() - defaultWidth) / 2;
+ }
+ else if (position == ImageRect::UPPER_RIGHT)
+ {
+ x = windowContainer->getWidth() - defaultWidth;
+ }
+ else if (position == ImageRect::LEFT)
+ {
+ y = (windowContainer->getHeight() - defaultHeight) / 2;
+ }
+ else if (position == ImageRect::CENTER)
+ {
+ x = (windowContainer->getWidth() - defaultWidth) / 2;
+ y = (windowContainer->getHeight() - defaultHeight) / 2;
+ }
+ else if (position == ImageRect::RIGHT)
+ {
+ x = windowContainer->getWidth() - defaultWidth;
+ y = (windowContainer->getHeight() - defaultHeight) / 2;
+ }
+ else if (position == ImageRect::LOWER_LEFT)
+ {
+ y = windowContainer->getHeight() - defaultHeight;
+ }
+ else if (position == ImageRect::LOWER_CENTER)
+ {
+ x = (windowContainer->getWidth() - defaultWidth) / 2;
+ y = windowContainer->getHeight() - defaultHeight;
+ }
+ else if (position == ImageRect::LOWER_RIGHT)
+ {
+ x = windowContainer->getWidth() - defaultWidth;
+ y = windowContainer->getHeight() - defaultHeight;
+ }
+
+ mDefaultX = x - offsetX;
+ mDefaultY = y - offsetY;
+ mDefaultWidth = defaultWidth;
+ mDefaultHeight = defaultHeight;
+}
+
void Window::resetToDefaultSize()
{
setPosition(mDefaultX, mDefaultY);