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