diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-09-18 17:49:18 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-09-18 17:49:18 +0300 |
commit | 70b520b1e876f9698bb95baa2d274ea289a0c6bd (patch) | |
tree | 152c7519b0d9b8fb424af2373ec48db823a85575 /src/gui/widgets/window.cpp | |
parent | 62ec17f6e489ec50f17219444468aeb8969dc961 (diff) | |
parent | 3b999f51c740d0541c53d223518e5e4bb482d996 (diff) | |
download | mv-stripped1.1.9.18.tar.gz mv-stripped1.1.9.18.tar.bz2 mv-stripped1.1.9.18.tar.xz mv-stripped1.1.9.18.zip |
Merge branch 'master' into strippedstripped1.1.9.18
Conflicts:
src/guichan/cliprectangle.cpp
src/guichan/focushandler.cpp
src/guichan/gui.cpp
src/guichan/include/guichan/cliprectangle.hpp
src/guichan/include/guichan/inputevent.hpp
src/guichan/include/guichan/keyevent.hpp
src/guichan/include/guichan/mouseevent.hpp
src/guichan/include/guichan/widgets/button.hpp
src/guichan/include/guichan/widgets/checkbox.hpp
src/guichan/include/guichan/widgets/dropdown.hpp
src/guichan/include/guichan/widgets/radiobutton.hpp
src/guichan/include/guichan/widgets/slider.hpp
src/guichan/include/guichan/widgets/tab.hpp
src/guichan/include/guichan/widgets/tabbedarea.hpp
src/guichan/include/guichan/widgets/textfield.hpp
src/guichan/include/guichan/widgets/window.hpp
src/guichan/inputevent.cpp
src/guichan/keyevent.cpp
src/guichan/mouseevent.cpp
src/guichan/widget.cpp
src/guichan/widgets/button.cpp
src/guichan/widgets/checkbox.cpp
src/guichan/widgets/dropdown.cpp
src/guichan/widgets/radiobutton.cpp
src/guichan/widgets/slider.cpp
src/guichan/widgets/tab.cpp
src/guichan/widgets/tabbedarea.cpp
src/guichan/widgets/textfield.cpp
src/guichan/widgets/window.cpp
Diffstat (limited to 'src/gui/widgets/window.cpp')
-rw-r--r-- | src/gui/widgets/window.cpp | 116 |
1 files changed, 63 insertions, 53 deletions
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 4435496a7..c52bf744e 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -47,7 +47,7 @@ int Window::instances = 0; int Window::mouseResize = 0; Window::Window(const std::string &caption, bool modal, Window *parent, - const std::string &skin): + std::string skin): gcn::Window(caption), mGrip(0), mParent(parent), @@ -63,8 +63,8 @@ Window::Window(const std::string &caption, bool modal, Window *parent, mStickyButtonLock(false), mMinWinWidth(100), mMinWinHeight(40), - mMaxWinWidth(graphics->mWidth), - mMaxWinHeight(graphics->mHeight), + mMaxWinWidth(mainGraphics->mWidth), + mMaxWinHeight(mainGraphics->mHeight), mVertexes(new GraphicsVertexes()), mRedraw(true) { @@ -79,8 +79,20 @@ Window::Window(const std::string &caption, bool modal, Window *parent, setPadding(3); setTitleBarHeight(20); + if (skin == "") + skin = "window.xml"; + // Loads the skin - mSkin = Theme::instance()->load(skin); + if (Theme::instance()) + { + mSkin = Theme::instance()->load(skin); + if (mSkin) + setPadding(mSkin->getPadding()); + } + else + { + mSkin = 0; + } // Add this window to the window container windowContainer->add(this); @@ -113,8 +125,6 @@ Window::~Window() mWidgets.clear(); -// need mWidgets.clean ? - removeWidgetListener(this); delete mVertexes; mVertexes = 0; @@ -122,7 +132,11 @@ Window::~Window() instances--; if (mSkin) - mSkin->instances--; + { + if (Theme::instance()) + Theme::instance()->unload(mSkin); + mSkin = 0; + } } void Window::setWindowContainer(WindowContainer *wc) @@ -244,39 +258,39 @@ void Window::setLocationRelativeTo(ImageRect::ImagePosition position, } else if (position == ImageRect::UPPER_CENTER) { - offsetX += (graphics->mWidth - getWidth()) / 2; + offsetX += (mainGraphics->mWidth - getWidth()) / 2; } else if (position == ImageRect::UPPER_RIGHT) { - offsetX += graphics->mWidth - getWidth(); + offsetX += mainGraphics->mWidth - getWidth(); } else if (position == ImageRect::LEFT) { - offsetY += (graphics->mHeight - getHeight()) / 2; + offsetY += (mainGraphics->mHeight - getHeight()) / 2; } else if (position == ImageRect::CENTER) { - offsetX += (graphics->mWidth - getWidth()) / 2; - offsetY += (graphics->mHeight - getHeight()) / 2; + offsetX += (mainGraphics->mWidth - getWidth()) / 2; + offsetY += (mainGraphics->mHeight - getHeight()) / 2; } else if (position == ImageRect::RIGHT) { - offsetX += graphics->mWidth - getWidth(); - offsetY += (graphics->mHeight - getHeight()) / 2; + offsetX += mainGraphics->mWidth - getWidth(); + offsetY += (mainGraphics->mHeight - getHeight()) / 2; } else if (position == ImageRect::LOWER_LEFT) { - offsetY += graphics->mHeight - getHeight(); + offsetY += mainGraphics->mHeight - getHeight(); } else if (position == ImageRect::LOWER_CENTER) { - offsetX += (graphics->mWidth - getWidth()) / 2; - offsetY += graphics->mHeight - getHeight(); + offsetX += (mainGraphics->mWidth - getWidth()) / 2; + offsetY += mainGraphics->mHeight - getHeight(); } else if (position == ImageRect::LOWER_RIGHT) { - offsetX += graphics->mWidth - getWidth(); - offsetY += graphics->mHeight - getHeight(); + offsetX += mainGraphics->mWidth - getWidth(); + offsetY += mainGraphics->mHeight - getHeight(); } setPosition(offsetX, offsetY); @@ -373,7 +387,7 @@ void Window::widgetHidden(const gcn::Event &event A_UNUSED) if (!mFocusHandler) return; - for (it = mWidgets.begin(); it != mWidgets.end(); it++) + for (it = mWidgets.begin(); it != mWidgets.end(); ++ it) { if (mFocusHandler->isFocused(*it)) mFocusHandler->focusNone(); @@ -443,7 +457,7 @@ void Window::mousePressed(gcn::MouseEvent &event) const int y = event.getY(); // Handle close button - if (mCloseButton) + if (mCloseButton && mSkin) { Image *img = mSkin->getCloseImage(); if (img) @@ -464,7 +478,7 @@ void Window::mousePressed(gcn::MouseEvent &event) } // Handle sticky button - if (mStickyButton) + if (mStickyButton && mSkin) { Image *button = mSkin->getStickyImage(mSticky); if (button) @@ -579,8 +593,8 @@ void Window::mouseDragged(gcn::MouseEvent &event) { int newX = std::max(0, getX()); int newY = std::max(0, getY()); - newX = std::min(graphics->mWidth - getWidth(), newX); - newY = std::min(graphics->mHeight - getHeight(), newY); + newX = std::min(mainGraphics->mWidth - getWidth(), newX); + newY = std::min(mainGraphics->mHeight - getHeight(), newY); setPosition(newX, newY); } @@ -621,14 +635,10 @@ void Window::mouseDragged(gcn::MouseEvent &event) newDim.height += newDim.y; newDim.y = 0; } - if (newDim.x + newDim.width > graphics->mWidth) - { - newDim.width = graphics->mWidth - newDim.x; - } - if (newDim.y + newDim.height > graphics->mHeight) - { - newDim.height = graphics->mHeight - newDim.y; - } + if (newDim.x + newDim.width > mainGraphics->mWidth) + newDim.width = mainGraphics->mWidth - newDim.x; + if (newDim.y + newDim.height > mainGraphics->mHeight) + newDim.height = mainGraphics->mHeight - newDim.y; // Update mouse offset when dragging bottom or right border if (mouseResize & BOTTOM) @@ -790,39 +800,39 @@ void Window::setDefaultSize(int defaultWidth, int defaultHeight, } else if (position == ImageRect::UPPER_CENTER) { - x = (graphics->mWidth - defaultWidth) / 2; + x = (mainGraphics->mWidth - defaultWidth) / 2; } else if (position == ImageRect::UPPER_RIGHT) { - x = graphics->mWidth - defaultWidth; + x = mainGraphics->mWidth - defaultWidth; } else if (position == ImageRect::LEFT) { - y = (graphics->mHeight - defaultHeight) / 2; + y = (mainGraphics->mHeight - defaultHeight) / 2; } else if (position == ImageRect::CENTER) { - x = (graphics->mWidth - defaultWidth) / 2; - y = (graphics->mHeight - defaultHeight) / 2; + x = (mainGraphics->mWidth - defaultWidth) / 2; + y = (mainGraphics->mHeight - defaultHeight) / 2; } else if (position == ImageRect::RIGHT) { - x = graphics->mWidth - defaultWidth; - y = (graphics->mHeight - defaultHeight) / 2; + x = mainGraphics->mWidth - defaultWidth; + y = (mainGraphics->mHeight - defaultHeight) / 2; } else if (position == ImageRect::LOWER_LEFT) { - y = graphics->mHeight - defaultHeight; + y = mainGraphics->mHeight - defaultHeight; } else if (position == ImageRect::LOWER_CENTER) { - x = (graphics->mWidth - defaultWidth) / 2; - y = graphics->mHeight - defaultHeight; + x = (mainGraphics->mWidth - defaultWidth) / 2; + y = mainGraphics->mHeight - defaultHeight; } else if (position == ImageRect::LOWER_RIGHT) { - x = graphics->mWidth - defaultWidth; - y = graphics->mHeight - defaultHeight; + x = mainGraphics->mWidth - defaultWidth; + y = mainGraphics->mHeight - defaultHeight; } mDefaultX = x - offsetX; @@ -994,11 +1004,11 @@ void Window::checkIfIsOffScreen(bool partially, bool entirely) // Look if the window is partially off-screen limits... if (partially) { - if (winDimension.x + winDimension.width > graphics->mWidth) - winDimension.x = graphics->mWidth - winDimension.width; + if (winDimension.x + winDimension.width > mainGraphics->mWidth) + winDimension.x = mainGraphics->mWidth - winDimension.width; - if (winDimension.y + winDimension.height > graphics->mHeight) - winDimension.y = graphics->mHeight - winDimension.height; + if (winDimension.y + winDimension.height > mainGraphics->mHeight) + winDimension.y = mainGraphics->mHeight - winDimension.height; setDimension(winDimension); return; @@ -1006,11 +1016,11 @@ void Window::checkIfIsOffScreen(bool partially, bool entirely) if (entirely) { - if (winDimension.x > graphics->mWidth) - winDimension.x = graphics->mWidth - winDimension.width; + if (winDimension.x > mainGraphics->mWidth) + winDimension.x = mainGraphics->mWidth - winDimension.width; - if (winDimension.y > graphics->mHeight) - winDimension.y = graphics->mHeight - winDimension.height; + if (winDimension.y > mainGraphics->mHeight) + winDimension.y = mainGraphics->mHeight - winDimension.height; } setDimension(winDimension); } @@ -1021,4 +1031,4 @@ gcn::Rectangle Window::getWindowArea() getPadding(), getWidth() - getPadding() * 2, getHeight() - getPadding() * 2); -}
\ No newline at end of file +} |