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
5 #ifndef __I_GUI_TABLE_H_INCLUDED__
\r
6 #define __I_GUI_TABLE_H_INCLUDED__
\r
8 #include "IGUIElement.h"
\r
16 class IGUIScrollBar;
\r
18 //! modes for ordering used when a column header is clicked
\r
19 enum EGUI_COLUMN_ORDERING
\r
21 //! Do not use ordering
\r
24 //! Send a EGET_TABLE_HEADER_CHANGED message when a column header is clicked.
\r
27 //! Sort it ascending by it's ascii value like: a,b,c,...
\r
30 //! Sort it descending by it's ascii value like: z,x,y,...
\r
33 //! Sort it ascending on first click, descending on next, etc
\r
34 EGCO_FLIP_ASCENDING_DESCENDING,
\r
36 //! Not used as mode, only to get maximum value for this enum
\r
40 //! Names for EGUI_COLUMN_ORDERING types
\r
41 const c8* const GUIColumnOrderingNames[] =
\r
51 enum EGUI_ORDERING_MODE
\r
53 //! No element ordering
\r
56 //! Elements are ordered from the smallest to the largest.
\r
59 //! Elements are ordered from the largest to the smallest.
\r
62 //! this value is not used, it only specifies the amount of default ordering types
\r
67 const c8* const GUIOrderingModeNames[] =
\r
75 enum EGUI_TABLE_DRAW_FLAGS
\r
79 EGTDF_ACTIVE_ROW = 4,
\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
89 class IGUITable : public IGUIElement
\r
93 IGUITable(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
\r
94 : IGUIElement(EGUIET_TABLE, environment, parent, id, rectangle) {}
\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
100 //! remove a column from the table
\r
101 virtual void removeColumn(u32 columnIndex) = 0;
\r
103 //! Returns the number of columns in the table control
\r
104 virtual s32 getColumnCount() const = 0;
\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
112 //! Returns which header is currently active
\r
113 virtual s32 getActiveColumn() const = 0;
\r
115 //! Returns the ordering used by the currently active column
\r
116 virtual EGUI_ORDERING_MODE getActiveColumnOrdering() const = 0;
\r
118 //! Set the width of a column
\r
119 virtual void setColumnWidth(u32 columnIndex, u32 width) = 0;
\r
121 //! Get the width of a column
\r
122 virtual u32 getColumnWidth(u32 columnIndex) const = 0;
\r
124 //! columns can be resized by drag 'n drop
\r
125 virtual void setResizableColumns(bool resizable) = 0;
\r
127 //! can columns be resized by drag 'n drop?
\r
128 virtual bool hasResizableColumns() const = 0;
\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
135 //! Returns which row is currently selected
\r
136 virtual s32 getSelected() const = 0;
\r
138 //! set which row is currently selected
\r
139 virtual void setSelected( s32 index ) = 0;
\r
141 //! Get amount of rows in the tabcontrol
\r
142 virtual s32 getRowCount() const = 0;
\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
154 //! Remove a row from the table
\r
155 virtual void removeRow(u32 rowIndex) = 0;
\r
157 //! clears the table rows, but keeps the columns intact
\r
158 virtual void clearRows() = 0;
\r
160 //! Swap two row positions.
\r
161 virtual void swapRows(u32 rowIndexA, u32 rowIndexB) = 0;
\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
172 //! Set the text of a cell
\r
173 virtual void setCellText(u32 rowIndex, u32 columnIndex, const core::stringw& text) = 0;
\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
178 //! Set the data of a cell
\r
179 virtual void setCellData(u32 rowIndex, u32 columnIndex, void *data) = 0;
\r
181 //! Set the color of a cell text
\r
182 virtual void setCellColor(u32 rowIndex, u32 columnIndex, video::SColor color) = 0;
\r
184 //! Get the text of a cell
\r
185 virtual const wchar_t* getCellText(u32 rowIndex, u32 columnIndex ) const = 0;
\r
187 //! Get the data of a cell
\r
188 virtual void* getCellData(u32 rowIndex, u32 columnIndex ) const = 0;
\r
190 //! clears the table, deletes all items in the table
\r
191 virtual void clear() = 0;
\r
193 //! Set flags, as defined in ::EGUI_TABLE_DRAW_FLAGS, which influence the layout
\r
194 virtual void setDrawFlags(s32 flags) = 0;
\r
196 //! Get the flags, as defined in ::EGUI_TABLE_DRAW_FLAGS, which influence the layout
\r
197 virtual s32 getDrawFlags() const = 0;
\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
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
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
213 //! Get the height of items/rows
\r
214 virtual s32 getItemHeight() const = 0;
\r
216 //! Access the vertical scrollbar
\r
217 virtual IGUIScrollBar* getVerticalScrollBar() const = 0;
\r
219 //! Access the horizontal scrollbar
\r
220 virtual IGUIScrollBar* getHorizontalScrollBar() const = 0;
\r
222 //! Sets whether to draw the background.
\r
223 virtual void setDrawBackground(bool draw) = 0;
\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
231 } // end namespace gui
\r
232 } // end namespace irr
\r