00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef __FONT_H__
00029 #define __FONT_H__
00030
00032
00033
00034
00035
00036
00056
00057
00058
00059
00060 #include <string>
00061 #include "SDL.h"
00062 #include "guichan/font.h"
00063
00064
00065
00066
00067
00068 class CGraphic;
00069
00071 class CFont : public gcn::Font {
00072 private:
00073 CFont(const std::string &ident) : Ident(ident), CharWidth(NULL),
00074 G(NULL) {}
00075
00076 public:
00077 virtual ~CFont();
00078
00079 static CFont *New(const std::string &ident, CGraphic *g);
00080 static CFont *Get(const std::string &ident);
00081
00082 int Height() const;
00083 int Width(const std::string &text) const;
00084 bool IsLoaded() const;
00085
00086 virtual int getHeight() const { return Height(); }
00087 virtual int getWidth(const std::string &text) const
00088 { return Width(text); }
00089 virtual void drawString(gcn::Graphics *graphics, const std::string &text,
00090 int x, int y);
00091
00092 void MeasureWidths();
00093
00094 std::string Ident;
00095 char *CharWidth;
00096 CGraphic *G;
00097 };
00098
00099 #define MaxFontColors 9
00100
00102 class CFontColor {
00103 public:
00104 CFontColor(const std::string &ident);
00105 ~CFontColor();
00106
00107 static CFontColor *New(const std::string &ident);
00108 static CFontColor *Get(const std::string &ident);
00109
00110 std::string Ident;
00111 SDL_Color Colors[MaxFontColors];
00112 };
00113
00114
00115
00116
00117
00121 #define FontRed "red"
00122 #define FontGreen "green"
00123 #define FontYellow "yellow"
00124 #define FontWhite "white"
00125 #define FontGrey "grey"
00126
00127
00128
00129
00130
00135 extern CFont *SmallFont;
00136 extern CFont *GameFont;
00137 extern CFont *LargeFont;
00138
00139
00140
00141
00142
00144 extern void SetDefaultTextColors(const std::string &normal, const std::string &reverse);
00146 extern void GetDefaultTextColors(std::string &normalp, std::string &reversep);
00148 extern int VideoDrawText(int x, int y, CFont *font, const std::string &text);
00150 extern int VideoDrawTextClip(int x, int y, CFont *font, const std::string &text);
00152 extern int VideoDrawReverseText(int x, int y, CFont *font, const std::string &text);
00154 extern int VideoDrawReverseTextClip(int x, int y, CFont *font, const std::string &text);
00156 extern int VideoDrawTextCentered(int x, int y, CFont *font, const std::string &text);
00158 extern int VideoDrawNumber(int x, int y, CFont *font, int number);
00160 extern int VideoDrawNumberClip(int x, int y, CFont *font, int number);
00162 extern int VideoDrawReverseNumber(int x, int y, CFont *font, int number);
00164 extern int VideoDrawReverseNumberClip(int x, int y, CFont *font, int number);
00165
00167 extern int GetHotKey(const std::string &text);
00168
00170 extern void LoadFonts();
00172 extern void FreeOpenGLFonts();
00174 extern void ReloadFonts();
00176 extern void CleanFonts();
00177
00179
00180 #endif // !__FONT_H__