2007-12-21 23:49:29 -08:00
|
|
|
// Copyright (C) 2002-2005 Nikolaus Gebhardt
|
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
2007-12-22 13:16:24 -08:00
|
|
|
// 07.10.2005 - Multicolor-Listbox addet by A. Buschhueter (Acki)
|
2007-12-21 23:49:29 -08:00
|
|
|
// A_Buschhueter@gmx.de
|
|
|
|
|
|
|
|
#ifndef __C_GUI_TABLE_BAR_H_INCLUDED__
|
|
|
|
#define __C_GUI_TABLE_BAR_H_INCLUDED__
|
|
|
|
|
|
|
|
#include "IGUITable.h"
|
|
|
|
#include "irrArray.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace gui
|
|
|
|
{
|
|
|
|
|
|
|
|
class IGUIFont;
|
|
|
|
class IGUIScrollBar;
|
|
|
|
|
|
|
|
class CGUITable : public IGUITable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//! constructor
|
2008-01-11 07:56:37 -08:00
|
|
|
CGUITable(IGUIEnvironment* environment, IGUIElement* parent,
|
2007-12-21 23:49:29 -08:00
|
|
|
s32 id, core::rect<s32> rectangle, bool clip=true,
|
|
|
|
bool drawBack=false, bool moveOverSelect=true);
|
|
|
|
|
|
|
|
//! destructor
|
|
|
|
~CGUITable();
|
|
|
|
|
|
|
|
//! Adds a column
|
2008-01-11 07:56:37 -08:00
|
|
|
//! If columnIndex is outside the current range, do push new colum at the end
|
|
|
|
virtual void addColumn(const wchar_t* caption, s32 columnIndex=-1);
|
|
|
|
|
|
|
|
//! remove a column from the table
|
|
|
|
virtual void removeColumn(u32 columnIndex);
|
2007-12-21 23:49:29 -08:00
|
|
|
|
|
|
|
//! Returns the number of columns in the table control
|
2007-12-30 16:28:51 -08:00
|
|
|
virtual s32 getColumnCount() const;
|
2007-12-21 23:49:29 -08:00
|
|
|
|
|
|
|
//! Makes a column active. This will trigger an ordering process.
|
|
|
|
/** \param idx: The id of the column to make active.
|
2008-01-11 07:56:37 -08:00
|
|
|
\return Returns true if successful. */
|
|
|
|
virtual bool setActiveColumn(s32 columnIndex, bool doOrder=false);
|
2007-12-21 23:49:29 -08:00
|
|
|
|
|
|
|
//! Returns which header is currently active
|
|
|
|
virtual s32 getActiveColumn() const;
|
|
|
|
|
|
|
|
//! Returns the ordering used by the currently active column
|
|
|
|
virtual EGUI_ORDERING_MODE getActiveColumnOrdering() const;
|
|
|
|
|
|
|
|
//! set a column width
|
|
|
|
virtual void setColumnWidth(u32 columnIndex, u32 width);
|
2008-01-11 07:56:37 -08:00
|
|
|
|
|
|
|
//! columns can be resized by drag 'n drop
|
|
|
|
virtual void setResizableColumns(bool resizable);
|
|
|
|
|
|
|
|
//! can columns be resized by dran 'n drop?
|
|
|
|
virtual bool hasResizableColumns() const;
|
|
|
|
|
|
|
|
//! This tells the table control which ordering mode should be used when
|
|
|
|
//! a column header is clicked.
|
2007-12-21 23:49:29 -08:00
|
|
|
/** \param columnIndex: The index of the column header.
|
2008-01-11 07:56:37 -08:00
|
|
|
\param state: If true, a EGET_TABLE_HEADER_CHANGED message will be sent and you can order the table data as you whish.*/
|
|
|
|
//! \param mode: One of the modes defined in EGUI_COLUMN_ORDERING
|
|
|
|
virtual void setColumnOrdering(u32 columnIndex, EGUI_COLUMN_ORDERING mode);
|
|
|
|
|
2007-12-21 23:49:29 -08:00
|
|
|
|
|
|
|
//! Returns which row is currently selected
|
|
|
|
virtual s32 getSelected() const;
|
|
|
|
|
|
|
|
//! Returns amount of rows in the tabcontrol
|
2007-12-30 16:28:51 -08:00
|
|
|
virtual s32 getRowCount() const;
|
2007-12-21 23:49:29 -08:00
|
|
|
|
|
|
|
//! adds a row to the table
|
2007-12-30 16:28:51 -08:00
|
|
|
/** \param rowIndex: zero based index of rows. The row will be
|
|
|
|
inserted at this position. If a row already exists
|
|
|
|
there, it will be placed after it. If the row is larger
|
|
|
|
than the actual number of rows by more than one, it
|
|
|
|
won't be created. Note that if you create a row that is
|
|
|
|
not at the end, there might be performance issues*/
|
2007-12-21 23:49:29 -08:00
|
|
|
virtual void addRow(u32 rowIndex);
|
|
|
|
|
|
|
|
//! Remove a row from the table
|
|
|
|
virtual void removeRow(u32 rowIndex);
|
|
|
|
|
2007-12-30 16:28:51 -08:00
|
|
|
//! clear the table rows, but keep the columns intact
|
2007-12-21 23:49:29 -08:00
|
|
|
virtual void clearRows();
|
|
|
|
|
|
|
|
//! Swap two row positions. This is useful for a custom ordering algo.
|
|
|
|
virtual void swapRows(u32 rowIndexA, u32 rowIndexB);
|
|
|
|
|
2007-12-30 16:28:51 -08:00
|
|
|
//! This tells the table to start ordering all the rows. You
|
|
|
|
//! need to explicitly tell the table to reorder the rows when
|
|
|
|
//! a new row is added or the cells data is changed. This makes
|
|
|
|
//! the system more flexible and doesn't make you pay the cost
|
|
|
|
//! of ordering when adding a lot of rows.
|
2008-01-11 07:56:37 -08:00
|
|
|
//! \param columnIndex: When set to -1 the active column is used.
|
|
|
|
virtual void orderRows(s32 columnIndex=-1, EGUI_ORDERING_MODE mode=EGOM_NONE);
|
|
|
|
|
2007-12-21 23:49:29 -08:00
|
|
|
|
|
|
|
//! Set the text of a cell
|
|
|
|
virtual void setCellText(u32 rowIndex, u32 columnIndex, const wchar_t* text);
|
|
|
|
|
|
|
|
//! Set the text of a cell, and set a color of this cell.
|
|
|
|
virtual void setCellText(u32 rowIndex, u32 columnIndex, const wchar_t* text, video::SColor color);
|
|
|
|
|
|
|
|
//! Set the data of a cell
|
2008-01-11 07:56:37 -08:00
|
|
|
//! data will not be serialized.
|
2007-12-21 23:49:29 -08:00
|
|
|
virtual void setCellData(u32 rowIndex, u32 columnIndex, void *data);
|
|
|
|
|
|
|
|
//! Set the color of a cell text
|
|
|
|
virtual void setCellColor(u32 rowIndex, u32 columnIndex, video::SColor color);
|
|
|
|
|
|
|
|
//! Get the text of a cell
|
|
|
|
virtual const wchar_t* getCellText(u32 rowIndex, u32 columnIndex ) const;
|
|
|
|
|
|
|
|
//! Get the data of a cell
|
|
|
|
virtual void* getCellData(u32 rowIndex, u32 columnIndex ) const;
|
|
|
|
|
|
|
|
//! clears the table, deletes all items in the table
|
|
|
|
virtual void clear();
|
|
|
|
|
|
|
|
//! called if an event happened.
|
2008-01-13 20:58:32 -08:00
|
|
|
virtual bool CGUITable::OnEvent(const SEvent &event);
|
2007-12-21 23:49:29 -08:00
|
|
|
|
|
|
|
//! draws the element and its children
|
|
|
|
virtual void draw();
|
|
|
|
|
2008-01-11 07:56:37 -08:00
|
|
|
//! Set flags, as defined in EGUI_TABLE_DRAW_FLAGS, which influence the layout
|
|
|
|
virtual void setDrawFlags(s32 flags);
|
|
|
|
|
|
|
|
//! Get the flags, as defined in EGUI_TABLE_DRAW_FLAGS, which influence the layout
|
|
|
|
virtual s32 getDrawFlags() const;
|
|
|
|
|
2007-12-22 18:48:02 -08:00
|
|
|
//! Writes attributes of the object.
|
2007-12-30 16:28:51 -08:00
|
|
|
//! Implement this to expose the attributes of your scene node animator for
|
2007-12-22 18:48:02 -08:00
|
|
|
//! scripting languages, editors, debuggers or xml serialization purposes.
|
|
|
|
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const;
|
|
|
|
|
|
|
|
//! Reads attributes of the object.
|
2007-12-30 16:28:51 -08:00
|
|
|
//! Implement this to set the attributes of your scene node animator for
|
2007-12-22 18:48:02 -08:00
|
|
|
//! scripting languages, editors, debuggers or xml deserialization purposes.
|
|
|
|
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0);
|
|
|
|
|
2008-01-11 07:56:37 -08:00
|
|
|
protected:
|
|
|
|
virtual void refreshControls();
|
|
|
|
virtual void checkScrollbars();
|
|
|
|
|
2007-12-21 23:49:29 -08:00
|
|
|
private:
|
|
|
|
|
|
|
|
struct Cell
|
|
|
|
{
|
2008-01-11 07:56:37 -08:00
|
|
|
Cell() : Data(0) {}
|
|
|
|
core::stringw Text;
|
2007-12-21 23:49:29 -08:00
|
|
|
core::stringw BrokenText;
|
2008-01-11 07:56:37 -08:00
|
|
|
video::SColor Color;
|
|
|
|
void *Data;
|
2007-12-21 23:49:29 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Row
|
|
|
|
{
|
2008-01-11 07:56:37 -08:00
|
|
|
Row() {}
|
2007-12-21 23:49:29 -08:00
|
|
|
core::array<Cell> Items;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Column
|
|
|
|
{
|
2008-01-11 07:56:37 -08:00
|
|
|
Column() : Width(0), OrderingMode(EGCO_NONE) {}
|
|
|
|
core::stringw Name;
|
2007-12-21 23:49:29 -08:00
|
|
|
video::SColor TextColor;
|
2008-01-11 07:56:37 -08:00
|
|
|
u32 Width;
|
|
|
|
EGUI_COLUMN_ORDERING OrderingMode;
|
2007-12-21 23:49:29 -08:00
|
|
|
};
|
|
|
|
|
2008-01-11 07:56:37 -08:00
|
|
|
void breakText(const core::stringw &text, core::stringw & brokenText, u32 cellWidth);
|
2007-12-21 23:49:29 -08:00
|
|
|
void selectNew(s32 ypos, bool onlyHover=false);
|
|
|
|
bool selectColumnHeader(s32 xpos, s32 ypos);
|
2008-01-11 07:56:37 -08:00
|
|
|
bool dragColumnStart(s32 xpos, s32 ypos);
|
|
|
|
bool dragColumnUpdate(s32 xpos);
|
|
|
|
void recalculateHeights();
|
|
|
|
void recalculateWidths();
|
2007-12-21 23:49:29 -08:00
|
|
|
|
|
|
|
core::array< Column > Columns;
|
|
|
|
core::array< Row > Rows;
|
|
|
|
gui::IGUIFont* Font;
|
2008-01-11 07:56:37 -08:00
|
|
|
gui::IGUIScrollBar* VerticalScrollBar;
|
|
|
|
gui::IGUIScrollBar* HorizontalScrollBar;
|
2007-12-21 23:49:29 -08:00
|
|
|
bool Clip;
|
|
|
|
bool DrawBack;
|
|
|
|
bool MoveOverSelect;
|
2007-12-30 16:28:51 -08:00
|
|
|
bool Selecting;
|
2008-01-11 07:56:37 -08:00
|
|
|
s32 CurrentResizedColumn;
|
|
|
|
s32 ResizeStart;
|
|
|
|
bool ResizableColumns;
|
2007-12-21 23:49:29 -08:00
|
|
|
|
2007-12-30 16:28:51 -08:00
|
|
|
s32 ItemHeight;
|
|
|
|
s32 TotalItemHeight;
|
2008-01-11 07:56:37 -08:00
|
|
|
s32 TotalItemWidth;
|
2007-12-21 23:49:29 -08:00
|
|
|
s32 Selected;
|
|
|
|
s32 CellHeightPadding;
|
2007-12-30 16:28:51 -08:00
|
|
|
s32 CellWidthPadding;
|
2007-12-21 23:49:29 -08:00
|
|
|
s32 ActiveTab;
|
2007-12-30 16:28:51 -08:00
|
|
|
EGUI_ORDERING_MODE CurrentOrdering;
|
2008-01-11 07:56:37 -08:00
|
|
|
s32 DrawFlags;
|
2007-12-21 23:49:29 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace gui
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
#endif
|
2007-12-30 16:28:51 -08:00
|
|
|
|