#ifndef __C_GUI_LIST_BOX_H_INCLUDED__
#define __C_GUI_LIST_BOX_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIListBox.h"
#include "irrArray.h"
namespace irr
{
namespace gui
{
class IGUIFont;
class IGUIScrollBar;
class CGUIListBox : public IGUIListBox
{
public:
CGUIListBox(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle, bool clip=true,
bool drawBack=false, bool moveOverSelect=false);
virtual ~CGUIListBox();
virtual u32 getItemCount() const;
virtual const wchar_t* getListItem(u32 id) const;
virtual u32 addItem(const wchar_t* text);
virtual void clear();
virtual s32 getSelected() const;
virtual void setSelected(s32 id);
virtual void setSelected(const wchar_t *item);
virtual bool OnEvent(const SEvent& event);
virtual void draw();
virtual u32 addItem(const wchar_t* text, s32 icon);
virtual s32 getIcon(u32 id) const;
virtual void removeItem(u32 id);
virtual void setSpriteBank(IGUISpriteBank* bank);
virtual void setAutoScrollEnabled(bool scroll);
virtual bool isAutoScrollEnabled() const;
virtual void updateAbsolutePosition();
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
virtual void setItemOverrideColor(u32 index, const video::SColor &color);
virtual void setItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType, const video::SColor &color);
virtual void clearItemOverrideColor(u32 index);
virtual void clearItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType);
virtual bool hasItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const;
virtual video::SColor getItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const;
virtual video::SColor getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) const;
virtual void setItem(u32 index, const wchar_t* text, s32 icon);
virtual s32 insertItem(u32 index, const wchar_t* text, s32 icon);
virtual void swapItems(u32 index1, u32 index2);
virtual void setItemHeight( s32 height );
virtual void setDrawBackground(bool draw);
private:
struct ListItem
{
ListItem() : icon(-1)
{}
core::stringw text;
s32 icon;
struct ListItemOverrideColor
{
ListItemOverrideColor() : Use(false) {}
bool Use;
video::SColor Color;
};
ListItemOverrideColor OverrideColors[EGUI_LBC_COUNT];
};
void recalculateItemHeight();
void selectNew(s32 ypos, bool onlyHover=false);
void recalculateScrollPos();
void recalculateItemWidth(s32 icon);
bool getSerializationLabels(EGUI_LISTBOX_COLOR colorType, core::stringc & useColorLabel, core::stringc & colorLabel) const;
core::array< ListItem > Items;
s32 Selected;
s32 ItemHeight;
s32 ItemHeightOverride;
s32 TotalItemHeight;
s32 ItemsIconWidth;
gui::IGUIFont* Font;
gui::IGUISpriteBank* IconBank;
gui::IGUIScrollBar* ScrollBar;
u32 selectTime;
u32 LastKeyTime;
core::stringw KeyBuffer;
bool Selecting;
bool DrawBack;
bool MoveOverSelect;
bool AutoScroll;
bool HighlightWhenNotFocused;
};
}
}
#endif
#endif