Pyrogenesis  trunk
COList.h
Go to the documentation of this file.
1 /* Copyright (C) 2023 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 
20 #include "gui/ObjectTypes/CList.h"
22 
23 #include <vector>
24 
25 /**
26  * Represents a column.
27  */
29 {
30 public:
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  CStr m_Id;
40  float m_Width;
45 };
46 
47 /**
48  * Multi-column list. One row can be selected by the user.
49  * Individual cells are clipped if the contained text is too long.
50  *
51  * The list can be sorted dynamically by JS code when a
52  * heading is clicked.
53  * A scroll-bar will appear when needed.
54  */
55 class COList : public CList
56 {
58 
59 public:
60  COList(CGUI& pGUI);
61 
62 protected:
63  void SetupText();
64  void HandleMessage(SGUIMessage& Message);
65 
66  /**
67  * Handle the <item> tag.
68  */
69  virtual bool HandleAdditionalChildren(const XMBData& xmb, const XMBElement& child);
70  virtual void AdditionalChildrenHandled();
71 
72  virtual void DrawList(
73  CCanvas2D& canvas, const int& selected, const CGUISpriteInstance& sprite, const CGUISpriteInstance& spriteOverlay,
74  const CGUISpriteInstance& spriteSelectarea, const CGUISpriteInstance& spriteSelectAreaOverlay, const CGUIColor& textColor);
75 
76  virtual CRect GetListRect() const;
77 
78  /**
79  * Available columns.
80  */
81  std::vector<COListColumn> m_Columns;
82 
90 
91 private:
92  static const CStr EventNameSelectionColumnChange;
93 
94  // Width of space available for columns
97 };
98 
99 #endif // INCLUDED_COLIST
CGUISimpleSetting< CGUISpriteInstance > m_SpriteNotSorted
Definition: COList.h:89
CGUISimpleSetting< CGUISpriteInstance > m_SpriteDesc
Definition: COList.h:88
CGUISimpleSetting< CStrW > m_Heading
Definition: COList.h:41
Same as the CColor class, but this one can also parse colors predefined in the GUI page (such as "yel...
Definition: CGUIColor.h:29
Represents a column.
Definition: COList.h:28
CGUISimpleSetting< CGUISpriteInstance > m_SpriteAsc
Definition: COList.h:87
CStr m_Id
Definition: COList.h:39
Definition: XMBData.h:135
float m_Width
Definition: COList.h:40
GUI object such as a button or an input-box.
Definition: IGUIObject.h:59
CGUISimpleSetting< i32 > m_SelectedColumnOrder
Definition: COList.h:86
The main object that represents a whole GUI page.
Definition: CGUI.h:60
CGUISimpleSetting< CGUISpriteInstance > m_SpriteHeading
Definition: COList.h:83
MOVABLE(COListColumn)
CGUISimpleSetting< CGUIList > m_List
Definition: COList.h:42
CGUISimpleSetting< bool > m_Hidden
Definition: COList.h:43
COListColumn(IGUIObject *owner, const CStr &cid)
Definition: COList.h:31
Definition: XMBData.h:95
float m_HeadingHeight
Definition: COList.h:96
Definition: Canvas2D.h:35
CGUISimpleSetting< CStr > m_SelectedColumn
Definition: COList.h:85
CGUISimpleSetting< i32 > m_SortOrder
Definition: COList.h:44
Create a list of elements, where one can be selected by the user.
Definition: CList.h:38
#define GUI_OBJECT(obj)
Definition: IGUIObject.h:50
std::vector< COListColumn > m_Columns
Available columns.
Definition: COList.h:81
Definition: CGUISprite.h:133
NONCOPYABLE(COListColumn)
Message send to IGUIObject::HandleMessage() in order to give life to Objects manually with a derived ...
Definition: SGUIMessage.h:67
CGUIColor m_TextColor
Definition: COList.h:38
static const CStr EventNameSelectionColumnChange
Definition: COList.h:92
float m_TotalAvailableColumnWidth
Definition: COList.h:95
CGUISimpleSetting< bool > m_Sortable
Definition: COList.h:84
Multi-column list.
Definition: COList.h:55
Rectangle class used for screen rectangles.
Definition: Rect.h:30