1
// Copyright (C) 2002-2011 Nikolaus Gebhardt
2
// This file is part of the "Irrlicht Engine".
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
5
#ifndef __C_GUI_COMBO_BOX_H_INCLUDED__
6
#define __C_GUI_COMBO_BOX_H_INCLUDED__
8
#include "IrrCompileConfig.h"
9
#ifdef _IRR_COMPILE_WITH_GUI_
11
#include "IGUIComboBox.h"
12
#include "IGUIStaticText.h"
13
#include "irrString.h"
23
//! Single line edit box for editing simple text.
24
class CGUIComboBox : public IGUIComboBox
29
CGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent,
30
s32 id, core::rect<s32> rectangle);
32
//! Returns amount of items in box
33
virtual u32 getItemCount() const;
35
//! returns string of an item. the idx may be a value from 0 to itemCount-1
36
virtual const wchar_t* getItem(u32 idx) const;
38
//! Returns item data of an item. the idx may be a value from 0 to itemCount-1
39
virtual u32 getItemData(u32 idx) const;
41
//! Returns index based on item data
42
virtual s32 getIndexForItemData( u32 data ) const;
44
//! adds an item and returns the index of it
45
virtual u32 addItem(const wchar_t* text, u32 data);
47
//! Removes an item from the combo box.
48
virtual void removeItem(u32 id);
50
//! deletes all items in the combo box
53
//! returns the text of the currently selected item
54
virtual const wchar_t* getText() const;
56
//! returns id of selected item. returns -1 if no item is selected.
57
virtual s32 getSelected() const;
59
//! sets the selected item. Set this to -1 if no item should be selected
60
virtual void setSelected(s32 idx);
62
//! sets the text alignment of the text part
63
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical);
65
//! called if an event happened.
66
virtual bool OnEvent(const SEvent& event);
68
//! draws the element and its children
71
//! Writes attributes of the element.
72
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
74
//! Reads attributes of the element
75
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
80
void sendSelectionChangedEvent();
82
IGUIButton* ListButton;
83
IGUIStaticText* SelectedText;
85
IGUIElement *LastFocus;
90
SComboData ( const wchar_t * text, u32 data )
91
: Name (text), Data ( data ) {}
96
core::array< SComboData > Items;
99
EGUI_ALIGNMENT HAlign, VAlign;
104
} // end namespace gui
105
} // end namespace irr
107
#endif // _IRR_COMPILE_WITH_GUI_
109
#endif // __C_GUI_COMBO_BOX_H_INCLUDED__