ScummVM API documentation
hypertext.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 NANCY_MISC_HYPERTEXT_H
23 #define NANCY_MISC_HYPERTEXT_H
24 
25 #include "engines/nancy/renderobject.h"
26 
27 namespace Nancy {
28 namespace Misc {
29 
30 // Base class for handling the engine's custom hypertext format
31 // Used by the Textbox and by Autotext action records
33 public:
34  HypertextParser() :
35  _backgroundColor(0),
36  _highlightBackgroundColor(0),
37  _numDrawnLines(0),
38  _drawnTextHeight(0),
39  _needsTextRedraw(false),
40  _defaultTextColor(0),
41  _imageVerticalOffset(0) {}
42  virtual ~HypertextParser() {};
43 
44  bool hasBeenDrawn() const { return !_needsTextRedraw; }
45 
46 protected:
47  void initSurfaces(uint width, uint height, const struct Graphics::PixelFormat &format, uint32 backgroundColor, uint32 highlightBackgroundColor);
48 
49  void addTextLine(const Common::String &text);
50  void addImage(uint16 lineID, const Common::Rect &src);
51  void setImageName(const Common::Path &name);
52 
53  void drawAllText(const Common::Rect &textBounds, uint leftOffsetNonNewline, uint fontID, uint highlightFontID);
54  virtual void clear();
55 
56  Graphics::ManagedSurface _fullSurface; // Contains all rendered text (may be cropped)
57  Graphics::ManagedSurface _textHighlightSurface; // Same as above, but drawn with the highlight font
58 
59  uint32 _backgroundColor;
60  uint32 _highlightBackgroundColor;
61  uint _defaultTextColor;
62  int _imageVerticalOffset;
63 
66 
67  // Data for displaying images inside text; used in Hypertext
68  Common::Path _imageName;
69  Common::Array<uint16> _imageLineIDs;
70  Common::Array<Common::Rect> _imageSrcs;
71 
72  uint16 _numDrawnLines;
73  uint16 _drawnTextHeight;
74  bool _needsTextRedraw;
75 };
76 
77 } // End of namespace Misc
78 } // End of namespace Nancy
79 
80 #endif // NANCY_MISC_HYPERTEXT_H
Definition: managed_surface.h:51
Definition: str.h:59
Definition: pixelformat.h:138
Definition: rect.h:144
Definition: path.h:52
Definition: hypertext.h:32
Definition: actionmanager.h:32