ScummVM API documentation
gui_listbox.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_LISTBOX_H
23#define AGS_SHARED_GUI_GUI_LISTBOX_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 {
30namespace AGS {
31namespace Shared {
32
33class GUIListBox : public GUIObject {
34public:
35 GUIListBox();
36
37 bool HasAlphaChannel() const override;
38 bool AreArrowsShown() const;
39 bool IsBorderShown() const;
40 bool IsSvgIndex() const;
41 bool IsInRightMargin(int x) const;
42 int GetItemAt(int x, int y) const;
43
44 // Operations
45 int AddItem(const String &text);
46 void Clear();
47 Rect CalcGraphicRect(bool clipped) override;
48 void Draw(Bitmap *ds, int x = 0, int y = 0) override;
49 int InsertItem(int index, const String &text);
50 void RemoveItem(int index);
51 void SetShowArrows(bool on);
52 void SetShowBorder(bool on);
53 void SetSvgIndex(bool on); // TODO: work around this
54 void SetFont(int font);
55 void SetItemText(int index, const String &textt);
56
57 // Events
58 bool OnMouseDown() override;
59 void OnMouseMove(int x, int y) override;
60 void OnResized() override;
61
62 // Serialization
63 void ReadFromFile(Stream *in, GuiVersion gui_version) override;
64 void WriteToFile(Stream *out) const override;
65 void ReadFromSavegame(Shared::Stream *in, GuiSvgVersion svg_ver) override;
66 void WriteToSavegame(Shared::Stream *out) const override;
67
68 // TODO: these members are currently public; hide them later
69public:
70 int32_t Font;
71 color_t TextColor;
72 HorAlignment TextAlignment;
73 color_t SelectedBgColor;
74 color_t SelectedTextColor;
75 int32_t RowHeight;
76 int32_t VisibleItemCount;
77
79 std::vector<int16_t> SavedGameIndex;
80 int32_t SelectedItem;
81 int32_t TopItem;
82 Point MousePos;
83
84 // TODO: remove these later
85 int32_t ItemCount;
86
87private:
88 int32_t ListBoxFlags;
89
90 // Updates dynamic metrics such as row height and others
91 void UpdateMetrics();
92 // Applies translation
93 void PrepareTextToDraw(const String &text);
94
95 // prepared text buffer/cache
96 String _textToDraw;
97};
98
99} // namespace Shared
100} // namespace AGS
101} // namespace AGS3
102
103#endif
Definition: allegro_bitmap.h:44
Definition: gui_listbox.h:33
Definition: gui_object.h:44
Definition: stream.h:52
Definition: string.h:60
Definition: fonts.h:43
Definition: geometry.h:87
Definition: geometry.h:219