From bd231fc40ca54f7dd2e091c5ab414f4cebb3b05e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 24 Sep 2012 13:26:20 +0300 Subject: Remove unused guichan classes. --- src/guichan/defaultfont.cpp | 95 --------------------- src/guichan/image.cpp | 26 ------ src/guichan/include/guichan/defaultfont.hpp | 100 ---------------------- src/guichan/include/guichan/image.hpp | 48 ----------- src/guichan/include/guichan/imageloader.hpp | 101 ----------------------- src/guichan/include/guichan/widget.hpp | 6 -- src/guichan/include/guichan/widgets/icon.hpp | 119 --------------------------- src/guichan/widget.cpp | 8 -- src/guichan/widgets/icon.cpp | 113 ------------------------- 9 files changed, 616 deletions(-) delete mode 100644 src/guichan/defaultfont.cpp delete mode 100644 src/guichan/include/guichan/defaultfont.hpp delete mode 100644 src/guichan/include/guichan/imageloader.hpp delete mode 100644 src/guichan/include/guichan/widgets/icon.hpp delete mode 100644 src/guichan/widgets/icon.cpp (limited to 'src/guichan') diff --git a/src/guichan/defaultfont.cpp b/src/guichan/defaultfont.cpp deleted file mode 100644 index e6da87fcd..000000000 --- a/src/guichan/defaultfont.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * Copyright (C) 2011-2012 The ManaPlus Developers - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/defaultfont.hpp" - -#include - -#include "guichan/graphics.hpp" -#include "guichan/rectangle.hpp" - -#include "debug.h" - -namespace gcn -{ - int DefaultFont::getHeight() const - { - return 8; - } - - int DefaultFont::getWidth(const std::string& text) const - { - return static_cast(8 * text.size()); - } - - int DefaultFont::drawGlyph(Graphics* graphics, - unsigned char glyph A_UNUSED, int x, int y) - { - graphics->drawRectangle( Rectangle(x, y, 8, 8)); - - return 8; - } - - void DefaultFont::drawString(Graphics* graphics, const std::string& text, - int x, int y) - { - for (size_t i = 0, sz = text.size(); i < sz; ++i) - { - drawGlyph(graphics, text.at(i), x, y); - x += getWidth(text); - } - } - - int DefaultFont::getStringIndexAt(const std::string& text, int x) const - { - if (x > static_cast(text.size() * 8)) - return static_cast(text.size()); - - return x / 8; - } -} diff --git a/src/guichan/image.cpp b/src/guichan/image.cpp index 1a560217f..09129e61f 100644 --- a/src/guichan/image.cpp +++ b/src/guichan/image.cpp @@ -49,15 +49,11 @@ #include "guichan/image.hpp" #include "guichan/exception.hpp" -#include "guichan/imageloader.hpp" #include "debug.h" namespace gcn { - - ImageLoader* Image::mImageLoader = nullptr; - Image::Image() { } @@ -65,26 +61,4 @@ namespace gcn Image::~Image() { } - - void Image::setImageLoader(ImageLoader* imageLoader) - { - mImageLoader = imageLoader; - } - - ImageLoader* Image::getImageLoader() - { - return mImageLoader; - } - - Image* Image::load(const std::string& filename, - bool convertToDisplayFormat) - { - if (!mImageLoader) - { - throw GCN_EXCEPTION("Trying to load an image but " - "no image loader is set."); - } - - return mImageLoader->load(filename, convertToDisplayFormat); - } } diff --git a/src/guichan/include/guichan/defaultfont.hpp b/src/guichan/include/guichan/defaultfont.hpp deleted file mode 100644 index c09802ee3..000000000 --- a/src/guichan/include/guichan/defaultfont.hpp +++ /dev/null @@ -1,100 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * Copyright (C) 2011-2012 The ManaPlus Developers - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_DEFAULTFONT_HPP -#define GCN_DEFAULTFONT_HPP - -#include "guichan/font.hpp" -#include "guichan/platform.hpp" - -#include "localconsts.h" - -namespace gcn -{ - /** - * A font only capable of drawing rectangles. It is used by default - * in Guichan if no font has been set merely to show that no font has - * been set. - */ - class GCN_CORE_DECLSPEC DefaultFont final : public Font - { - public: - - /** - * Destructor. - */ - virtual ~DefaultFont(){} - - /** - * Draws a glyph as a rectangle. The glyphs will always be drawn as - * rectangles no matter the glyph. - * - * NOTE: You normally won't use this function to draw text since - * the Graphics class contains better functions for drawing - * text. - * - * @param graphics A Graphics object to be used for drawing. - * @param glyph The glyph to draw. - * @param x The x coordinate where to draw the glyph. - * @param y The y coordinate where to draw the glyph. - * @return The width of the drawn glyph in pixels. - */ - virtual int drawGlyph(Graphics* graphics, unsigned char glyph, - int x, int y); - - - // Inherited from Font - - virtual void drawString(Graphics* graphics, const std::string& text, - int x, int y); - - virtual int getWidth(const std::string& text) const; - - virtual int getHeight() const; - - virtual int getStringIndexAt(const std::string& text, int x) const; - }; -} - -#endif // end GCN_DEFAULTFONT_HPP diff --git a/src/guichan/include/guichan/image.hpp b/src/guichan/include/guichan/image.hpp index f4de86679..7e4ad7b78 100644 --- a/src/guichan/include/guichan/image.hpp +++ b/src/guichan/include/guichan/image.hpp @@ -52,7 +52,6 @@ namespace gcn { class Color; - class ImageLoader; /** * Holds an image. To be able to use this class you must first set an @@ -82,47 +81,6 @@ namespace gcn */ virtual ~Image(); - /** - * Loads an image by using the class' image loader. All image loaders - * implemented in Guichan return a newly instantiated image which must - * be deleted in order to avoid a memory leak. - * - * NOTE: The functions getPixel and putPixel are only guaranteed to work - * before an image has been converted to display format. - * - * @param filename The file to load. - * @param convertToDisplayFormat True if the image should be converted - * to display, false otherwise. - * @since 0.5.0 - */ - static Image* load(const std::string& filename, - bool convertToDisplayFormat = true); - - /** - * Gets the image loader used for loading images. - * - * @return The image loader used for loading images. - * @see setImageLoader, AllegroImageLoader, HGEImageLoader, - * OpenLayerImageLoader, OpenGLAllegroImageLoader, - * OpenGLSDLImageLoader, SDLImageLoader - * @since 0.1.0 - */ - static ImageLoader* getImageLoader(); - - /** - * Sets the ImageLoader to be used for loading images. - * - * IMPORTANT: The image loader is static and MUST be set before - * loading images! - * - * @param imageLoader The image loader to be used for loading images. - * @see getImageLoader, AllegroImageLoader, HGEImageLoader, - * OpenLayerImageLoader, OpenGLAllegroImageLoader, - * OpenGLSDLImageLoader, SDLImageLoader - * @since 0.1.0 - */ - static void setImageLoader(ImageLoader* imageLoader); - /** * Frees an image. * @@ -180,12 +138,6 @@ namespace gcn * @since 0.5.0 */ virtual void convertToDisplayFormat() = 0; - - protected: - /** - * Holds the image loader to be used when loading images. - */ - static ImageLoader* mImageLoader; }; } diff --git a/src/guichan/include/guichan/imageloader.hpp b/src/guichan/include/guichan/imageloader.hpp deleted file mode 100644 index d8fef4f6a..000000000 --- a/src/guichan/include/guichan/imageloader.hpp +++ /dev/null @@ -1,101 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * Copyright (C) 2011-2012 The ManaPlus Developers - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_IMAGELOADER_HPP -#define GCN_IMAGELOADER_HPP - -#include - -#include "guichan/platform.hpp" - -namespace gcn -{ - class Image; - - /** - * Abstract class for providing functions for loading images. - * - * Guichan contains implementations of ImageLoader for common - * libraries like the Allegro library, the HGE library, - * he OpenLayer library, and the SDL library. - * To make Guichan usable with other libraries, an ImageLoader - * class must be implemented. - * - * To make Guichan use an image loader, the image loader needs - * to be passed to the Image class using the static method - * Image::setImageLoader. - * - * @see Image::setImageLoader, Image::getImageLoader, - * AllegroImageLoader, HGEImageLoader, OpenLayerImageLoader, - * OpenGLAllegroImageLoader, OpenGLSDLImageLoader, - * SDLImageLoader - * @since 0.1.0 - */ - class GCN_CORE_DECLSPEC ImageLoader - { - public: - - /** - * Destructor. - */ - virtual ~ImageLoader() - { } - - /** - * Loads an image. - * - * NOTE: The functions Image::getPixel and Image::putPixel - * are only guaranteed to work before an image has - * been converted to display format. - * - * @param filename The filename of the image to load. - * @param convertToDisplayFormat True if the image should be converted - * to display, false otherwise. - */ - virtual Image* load(const std::string& filename, - bool convertToDisplayFormat = true) = 0; - }; -} - -#endif // end GCN_IMAGELOADER_HPP diff --git a/src/guichan/include/guichan/widget.hpp b/src/guichan/include/guichan/widget.hpp index f4429dbee..69dfd1fc4 100644 --- a/src/guichan/include/guichan/widget.hpp +++ b/src/guichan/include/guichan/widget.hpp @@ -59,7 +59,6 @@ namespace gcn class ActionListener; class BasicContainer; class DeathListener; - class DefaultFont; class FocusHandler; class FocusListener; class Font; @@ -1187,11 +1186,6 @@ namespace gcn */ Font* mCurrentFont; - /** - * Holds the default font used by the widget. - */ - static DefaultFont mDefaultFont; - /** * Holds the global font used by the widget. */ diff --git a/src/guichan/include/guichan/widgets/icon.hpp b/src/guichan/include/guichan/widgets/icon.hpp deleted file mode 100644 index ed010c31a..000000000 --- a/src/guichan/include/guichan/widgets/icon.hpp +++ /dev/null @@ -1,119 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * Copyright (C) 2011-2012 The ManaPlus Developers - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_ICON_HPP -#define GCN_ICON_HPP - -#include "guichan/image.hpp" -#include "guichan/platform.hpp" -#include "guichan/widget.hpp" - -namespace gcn -{ - /** - * Implements an icon capable of displaying an image. - */ - class GCN_CORE_DECLSPEC Icon: public Widget - { - public: - /** - * Default constructor. - */ - Icon(); - - /** - * Constructor. - * - * @param filename The filename of the image to display. - */ - Icon(const std::string& filename); - - /** - * Constructor. - * - * @param image The image to display. - */ - Icon(const Image *const image); - - /** - * Descructor. - */ - virtual ~Icon(); - - /** - * Sets the image to display. Existing image is freed automatically - * if it was loaded internally. - * - * @param image The image to display. - */ - void setImage(const Image* image); - - /** - * Gets the current image. - * - * @return The current image. - */ - const Image* getImage() const; - - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - protected: - /** - * The image to display. - */ - const Image* mImage; - - /** - * True if the image has been loaded internally, false otherwise. - * An image not loaded internally should not be deleted in the - * destructor. - */ - bool mInternalImage; - }; -} - -#endif // end GCN_ICON_HPP diff --git a/src/guichan/widget.cpp b/src/guichan/widget.cpp index 8fa7cf65a..95e026d98 100644 --- a/src/guichan/widget.cpp +++ b/src/guichan/widget.cpp @@ -52,7 +52,6 @@ #include "guichan/actionlistener.hpp" #include "guichan/basiccontainer.hpp" #include "guichan/deathlistener.hpp" -#include "guichan/defaultfont.hpp" #include "guichan/event.hpp" #include "guichan/exception.hpp" #include "guichan/focushandler.hpp" @@ -68,7 +67,6 @@ namespace gcn { Font* Widget::mGlobalFont = nullptr; - DefaultFont Widget::mDefaultFont; std::list Widget::mWidgets; std::set Widget::mWidgetsSet; @@ -445,13 +443,7 @@ namespace gcn Font* Widget::getFont() const { if (!mCurrentFont) - { - if (!mGlobalFont) - return &mDefaultFont; - return mGlobalFont; - } - return mCurrentFont; } diff --git a/src/guichan/widgets/icon.cpp b/src/guichan/widgets/icon.cpp deleted file mode 100644 index a030e2413..000000000 --- a/src/guichan/widgets/icon.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * Copyright (C) 2011-2012 The ManaPlus Developers - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/widgets/icon.hpp" - -#include "guichan/graphics.hpp" -#include "guichan/image.hpp" -#include "guichan/rectangle.hpp" - -#include "debug.h" - -namespace gcn -{ - Icon::Icon() : - Widget(), - mImage(nullptr), - mInternalImage(false) - { - setSize(0, 0); - } - - Icon::Icon(const std::string& filename) : - Widget(), - mImage(Image::load(filename)), - mInternalImage(true) - { - setSize(mImage->getWidth(), - mImage->getHeight()); - } - - Icon::Icon(const Image *const image) : - Widget(), - mImage(image), - mInternalImage(false) - { - setSize(mImage->getWidth(), - mImage->getHeight()); - } - - Icon::~Icon() - { - if (mInternalImage) - { - delete mImage; - mImage = nullptr; - } - } - - void Icon::setImage(const Image* image) - { - if (mInternalImage) - delete mImage; - - mImage = image; - mInternalImage = false; - setSize(mImage->getWidth(), - mImage->getHeight()); - } - - const Image* Icon::getImage() const - { - return mImage; - } - - void Icon::draw(Graphics* graphics A_UNUSED) - { - } -} -- cgit v1.2.3-60-g2f50