ScummVM API documentation
gui_label.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 AGS_SHARED_GUI_GUI_LABEL_H
23#define AGS_SHARED_GUI_GUI_LABEL_H
24
25#include "common/std/vector.h"
26#include "ags/shared/gui/gui_object.h"
27#include "ags/shared/util/string.h"
28
29namespace AGS3 {
30
31namespace AGS {
32namespace Shared {
33
34class GUILabel : public GUIObject {
35public:
36 GUILabel();
37
38 bool HasAlphaChannel() const override;
39 // Gets label's text property in original set form (with macros etc)
40 String GetText() const;
41 // Gets which macro are contained within label's text
42 GUILabelMacro GetTextMacros() const;
43
44 // Operations
45 Rect CalcGraphicRect(bool clipped) override;
46 void Draw(Bitmap *ds, int x = 0, int y = 0) override;
47 void SetText(const String &text);
48
49 // Serialization
50 void ReadFromFile(Stream *in, GuiVersion gui_version) override;
51 void WriteToFile(Stream *out) const override;
52 void ReadFromSavegame(Shared::Stream *in, GuiSvgVersion svg_ver) override;
53 void WriteToSavegame(Shared::Stream *out) const override;
54
55 // TODO: these members are currently public; hide them later
56public:
57 String Text;
58 int32_t Font;
59 color_t TextColor;
60 HorAlignment TextAlignment;
61
62private:
63 // Transforms the Text property to a drawn text, applies translation,
64 // replaces macros, splits and wraps, etc; returns number of lines.
65 int PrepareTextToDraw();
66
67 // Information on macros contained within Text field
68 GUILabelMacro _textMacro;
69 // prepared text buffer/cache
70 // TODO: cache split lines instead?
71 String _textToDraw;
72};
73
74} // namespace Shared
75} // namespace AGS
76} // namespace AGS3
77
78#endif
Definition: allegro_bitmap.h:44
Definition: gui_label.h:34
Definition: gui_object.h:44
Definition: stream.h:52
Definition: string.h:60
Definition: fonts.h:43
Definition: geometry.h:219