# wiesel / src / common / wiesel / ui / font.h

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 /** * Copyright (C) 2012 * Christian Fischer * * https://bitbucket.org/baldur/wiesel/ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA */ #ifndef __WIESEL_UI_FONT_H__ #define __WIESEL_UI_FONT_H__ #include #include "wiesel/util/shared_object.h" #include #include namespace wiesel { // predeclaration class MultiSpriteNode; /** * @brief A class used by \ref LabelNode */ class WIESEL_COMMON_EXPORT Font : public virtual SharedObject { protected: Font(); private: Font(const Font&) {}; public: virtual ~Font(); public: /** * @brief This font will be assigned to a specific node. * The font object may perform some initialization here. * @param node The node this font will be assigned to. */ virtual void onAssignToNode(MultiSpriteNode *node) const; /** * @brief This font will be deassigned from a node, which has previously used this font. * The font object may undo some settings, which were initialized in onAssignToNode. * @param node The node this font will be unassigned from. */ virtual void onDeassignFromNode(MultiSpriteNode *node) const; /** * @brief Measure a character's width. */ virtual float getCharWidth(char c) const = 0; /** * @brief Measure a string's width. */ virtual float getStringWidth(const std::string &text) const; /** * @brief Measure a character's height. */ virtual float getCharHeight(char c) const = 0; /** * @brief Measure a string's height. */ virtual float getStringHeight(const std::string &text) const; /** * @brief Fills a Label node with image content to display the given text. * The text may contain linebreaks. * @param msn A MultiSpriteNode (usually a LabelNode), which should display the text. * @param text The text to be displayed. * @param align A float value controlling the alignment of the text. * 0.0 means left aligned * 0.5 means centered * 1.0 means right aligned */ virtual void fillLabelNode( MultiSpriteNode *msn, const std::string &text, float align=0.0f ) const; /** * @brief Fills a Label node with image content to display the given text. * @param msn A MultiSpriteNode (usually a LabelNode), which should display the text. * @param text A vector containing mulitple lines of text. * @param align A float value controlling the alignment of the text. * 0.0 means left aligned * 0.5 means centered * 1.0 means right aligned */ virtual void fillLabelNode( MultiSpriteNode *msn, const std::vector &text, float align=0.0f ) const = 0; }; } #endif // __WIESEL_UI_FONT_H__