1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
\r
2 // This file is part of the "Irrlicht Engine".
\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
\r
5 #ifndef __C_GUI_COMBO_BOX_H_INCLUDED__
\r
6 #define __C_GUI_COMBO_BOX_H_INCLUDED__
\r
8 #include "IrrCompileConfig.h"
\r
9 #ifdef _IRR_COMPILE_WITH_GUI_
\r
11 #include "IGUIComboBox.h"
\r
12 #include "IGUIStaticText.h"
\r
13 #include "irrString.h"
\r
14 #include "irrArray.h"
\r
23 //! Single line edit box for editing simple text.
\r
24 class CGUIComboBox : public IGUIComboBox
\r
29 CGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent,
\r
30 s32 id, core::rect<s32> rectangle);
\r
32 //! Returns amount of items in box
\r
33 u32 getItemCount() const override;
\r
35 //! returns string of an item. the idx may be a value from 0 to itemCount-1
\r
36 const wchar_t* getItem(u32 idx) const override;
\r
38 //! Returns item data of an item. the idx may be a value from 0 to itemCount-1
\r
39 u32 getItemData(u32 idx) const override;
\r
41 //! Returns index based on item data
\r
42 s32 getIndexForItemData( u32 data ) const override;
\r
44 //! adds an item and returns the index of it
\r
45 u32 addItem(const wchar_t* text, u32 data) override;
\r
47 //! Removes an item from the combo box.
\r
48 void removeItem(u32 id) override;
\r
50 //! deletes all items in the combo box
\r
51 void clear() override;
\r
53 //! returns the text of the currently selected item
\r
54 const wchar_t* getText() const override;
\r
56 //! returns id of selected item. returns -1 if no item is selected.
\r
57 s32 getSelected() const override;
\r
59 //! sets the selected item. Set this to -1 if no item should be selected
\r
60 void setSelected(s32 idx) override;
\r
62 //! sets the text alignment of the text part
\r
63 void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) override;
\r
65 //! Set the maximal number of rows for the selection listbox
\r
66 void setMaxSelectionRows(u32 max) override;
\r
68 //! Get the maximal number of rows for the selection listbox
\r
69 u32 getMaxSelectionRows() const override;
\r
71 //! called if an event happened.
\r
72 bool OnEvent(const SEvent& event) override;
\r
74 //! draws the element and its children
\r
75 void draw() override;
\r
79 void openCloseMenu();
\r
80 void sendSelectionChangedEvent();
\r
81 void updateListButtonWidth(s32 width);
\r
83 IGUIButton* ListButton;
\r
84 IGUIStaticText* SelectedText;
\r
85 IGUIListBox* ListBox;
\r
86 IGUIElement *LastFocus;
\r
91 SComboData ( const wchar_t * text, u32 data )
\r
92 : Name (text), Data ( data ) {}
\r
97 core::array< SComboData > Items;
\r
100 EGUI_ALIGNMENT HAlign, VAlign;
\r
101 u32 MaxSelectionRows;
\r
103 IGUIFont* ActiveFont;
\r
107 } // end namespace gui
\r
108 } // end namespace irr
\r
110 #endif // _IRR_COMPILE_WITH_GUI_
\r
112 #endif // __C_GUI_COMBO_BOX_H_INCLUDED__
\r