ScummVM API documentation
text.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef ASYLUM_SYSTEM_TEXT_H
23 #define ASYLUM_SYSTEM_TEXT_H
24 
25 #include "common/rect.h"
26 #include "common/scummsys.h"
27 #include "graphics/font.h"
28 
29 #include "asylum/shared.h"
30 
31 namespace Asylum {
32 
33 class AsylumEngine;
34 class GraphicResource;
35 class ResourcePack;
36 
37 enum TextCentering {
38  kTextNormal,
39  kTextCenter,
40  kTextCalculate
41 };
42 
43 class Text {
44 public:
45  Text(AsylumEngine *engine);
46  ~Text();
47 
48  ResourceId loadFont(ResourceId resourceId);
49 
50  void setPosition(const Common::Point &point);
51  int16 getWidth(const char *text);
52  int16 getWidth(const char *text, int16 length);
53  int16 getWidth(ResourceId resourceId);
54  char *get(ResourceId resourceId);
55 
56  void drawASCII(char character) { drawChar(character); }
57  void draw(const char *text);
58  void draw(const Common::Point &point, const char *text);
59  void draw(ResourceId resourceId);
60  void draw(const Common::Point &point, ResourceId resourceId);
61  void draw(const char *text, ResourceId fontResourceId, int16 y);
62  void draw(const char *text, int16 length);
63  int16 draw(TextCentering centering, const Common::Point &point, int16 spacing, int16 width, const char *text);
64  void drawChinese(const Common::U32String &utext);
65  int16 draw(int16 a1, int16 a2, TextCentering centering, const Common::Point &point, int16 spacing, int16 width, const char *text);
66 
67  void drawCentered(const Common::Point &point, int16 width, const char *text);
68  void drawCentered(const Common::Point &point, int16 width, ResourceId resourceId);
69  void drawCentered(const Common::Point &point, int16 width, int16 length, const char *text);
70 
71  void setTransTableNum(uint32 val) { _transTableNum = val; }
72 
73 private:
74  int16 getWidth(char c);
75  void drawChar(char character);
76 
77  int16 getChineseWidth(const Common::U32String &utext);
78  void loadChineseFont();
79 
80  AsylumEngine *_vm;
81 
82  GraphicResource *_fontResource;
83 
84  uint32 _transTableNum;
85 
86  Common::Point _position;
87  uint8 _curFontFlags;
88 
90  bool _chineseFontLoadAttempted;
91 };
92 
93 } // end of namespace Asylum
94 
95 #endif // ASYLUM_SYSTEM_TEXT_H
Definition: asylum.h:53
Definition: text.h:43
Definition: ustr.h:57
Definition: rect.h:45
Definition: asylum.h:70
Definition: graphics.h:58