Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
COList.h
Go to the documentation of this file.
1/* Copyright (C) 2024 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17#ifndef INCLUDED_COLIST
18#define INCLUDED_COLIST
19
22
23#include <vector>
24
25/**
26 * Represents a column.
27 */
29{
30public:
31 COListColumn(IGUIObject* owner, const CStr& cid)
32 : m_Id(cid), m_Width(0), m_Heading(owner, "heading_" + cid), m_List(owner, "list_" + cid),
33 m_Hidden(owner, "hidden_" + cid, false), m_SortOrder(owner, " sort_order_" + cid, 1)
34 {}
35 // Avoid copying the strings.
39
42 CStr m_Id;
43 float m_Width;
48};
49
50/**
51 * Multi-column list. One row can be selected by the user.
52 * Individual cells are clipped if the contained text is too long.
53 *
54 * The list can be sorted dynamically by JS code when a
55 * heading is clicked.
56 * A scroll-bar will appear when needed.
57 */
58class COList : public CList
59{
61
62public:
63 COList(CGUI& pGUI);
64
65protected:
66 void SetupText();
67 void HandleMessage(SGUIMessage& Message);
68
69 /**
70 * Handle the <item> tag.
71 */
72 virtual bool HandleAdditionalChildren(const XMBData& xmb, const XMBElement& child);
73 virtual void AdditionalChildrenHandled();
74
75 virtual void DrawList(
76 CCanvas2D& canvas, const int& selected, const CGUISpriteInstance& sprite, const CGUISpriteInstance& spriteOverlay,
77 const CGUISpriteInstance& spriteSelectarea, const CGUISpriteInstance& spriteSelectAreaOverlay, const CGUIColor& textColor);
78
79 virtual CRect GetListRect() const;
80
81 /**
82 * Available columns.
83 */
84 std::vector<COListColumn> m_Columns;
85
93
94private:
96
97 // Width of space available for columns
100};
101
102#endif // INCLUDED_COLIST
#define GUI_OBJECT(obj)
Definition: IGUIObject.h:50
Definition: Canvas2D.h:36
Definition: CGUISprite.h:134
The main object that represents a whole GUI page.
Definition: CGUI.h:61
Create a list of elements, where one can be selected by the user.
Definition: CList.h:39
Represents a column.
Definition: COList.h:29
float m_Width
Definition: COList.h:43
CGUISimpleSetting< CGUIList > m_List
Definition: COList.h:45
NONCOPYABLE(COListColumn)
COListColumn(COListColumn &&)=default
COListColumn(IGUIObject *owner, const CStr &cid)
Definition: COList.h:31
CGUISimpleSetting< i32 > m_SortOrder
Definition: COList.h:47
CGUIColor m_TextColorSelected
Definition: COList.h:41
COListColumn & operator=(COListColumn &&)=delete
CGUISimpleSetting< CStrW > m_Heading
Definition: COList.h:44
CGUIColor m_TextColor
Definition: COList.h:40
CGUISimpleSetting< bool > m_Hidden
Definition: COList.h:46
CStr m_Id
Definition: COList.h:42
Multi-column list.
Definition: COList.h:59
CGUISimpleSetting< i32 > m_SelectedColumnOrder
Definition: COList.h:89
void HandleMessage(SGUIMessage &Message)
Definition: COList.cpp:123
CGUISimpleSetting< CStr > m_SelectedColumn
Definition: COList.h:88
CGUISimpleSetting< CGUISpriteInstance > m_SpriteHeading
Definition: COList.h:86
CGUISimpleSetting< CGUISpriteInstance > m_SpriteDesc
Definition: COList.h:91
static const CStr EventNameSelectionColumnChange
Definition: COList.h:95
CGUISimpleSetting< bool > m_Sortable
Definition: COList.h:87
virtual void DrawList(CCanvas2D &canvas, const int &selected, const CGUISpriteInstance &sprite, const CGUISpriteInstance &spriteOverlay, const CGUISpriteInstance &spriteSelectarea, const CGUISpriteInstance &spriteSelectAreaOverlay, const CGUIColor &textColor)
Definition: COList.cpp:300
std::vector< COListColumn > m_Columns
Available columns.
Definition: COList.h:84
void SetupText()
Sets up text, should be called every time changes has been made that can change the visual.
Definition: COList.cpp:46
float m_HeadingHeight
Definition: COList.h:99
float m_TotalAvailableColumnWidth
Definition: COList.h:98
virtual void AdditionalChildrenHandled()
Allow the GUI object to process after all child items were handled.
Definition: COList.cpp:295
CGUISimpleSetting< CGUISpriteInstance > m_SpriteAsc
Definition: COList.h:90
virtual bool HandleAdditionalChildren(const XMBData &xmb, const XMBElement &child)
Handle the <item> tag.
Definition: COList.cpp:184
COList(CGUI &pGUI)
Definition: COList.cpp:34
CGUISimpleSetting< CGUISpriteInstance > m_SpriteNotSorted
Definition: COList.h:92
virtual CRect GetListRect() const
Definition: COList.cpp:118
Rectangle class used for screen rectangles.
Definition: Rect.h:31
GUI object such as a button or an input-box.
Definition: IGUIObject.h:60
Definition: XMBData.h:96
Definition: XMBData.h:136
Same as the CColor class, but this one can also parse colors predefined in the GUI page (such as "yel...
Definition: CGUIColor.h:30
Message send to IGUIObject::HandleMessage() in order to give life to Objects manually with a derived ...
Definition: SGUIMessage.h:68