summaryrefslogtreecommitdiff
path: root/src/gui/widgets/popup.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-10-10 22:14:45 +0300
committerAndrei Karas <akaras@inbox.ru>2017-10-10 22:15:57 +0300
commitaa3f63fd497558a02feb3ddbc44f31eac091f39b (patch)
tree0e28b9b1f0501dd8be9e1a38db4ec1777fa3fbfa /src/gui/widgets/popup.cpp
parent7c10a6b61e9d06a4ae9cc9f942dfacb6fcfd9d3d (diff)
downloadplus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.gz
plus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.bz2
plus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.xz
plus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.zip
Remove most unused files.
Diffstat (limited to 'src/gui/widgets/popup.cpp')
-rw-r--r--src/gui/widgets/popup.cpp273
1 files changed, 0 insertions, 273 deletions
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
deleted file mode 100644
index 0f5c5a31a..000000000
--- a/src/gui/widgets/popup.cpp
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- * Copyright (C) 2009 Aethyra Development Team
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "gui/widgets/popup.h"
-
-#include "gui/popupmanager.h"
-#include "gui/skin.h"
-
-#include "gui/widgets/windowcontainer.h"
-
-#include "utils/delete2.h"
-
-#include "render/graphics.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "debug.h"
-
-Popup::Popup(const std::string &name,
- std::string skin) :
- Container(nullptr),
- MouseListener(),
- WidgetListener(),
- mPadding(3),
- mSkin(nullptr),
- mPopupName(name),
- mVertexes(new ImageCollection),
- mMinWidth(100),
- mMinHeight(40),
- mMaxWidth(mainGraphics->mWidth),
- mMaxHeight(mainGraphics->mHeight),
- mInit(false)
-{
- logger->log("Popup::Popup(\"%s\")", name.c_str());
-
- mWindow = this;
-
- addWidgetListener(this);
-
- if (skin.empty())
- skin = "popup.xml";
-
- if (theme != nullptr)
- {
- mSkin = theme->load(skin, "popup.xml");
- if (mSkin != nullptr)
- {
- setPadding(mSkin->getPadding());
- setPalette(mSkin->getOption("palette"));
- }
- }
-
- if (windowContainer != nullptr)
- windowContainer->add(this);
-
- // Popups are invisible by default
- setVisible(Visible_false);
-}
-
-Popup::~Popup()
-{
- logger->log("Popup::~Popup(\"%s\")", mPopupName.c_str());
-
- delete2(mVertexes);
-
- if (mSkin != nullptr)
- {
- if (theme != nullptr)
- theme->unload(mSkin);
- mSkin = nullptr;
- }
-
- if (!mInit)
- {
- logger->log("error: Popup created without calling postInit(): "
- + mPopupName);
- }
-}
-
-void Popup::setWindowContainer(WindowContainer *const wc)
-{
- windowContainer = wc;
-}
-
-void Popup::draw(Graphics *const graphics)
-{
- BLOCK_START("Popup::draw")
-
- if (mSkin != nullptr)
- {
- if (mRedraw)
- {
- mRedraw = false;
- mVertexes->clear();
- graphics->calcWindow(mVertexes,
- 0, 0,
- mDimension.width, mDimension.height,
- mSkin->getBorder());
- }
- // need cache or remove calc call.
- graphics->finalize(mVertexes);
- graphics->drawTileCollection(mVertexes);
- }
-
- drawChildren(graphics);
- BLOCK_END("Popup::draw")
-}
-
-void Popup::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("Popup::safeDraw")
-
- if (mSkin != nullptr)
- {
- graphics->drawImageRect(0, 0,
- mDimension.width, mDimension.height,
- mSkin->getBorder());
- }
-
- safeDrawChildren(graphics);
- BLOCK_END("Popup::safeDraw")
-}
-
-Rect Popup::getChildrenArea()
-{
- const int pad2 = mPadding * 2;
- return Rect(mPadding, mPadding,
- mDimension.width - pad2, mDimension.height - pad2);
-}
-
-void Popup::setContentSize(int width, int height)
-{
- const int pad2 = mPadding * 2;
- width += pad2;
- height += pad2;
-
- if (mMinWidth > width)
- width = mMinWidth;
- else if (mMaxWidth < width)
- width = mMaxWidth;
- if (mMinHeight > height)
- height = mMinHeight;
- else if (mMaxHeight < height)
- height = mMaxHeight;
-
- setSize(width, height);
- mRedraw = true;
-}
-
-void Popup::setLocationRelativeTo(const Widget *const widget)
-{
- if (widget == nullptr)
- return;
-
- int wx, wy;
- int x, y;
-
- widget->getAbsolutePosition(wx, wy);
- getAbsolutePosition(x, y);
-
- setPosition(mDimension.x + (wx + (widget->getWidth()
- - mDimension.width) / 2 - x),
- mDimension.y + (wy + (widget->getHeight()
- - mDimension.height) / 2 - y));
- mRedraw = true;
-}
-
-void Popup::setMinWidth(const int width)
-{
- if (mSkin != nullptr)
- {
- mMinWidth = width > mSkin->getMinWidth()
- ? width : mSkin->getMinWidth();
- }
- else
- {
- mMinWidth = width;
- }
-}
-
-void Popup::setMinHeight(const int height)
-{
- if (mSkin != nullptr)
- {
- mMinHeight = height > mSkin->getMinHeight() ?
- height : mSkin->getMinHeight();
- }
- else
- {
- mMinHeight = height;
- }
-}
-
-void Popup::setMaxWidth(const int width)
-{
- mMaxWidth = width;
-}
-
-void Popup::setMaxHeight(const int height)
-{
- mMaxHeight = height;
-}
-
-void Popup::scheduleDelete()
-{
- windowContainer->scheduleDelete(this);
-}
-
-void Popup::position(const int x, const int y)
-{
- const int distance = 20;
-
- const int width = mDimension.width;
- const int height = mDimension.height;
- int posX = std::max(0, x - width / 2);
- int posY = y + distance;
-
- if (posX + width > mainGraphics->mWidth)
- posX = mainGraphics->mWidth - width;
- if (posY + height > mainGraphics->mHeight)
- posY = y - height - distance;
-
- setPosition(posX, posY);
- setVisible(Visible_true);
- requestMoveToTop();
- mRedraw = true;
-}
-
-void Popup::mouseMoved(MouseEvent &event A_UNUSED)
-{
- if (popupManager != nullptr)
- {
- PopupManager::hideBeingPopup();
- PopupManager::hideTextPopup();
- }
- mRedraw = true;
-}
-
-void Popup::hide()
-{
- setVisible(Visible_false);
- mRedraw = true;
-}
-
-void Popup::widgetResized(const Event &event A_UNUSED)
-{
- mRedraw = true;
-}
-
-void Popup::widgetMoved(const Event &event A_UNUSED)
-{
- mRedraw = true;
-}