ScummVM API documentation
text16.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 SCI_GRAPHICS_TEXT16_H
23 #define SCI_GRAPHICS_TEXT16_H
24 
25 namespace Graphics {
26 class Font;
27 }
28 
29 namespace Sci {
30 
31 #define SCI_TEXT16_ALIGNMENT_RIGHT -1
32 #define SCI_TEXT16_ALIGNMENT_CENTER 1
33 #define SCI_TEXT16_ALIGNMENT_LEFT 0
34 
35 typedef Common::Array<Common::Rect> CodeRefRectArray;
36 
37 class GfxPorts;
38 class GfxPaint16;
39 class GfxScreen;
40 class GfxFont;
41 class GfxMacFontManager;
45 class GfxText16 {
46 public:
47  GfxText16(GfxCache *fonts, GfxPorts *ports, GfxPaint16 *paint16, GfxScreen *screen, GfxMacFontManager *macFontManager);
48  ~GfxText16();
49 
50  GuiResourceId GetFontId();
51  GfxFont *GetFont();
52  void SetFont(GuiResourceId fontId);
53 
54  int16 CodeProcessing(const char *&text, GuiResourceId orgFontId, int16 orgPenColor, bool doingDrawing);
55 
56 #if 0
57  void ClearChar(int16 chr);
58 #endif
59 
60  int16 GetLongest(const char *&text, int16 maxWidth, GuiResourceId orgFontId);
61  void Width(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight, bool restoreFont);
62  void StringWidth(const Common::String &str, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight);
63 #if 0
64  void ShowString(const Common::String &str, GuiResourceId orgFontId, int16 orgPenColor);
65 #endif
66  void DrawString(const Common::String &str, GuiResourceId orgFontId, int16 orgPenColor);
67  int16 Size(Common::Rect &rect, const char *text, uint16 textLanguage, GuiResourceId fontId, int16 maxWidth);
68  void Draw(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 orgPenColor);
69  void Show(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 orgPenColor);
70  void Box(const char *text, uint16 languageSplitter, bool show, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId);
71 
72  void Box(const char *text, bool show, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId) {
73  Box(text, 0, show, rect, alignment, fontId);
74  }
75 
76  void DrawString(const Common::String &str);
77  void DrawStatus(const Common::String &str);
78 
79  GfxFont *_font;
80 
81  reg_t allocAndFillReferenceRectArray();
82 
83  void kernelTextSize(const char *text, uint16 textLanguage, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight);
84  void kernelTextFonts(int argc, reg_t *argv);
85  void kernelTextColors(int argc, reg_t *argv);
86 
87  void macTextSize(const Common::String &text, GuiResourceId sciFontId, GuiResourceId origSciFontId, int16 maxWidth, int16 *textWidth, int16 *textHeight);
88  void macDraw(const Common::String &text, Common::Rect rect, TextAlignment alignment, GuiResourceId sciFontId, GuiResourceId origSciFontId, int16 color);
89 private:
90  void init();
91  bool SwitchToFont1001OnKorean(const char *text, uint16 languageSplitter);
92  bool SwitchToFont900OnSjis(const char *text, uint16 languageSplitter);
93  static bool isJapaneseNewLine(int16 curChar, int16 nextChar);
94  int16 macGetLongest(const Common::String &text, uint start, const Graphics::Font *font, int16 maxWidth, int16 *lineWidth);
95 
96  GfxCache *_cache;
97  GfxPorts *_ports;
98  GfxPaint16 *_paint16;
99  GfxScreen *_screen;
100  GfxMacFontManager *_macFontManager; // null when not applicable
101 
102  int _codeFontsCount;
103  GuiResourceId *_codeFonts;
104  int _codeColorsCount;
105  uint16 *_codeColors;
106 
107  bool _useEarlyGetLongestTextCalculations;
108 
109  Common::Rect _codeRefTempRect;
110  CodeRefRectArray _codeRefRects;
111 };
112 
113 } // End of namespace Sci
114 
115 #endif // SCI_GRAPHICS_TEXT16_H
Definition: paint16.h:36
Definition: ports.h:52
Definition: str.h:59
Definition: font.h:83
Definition: macfont.h:78
Definition: rect.h:144
Definition: scifont.h:37
Definition: formatinfo.h:28
Definition: cache.h:38
Definition: console.h:28
Definition: text16.h:45
Definition: screen.h:70
Definition: vm_types.h:39