diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2004-12-19 00:06:24 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2004-12-19 00:06:24 +0000 |
commit | 75668f13e61ef137d1835b3d60e6de9a7a9ecb42 (patch) | |
tree | f3973b20dce7f0ed61b935305056c8e8d3735670 /src/gui/window.cpp | |
parent | 55372882029946d8193ca4414091b65abd64a6ae (diff) | |
download | mana-75668f13e61ef137d1835b3d60e6de9a7a9ecb42.tar.gz mana-75668f13e61ef137d1835b3d60e6de9a7a9ecb42.tar.bz2 mana-75668f13e61ef137d1835b3d60e6de9a7a9ecb42.tar.xz mana-75668f13e61ef137d1835b3d60e6de9a7a9ecb42.zip |
Implemented setLocationRelativeTo method on Window allowing the dialogs to be
centered on screen.
Diffstat (limited to 'src/gui/window.cpp')
-rw-r--r-- | src/gui/window.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/gui/window.cpp b/src/gui/window.cpp index c038312c..a75dd242 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -48,6 +48,7 @@ Window::Window(std::string text) : // Add chrome chrome = new gcn::Container(); chrome->setOpaque(false); + chrome->setY(titlebarHeight); gcn::Container::add(chrome); } @@ -115,6 +116,37 @@ void Window::setDimension(const gcn::Rectangle &dimension) dimension.width, dimension.height)); } +void Window::setWidth(int width) +{ + gcn::Container::setWidth(width); + chrome->setWidth(width); +} + +void Window::setHeight(int height) +{ + gcn::Container::setHeight(height + titlebarHeight); + chrome->setHeight(height); +} + +void Window::setLocationRelativeTo(gcn::Widget* widget) +{ + int wx, wy; + int x, y; + + widget->getAbsolutePosition(wx, wy); + getAbsolutePosition(x, y); + + setPosition( + getX() + (wx + (widget->getWidth() - getWidth()) / 2 - x), + getY() + (wy + (widget->getHeight() - getHeight()) / 2 - y)); +} + +void Window::setSize(int width, int height) +{ + setWidth(width); + setHeight(height); +} + void Window::add(gcn::Widget *w) { chrome->add(w); |