ScummVM API documentation
groupedlist.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 GUI_WIDGETS_GROUPEDLIST_H
23 #define GUI_WIDGETS_GROUPEDLIST_H
24 
25 #include "gui/widgets/list.h"
26 
27 namespace GUI {
28 
29 class ListWidget;
30 
31 /* GroupedListWidget */
32 class GroupedListWidget : public ListWidget {
33 protected:
34  Common::String _groupingAttribute;
36  Common::Array<bool> _groupExpanded;
37  Common::U32String _groupHeaderPrefix;
38  Common::U32String _groupHeaderSuffix;
39  Common::U32StringArray _groupHeaders;
40  Common::U32StringArray _attributeValues;
41  Common::StringMap _metadataNames;
43  bool _groupsVisible;
44 
45 public:
46  GroupedListWidget(Dialog *boss, const Common::String &name, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0);
47  GroupedListWidget(Dialog *boss, int x, int y, int w, int h, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0);
48 
49  void setList(const Common::U32StringArray &list);
50  void setAttributeValues(const Common::U32StringArray &attrValues);
51  void setMetadataNames(const Common::StringMap &metadata);
52 
53  void setGroupHeaderFormat(const Common::U32String &prefix, const Common::U32String &suffix);
54  void groupByAttribute();
55  void loadClosedGroups(const Common::U32String &groupName);
56  void saveClosedGroups(const Common::U32String &groupName);
57 
58  void setSelected(int item);
59  int getSelected() const { return (_selectedItem == -1) ? _selectedItem : _listIndex[_selectedItem]; }
60 
61  void setFilter(const Common::U32String &filter, bool redraw = true);
62 
63  void handleMouseDown(int x, int y, int button, int clickCount) override;
64  void handleMouseUp(int x, int y, int button, int clickCount) override;
65  void handleMouseWheel(int x, int y, int direction) override;
66  void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
67 
68  void setGroupsVisibility(bool val) { _groupsVisible = val; }
69 
70  int getNextPos(int oldSel);
71  int getNewSel(int index);
72 
73  void startEditMode() override { error("Edit mode is not supported for Grouped Lists"); }
74 
75 protected:
76  void sortGroups();
77  void toggleGroup(int groupID);
78  void drawWidget() override;
79 };
80 
81 } // End of namespace GUI
82 
83 #endif
Definition: str.h:59
Definition: groupedlist.h:32
Definition: system.h:46
Definition: ustr.h:57
Definition: list.h:51
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: dialog.h:49
Definition: object.h:40