1
// Copyright (C) 2003-2011 Nikolaus Gebhardt
2
// This file is part of the "Irrlicht Engine".
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
5
#ifndef __I_GUI_TABLE_H_INCLUDED__
6
#define __I_GUI_TABLE_H_INCLUDED__
8
#include "IGUIElement.h"
18
//! modes for ordering used when a column header is clicked
19
enum EGUI_COLUMN_ORDERING
21
//! Do not use ordering
24
//! Send a EGET_TABLE_HEADER_CHANGED message when a column header is clicked.
27
//! Sort it ascending by it's ascii value like: a,b,c,...
30
//! Sort it descending by it's ascii value like: z,x,y,...
33
//! Sort it ascending on first click, descending on next, etc
34
EGCO_FLIP_ASCENDING_DESCENDING,
36
//! Not used as mode, only to get maximum value for this enum
40
//! Names for EGUI_COLUMN_ORDERING types
41
const c8* const GUIColumnOrderingNames[] =
51
enum EGUI_ORDERING_MODE
53
//! No element ordering
56
//! Elements are ordered from the smallest to the largest.
59
//! Elements are ordered from the largest to the smallest.
62
//! this value is not used, it only specifies the amount of default ordering types
67
const c8* const GUIOrderingModeNames[] =
75
enum EGUI_TABLE_DRAW_FLAGS
83
//! Default list box GUI element.
84
class IGUITable : public IGUIElement
88
IGUITable(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
89
: IGUIElement(EGUIET_TABLE, environment, parent, id, rectangle) {}
92
/** If columnIndex is outside the current range, do push new colum at the end */
93
virtual void addColumn(const wchar_t* caption, s32 columnIndex=-1) = 0;
95
//! remove a column from the table
96
virtual void removeColumn(u32 columnIndex) = 0;
98
//! Returns the number of columns in the table control
99
virtual s32 getColumnCount() const = 0;
101
//! Makes a column active. This will trigger an ordering process.
102
/** \param idx: The id of the column to make active.
103
\param doOrder: Do also the ordering which depending on mode for active column
104
\return True if successful. */
105
virtual bool setActiveColumn(s32 idx, bool doOrder=false) = 0;
107
//! Returns which header is currently active
108
virtual s32 getActiveColumn() const = 0;
110
//! Returns the ordering used by the currently active column
111
virtual EGUI_ORDERING_MODE getActiveColumnOrdering() const = 0;
113
//! Set the width of a column
114
virtual void setColumnWidth(u32 columnIndex, u32 width) = 0;
116
//! Get the width of a column
117
virtual u32 getColumnWidth(u32 columnIndex) const = 0;
119
//! columns can be resized by drag 'n drop
120
virtual void setResizableColumns(bool resizable) = 0;
122
//! can columns be resized by dran 'n drop?
123
virtual bool hasResizableColumns() const = 0;
125
//! This tells the table control which ordering mode should be used when a column header is clicked.
126
/** \param columnIndex The index of the column header.
127
\param mode: One of the modes defined in EGUI_COLUMN_ORDERING */
128
virtual void setColumnOrdering(u32 columnIndex, EGUI_COLUMN_ORDERING mode) = 0;
130
//! Returns which row is currently selected
131
virtual s32 getSelected() const = 0;
133
//! set wich row is currently selected
134
virtual void setSelected( s32 index ) = 0;
136
//! Get amount of rows in the tabcontrol
137
virtual s32 getRowCount() const = 0;
139
//! adds a row to the table
140
/** \param rowIndex Zero based index of rows. The row will be
141
inserted at this position, if a row already exist there, it
142
will be placed after it. If the row is larger than the actual
143
number of row by more than one, it won't be created. Note that
144
if you create a row that's not at the end, there might be
146
\return index of inserted row. */
147
virtual u32 addRow(u32 rowIndex) = 0;
149
//! Remove a row from the table
150
virtual void removeRow(u32 rowIndex) = 0;
152
//! clears the table rows, but keeps the columns intact
153
virtual void clearRows() = 0;
155
//! Swap two row positions.
156
virtual void swapRows(u32 rowIndexA, u32 rowIndexB) = 0;
158
//! This tells the table to start ordering all the rows.
159
/** You need to explicitly tell the table to re order the rows
160
when a new row is added or the cells data is changed. This
161
makes the system more flexible and doesn't make you pay the
162
cost of ordering when adding a lot of rows.
163
\param columnIndex: When set to -1 the active column is used.
164
\param mode Ordering mode of the rows. */
165
virtual void orderRows(s32 columnIndex=-1, EGUI_ORDERING_MODE mode=EGOM_NONE) = 0;
167
//! Set the text of a cell
168
virtual void setCellText(u32 rowIndex, u32 columnIndex, const core::stringw& text) = 0;
170
//! Set the text of a cell, and set a color of this cell.
171
virtual void setCellText(u32 rowIndex, u32 columnIndex, const core::stringw& text, video::SColor color) = 0;
173
//! Set the data of a cell
174
virtual void setCellData(u32 rowIndex, u32 columnIndex, void *data) = 0;
176
//! Set the color of a cell text
177
virtual void setCellColor(u32 rowIndex, u32 columnIndex, video::SColor color) = 0;
179
//! Get the text of a cell
180
virtual const wchar_t* getCellText(u32 rowIndex, u32 columnIndex ) const = 0;
182
//! Get the data of a cell
183
virtual void* getCellData(u32 rowIndex, u32 columnIndex ) const = 0;
185
//! clears the table, deletes all items in the table
186
virtual void clear() = 0;
188
//! Set flags, as defined in EGUI_TABLE_DRAW_FLAGS, which influence the layout
189
virtual void setDrawFlags(s32 flags) = 0;
191
//! Get the flags, as defined in EGUI_TABLE_DRAW_FLAGS, which influence the layout
192
virtual s32 getDrawFlags() const = 0;
196
} // end namespace gui
197
} // end namespace irr