]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/CGUIFont.h
Drop _IRR_COMPILE_WITH_GUI_
[irrlicht.git] / source / Irrlicht / CGUIFont.h
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt\r
2 // This file is part of the "Irrlicht Engine".\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h\r
4 \r
5 #ifndef __C_GUI_FONT_H_INCLUDED__\r
6 #define __C_GUI_FONT_H_INCLUDED__\r
7 \r
8 #include "IrrCompileConfig.h"\r
9 #include "IGUIFontBitmap.h"\r
10 #include "irrString.h"\r
11 #include "IReadFile.h"\r
12 #include "irrArray.h"\r
13 #include <map>\r
14 \r
15 namespace irr\r
16 {\r
17 \r
18 namespace video\r
19 {\r
20         class IVideoDriver;\r
21         class IImage;\r
22 }\r
23 \r
24 namespace gui\r
25 {\r
26 \r
27         class IGUIEnvironment;\r
28 \r
29 class CGUIFont : public IGUIFontBitmap\r
30 {\r
31 public:\r
32 \r
33         //! constructor\r
34         CGUIFont(IGUIEnvironment* env, const io::path& filename);\r
35 \r
36         //! destructor\r
37         virtual ~CGUIFont();\r
38 \r
39         //! loads a font from a texture file\r
40         bool load(const io::path& filename);\r
41 \r
42         //! loads a font from a texture file\r
43         bool load(io::IReadFile* file);\r
44 \r
45         //! draws an text and clips it to the specified rectangle if wanted\r
46         virtual void draw(const core::stringw& text, const core::rect<s32>& position,\r
47                         video::SColor color, bool hcenter=false,\r
48                         bool vcenter=false, const core::rect<s32>* clip=0) override;\r
49 \r
50         //! returns the dimension of a text\r
51         core::dimension2d<u32> getDimension(const wchar_t* text) const override;\r
52 \r
53         //! Calculates the index of the character in the text which is on a specific position.\r
54         s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const override;\r
55 \r
56         //! Returns the type of this font\r
57         EGUI_FONT_TYPE getType() const override { return EGFT_BITMAP; }\r
58 \r
59         //! set an Pixel Offset on Drawing ( scale position on width )\r
60         void setKerningWidth (s32 kerning) override;\r
61         void setKerningHeight (s32 kerning) override;\r
62 \r
63         //! set an Pixel Offset on Drawing ( scale position on width )\r
64         s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) const override;\r
65         s32 getKerningHeight() const override;\r
66 \r
67         //! gets the sprite bank\r
68         IGUISpriteBank* getSpriteBank() const override;\r
69 \r
70         //! returns the sprite number from a given character\r
71         u32 getSpriteNoFromChar(const wchar_t *c) const override;\r
72 \r
73         void setInvisibleCharacters( const wchar_t *s ) override;\r
74 \r
75 private:\r
76 \r
77         struct SFontArea\r
78         {\r
79                 SFontArea() : underhang(0), overhang(0), width(0), spriteno(0) {}\r
80                 s32                             underhang;\r
81                 s32                             overhang;\r
82                 s32                             width;\r
83                 u32                             spriteno;\r
84         };\r
85 \r
86         //! load & prepare font from ITexture\r
87         bool loadTexture(video::IImage * image, const io::path& name);\r
88 \r
89         void readPositions(video::IImage* texture, s32& lowerRightPositions);\r
90 \r
91         s32 getAreaFromCharacter (const wchar_t c) const;\r
92         void setMaxHeight();\r
93 \r
94         void pushTextureCreationFlags(bool(&flags)[3]);\r
95         void popTextureCreationFlags(const bool(&flags)[3]);\r
96 \r
97         core::array<SFontArea>          Areas;\r
98         std::map<wchar_t, s32>          CharacterMap;\r
99         video::IVideoDriver*            Driver;\r
100         IGUISpriteBank*                 SpriteBank;\r
101         IGUIEnvironment*                Environment;\r
102         u32                             WrongCharacter;\r
103         s32                             MaxHeight;\r
104         s32                             GlobalKerningWidth, GlobalKerningHeight;\r
105 \r
106         core::stringw Invisible;\r
107 };\r
108 \r
109 } // end namespace gui\r
110 } // end namespace irr\r
111 \r
112 #endif // __C_GUI_FONT_H_INCLUDED__\r