gui_font.h

00001 /***************************************************************************
00002  *   Copyright (C) 2005-2008 by the FIFE team                              *
00003  *   http://www.fifengine.de                                               *
00004  *   This file is part of FIFE.                                            *
00005  *                                                                         *
00006  *   FIFE is free software; you can redistribute it and/or                 *
00007  *   modify it under the terms of the GNU Lesser General Public            *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2.1 of the License, or (at your option) any later version.    *
00010  *                                                                         *
00011  *   This library is distributed in the hope that it will be useful,       *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00014  *   Lesser General Public License for more details.                       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with this library; if not, write to the                 *
00018  *   Free Software Foundation, Inc.,                                       *
00019  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
00020  ***************************************************************************/
00021 
00022 #ifndef FIFE_GUI_FONT_H
00023 #define FIFE_GUI_FONT_H
00024 
00025 // Standard C++ library includes
00026 
00027 // 3rd party library includes
00028 #include <guichan/font.hpp>
00029 
00030 // FIFE includes
00031 // These includes are split up in two parts, separated by one empty line
00032 // First block: files included from the FIFE root src directory
00033 // Second block: files included from the same folder
00034 #include "video/fonts/abstractfont.h"
00035 
00036 
00037 namespace FIFE {
00038 
00039     class GuiFont : public gcn::Font, public AbstractFont {
00040     public:
00044         GuiFont(AbstractFont* font);
00045         virtual ~GuiFont();
00046         
00047         int getStringIndexAt(const std::string& text, int x) const;
00048         void drawString(gcn::Graphics* graphics, const std::string& text, int x, int y);
00049         void drawMultiLineString(gcn::Graphics* graphics, const std::string& text, int x, int y);
00050         std::string splitTextToWidth (const std::string& text, int render_width);
00051 
00052         void setRowSpacing (int spacing);
00053         int getRowSpacing() const;
00054         void setGlyphSpacing(int spacing);
00055         int getGlyphSpacing() const;
00056         void setAntiAlias(bool antiAlias);
00057         bool isAntiAlias();
00058         Image* getAsImage(const std::string& text);
00059         Image* getAsImageMultiline(const std::string& text);
00060         void setColor(uint8_t r,uint8_t g,uint8_t b);
00061         SDL_Color getColor() const;
00062         int getWidth(const std::string& text) const;
00063         int getHeight() const;
00064         
00065     private:
00066         AbstractFont* m_font;
00067     };
00068 }
00069 
00070 #endif