aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/source/Irrlicht/CGUIListBox.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CGUIListBox.h')
-rw-r--r--src/others/irrlicht-1.8.1/source/Irrlicht/CGUIListBox.h190
1 files changed, 190 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CGUIListBox.h b/src/others/irrlicht-1.8.1/source/Irrlicht/CGUIListBox.h
new file mode 100644
index 0000000..d00921f
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CGUIListBox.h
@@ -0,0 +1,190 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5#ifndef __C_GUI_LIST_BOX_H_INCLUDED__
6#define __C_GUI_LIST_BOX_H_INCLUDED__
7
8#include "IrrCompileConfig.h"
9#ifdef _IRR_COMPILE_WITH_GUI_
10
11#include "IGUIListBox.h"
12#include "irrArray.h"
13
14namespace irr
15{
16namespace gui
17{
18
19 class IGUIFont;
20 class IGUIScrollBar;
21
22 class CGUIListBox : public IGUIListBox
23 {
24 public:
25 //! constructor
26 CGUIListBox(IGUIEnvironment* environment, IGUIElement* parent,
27 s32 id, core::rect<s32> rectangle, bool clip=true,
28 bool drawBack=false, bool moveOverSelect=false);
29
30 //! destructor
31 virtual ~CGUIListBox();
32
33 //! returns amount of list items
34 virtual u32 getItemCount() const;
35
36 //! returns string of a list item. the id may be a value from 0 to itemCount-1
37 virtual const wchar_t* getListItem(u32 id) const;
38
39 //! adds an list item, returns id of item
40 virtual u32 addItem(const wchar_t* text);
41
42 //! clears the list
43 virtual void clear();
44
45 //! returns id of selected item. returns -1 if no item is selected.
46 virtual s32 getSelected() const;
47
48 //! sets the selected item. Set this to -1 if no item should be selected
49 virtual void setSelected(s32 id);
50
51 //! sets the selected item. Set this to -1 if no item should be selected
52 virtual void setSelected(const wchar_t *item);
53
54 //! called if an event happened.
55 virtual bool OnEvent(const SEvent& event);
56
57 //! draws the element and its children
58 virtual void draw();
59
60 //! adds an list item with an icon
61 //! \param text Text of list entry
62 //! \param icon Sprite index of the Icon within the current sprite bank. Set it to -1 if you want no icon
63 //! \return
64 //! returns the id of the new created item
65 virtual u32 addItem(const wchar_t* text, s32 icon);
66
67 //! Returns the icon of an item
68 virtual s32 getIcon(u32 id) const;
69
70 //! removes an item from the list
71 virtual void removeItem(u32 id);
72
73 //! get the the id of the item at the given absolute coordinates
74 virtual s32 getItemAt(s32 xpos, s32 ypos) const;
75
76 //! Sets the sprite bank which should be used to draw list icons. This font is set to the sprite bank of
77 //! the built-in-font by default. A sprite can be displayed in front of every list item.
78 //! An icon is an index within the icon sprite bank. Several default icons are available in the
79 //! skin through getIcon
80 virtual void setSpriteBank(IGUISpriteBank* bank);
81
82 //! set whether the listbox should scroll to newly selected items
83 virtual void setAutoScrollEnabled(bool scroll);
84
85 //! returns true if automatic scrolling is enabled, false if not.
86 virtual bool isAutoScrollEnabled() const;
87
88 //! Update the position and size of the listbox, and update the scrollbar
89 virtual void updateAbsolutePosition();
90
91 //! Writes attributes of the element.
92 virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
93
94 //! Reads attributes of the element
95 virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
96
97 //! set all item colors at given index to color
98 virtual void setItemOverrideColor(u32 index, video::SColor color);
99
100 //! set all item colors of specified type at given index to color
101 virtual void setItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType, video::SColor color);
102
103 //! clear all item colors at index
104 virtual void clearItemOverrideColor(u32 index);
105
106 //! clear item color at index for given colortype
107 virtual void clearItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType);
108
109 //! has the item at index its color overwritten?
110 virtual bool hasItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const;
111
112 //! return the overwrite color at given item index.
113 virtual video::SColor getItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const;
114
115 //! return the default color which is used for the given colorType
116 virtual video::SColor getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) const;
117
118 //! set the item at the given index
119 virtual void setItem(u32 index, const wchar_t* text, s32 icon);
120
121 //! Insert the item at the given index
122 //! Return the index on success or -1 on failure.
123 virtual s32 insertItem(u32 index, const wchar_t* text, s32 icon);
124
125 //! Swap the items at the given indices
126 virtual void swapItems(u32 index1, u32 index2);
127
128 //! set global itemHeight
129 virtual void setItemHeight( s32 height );
130
131 //! Sets whether to draw the background
132 virtual void setDrawBackground(bool draw);
133
134
135 private:
136
137 struct ListItem
138 {
139 ListItem() : icon(-1)
140 {}
141
142 core::stringw text;
143 s32 icon;
144
145 // A multicolor extension
146 struct ListItemOverrideColor
147 {
148 ListItemOverrideColor() : Use(false) {}
149 bool Use;
150 video::SColor Color;
151 };
152 ListItemOverrideColor OverrideColors[EGUI_LBC_COUNT];
153 };
154
155 void recalculateItemHeight();
156 void selectNew(s32 ypos, bool onlyHover=false);
157 void recalculateScrollPos();
158
159 // extracted that function to avoid copy&paste code
160 void recalculateItemWidth(s32 icon);
161
162 // get labels used for serialization
163 bool getSerializationLabels(EGUI_LISTBOX_COLOR colorType, core::stringc & useColorLabel, core::stringc & colorLabel) const;
164
165 core::array< ListItem > Items;
166 s32 Selected;
167 s32 ItemHeight;
168 s32 ItemHeightOverride;
169 s32 TotalItemHeight;
170 s32 ItemsIconWidth;
171 gui::IGUIFont* Font;
172 gui::IGUISpriteBank* IconBank;
173 gui::IGUIScrollBar* ScrollBar;
174 u32 selectTime;
175 u32 LastKeyTime;
176 core::stringw KeyBuffer;
177 bool Selecting;
178 bool DrawBack;
179 bool MoveOverSelect;
180 bool AutoScroll;
181 bool HighlightWhenNotFocused;
182 };
183
184
185} // end namespace gui
186} // end namespace irr
187
188#endif // _IRR_COMPILE_WITH_GUI_
189
190#endif