Added different textures for each ptolemaic camel rank
[0ad.git] / source / gui / CList.h
blobcd88aff5fd597fc9fd9c994504536badf127fea6
1 /* Copyright (C) 2009 Wildfire Games.
2 * This file is part of 0 A.D.
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.
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.
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/>.
19 GUI Object - List [box]
21 --Overview--
23 GUI Object for creating lists of information, wherein one
24 of the elements can be selected. A scroll-bar will aid
25 when there's too much information to be displayed at once.
27 --More info--
29 Check GUI.h
33 #ifndef INCLUDED_CLIST
34 #define INCLUDED_CLIST
36 //--------------------------------------------------------
37 // Includes / Compiler directives
38 //--------------------------------------------------------
40 #include "IGUIScrollBar.h"
42 //--------------------------------------------------------
43 // Macros
44 //--------------------------------------------------------
46 //--------------------------------------------------------
47 // Types
48 //--------------------------------------------------------
50 //--------------------------------------------------------
51 // Declarations
52 //--------------------------------------------------------
55 /**
56 * Create a list of elements, where one can be selected
57 * by the user. The control will use a pre-processed
58 * text-object for each element, which will be managed
59 * by the IGUITextOwner structure.
61 * A scroll-bar will appear when needed. This will be
62 * achieve with the IGUIScrollBarOwner structure.
66 class CList : public IGUIScrollBarOwner, public IGUITextOwner
68 GUI_OBJECT(CList)
70 public:
71 CList();
72 virtual ~CList();
74 /**
75 * @see IGUIObject#ResetStates()
77 virtual void ResetStates() { IGUIScrollBarOwner::ResetStates(); }
79 /**
80 * Adds an item last to the list.
82 virtual void AddItem(const CStrW& str, const CStrW& data);
84 protected:
85 /**
86 * Sets up text, should be called every time changes has been
87 * made that can change the visual.
89 virtual void SetupText();
91 /**
92 * @see IGUIObject#HandleMessage()
94 virtual void HandleMessage(SGUIMessage &Message);
96 /**
97 * Handle events manually to catch keyboard inputting.
99 virtual InReaction ManuallyHandleEvent(const SDL_Event_* ev);
102 * Draws the List box
104 virtual void Draw();
107 * Easy select elements functions
109 virtual void SelectNextElement();
110 virtual void SelectPrevElement();
111 virtual void SelectFirstElement();
112 virtual void SelectLastElement();
115 * Handle the \<item\> tag.
117 virtual bool HandleAdditionalChildren(const XMBElement& child, CXeromyces* pFile);
119 // Called every time the auto-scrolling should be checked.
120 void UpdateAutoScroll();
122 // Extended drawing interface, this is so that classes built on the this one
123 // can use other sprite names.
124 virtual void DrawList(const int &selected, const CStr& _sprite,
125 const CStr& _sprite_selected, const CStr& _textcolor);
127 // Get the area of the list. This is so that it can easily be changed, like in CDropDown
128 // where the area is not equal to m_CachedActualSize.
129 virtual CRect GetListRect() const { return m_CachedActualSize; }
131 // Returns whether SetupText() has run since the last message was received
132 // (and thus whether list items have possibly changed).
133 virtual bool GetModified() const { return m_Modified; }
135 // List of items.
136 //CGUIList m_List;
139 * List of each element's relative y position. Will be
140 * one larger than m_Items, because it will end with the
141 * bottom of the last element. First element will always
142 * be zero, but still stored for easy handling.
144 std::vector<float> m_ItemsYPositions;
146 private:
147 // Whether the list's items have been modified since last handling a message.
148 bool m_Modified;
151 #endif