Changeset View
Changeset View
Standalone View
Standalone View
source/gui/ObjectTypes/COList.h
/* Copyright (C) 2019 Wildfire Games. | /* Copyright (C) 2021 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
Show All 10 Lines | |||||
#include "gui/ObjectTypes/CList.h" | #include "gui/ObjectTypes/CList.h" | ||||
#include "gui/SettingTypes/CGUIColor.h" | #include "gui/SettingTypes/CGUIColor.h" | ||||
#include <vector> | #include <vector> | ||||
/** | /** | ||||
* Represents a column. | * Represents a column. | ||||
*/ | */ | ||||
struct COListColumn | class COListColumn | ||||
{ | { | ||||
public: | |||||
COListColumn(IGUIObject* owner, const CStr& cid) | |||||
: m_Width(0), m_Id(cid), m_List(owner, "list_" + cid), m_Hidden(owner, "hidden_" + cid, false) | |||||
{} | |||||
// Avoid copying the strings. | // Avoid copying the strings. | ||||
NONCOPYABLE(COListColumn); | NONCOPYABLE(COListColumn); | ||||
MOVABLE(COListColumn); | MOVABLE(COListColumn); | ||||
COListColumn() : m_Width(0), m_Hidden(false) {} | |||||
CGUIColor m_TextColor; | CGUIColor m_TextColor; | ||||
CStr m_Id; | CStr m_Id; | ||||
float m_Width; | float m_Width; | ||||
CStrW m_Heading; // CGUIString?? | CStrW m_Heading; // CGUIString?? | ||||
CGUIList m_List; | CGUISimpleSetting<CGUIList> m_List; | ||||
bool m_Hidden; | CGUISimpleSetting<bool> m_Hidden; | ||||
}; | }; | ||||
/** | /** | ||||
* Multi-column list. One row can be selected by the user. | * Multi-column list. One row can be selected by the user. | ||||
* Individual cells are clipped if the contained text is too long. | * Individual cells are clipped if the contained text is too long. | ||||
* | * | ||||
* The list can be sorted dynamically by JS code when a | * The list can be sorted dynamically by JS code when a | ||||
* heading is clicked. | * heading is clicked. | ||||
Show All 20 Lines | protected: | ||||
virtual CRect GetListRect() const; | virtual CRect GetListRect() const; | ||||
/** | /** | ||||
* Available columns. | * Available columns. | ||||
*/ | */ | ||||
std::vector<COListColumn> m_Columns; | std::vector<COListColumn> m_Columns; | ||||
// Settings | CGUISimpleSetting<CGUISpriteInstance> m_SpriteHeading; | ||||
CGUISpriteInstance m_SpriteHeading; | CGUISimpleSetting<bool> m_Sortable; | ||||
bool m_Sortable; | CGUISimpleSetting<CStr> m_SelectedColumn; | ||||
CStr m_SelectedColumn; | CGUISimpleSetting<i32> m_SelectedColumnOrder; | ||||
i32 m_SelectedColumnOrder; | CGUISimpleSetting<CGUISpriteInstance> m_SpriteAsc; | ||||
CGUISpriteInstance m_SpriteAsc; | CGUISimpleSetting<CGUISpriteInstance> m_SpriteDesc; | ||||
CGUISpriteInstance m_SpriteDesc; | CGUISimpleSetting<CGUISpriteInstance> m_SpriteNotSorted; | ||||
CGUISpriteInstance m_SpriteNotSorted; | |||||
private: | private: | ||||
static const CStr EventNameSelectionColumnChange; | static const CStr EventNameSelectionColumnChange; | ||||
// Width of space available for columns | // Width of space available for columns | ||||
float m_TotalAvailableColumnWidth; | float m_TotalAvailableColumnWidth; | ||||
float m_HeadingHeight; | float m_HeadingHeight; | ||||
}; | }; | ||||
#endif // INCLUDED_COLIST | #endif // INCLUDED_COLIST |
Wildfire Games · Phabricator