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/CList.h

Last change on this file was 27965, checked in by Vladislav Belov, 13 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: 5.1 KB
RevLine 
[25140]1/* Copyright (C) 2021 Wildfire Games.
[27965]2 * This file is part of 0 A.D.
[6830]3 *
[27965]4 * 0 A.D. is free software: you can redistribute it and/or modify
[6830]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,
[6830]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/>.
[6830]16 */
17
[5040]18#ifndef INCLUDED_CLIST
19#define INCLUDED_CLIST
[3802]20
[23005]21#include "gui/CGUISprite.h"
[24352]22#include "gui/ObjectBases/IGUIObject.h"
[23028]23#include "gui/ObjectBases/IGUIScrollBarOwner.h"
24#include "gui/ObjectBases/IGUITextOwner.h"
25#include "gui/SettingTypes/CGUIList.h"
[3802]26
[22941]27#include <vector>
28
[3802]29/**
30 * Create a list of elements, where one can be selected
31 * by the user. The control will use a pre-processed
32 * text-object for each element, which will be managed
33 * by the IGUITextOwner structure.
34 *
35 * A scroll-bar will appear when needed. This will be
[16931]36 * achieved with the IGUIScrollBarOwner structure.
[3802]37 */
[23020]38class CList : public IGUIObject, public IGUIScrollBarOwner, public IGUITextOwner
[3802]39{
40 GUI_OBJECT(CList)
41public:
[22741]42 CList(CGUI& pGUI);
[3802]43 virtual ~CList();
44
[9340]45 /**
46 * @see IGUIObject#ResetStates()
47 */
[23020]48 virtual void ResetStates();
[3802]49
50 /**
[23020]51 * @see IGUIObject#UpdateCachedSize()
52 */
53 virtual void UpdateCachedSize();
54
55 /**
[3802]56 * Adds an item last to the list.
57 */
[24306]58 virtual void AddItem(const CGUIString& str, const CGUIString& data);
[3802]59
[25225]60 /**
61 * Add an item where both parameters are identical.
62 */
63 void AddItem(const CGUIString& strAndData);
64
[3802]65protected:
66 /**
67 * Sets up text, should be called every time changes has been
68 * made that can change the visual.
[24306]69 * @param append - if true, we assume we only need to render the new element at the end of the list.
[3802]70 */
[14098]71 virtual void SetupText();
[24306]72 virtual void SetupText(bool append);
[3802]73
74 /**
[9340]75 * @see IGUIObject#HandleMessage()
[3802]76 */
[16931]77 virtual void HandleMessage(SGUIMessage& Message);
[3802]78
79 /**
80 * Handle events manually to catch keyboard inputting.
81 */
[24215]82 virtual InReaction ManuallyHandleKeys(const SDL_Event_* ev);
[3802]83
84 /**
85 * Draws the List box
86 */
[25588]87 virtual void Draw(CCanvas2D& canvas);
[3802]88
[24306]89 virtual void CreateJSObject();
90
[3802]91 /**
92 * Easy select elements functions
93 */
94 virtual void SelectNextElement();
95 virtual void SelectPrevElement();
96 virtual void SelectFirstElement();
97 virtual void SelectLastElement();
98
99 /**
[7813]100 * Handle the \<item\> tag.
[3802]101 */
[25378]102 virtual bool HandleAdditionalChildren(const XMBData& xmb, const XMBElement& child);
[3802]103
104 // Called every time the auto-scrolling should be checked.
105 void UpdateAutoScroll();
106
107 // Extended drawing interface, this is so that classes built on the this one
108 // can use other sprite names.
[25591]109 virtual void DrawList(CCanvas2D& canvas, const int& selected, const CGUISpriteInstance& sprite, const CGUISpriteInstance& spriteOverlay,
[25587]110 const CGUISpriteInstance& spriteSelectArea, const CGUISpriteInstance& spriteSelectAreaOverlay, const CGUIColor& textColor);
[3802]111
[12244]112 // Get the area of the list. This is so that it can easily be changed, like in CDropDown
[3802]113 // where the area is not equal to m_CachedActualSize.
114 virtual CRect GetListRect() const { return m_CachedActualSize; }
115
[12244]116 // Returns whether SetupText() has run since the last message was received
117 // (and thus whether list items have possibly changed).
118 virtual bool GetModified() const { return m_Modified; }
119
[3802]120 /**
121 * List of each element's relative y position. Will be
122 * one larger than m_Items, because it will end with the
123 * bottom of the last element. First element will always
124 * be zero, but still stored for easy handling.
125 */
126 std::vector<float> m_ItemsYPositions;
[12244]127
[19588]128 virtual int GetHoveredItem();
129
[25392]130 CGUISimpleSetting<float> m_BufferZone;
131 CGUISimpleSetting<CStrW> m_Font;
132 CGUISimpleSetting<bool> m_ScrollBar;
133 CGUISimpleSetting<CStr> m_ScrollBarStyle;
134 CGUISimpleSetting<bool> m_ScrollBottom;
135 CGUISimpleSetting<CStrW> m_SoundDisabled;
136 CGUISimpleSetting<CStrW> m_SoundSelected;
137 CGUISimpleSetting<CGUISpriteInstance> m_Sprite;
[25587]138 CGUISimpleSetting<CGUISpriteInstance> m_SpriteOverlay;
[25392]139 CGUISimpleSetting<CGUISpriteInstance> m_SpriteSelectArea;
[25587]140 CGUISimpleSetting<CGUISpriteInstance> m_SpriteSelectAreaOverlay;
[25392]141 CGUISimpleSetting<CGUIColor> m_TextColor;
142 CGUISimpleSetting<CGUIColor> m_TextColorSelected;
143 CGUISimpleSetting<i32> m_Selected;
144 CGUISimpleSetting<bool> m_AutoScroll;
145 CGUISimpleSetting<i32> m_Hovered;
146 CGUISimpleSetting<CGUIList> m_List;
147 CGUISimpleSetting<CGUIList> m_ListData;
[23005]148
[12244]149private:
[23403]150 static const CStr EventNameSelectionChange;
151 static const CStr EventNameHoverChange;
152 static const CStr EventNameMouseLeftClickItem;
153 static const CStr EventNameMouseLeftDoubleClickItem;
154
[12244]155 // Whether the list's items have been modified since last handling a message.
156 bool m_Modified;
[17274]157
158 // Used for doubleclick registration
159 int m_PrevSelectedItem;
160
161 // Last time a click on an item was issued
162 double m_LastItemClickTime;
[3802]163};
164
[16931]165#endif // INCLUDED_CLIST
Note: See TracBrowser for help on using the repository browser.