]> git.lizzy.rs Git - irrlicht.git/blob - include/IGUITable.h
Make irrArray backed by std::vector (#101)
[irrlicht.git] / include / IGUITable.h
1 // Copyright (C) 2003-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 __I_GUI_TABLE_H_INCLUDED__\r
6 #define __I_GUI_TABLE_H_INCLUDED__\r
7 \r
8 #include "IGUIElement.h"\r
9 #include "SColor.h"\r
10 \r
11 namespace irr\r
12 {\r
13 namespace gui\r
14 {\r
15         class IGUIFont;\r
16         class IGUIScrollBar;\r
17 \r
18         //! modes for ordering used when a column header is clicked\r
19         enum EGUI_COLUMN_ORDERING\r
20         {\r
21                 //! Do not use ordering\r
22                 EGCO_NONE,\r
23 \r
24                 //! Send a EGET_TABLE_HEADER_CHANGED message when a column header is clicked.\r
25                 EGCO_CUSTOM,\r
26 \r
27                 //! Sort it ascending by it's ascii value like: a,b,c,...\r
28                 EGCO_ASCENDING,\r
29 \r
30                 //! Sort it descending by it's ascii value like: z,x,y,...\r
31                 EGCO_DESCENDING,\r
32 \r
33                 //! Sort it ascending on first click, descending on next, etc\r
34                 EGCO_FLIP_ASCENDING_DESCENDING,\r
35 \r
36                 //! Not used as mode, only to get maximum value for this enum\r
37                 EGCO_COUNT\r
38         };\r
39 \r
40         //! Names for EGUI_COLUMN_ORDERING types\r
41         const c8* const GUIColumnOrderingNames[] =\r
42         {\r
43                 "none",\r
44                 "custom",\r
45                 "ascend",\r
46                 "descend",\r
47                 "ascend_descend",\r
48                 0,\r
49         };\r
50 \r
51         enum EGUI_ORDERING_MODE\r
52         {\r
53                 //! No element ordering\r
54                 EGOM_NONE,\r
55 \r
56                 //! Elements are ordered from the smallest to the largest.\r
57                 EGOM_ASCENDING,\r
58 \r
59                 //! Elements are ordered from the largest to the smallest.\r
60                 EGOM_DESCENDING,\r
61 \r
62                 //! this value is not used, it only specifies the amount of default ordering types\r
63                 //! available.\r
64                 EGOM_COUNT\r
65         };\r
66 \r
67         const c8* const GUIOrderingModeNames[] =\r
68         {\r
69                 "none",\r
70                 "ascending",\r
71                 "descending",\r
72                 0\r
73         };\r
74 \r
75         enum EGUI_TABLE_DRAW_FLAGS\r
76         {\r
77                 EGTDF_ROWS = 1,\r
78                 EGTDF_COLUMNS = 2,\r
79                 EGTDF_ACTIVE_ROW = 4,\r
80                 EGTDF_COUNT\r
81         };\r
82 \r
83         //! Default list box GUI element.\r
84         /** \par This element can create the following events of type EGUI_EVENT_TYPE:\r
85         \li EGET_TABLE_CHANGED\r
86         \li EGET_TABLE_SELECTED_AGAIN\r
87         \li EGET_TABLE_HEADER_CHANGED\r
88         */\r
89         class IGUITable : public IGUIElement\r
90         {\r
91         public:\r
92                 //! constructor\r
93                 IGUITable(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)\r
94                         : IGUIElement(EGUIET_TABLE, environment, parent, id, rectangle) {}\r
95 \r
96                 //! Adds a column\r
97                 /** If columnIndex is outside the current range, do push new column at the end */\r
98                 virtual void addColumn(const wchar_t* caption, s32 columnIndex=-1) = 0;\r
99 \r
100                 //! remove a column from the table\r
101                 virtual void removeColumn(u32 columnIndex) = 0;\r
102 \r
103                 //! Returns the number of columns in the table control\r
104                 virtual s32 getColumnCount() const = 0;\r
105 \r
106                 //! Makes a column active. This will trigger an ordering process.\r
107                 /** \param idx: The id of the column to make active or a negative number to make non active.\r
108                 \param doOrder: Do also the ordering which depending on mode for active column\r
109                 \return True when the column could be set active (aka - it did exist). */\r
110                 virtual bool setActiveColumn(s32 idx, bool doOrder=false) = 0;\r
111 \r
112                 //! Returns which header is currently active\r
113                 virtual s32 getActiveColumn() const = 0;\r
114 \r
115                 //! Returns the ordering used by the currently active column\r
116                 virtual EGUI_ORDERING_MODE getActiveColumnOrdering() const = 0;\r
117 \r
118                 //! Set the width of a column\r
119                 virtual void setColumnWidth(u32 columnIndex, u32 width) = 0;\r
120 \r
121                 //! Get the width of a column\r
122                 virtual u32 getColumnWidth(u32 columnIndex) const = 0;\r
123 \r
124                 //! columns can be resized by drag 'n drop\r
125                 virtual void setResizableColumns(bool resizable) = 0;\r
126 \r
127                 //! can columns be resized by drag 'n drop?\r
128                 virtual bool hasResizableColumns() const = 0;\r
129 \r
130                 //! This tells the table control which ordering mode should be used when a column header is clicked.\r
131                 /** \param columnIndex The index of the column header.\r
132                 \param mode: One of the modes defined in EGUI_COLUMN_ORDERING */\r
133                 virtual void setColumnOrdering(u32 columnIndex, EGUI_COLUMN_ORDERING mode) = 0;\r
134 \r
135                 //! Returns which row is currently selected\r
136                 virtual s32 getSelected() const = 0;\r
137 \r
138                 //! set which row is currently selected\r
139                 virtual void setSelected( s32 index ) = 0;\r
140 \r
141                 //! Get amount of rows in the tabcontrol\r
142                 virtual s32 getRowCount() const = 0;\r
143 \r
144                 //! adds a row to the table\r
145                 /** \param rowIndex Zero based index of rows. The row will be\r
146                 inserted at this position, if a row already exist there, it\r
147                 will be placed after it. If the row is larger than the actual\r
148                 number of row by more than one, it won't be created.  Note that\r
149                 if you create a row that's not at the end, there might be\r
150                 performance issues.\r
151                 \return index of inserted row. */\r
152                 virtual u32 addRow(u32 rowIndex) = 0;\r
153 \r
154                 //! Remove a row from the table\r
155                 virtual void removeRow(u32 rowIndex) = 0;\r
156 \r
157                 //! clears the table rows, but keeps the columns intact\r
158                 virtual void clearRows() = 0;\r
159 \r
160                 //! Swap two row positions.\r
161                 virtual void swapRows(u32 rowIndexA, u32 rowIndexB) = 0;\r
162 \r
163                 //! This tells the table to start ordering all the rows.\r
164                 /** You need to explicitly tell the table to re order the rows\r
165                 when a new row is added or the cells data is changed. This\r
166                 makes the system more flexible and doesn't make you pay the\r
167                 cost of ordering when adding a lot of rows.\r
168                 \param columnIndex: When set to -1 the active column is used.\r
169                 \param mode Ordering mode of the rows. */\r
170                 virtual void orderRows(s32 columnIndex=-1, EGUI_ORDERING_MODE mode=EGOM_NONE) = 0;\r
171 \r
172                 //! Set the text of a cell\r
173                 virtual void setCellText(u32 rowIndex, u32 columnIndex, const core::stringw& text) = 0;\r
174 \r
175                 //! Set the text of a cell, and set a color of this cell.\r
176                 virtual void setCellText(u32 rowIndex, u32 columnIndex, const core::stringw& text, video::SColor color) = 0;\r
177 \r
178                 //! Set the data of a cell\r
179                 virtual void setCellData(u32 rowIndex, u32 columnIndex, void *data) = 0;\r
180 \r
181                 //! Set the color of a cell text\r
182                 virtual void setCellColor(u32 rowIndex, u32 columnIndex, video::SColor color) = 0;\r
183 \r
184                 //! Get the text of a cell\r
185                 virtual const wchar_t* getCellText(u32 rowIndex, u32 columnIndex ) const = 0;\r
186 \r
187                 //! Get the data of a cell\r
188                 virtual void* getCellData(u32 rowIndex, u32 columnIndex ) const = 0;\r
189 \r
190                 //! clears the table, deletes all items in the table\r
191                 virtual void clear() = 0;\r
192 \r
193                 //! Set flags, as defined in ::EGUI_TABLE_DRAW_FLAGS, which influence the layout\r
194                 virtual void setDrawFlags(s32 flags) = 0;\r
195 \r
196                 //! Get the flags, as defined in ::EGUI_TABLE_DRAW_FLAGS, which influence the layout\r
197                 virtual s32 getDrawFlags() const = 0;\r
198 \r
199                 //! Sets another skin independent font.\r
200                 /** If this is set to zero, the button uses the font of the skin.\r
201                 \param font: New font to set. */\r
202                 virtual void setOverrideFont(IGUIFont* font=0) = 0;\r
203 \r
204                 //! Gets the override font (if any)\r
205                 /** \return The override font (may be 0) */\r
206                 virtual IGUIFont* getOverrideFont(void) const = 0;\r
207 \r
208                 //! Get the font which is used right now for drawing\r
209                 /** Currently this is the override font when one is set and the\r
210                 font of the active skin otherwise */\r
211                 virtual IGUIFont* getActiveFont() const = 0;\r
212 \r
213                 //! Get the height of items/rows\r
214                 virtual s32 getItemHeight() const = 0;\r
215 \r
216                 //! Access the vertical scrollbar\r
217                 virtual IGUIScrollBar* getVerticalScrollBar() const = 0;\r
218 \r
219                 //! Access the horizontal scrollbar\r
220                 virtual IGUIScrollBar* getHorizontalScrollBar() const = 0;\r
221 \r
222                 //! Sets whether to draw the background.\r
223                 virtual void setDrawBackground(bool draw) = 0;\r
224 \r
225                 //! Checks if background drawing is enabled\r
226                 /** \return true if background drawing is enabled, false otherwise */\r
227                 virtual bool isDrawBackgroundEnabled() const = 0;\r
228         };\r
229 \r
230 \r
231 } // end namespace gui\r
232 } // end namespace irr\r
233 \r
234 #endif\r
235 \r