]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/CGUIComboBox.h
Reduce IrrCompileConfig usage to files that actually need it
[irrlicht.git] / source / Irrlicht / CGUIComboBox.h
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
4 \r
5 #ifndef __C_GUI_COMBO_BOX_H_INCLUDED__\r
6 #define __C_GUI_COMBO_BOX_H_INCLUDED__\r
7 \r
8 #include "IGUIComboBox.h"\r
9 #include "IGUIStaticText.h"\r
10 #include "irrString.h"\r
11 #include "irrArray.h"\r
12 \r
13 namespace irr\r
14 {\r
15 namespace gui\r
16 {\r
17         class IGUIButton;\r
18         class IGUIListBox;\r
19 \r
20         //! Single line edit box for editing simple text.\r
21         class CGUIComboBox : public IGUIComboBox\r
22         {\r
23         public:\r
24 \r
25                 //! constructor\r
26                 CGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent,\r
27                         s32 id, core::rect<s32> rectangle);\r
28 \r
29                 //! Returns amount of items in box\r
30                 u32 getItemCount() const override;\r
31 \r
32                 //! returns string of an item. the idx may be a value from 0 to itemCount-1\r
33                 const wchar_t* getItem(u32 idx) const override;\r
34 \r
35                 //! Returns item data of an item. the idx may be a value from 0 to itemCount-1\r
36                 u32 getItemData(u32 idx) const override;\r
37 \r
38                 //! Returns index based on item data\r
39                 s32 getIndexForItemData( u32 data ) const override;\r
40 \r
41                 //! adds an item and returns the index of it\r
42                 u32 addItem(const wchar_t* text, u32 data) override;\r
43 \r
44                 //! Removes an item from the combo box.\r
45                 void removeItem(u32 id) override;\r
46 \r
47                 //! deletes all items in the combo box\r
48                 void clear() override;\r
49 \r
50                 //! returns the text of the currently selected item\r
51                 const wchar_t* getText() const override;\r
52 \r
53                 //! returns id of selected item. returns -1 if no item is selected.\r
54                 s32 getSelected() const override;\r
55 \r
56                 //! sets the selected item. Set this to -1 if no item should be selected\r
57                 void setSelected(s32 idx) override;\r
58 \r
59                 //! sets the text alignment of the text part\r
60                 void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) override;\r
61 \r
62                 //! Set the maximal number of rows for the selection listbox\r
63                 void setMaxSelectionRows(u32 max) override;\r
64 \r
65                 //! Get the maximal number of rows for the selection listbox\r
66                 u32 getMaxSelectionRows() const override;\r
67 \r
68                 //! called if an event happened.\r
69                 bool OnEvent(const SEvent& event) override;\r
70 \r
71                 //! draws the element and its children\r
72                 void draw() override;\r
73 \r
74         private:\r
75 \r
76                 void openCloseMenu();\r
77                 void sendSelectionChangedEvent();\r
78                 void updateListButtonWidth(s32 width);\r
79 \r
80                 IGUIButton* ListButton;\r
81                 IGUIStaticText* SelectedText;\r
82                 IGUIListBox* ListBox;\r
83                 IGUIElement *LastFocus;\r
84 \r
85 \r
86                 struct SComboData\r
87                 {\r
88                         SComboData ( const wchar_t * text, u32 data )\r
89                                 : Name (text), Data ( data ) {}\r
90 \r
91                         core::stringw Name;\r
92                         u32 Data;\r
93                 };\r
94                 core::array< SComboData > Items;\r
95 \r
96                 s32 Selected;\r
97                 EGUI_ALIGNMENT HAlign, VAlign;\r
98                 u32 MaxSelectionRows;\r
99                 bool HasFocus;\r
100                 IGUIFont* ActiveFont;\r
101         };\r
102 \r
103 \r
104 } // end namespace gui\r
105 } // end namespace irr\r
106 \r
107 #endif // __C_GUI_COMBO_BOX_H_INCLUDED__\r