source: ps/trunk/source/gui/ObjectTypes/COList.h@ 27965

Last change on this file since 27965 was 27965, checked in by Vladislav Belov, 8 months ago

Revert non-ASCII characters from source and configuration files introduced in rP27786.

Fixes #6846

Differential Revision: https://code.wildfiregames.com/D5185

  • Property svn:eol-style set to native
File size: 2.9 KB
Line 
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"
21#include "gui/SettingTypes/CGUIColor.h"
22
23#include <vector>
24
25/**
26 * Represents a column.
27 */
28class COListColumn
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.
36 NONCOPYABLE(COListColumn);
37 COListColumn(COListColumn&&) = default;
38 COListColumn& operator=(COListColumn&&) = delete;
39
40 CGUIColor m_TextColor;
41 CStr m_Id;
42 float m_Width;
43 CGUISimpleSetting<CStrW> m_Heading; // CGUIString??
44 CGUISimpleSetting<CGUIList> m_List;
45 CGUISimpleSetting<bool> m_Hidden;
46 CGUISimpleSetting<i32> m_SortOrder;
47};
48
49/**
50 * Multi-column list. One row can be selected by the user.
51 * Individual cells are clipped if the contained text is too long.
52 *
53 * The list can be sorted dynamically by JS code when a
54 * heading is clicked.
55 * A scroll-bar will appear when needed.
56 */
57class COList : public CList
58{
59 GUI_OBJECT(COList)
60
61public:
62 COList(CGUI& pGUI);
63
64protected:
65 void SetupText();
66 void HandleMessage(SGUIMessage& Message);
67
68 /**
69 * Handle the \<item\> tag.
70 */
71 virtual bool HandleAdditionalChildren(const XMBData& xmb, const XMBElement& child);
72 virtual void AdditionalChildrenHandled();
73
74 virtual void DrawList(
75 CCanvas2D& canvas, const int& selected, const CGUISpriteInstance& sprite, const CGUISpriteInstance& spriteOverlay,
76 const CGUISpriteInstance& spriteSelectarea, const CGUISpriteInstance& spriteSelectAreaOverlay, const CGUIColor& textColor);
77
78 virtual CRect GetListRect() const;
79
80 /**
81 * Available columns.
82 */
83 std::vector<COListColumn> m_Columns;
84
85 CGUISimpleSetting<CGUISpriteInstance> m_SpriteHeading;
86 CGUISimpleSetting<bool> m_Sortable;
87 CGUISimpleSetting<CStr> m_SelectedColumn;
88 CGUISimpleSetting<i32> m_SelectedColumnOrder;
89 CGUISimpleSetting<CGUISpriteInstance> m_SpriteAsc;
90 CGUISimpleSetting<CGUISpriteInstance> m_SpriteDesc;
91 CGUISimpleSetting<CGUISpriteInstance> m_SpriteNotSorted;
92
93private:
94 static const CStr EventNameSelectionColumnChange;
95
96 // Width of space available for columns
97 float m_TotalAvailableColumnWidth;
98 float m_HeadingHeight;
99};
100
101#endif // INCLUDED_COLIST
Note: See TracBrowser for help on using the repository browser.