This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

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

Last change on this file was 28135, checked in by Stan, 6 months ago

Finish implementing property "textcolor_selected" for list GUI objects
Fixes #6920
Patch by: @Vantha
Differential Revision: https://code.wildfiregames.com/D5269

  • Property svn:eol-style set to native
File size: 3.0 KB
RevLine 
[28135]1/* Copyright (C) 2024 Wildfire Games.
[27965]2 * This file is part of 0 A.D.
[15300]3 *
[27965]4 * 0 A.D. is free software: you can redistribute it and/or modify
[15300]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 *
[27965]9 * 0 A.D. is distributed in the hope that it will be useful,
[15300]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
[27965]15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
[15300]16 */
[14098]17#ifndef INCLUDED_COLIST
18#define INCLUDED_COLIST
19
[23028]20#include "gui/ObjectTypes/CList.h"
21#include "gui/SettingTypes/CGUIColor.h"
[14098]22
[22941]23#include <vector>
24
[18339]25/**
26 * Represents a column.
27 */
[25392]28class COListColumn
[14098]29{
[25392]30public:
31 COListColumn(IGUIObject* owner, const CStr& cid)
[27384]32 : m_Id(cid), m_Width(0), m_Heading(owner, "heading_" + cid), m_List(owner, "list_" + cid),
[27429]33 m_Hidden(owner, "hidden_" + cid, false), m_SortOrder(owner, " sort_order_" + cid, 1)
[25392]34 {}
[22638]35 // Avoid copying the strings.
36 NONCOPYABLE(COListColumn);
[27763]37 COListColumn(COListColumn&&) = default;
38 COListColumn& operator=(COListColumn&&) = delete;
39
[22638]40 CGUIColor m_TextColor;
[28135]41 CGUIColor m_TextColorSelected;
[22638]42 CStr m_Id;
43 float m_Width;
[27384]44 CGUISimpleSetting<CStrW> m_Heading; // CGUIString??
[25392]45 CGUISimpleSetting<CGUIList> m_List;
46 CGUISimpleSetting<bool> m_Hidden;
[27398]47 CGUISimpleSetting<i32> m_SortOrder;
[14098]48};
49
50/**
[16931]51 * Multi-column list. One row can be selected by the user.
52 * Individual cells are clipped if the contained text is too long.
[14098]53 *
[16931]54 * The list can be sorted dynamically by JS code when a
[18339]55 * heading is clicked.
[16931]56 * A scroll-bar will appear when needed.
[14098]57 */
58class COList : public CList
59{
60 GUI_OBJECT(COList)
61
62public:
[22741]63 COList(CGUI& pGUI);
[14098]64
65protected:
66 void SetupText();
[16931]67 void HandleMessage(SGUIMessage& Message);
[14098]68
69 /**
70 * Handle the \<item\> tag.
71 */
[25378]72 virtual bool HandleAdditionalChildren(const XMBData& xmb, const XMBElement& child);
[23005]73 virtual void AdditionalChildrenHandled();
[14098]74
[25591]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);
[14098]78
79 virtual CRect GetListRect() const;
80
[18339]81 /**
82 * Available columns.
83 */
[18652]84 std::vector<COListColumn> m_Columns;
[18339]85
[25392]86 CGUISimpleSetting<CGUISpriteInstance> m_SpriteHeading;
87 CGUISimpleSetting<bool> m_Sortable;
88 CGUISimpleSetting<CStr> m_SelectedColumn;
89 CGUISimpleSetting<i32> m_SelectedColumnOrder;
90 CGUISimpleSetting<CGUISpriteInstance> m_SpriteAsc;
91 CGUISimpleSetting<CGUISpriteInstance> m_SpriteDesc;
92 CGUISimpleSetting<CGUISpriteInstance> m_SpriteNotSorted;
[23005]93
[14098]94private:
[23403]95 static const CStr EventNameSelectionColumnChange;
96
[18652]97 // Width of space available for columns
98 float m_TotalAvailableColumnWidth;
[22066]99 float m_HeadingHeight;
[14098]100};
101
102#endif // INCLUDED_COLIST
Note: See TracBrowser for help on using the repository browser.