summaryrefslogtreecommitdiff
path: root/src/gui/widgets/popup.h
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-07 23:47:57 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-07 23:52:46 +0200
commitd69d85f06fa6dc22ac4c7789e4140e32d119a7f1 (patch)
tree1d2311bfdba616136d0ac26f8cbe9ab73c88f0e4 /src/gui/widgets/popup.h
parent303c1f69761e90b83d4809e911f7785ec66b46aa (diff)
downloadmana-d69d85f06fa6dc22ac4c7789e4140e32d119a7f1.tar.gz
mana-d69d85f06fa6dc22ac4c7789e4140e32d119a7f1.tar.bz2
mana-d69d85f06fa6dc22ac4c7789e4140e32d119a7f1.tar.xz
mana-d69d85f06fa6dc22ac4c7789e4140e32d119a7f1.zip
Moved basic widgets into the gui/widgets directory
In an attempt to make the GUI code a little more structured, basic widgets are now put in gui/widgets. Many includes were also cleaned up.
Diffstat (limited to 'src/gui/widgets/popup.h')
-rw-r--r--src/gui/widgets/popup.h165
1 files changed, 165 insertions, 0 deletions
diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h
new file mode 100644
index 00000000..71ce2d89
--- /dev/null
+++ b/src/gui/widgets/popup.h
@@ -0,0 +1,165 @@
+/*
+ * The Mana World
+ * Copyright (C) 2004 The Mana World Development Team
+ * Copyright (C) 2009 Aethyra Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef POPUP_H
+#define POPUP_H
+
+#include <guichan/widgets/container.hpp>
+
+#include "guichanfwd.h"
+
+class Skin;
+class SkinLoader;
+class WindowContainer;
+
+/**
+ * A rather reduced down version of the Window class that is particularly suited
+ * for popup type functionality that doesn't need to be resized or moved around
+ * by the mouse once created, but only needs to display some simple content,
+ * like a static message. Popups, in general, shouldn't also need to update
+ * their content once created, although this is not an explicit requirement to
+ * use the popup class.
+ *
+ * \ingroup GUI
+ */
+class Popup : public gcn::Container
+{
+ public:
+ /**
+ * Constructor. Initializes the title to the given text and hooks
+ * itself into the popup container.
+ *
+ * @param name A human readable name for the popup. Only useful for
+ * debugging purposes.
+ * @param skin The location where the Popup's skin XML can be found.
+ */
+ Popup(const std::string &name = "",
+ const std::string &skin = "graphics/gui/gui.xml");
+
+ /**
+ * Destructor. Deletes all the added widgets.
+ */
+ ~Popup();
+
+ /**
+ * Sets the window container to be used by new popups.
+ */
+ static void setWindowContainer(WindowContainer *windowContainer);
+
+ /**
+ * Changes the popup's skin to use the skin defined in the saved
+ * configuration file.
+ */
+ void loadPopupConfiguration();
+
+ /**
+ * Currently only saves the skin used by the popup so that when the
+ * client is reloaded, it can use the saved skin.
+ */
+ void savePopupConfiguration();
+
+ /**
+ * Draws the popup.
+ */
+ void draw(gcn::Graphics *graphics);
+
+ /**
+ * Sets the size of this popup.
+ */
+ void setContentSize(int width, int height);
+
+ /**
+ * Sets the location relative to the given widget.
+ */
+ void setLocationRelativeTo(gcn::Widget *widget);
+
+ /**
+ * Sets the minimum width of the popup.
+ */
+ void setMinWidth(int width);
+
+ int getMinWidth() const { return mMinWidth; }
+
+ /**
+ * Sets the minimum height of the popup.
+ */
+ void setMinHeight(int height);
+
+ int getMinHeight() const { return mMinHeight; }
+
+ /**
+ * Sets the maximum width of the popup.
+ */
+ void setMaxWidth(int width);
+
+ int getMaxWidth() const { return mMaxWidth; }
+
+ /**
+ * Sets the minimum height of the popup.
+ */
+ void setMaxHeight(int height);
+
+ int getMaxHeight() const { return mMaxHeight; }
+
+ /**
+ * Gets the padding of the popup. The padding is the distance between
+ * the popup border and the content.
+ *
+ * @return The padding of the popup.
+ * @see setPadding
+ */
+ int getPadding() const { return mPadding; }
+
+ void setPadding(int padding) { mPadding = padding; }
+
+ /**
+ * Sets the name of the popup. This is only useful for debug purposes.
+ */
+ void setPopupName(const std::string &name)
+ { mPopupName = name; }
+
+ const std::string &getPopupName() const
+ { return mPopupName; }
+
+ /**
+ * Schedule this popup for deletion. It will be deleted at the start
+ * of the next logic update.
+ */
+ void scheduleDelete();
+
+ // Inherited from BasicContainer
+
+ virtual gcn::Rectangle getChildrenArea();
+
+ private:
+ std::string mPopupName; /**< Name of the popup */
+ std::string mDefaultSkinPath; /**< Default skin path for this popup */
+ int mMinWidth; /**< Minimum popup width */
+ int mMinHeight; /**< Minimum popup height */
+ int mMaxWidth; /**< Maximum popup width */
+ int mMaxHeight; /**< Maximum popup height */
+ int mPadding; /**< Holds the padding of the popup. */
+
+ Skin *mSkin; /**< Skin in use by this popup */
+};
+
+#endif