summaryrefslogtreecommitdiff
path: root/src/gui/base
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-02-16 22:17:22 +0300
committerAndrei Karas <akaras@inbox.ru>2014-02-16 22:17:22 +0300
commit6e6c5b2ba399e0ed364ada843c4c759ee54de219 (patch)
tree562e6a840c856ba8c4d35c6806020289c65d54d2 /src/gui/base
parent82ac4641828ec7387863bb18cf4493190c4cc68f (diff)
downloadManaVerse-6e6c5b2ba399e0ed364ada843c4c759ee54de219.tar.gz
ManaVerse-6e6c5b2ba399e0ed364ada843c4c759ee54de219.tar.bz2
ManaVerse-6e6c5b2ba399e0ed364ada843c4c759ee54de219.tar.xz
ManaVerse-6e6c5b2ba399e0ed364ada843c4c759ee54de219.zip
combine font classes in one.
Diffstat (limited to 'src/gui/base')
-rw-r--r--src/gui/base/font.cpp87
-rw-r--r--src/gui/base/font.hpp133
-rw-r--r--src/gui/base/widget.hpp2
-rw-r--r--src/gui/base/widgets/button.cpp3
-rw-r--r--src/gui/base/widgets/checkbox.cpp3
-rw-r--r--src/gui/base/widgets/label.cpp2
-rw-r--r--src/gui/base/widgets/listbox.cpp4
-rw-r--r--src/gui/base/widgets/radiobutton.cpp3
-rw-r--r--src/gui/base/widgets/textbox.cpp3
-rw-r--r--src/gui/base/widgets/textfield.cpp3
-rw-r--r--src/gui/base/widgets/window.cpp3
11 files changed, 17 insertions, 229 deletions
diff --git a/src/gui/base/font.cpp b/src/gui/base/font.cpp
deleted file mode 100644
index ccb2f7022..000000000
--- a/src/gui/base/font.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * 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 "gui/base/font.hpp"
-
-#include <string>
-
-#include "debug.h"
-
-namespace gcn
-{
- int Font::getStringIndexAt(const std::string& text, const int x) const
- {
- const size_t sz = text.size();
- for (size_t i = 0; i < sz; ++i)
- {
- if (getWidth(text.substr(0, i)) > x)
- return i;
- }
-
- return static_cast<int>(sz);
- }
-} // namespace gcn
diff --git a/src/gui/base/font.hpp b/src/gui/base/font.hpp
deleted file mode 100644
index 075af4136..000000000
--- a/src/gui/base/font.hpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * 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_FONT_HPP
-#define GCN_FONT_HPP
-
-#include <string>
-
-#include "localconsts.h"
-
-class Graphics;
-
-namespace gcn
-{
- /**
- * Interface for a font.
- *
- * @see ImageFont
- */
- class Font
- {
- public:
- /**
- * Destructor.
- */
- virtual ~Font()
- { }
-
- /**
- * Gets the width of a string. The width of a string is not necesserily
- * the sum of all the widths of it's glyphs.
- *
- * @param text The string to return the width of.
- * @return The width of a string.
- */
- virtual int getWidth(const std::string& text) const A_WARN_UNUSED = 0;
-
- /**
- * Gets the height of the glyphs in the font.
- *
- * @return The height of the glyphs int the font.
- */
- virtual int getHeight() const A_WARN_UNUSED = 0;
-
- /**
- * Gets a string index in a string providing an x coordinate.
- * Used to retrive a string index (for a character in a
- * string) at a certain x position. It is especially useful
- * when a mouse clicks in a TextField and you want to know which
- * character was clicked.
- *
- * @return A string index in a string providing an x coordinate.
- */
- virtual int getStringIndexAt(const std::string& text,
- const int x) const A_WARN_UNUSED;
-
- /**
- * Draws a string.
- *
- * NOTE: You normally won't use this function to draw text since
- * Graphics contains better functions for drawing text.
- *
- * @param graphics A Graphics object to use for drawing.
- * @param text The string to draw.
- * @param x The x coordinate where to draw the string.
- * @param y The y coordinate where to draw the string.
- */
- virtual void drawString(Graphics* graphics, const std::string& text,
- int x, int y) = 0;
- };
-} // namespace gcn
-
-#endif // end GCN_FONT_HPP
diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp
index ce32b14f3..a459ab4f2 100644
--- a/src/gui/base/widget.hpp
+++ b/src/gui/base/widget.hpp
@@ -76,6 +76,7 @@
class ActionListener;
class DeathListener;
class FocusListener;
+class Font;
class Graphics;
class KeyListener;
class MouseListener;
@@ -85,7 +86,6 @@ namespace gcn
{
class BasicContainer;
class FocusHandler;
- class Font;
class KeyInput;
class MouseInput;
diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp
index 1276b82b2..9b7473293 100644
--- a/src/gui/base/widgets/button.cpp
+++ b/src/gui/base/widgets/button.cpp
@@ -67,7 +67,8 @@
#include "gui/base/widgets/button.hpp"
-#include "gui/base/font.hpp"
+#include "gui/font.h"
+
#include "gui/base/key.hpp"
#include "gui/base/mouseinput.hpp"
diff --git a/src/gui/base/widgets/checkbox.cpp b/src/gui/base/widgets/checkbox.cpp
index 5f2477b4d..0a3171fe8 100644
--- a/src/gui/base/widgets/checkbox.cpp
+++ b/src/gui/base/widgets/checkbox.cpp
@@ -67,7 +67,8 @@
#include "gui/base/widgets/checkbox.hpp"
-#include "gui/base/font.hpp"
+#include "gui/font.h"
+
#include "gui/base/key.hpp"
#include "gui/base/mouseinput.hpp"
diff --git a/src/gui/base/widgets/label.cpp b/src/gui/base/widgets/label.cpp
index c23666eac..cbee2ac4c 100644
--- a/src/gui/base/widgets/label.cpp
+++ b/src/gui/base/widgets/label.cpp
@@ -67,7 +67,7 @@
#include "gui/base/widgets/label.hpp"
-#include "gui/base/font.hpp"
+#include "gui/font.h"
#include "render/graphics.h"
diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp
index 7f46b4b10..6c6472636 100644
--- a/src/gui/base/widgets/listbox.cpp
+++ b/src/gui/base/widgets/listbox.cpp
@@ -67,11 +67,13 @@
#include "gui/base/widgets/listbox.hpp"
+#include "gui/font.h"
+
#include "gui/base/basiccontainer.hpp"
-#include "gui/base/font.hpp"
#include "gui/base/key.hpp"
#include "gui/base/listmodel.hpp"
#include "gui/base/mouseinput.hpp"
+
#include "listeners/selectionlistener.h"
#include "render/graphics.h"
diff --git a/src/gui/base/widgets/radiobutton.cpp b/src/gui/base/widgets/radiobutton.cpp
index e42773de1..f0430c7a2 100644
--- a/src/gui/base/widgets/radiobutton.cpp
+++ b/src/gui/base/widgets/radiobutton.cpp
@@ -67,7 +67,8 @@
#include "gui/base/widgets/radiobutton.hpp"
-#include "gui/base/font.hpp"
+#include "gui/font.h"
+
#include "gui/base/key.hpp"
#include "gui/base/mouseinput.hpp"
diff --git a/src/gui/base/widgets/textbox.cpp b/src/gui/base/widgets/textbox.cpp
index 06d0e6379..e994804d8 100644
--- a/src/gui/base/widgets/textbox.cpp
+++ b/src/gui/base/widgets/textbox.cpp
@@ -67,8 +67,9 @@
#include "gui/base/widgets/textbox.hpp"
+#include "gui/font.h"
+
#include "gui/base/basiccontainer.hpp"
-#include "gui/base/font.hpp"
#include "gui/base/key.hpp"
#include "gui/base/mouseinput.hpp"
diff --git a/src/gui/base/widgets/textfield.cpp b/src/gui/base/widgets/textfield.cpp
index df1b844d4..1514d3afb 100644
--- a/src/gui/base/widgets/textfield.cpp
+++ b/src/gui/base/widgets/textfield.cpp
@@ -67,7 +67,8 @@
#include "gui/base/widgets/textfield.hpp"
-#include "gui/base/font.hpp"
+#include "gui/font.h"
+
#include "gui/base/key.hpp"
#include "gui/base/mouseinput.hpp"
diff --git a/src/gui/base/widgets/window.cpp b/src/gui/base/widgets/window.cpp
index 9207fe449..fbd42aff2 100644
--- a/src/gui/base/widgets/window.cpp
+++ b/src/gui/base/widgets/window.cpp
@@ -67,7 +67,8 @@
#include "gui/base/widgets/window.hpp"
-#include "gui/base/font.hpp"
+#include "gui/font.h"
+
#include "gui/base/mouseinput.hpp"
#include "render/graphics.h"