ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

font.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GRAPHICS_FONT_H
00024 #define GRAPHICS_FONT_H
00025 
00026 #include "common/str.h"
00027 #include "common/ustr.h"
00028 #include "common/rect.h"
00029 
00030 namespace Common {
00031 template<class T> class Array;
00032 }
00033 
00034 namespace Graphics {
00035 
00036 struct Surface;
00037 class ManagedSurface;
00038 
00040 enum TextAlign {
00041     kTextAlignInvalid,
00042     kTextAlignLeft,     
00043     kTextAlignCenter,   
00044     kTextAlignRight     
00045 };
00046 
00052 class Font {
00053 public:
00054     Font() {}
00055     virtual ~Font() {}
00056 
00062     virtual int getFontHeight() const = 0;
00063 
00069     virtual int getMaxCharWidth() const = 0;
00070 
00077     virtual int getCharWidth(uint32 chr) const = 0;
00078 
00086     virtual int getKerningOffset(uint32 left, uint32 right) const;
00087 
00102     virtual Common::Rect getBoundingBox(uint32 chr) const;
00103 
00121     Common::Rect getBoundingBox(const Common::String &str, int x = 0, int y = 0, const int w = 0, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = false) const;
00122     Common::Rect getBoundingBox(const Common::U32String &str, int x = 0, int y = 0, const int w = 0, TextAlign align = kTextAlignLeft) const;
00123 
00144     virtual void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const = 0;
00145     void drawChar(ManagedSurface *dst, uint32 chr, int x, int y, uint32 color) const;
00146 
00147     // TODO: Add doxygen comments to this
00148     void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const;
00149     void drawString(Surface *dst, const Common::U32String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0) const;
00150     void drawString(ManagedSurface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const;
00151     void drawString(ManagedSurface *dst, const Common::U32String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0) const;
00152 
00161     int getStringWidth(const Common::String &str) const;
00162     int getStringWidth(const Common::U32String &str) const;
00163 
00178     int wordWrapText(const Common::String &str, int maxWidth, Common::Array<Common::String> &lines, int initWidth = 0) const;
00179     int wordWrapText(const Common::U32String &str, int maxWidth, Common::Array<Common::U32String> &lines, int initWidth = 0) const;
00180 
00181 private:
00182     Common::String handleEllipsis(const Common::String &str, int w) const;
00183 };
00184 
00185 } // End of namespace Graphics
00186 
00187 #endif


Generated on Sat Oct 12 2019 05:00:49 for ResidualVM by doxygen 1.7.1
curved edge   curved edge