#ifndef __C_GUI_TABLE_BAR_H_INCLUDED__
#define __C_GUI_TABLE_BAR_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUITable.h"
#include "irrArray.h"
namespace irr
{
namespace gui
{
class IGUIFont;
class IGUIScrollBar;
class CGUITable : public IGUITable
{
public:
CGUITable(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, const core::rect<s32>& rectangle, bool clip=true,
bool drawBack=false, bool moveOverSelect=true);
~CGUITable();
virtual void addColumn(const wchar_t* caption, s32 columnIndex=-1);
virtual void removeColumn(u32 columnIndex);
virtual s32 getColumnCount() const;
virtual bool setActiveColumn(s32 columnIndex, bool doOrder=false);
virtual s32 getActiveColumn() const;
virtual EGUI_ORDERING_MODE getActiveColumnOrdering() const;
virtual void setColumnWidth(u32 columnIndex, u32 width);
virtual void setResizableColumns(bool resizable);
virtual bool hasResizableColumns() const;
virtual void setColumnOrdering(u32 columnIndex, EGUI_COLUMN_ORDERING mode);
virtual s32 getSelected() const;
virtual void setSelected( s32 index );
virtual s32 getRowCount() const;
virtual u32 addRow(u32 rowIndex);
virtual void removeRow(u32 rowIndex);
virtual void clearRows();
virtual void swapRows(u32 rowIndexA, u32 rowIndexB);
virtual void orderRows(s32 columnIndex=-1, EGUI_ORDERING_MODE mode=EGOM_NONE);
virtual void setCellText(u32 rowIndex, u32 columnIndex, const core::stringw& text);
virtual void setCellText(u32 rowIndex, u32 columnIndex, const core::stringw& text, video::SColor color);
virtual void setCellData(u32 rowIndex, u32 columnIndex, void *data);
virtual void setCellColor(u32 rowIndex, u32 columnIndex, video::SColor color);
virtual const wchar_t* getCellText(u32 rowIndex, u32 columnIndex ) const;
virtual void* getCellData(u32 rowIndex, u32 columnIndex ) const;
virtual void clear();
virtual bool OnEvent(const SEvent &event);
virtual void draw();
virtual void setDrawFlags(s32 flags);
virtual s32 getDrawFlags() const;
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const;
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0);
protected:
virtual void refreshControls();
virtual void checkScrollbars();
private:
struct Cell
{
Cell() : IsOverrideColor(false), Data(0) {}
core::stringw Text;
core::stringw BrokenText;
bool IsOverrideColor;
video::SColor Color;
void *Data;
};
struct Row
{
Row() {}
core::array<Cell> Items;
};
struct Column
{
Column() : Width(0), OrderingMode(EGCO_NONE) {}
core::stringw Name;
u32 Width;
EGUI_COLUMN_ORDERING OrderingMode;
};
void breakText(const core::stringw &text, core::stringw & brokenText, u32 cellWidth);
void selectNew(s32 ypos, bool onlyHover=false);
bool selectColumnHeader(s32 xpos, s32 ypos);
bool dragColumnStart(s32 xpos, s32 ypos);
bool dragColumnUpdate(s32 xpos);
void recalculateHeights();
void recalculateWidths();
core::array< Column > Columns;
core::array< Row > Rows;
gui::IGUIFont* Font;
gui::IGUIScrollBar* VerticalScrollBar;
gui::IGUIScrollBar* HorizontalScrollBar;
bool Clip;
bool DrawBack;
bool MoveOverSelect;
bool Selecting;
s32 CurrentResizedColumn;
s32 ResizeStart;
bool ResizableColumns;
s32 ItemHeight;
s32 TotalItemHeight;
s32 TotalItemWidth;
s32 Selected;
s32 CellHeightPadding;
s32 CellWidthPadding;
s32 ActiveTab;
EGUI_ORDERING_MODE CurrentOrdering;
s32 DrawFlags;
};
}
}
#endif
#endif