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 DIRECTOR_CASTMEMBER_TEXT_H
23 #define DIRECTOR_CASTMEMBER_TEXT_H
24 
25 #include "director/castmember/castmember.h"
26 
27 namespace Graphics {
28 class MacText;
29 }
30 
31 namespace Director {
32 
33 class TextCastMember : public CastMember {
34 public:
35  TextCastMember(Cast *cast, uint16 castId, Common::SeekableReadStreamEndian &stream, uint16 version, uint8 flags1 = 0, bool asButton = false);
36  TextCastMember(Cast *cast, uint16 castId, TextCastMember &source);
37 
38  CastMember *duplicate(Cast *cast, uint16 castId) override { return (CastMember *)(new TextCastMember(cast, castId, *this)); }
39 
40  void setColors(uint32 *fgcolor, uint32 *bgcolor) override;
41 
42  Graphics::MacWidget *createWidget(Common::Rect &bbox, Channel *channel, SpriteType spriteType) override;
43 
44  Graphics::MacText *getWidget();
45 
46  CollisionTest isWithin(const Common::Rect &bbox, const Common::Point &pos, InkType ink) override;
47 
48  bool isEditable() override { return _editable; }
49  void setEditable(bool editable) override { _editable = editable; }
50  void updateFromWidget(Graphics::MacWidget *widget, bool spriteEditable) override;
51  Graphics::TextAlign getAlignment();
52 
53  uint32 getBackColor() override { return _bgcolor; }
54  void setBackColor(uint32 bgCol) override;
55  uint32 getForeColor() override { return _fgcolor; }
56  uint32 getForeColor(int start, int end);
57  void setForeColor(uint32 fgCol) override;
58  void setForeColor(uint32 fgCol, int start, int end);
59 
60  bool hasField(int field) override;
61  Datum getField(int field) override;
62  bool setField(int field, const Datum &value) override;
63 
64  bool hasChunkField(int field);
65  Datum getChunkField(int field, int start, int end);
66  bool setChunkField(int field, int start, int end, const Datum &value);
67 
68  int getLineCount();
69  int getLineHeight(int line);
70 
71  int getTextHeight();
72 
73  Common::String getTextFont();
74  Common::String getTextFont(int start, int end);
75  void setTextFont(const Common::String &fontName);
76  void setTextFont(const Common::String &fontName, int start, int end);
77 
78  int getTextSize();
79  int getTextSize(int start, int end);
80  void setTextSize(int textSize);
81  void setTextSize(int textSize, int start, int end);
82 
83  Common::String getTextStyle();
84  Common::String getTextStyle(int start, int end);
85  void setTextStyle(const Common::String &textStyle);
86  void setTextStyle(const Common::String &textStyle, int start, int end);
87 
88  void scrollByLine(int count);
89 
90  Common::String formatInfo() override;
91 
92  void load() override;
93  void unload() override;
94 
95  void writeCastData(Common::SeekableWriteStream *writeStream) override;
96  uint32 getCastDataSize() override; // This is the size of the data in the 'CASt' resource
97 
98  uint32 getSTXTResourceSize();
99  uint32 writeSTXTResource(Common::SeekableWriteStream *writeStream, uint32 offset);
100  uint8 getFormattingCount();
101 
102  uint8 _borderSize;
103  uint8 _gutterSize;
104  uint8 _boxShadow;
105  uint16 _maxHeight;
106  uint16 _textHeight;
107 
108  uint32 _fontId;
109  uint16 _height;
110  uint16 _ascent;
111  uint16 _fontSize;
112  TextType _textType;
113  TextAlignType _textAlign;
114  uint8 _textShadow;
115  uint16 _scroll;
116  byte _textSlant;
117  byte _textFlags;
118  uint16 _bgpalinfo1, _bgpalinfo2, _bgpalinfo3;
119  uint16 _fgpalinfo1, _fgpalinfo2, _fgpalinfo3;
120  ButtonType _buttonType;
121  bool _editable;
122  int _lineSpacing;
123 
124  Common::U32String _ftext;
125  Common::U32String _ptext;
126  Common::String _rtext;
127  void importStxt(const Stxt *stxt);
128  void importRTE(byte *text);
129 
130  Common::U32String getText();
131  Common::String getRawText();
132  void setRawText(const Common::String &text);
133 
134 private:
135  Graphics::MacWidget *createWindowOrWidget(Common::Rect &bbox, Common::Rect dims, Graphics::MacFont *macFont);
136 
137  uint32 _bgcolor;
138  uint32 _fgcolor;
139 };
140 
141 } // End of namespace Director
142 
143 #endif
Definition: cast.h:87
Definition: str.h:59
TextAlign
Definition: font.h:48
Definition: channel.h:40
Definition: mactext.h:47
Definition: stxt.h:51
Definition: rect.h:524
Definition: archive.h:36
Definition: ustr.h:57
Definition: formatinfo.h:28
Definition: rect.h:144
Definition: macwidget.h:39
Definition: lingo.h:130
Definition: macfontmanager.h:106
Definition: stream.h:351
Definition: stream.h:944
Definition: text.h:33
Definition: castmember.h:48