nux-1.16.0
|
Public Types | |
typedef void(TableCtrl::* | ItemOperator )(TableItem *) |
Public Member Functions | |
TableCtrl (bool floating_column=true) | |
Constructor. | |
virtual long | ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo) |
virtual void | Draw (GraphicsEngine &GfxContext, bool force_draw) |
virtual void | DrawContent (GraphicsEngine &GfxContext, bool force_draw) |
virtual void | PostDraw (GraphicsEngine &GfxContext, bool force_draw) |
void | DrawTable (GraphicsEngine &GfxContext) |
void | DrawHeader (GraphicsEngine &GfxContext) |
void | DrawHeaderPreview (GraphicsEngine &GfxContext) |
void | OverlayDrawing (GraphicsEngine &GfxContext) |
void | addHeader (const TCHAR *name, bool fixed_width=false, int column_width=10) |
void | FormatTable () |
int | FormatHeader () |
virtual void | AddColumn (const TCHAR *column_name, bool fixed_width=false, int column_width=10) |
Add a column to the table. | |
void | setTableItems (TableItem *item, bool isOpen=false) |
void | AddTableItem (TableItem *item) |
Add a table item as a child of the root node of the table controller. | |
void | ResetTable () |
void | TraverseItem (TableItem *item, bool open_only, ItemOperator) |
void | DeleteRowSizeHandler () |
void | DeleteRowHeader () |
void | OpBuildItemDepth (TableItem *item, int depth) |
void | OpAddItem (TableItem *item) |
void | OpCloseItem (TableItem *item) |
void | OpOpenItem (TableItem *item) |
void | OpHideItem (TableItem *item) |
void | OpShowItem (TableItem *item) |
virtual void | EnableRowResizing (bool b) |
EnableResizing the height of row headers. | |
virtual void | EnableColumnResizing (bool b) |
EnableResizing the width of column headers. | |
virtual void | ShowRowHeader (bool b) |
Show the row headers. | |
virtual void | ShowColumnHeader (bool b) |
Show the column headers. | |
void | ShowVerticalSeparationLine (bool b) |
Show the columns vertical separation lines. | |
void | ShowHorizontalSeparationLine (bool b) |
Show the rows horizontal separation lines. | |
void | ShowSeparationLine (bool bHor, bool bVert) |
void | ClickSelectRow () |
void | ClickSelectColumn () |
void | ClickSelectCell () |
virtual void | PaintDecoration (GraphicsEngine &GfxContext, TableItem *item) |
Paint Decoration. | |
virtual void | PaintRowDecoration (GraphicsEngine &GfxContext, TableItem *item, Color color) |
Paint Item row header decoration. | |
t_u32 | PushItemBackground (GraphicsEngine &GfxContext, TableItem *item, bool MouseOver=false) |
Paint Item Background. | |
void | PopItemBackground (GraphicsEngine &GfxContext, t_u32 NumBackground) |
Pop the item background pushed on the painter stack. | |
void | EnableApplyItemBestHeight (bool b) |
void | SetMouseOverColor (Color color) |
Set ItemBackgroundColor when the mouse is over the Item. | |
Color | GetMouseOverColor () |
Return the user defined color used as background color when the mouse is over the item. | |
void | EnableMouseOverColor (bool b) |
Enable the use of a user defined color when the mouse is over the item. | |
void | SetRowColorOdd (Color color) |
Color | GetRowColorOdd () const |
void | SetRowColorEven (Color color) |
Color | GetRowColorEven () const |
void | SetRowColor (Color evencolor, Color oddcolor) |
void | SetHorizontalSeparationLineColor (Color color) |
Color | GetHorizontalSeparationLineColor () const |
void | SetVerticalSeparationLineColor (Color color) |
Color | GetVerticalSeparationLineColor () const |
void | SetSeparationLineColor (const Color &horcolor, const Color &vertcolor) |
virtual bool | CanBreakLayout () |
Return true if this object can break the layout. | |
void | SetFloatingColumn (bool b) |
set Floating column. | |
bool | isFloatingColumn () |
Return true if the columns are floating. | |
void | FindItemUnderPointer (int x, int y, TableItem **ppItem, int &row, int &column) |
Get information about the item below the pointer. | |
void | SetSelectionColor (const Color &color) |
const Color | GetSelectionColor () |
TableItem * | GetSelectedItem () |
t_u32 | GetSelectedRow () |
t_u32 | GetSelectedColumn () |
t_s32 | GetNumColumn () |
Get the number of column in the table. | |
t_s32 | GetNumRow () |
Get the number of row in the table. | |
void | ResetItems () |
reset Items flags. | |
const TableItem * | GetRootNode () const |
TableItem * | GetRootNode () |
int | GetNumRootChild () const |
void | EmptyTable () |
void | HighlightItem (int row, int column) |
virtual void | mouse_double_click (int x, int y, unsigned long button_flags, unsigned long key_flags) |
virtual void | OnMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags) |
void | OnMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags) |
void | mouse_drag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags) |
void | OnKeyboardFocus () |
void | OnLostKeyboardFocus () |
void | OnResizeHeaderMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags, t_u32 header_pos) |
void | OnResizeHeaderMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags, t_u32 header_pos) |
void | OnResizeHeaderMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags, t_u32 header_pos) |
void | OnResizeRowMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags, t_u32 header_pos) |
void | OnResizeRowMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags, t_u32 header_pos) |
Public Attributes | |
int | m_ItemX |
int | m_ItemY |
int | m_OpenItemTotalHeight |
sigc::signal< void, int, int > | sigItemSelected |
sigc::signal< void, const TableItem & > | sigItemChange |
sigc::signal< void, TableCtrl &, TableItem &, int, int > | sigTableItemSelected |
sigc::signal< void > | sigLostFocus |
Protected Types | |
enum | CELL_SELECT { CLICK_SELECT_CELL, CLICK_SELECT_COLUMN, CLICK_SELECT_ROW } |
Protected Member Functions | |
void | QueueDraw () |
Causes a redraw. The widget parameter _need_redraw is set to true. The widget Draw(), DrawContent() and PostDraw() are called. | |
virtual void | SetGeometry (const Geometry &geo) |
Inherited from Area. | |
void | ComputeNonFloatingColumn () |
void | AdjustNonFloatingColumn () |
virtual void | PreLayoutManagement () |
virtual long | PostLayoutManagement (long LayoutResult) |
virtual void | PositionChildLayout (float offsetX, float offsetY) |
virtual void | ScrollLeft (float stepx, int mousedx) |
virtual void | ScrollRight (float stepx, int mousedx) |
virtual void | ScrollUp (float stepy, int mousedy) |
virtual void | ScrollDown (float stepy, int mousedy) |
Protected Attributes | |
InputArea * | m_TableArea |
VLayout * | m_VLayout |
int | m_tableNumRow |
int | m_tableNumColumn |
int | m_selectedRow |
int | m_selectedColumn |
Geometry | m_selectedGeometry |
TableItem * | m_selectedTableItem |
TableItem * | m_selectedMouseDownTableItem |
TableItem * | m_TableItemHead |
bool | m_bEnableRowResizing |
bool | m_bEnableColumnResizing |
bool | m_bShowRowHeader |
bool | m_bShowColumnHeader |
bool | m_bShowVerticalSeparationLine |
bool | m_bShowHorizontalSeparationLine |
bool | m_bEnableItemBestHeight |
std::vector< RowHeader * > | m_row_header |
std::vector< ColumnHeader > | m_column_header |
std::vector< ColumnHeader > | m_column_header_preview |
std::vector< sizehandler2 * > | m_column_sizehandler |
std::vector< sizehandler2 * > | m_row_sizehandler |
bool | m_FloatingColumn |
Color | m_RowColorOdd |
Color | m_RowColorEven |
Color | m_SelectionColor |
Color | m_TableBottomColor |
Color | m_HorizontalSeparationLineColor |
Color | m_VerticalSeparationLineColor |
Geometry | m_PreviousGeometry |
bool | m_DrawBackgroundOnPreviousGeometry |
CELL_SELECT | m_ClickSelect |
Point | m_point0 |
Point | m_point1 |
Friends | |
class | ComboBoxComplex |
class | ComboBoxSimple |
Definition at line 46 of file TableCtrl.h.
nux::TableCtrl::TableCtrl | ( | bool | floating_column = true | ) |
Constructor.
Construct the TableCtrl class. The parameter floating_column columns can be resized past the size of the content view area.
floating_column | set the column as floating. Default is set to true |
Definition at line 66 of file TableCtrl.cpp.
References nux::Layout::AddView(), nux::InputArea::begin_key_focus, nux::eFull, nux::eLeft, nux::InputArea::EnableDoubleClick(), nux::InputArea::end_key_focus, nux::eStackTop, nux::InputArea::mouse_double_click, nux::InputArea::mouse_down, nux::InputArea::mouse_drag, nux::InputArea::mouse_up, nux::TableItem::Open(), nux::View::SetCompositionLayout(), nux::Layout::SetContentDistribution(), SetGeometry(), nux::Area::SetGeometry(), nux::TableItem::Show(), ShowColumnHeader(), and ShowRowHeader().
{ m_bEnableRowResizing = false; m_bEnableColumnResizing = true; m_bShowRowHeader = true; m_bShowColumnHeader = true; m_bShowVerticalSeparationLine = true; m_bShowHorizontalSeparationLine = false; m_bEnableItemBestHeight = true; m_FloatingColumn = floating_column; m_ClickSelect = CLICK_SELECT_CELL; m_RowColorOdd = Color (0xFF343434); m_RowColorEven = Color (0xFF3f3f3f); m_TableBottomColor = Color (0xFF555555); m_SelectionColor = Color (0xFF202020); m_MouseOverColor = Color (0xFF666666); m_HorizontalSeparationLineColor = Color (0xFF747474); m_VerticalSeparationLineColor = Color (0xFF747474); m_IsEnableMouseOverColor = false; m_DrawBackgroundOnPreviousGeometry = false; m_TableItemHead = 0; m_TableItemHead = new TableItem (TEXT ("TableRootNode") ); m_TableItemHead->m_Table = this; m_TableItemHead->Open(); m_TableItemHead->Show(); m_TableArea = new InputArea (NUX_TRACKER_LOCATION); m_TableArea->mouse_down.connect (sigc::mem_fun (this, &TableCtrl::OnMouseDown) ); m_TableArea->mouse_double_click.connect (sigc::mem_fun (this, &TableCtrl::mouse_double_click) ); m_TableArea->mouse_up.connect (sigc::mem_fun (this, &TableCtrl::OnMouseUp) ); m_TableArea->mouse_drag.connect (sigc::mem_fun (this, &TableCtrl::mouse_drag) ); m_TableArea->begin_key_focus.connect (sigc::mem_fun (this, &TableCtrl::OnKeyboardFocus) ); m_TableArea->end_key_focus.connect (sigc::mem_fun (this, &TableCtrl::OnLostKeyboardFocus) ); m_tableNumRow = 0; m_tableNumColumn = 0; m_selectedRow = -1; m_selectedColumn = -1; m_selectedTableItem = 0; m_selectedMouseDownTableItem = 0; m_OpenItemTotalHeight = 0; EnableVerticalScrollBar (true); EnableHorizontalScrollBar (true); m_VLayout = new VLayout (TEXT ("TABLELAYOUT"), NUX_TRACKER_LOCATION); m_VLayout->SetVerticalInternalMargin (4); m_TableArea->SetGeometry (0, 0, 300, 40); // Setting the minimum of size m_TableArea forces the composition layout fit match the size of the Table area (+/- margins). if the layout is too large, then // the scrollbar will reflect that. // It is not enough to do something like: // m_VLayout->AddLayout(new WidgetLayout(&m_TableArea), 0, eLeft, eFull); // with a stretch factor equal to 0. Because m_VLayout is either a HLayout or a VLayout (here it is a VLayout), only one dimension of the composition layout // will match the similar dimension of TableArea. So only one scrollbar (Horizontal or Vertical) will be adjusted. // See FormatTable. m_VLayout->AddView (m_TableArea, 1, eLeft, eFull); m_VLayout->SetContentDistribution (eStackTop); m_VLayout->SetStretchFactor (1); SetMinimumSize (50, 50); SetGeometry (Geometry (0, 0, 50, 50) ); m_top_border = 0; m_border = 0; SetViewContentRightMargin (2); SetViewContentBottomMargin (2); SetCompositionLayout (m_VLayout); FormatContent(); m_TableArea->EnableDoubleClick (false); ShowRowHeader (true); ShowColumnHeader (true); }
void nux::TableCtrl::AddColumn | ( | const TCHAR * | column_name, |
bool | fixed_width = false , |
||
int | column_width = 10 |
||
) | [virtual] |
Add a column to the table.
Add a column to the table.
title | The title of the column. |
fixed_wided | True if the column should have a fixed width. |
width | The width of the column. This parameter is used if the width is not fixed. |
Definition at line 1436 of file TableCtrl.cpp.
{ if (width < MIN_COLUMN_WIDTH) addHeader (title, fixed_width, MIN_COLUMN_WIDTH); else addHeader (title, fixed_width, width); m_tableNumColumn += 1; // m_tableNumColumn = HeaderList.size(); }
void nux::TableCtrl::AdjustNonFloatingColumn | ( | ) | [protected] |
This function member computes the size of the headers for a non-floating column table. Given the m_ViewWidth, the width of the view content area. AdjustNonFloatingColumn rescale the width of headers so they fit within the width of the view content area. The new width of each headers respect the its current scales compare to other headers. Fix-width columns remain unchanged.
Definition at line 1073 of file TableCtrl.cpp.
References nux::ScrollView::m_ViewWidth.
{ int new_width = m_ViewWidth; new_width -= (m_bShowRowHeader ? ROWHEADERWIDTH : 0); // space_to_share represents the difference between the available width and the total width occupied by the headers. // This value can be close but not equal to 0 due to fractional errors when computing the sizes. // Computations is done is float but results are stored in integers. Every things below 1.0 is rounded down to the integer value 0. int space_to_share = new_width; int total_non_fix_width = 0; std::vector<ColumnHeader>::iterator it; ColumnHeader *LastNonFixHeader = 0; for (it = m_column_header.begin(); it != m_column_header.end(); it++) { if ( (*it)._fix_width) { // First do a little correction in case the fix width is less than MIN_COLUMN_WIDTH. if ( (*it)._fix_width_value < MIN_COLUMN_WIDTH) { (*it)._fix_width_value = MIN_COLUMN_WIDTH; } space_to_share -= (*it)._fix_width_value; } else { LastNonFixHeader = & (*it); total_non_fix_width += (*it).m_header_area->GetBaseWidth(); space_to_share -= (*it).m_header_area->GetBaseWidth(); } } int RemainingSpace = new_width; for (it = m_column_header.begin(); it != m_column_header.end(); it++) { if ( (*it)._fix_width) { RemainingSpace -= (*it)._fix_width_value; } } for (it = m_column_header.begin(); it != m_column_header.end(); it++) { if (! (*it)._fix_width) { int w = (*it).m_header_area->GetBaseWidth(); int nw = w + space_to_share * (float (w) / float (total_non_fix_width) ); if (nw < MIN_COLUMN_WIDTH) nw = MIN_COLUMN_WIDTH; if (& (*it) == LastNonFixHeader) { // This is to absorb the remaining space completely. We do that because of rounding // error(in the division and multiply calculus) that might leave some space unoccupied. // Set the RemainingSpace only if it is bigger than nw. if (RemainingSpace > nw) (*it).m_header_area->SetBaseWidth (RemainingSpace); else (*it).m_header_area->SetBaseWidth (nw); } else { RemainingSpace -= nw; (*it).m_header_area->SetBaseWidth (nw); } } } }
void nux::TableCtrl::ComputeNonFloatingColumn | ( | ) | [protected] |
Distribute the width to headers equally, except for fix-width headers. ComputeNonFloatingColumn is called when a new column is added to the table.
Definition at line 1147 of file TableCtrl.cpp.
References nux::ScrollView::m_ViewWidth.
Referenced by SetFloatingColumn().
{ int total_non_fix_column_width = m_ViewWidth; t_u32 num_non_fix_column = (t_u32) m_column_header.size(); total_non_fix_column_width -= (m_bShowRowHeader ? ROWHEADERWIDTH : 0); std::vector<ColumnHeader>::iterator it; for (it = m_column_header.begin(); it != m_column_header.end(); it++) { if ( (*it)._fix_width) { // First do a little correction in case the fix width is less than MIN_COLUMN_WIDTH. if ( (*it)._fix_width_value < MIN_COLUMN_WIDTH) { (*it)._fix_width_value = MIN_COLUMN_WIDTH; } total_non_fix_column_width -= (*it)._fix_width_value; num_non_fix_column--; } } int initial_column_width = 0; if (num_non_fix_column != 0) { initial_column_width = total_non_fix_column_width / num_non_fix_column; } if (initial_column_width < MIN_COLUMN_WIDTH) { initial_column_width = MIN_COLUMN_WIDTH; } for (it = m_column_header.begin(); it != m_column_header.end(); it++) { if ( (*it)._fix_width) { (*it).m_header_area->SetBaseWidth ( (*it)._fix_width_value); } else { if (initial_column_width < MIN_COLUMN_WIDTH) (*it).m_header_area->SetBaseWidth (MIN_COLUMN_WIDTH); else (*it).m_header_area->SetBaseWidth (initial_column_width); } } }
void nux::TableCtrl::DeleteRowHeader | ( | ) |
Delete the row header. All elements are delete.
Definition at line 1599 of file TableCtrl.cpp.
Referenced by ResetTable().
{ std::vector<RowHeader *>::iterator it; for (it = m_row_header.begin(); it != m_row_header.end(); it++) { delete (*it); } m_row_header.clear(); }
void nux::TableCtrl::DeleteRowSizeHandler | ( | ) |
Delete the row size handler. All elements are delete.
Definition at line 1587 of file TableCtrl.cpp.
Referenced by ResetTable().
{
std::vector<sizehandler2 *>::iterator it;
for (it = m_row_sizehandler.begin(); it != m_row_sizehandler.end(); it++)
{
(*it)->UnReference();
}
m_row_sizehandler.clear();
}
void nux::TableCtrl::DrawContent | ( | GraphicsEngine & | GfxContext, |
bool | force_draw | ||
) | [virtual] |
Draw the first column items ///
Reimplemented from nux::ScrollView.
Definition at line 420 of file TableCtrl.cpp.
References nux::ScrollView::_delta_x, nux::ScrollView::_delta_y, nux::Area::GetGeometry(), nux::ScrollView::m_ViewHeight, nux::ScrollView::m_ViewWidth, nux::ScrollView::m_ViewX, nux::ScrollView::m_ViewY, nux::GraphicsEngine::PopModelViewMatrix(), and nux::GraphicsEngine::Push2DTranslationModelViewMatrix().
{ GfxContext.PushClippingRectangle (GetGeometry() ); int num_row = (t_u32) m_row_header.size(); int ItemOffsetY = (m_bShowColumnHeader ? COLUMNHEADERHEIGHT : 0); GfxContext.PushClippingRectangle (Geometry (m_ViewX, m_ViewY + (m_bShowColumnHeader ? COLUMNHEADERHEIGHT : 0), m_ViewWidth, m_ViewHeight - (m_bShowColumnHeader ? COLUMNHEADERHEIGHT : 0) ) ); GfxContext.PushClipOffset (_delta_x, _delta_y); GfxContext.Push2DTranslationModelViewMatrix (_delta_x, _delta_y, 0.0f); { int odd_or_even = 0; for (int r = 0; r < num_row; r++) { if (m_row_header[r]->_table_item->IsParentOpen() ) { Geometry geo = m_row_header[r]->_table_item->_row_header_area->GetGeometry(); if (m_row_header[r]->_table_item->FirstChildNode() != 0) { geo.SetX (m_TableArea->GetBaseX() + (m_bShowRowHeader ? ROWHEADERWIDTH : 0) + ITEM_DEPTH_MARGIN * m_row_header[r]->_table_item->m_depth + OPENCLOSE_BTN_WIDTH); geo.SetY (m_TableArea->GetBaseY() + ItemOffsetY); geo.SetWidth (m_column_header[0].m_header_area->GetBaseWidth() - ITEM_DEPTH_MARGIN * m_row_header[r]->_table_item->m_depth - OPENCLOSE_BTN_WIDTH); } else { geo.SetX (m_TableArea->GetBaseX() + (m_bShowRowHeader ? ROWHEADERWIDTH : 0) + ITEM_DEPTH_MARGIN * m_row_header[r]->_table_item->m_depth); geo.SetY (m_TableArea->GetBaseY() + ItemOffsetY); geo.SetWidth (m_column_header[0].m_header_area->GetBaseWidth() - ITEM_DEPTH_MARGIN * m_row_header[r]->_table_item->m_depth); } // Draw content of a row { m_row_header[r]->_table_item->DrawProperty (GfxContext, this, force_draw, geo, GetPainter(), m_row_header[r], m_column_header, odd_or_even ? GetRowColorEven() : GetRowColorOdd() ); } ItemOffsetY += m_row_header[r]->_table_item->_row_header_area->GetBaseHeight(); } odd_or_even = !odd_or_even; } } GfxContext.PopModelViewMatrix (); GfxContext.PopClipOffset (); GfxContext.PopClippingRectangle(); if (m_vertical_scrollbar_enable) { _vscrollbar->ProcessDraw (GfxContext, force_draw); } if (m_horizontal_scrollbar_enable) { _hscrollbar->ProcessDraw (GfxContext, force_draw); } GfxContext.PopClippingRectangle(); }
void nux::TableCtrl::DrawHeader | ( | GraphicsEngine & | GfxContext | ) |
Draw the first column items ///
DRAW THE HEADER PART ///
Definition at line 823 of file TableCtrl.cpp.
References nux::Area::GetGeometry(), isFloatingColumn(), nux::ScrollView::m_ViewHeight, nux::ScrollView::m_ViewWidth, nux::ScrollView::m_ViewX, and nux::ScrollView::m_ViewY.
{ GfxContext.PushClippingRectangle (Geometry (m_ViewX, m_ViewY /*+ (!m_bShowColumnHeader? COLUMNHEADERHEIGHT : 0)*/, m_ViewWidth, m_ViewHeight /*- (!m_bShowColumnHeader? COLUMNHEADERHEIGHT : 0)*/) ); std::vector<ColumnHeader>::iterator column_iterator; std::vector<RowHeader*>::iterator row_iterator; int ItemOffsetY = 0; t_u32 num_row = (t_u32) m_row_header.size(); ItemOffsetY = (m_bShowColumnHeader ? COLUMNHEADERHEIGHT : 0); for (t_u32 r = 0; r < num_row; r++) { if (m_row_header[r]->_table_item->IsParentOpen() ) { ItemOffsetY += m_row_header[r]->_table_item->_row_header_area->GetBaseHeight(); } } int row_height = 0; for (row_iterator = m_row_header.begin(); row_iterator != m_row_header.end(); row_iterator++) { if ( (*row_iterator)->_table_item->IsParentOpen() ) row_height += (*row_iterator)->_table_item->_row_header_area->GetBaseHeight(); } // Draw Top Header Background Geometry header_geo = Geometry (m_ViewX, m_ViewY, m_ViewWidth, (m_bShowColumnHeader ? COLUMNHEADERHEIGHT : 0) ); //--->GetPainter().Paint2DQuadColor(header_geo, Color(HEADER_BACKGROUND_COLOR)); if (m_bShowColumnHeader) { //GetPainter().PaintShapeCorner(GfxContext, header_geo, 0xFF2f2f2f, eSHAPE_CORNER_ROUND10, eCornerTopLeft|eCornerTopRight); } int xl, yl; // Render header name and vertical separations xl = m_TableArea->GetGeometry().x + (m_bShowRowHeader ? ROWHEADERWIDTH : 0); // skip the width of the Row header yl = m_TableArea->GetGeometry().y + (m_bShowColumnHeader ? COLUMNHEADERHEIGHT : 0); // Paint the first vertical separation line. if (m_bShowRowHeader == false) { // Do not draw the first vertical separation line if the row header is not visible. } else { GetPainter().Draw2DLine (GfxContext, xl, yl, xl, yl + row_height, GetVerticalSeparationLineColor() ); } if (m_bShowColumnHeader) { if (m_bShowRowHeader) { // Draw the Top-Left corner of the header Geometry geo = Geometry (GetBaseX(), GetBaseY(), ROWHEADERWIDTH, COLUMNHEADERHEIGHT); geo.OffsetSize (-1, 0); GetPainter().PaintShape (GfxContext, geo, TABLE_HEADER_BASE_COLOR, eSHAPE_CORNER_ROUND4/*, eCornerTopLeft|eCornerTopRight*/); } for (column_iterator = m_column_header.begin(); column_iterator != m_column_header.end(); column_iterator++) { // if(!isFloatingColumn() && (column_iterator + 1 == m_column_header.end())) // { // // Do not draw the last vertical separation line // break; // } // elements in m_column_header are relative to m_TableArea-> Get their absolute position in geo. Geometry geo = (*column_iterator).m_header_area->GetGeometry(); Geometry header_title_geo = geo; geo.OffsetPosition (m_TableArea->GetBaseX(), m_ViewY); header_title_geo = geo; if ( (column_iterator == m_column_header.begin() ) && (m_bShowRowHeader == false) ) { header_title_geo.OffsetSize (-1, 0); // this is not the first column } else if (column_iterator + 1 == m_column_header.end() ) { // The last column header_title_geo.OffsetSize (-1, 0); header_title_geo.OffsetPosition (1, 0); } else { header_title_geo.OffsetSize (-2, 0); header_title_geo.OffsetPosition (1, 0); } GetPainter().PaintShape (GfxContext, header_title_geo, TABLE_HEADER_BASE_COLOR/*0xFF2f2f2f*/, eSHAPE_CORNER_ROUND4/*, eCornerTopLeft|eCornerTopRight*/); // This is arbitrary to get the text away from the borders of the column. { geo.OffsetPosition (4, 0); geo.OffsetSize (-8, 0); } GetPainter().PaintTextLineStatic (GfxContext, GetSysBoldFont(), geo, (*column_iterator).m_header_area->GetBaseString().GetTCharPtr(), TABLE_HEADER_TEXT_COLOR); if (!isFloatingColumn() && (column_iterator + 1 == m_column_header.end() ) ) { // Do not draw the last vertical separation line if the columns are not floating break; } else { // Paint column vertical separation. xl += (*column_iterator).m_header_area->GetGeometry().GetWidth(); //GetPainter().Draw2DLine(GfxContext, xl, yl, xl, yl + row_height, GetVerticalSeparationLineColor()); } // Draw the column size handler on the line Geometry sizehandler_geo (xl - HANDLERSIZE / 2, m_ViewY, HANDLERSIZE, (m_bShowColumnHeader ? COLUMNHEADERHEIGHT : 0) ); //GetPainter().Paint2DQuadColor(sizehandler_geo, Color(0.1, 0.1, 0.1, 1.0)); } if (isFloatingColumn() && (m_column_header.size() > 0) ) { column_iterator = m_column_header.end() - 1; // Draw the Top-Left corner of the header int width = m_ViewWidth - ( (*column_iterator).m_header_area->GetBaseX() + (*column_iterator).m_header_area->GetBaseWidth() ); if (width > 5) { Geometry geo = Geometry ( (*column_iterator).m_header_area->GetBaseX() + (*column_iterator).m_header_area->GetBaseWidth(), GetBaseY(), width, COLUMNHEADERHEIGHT); geo.OffsetSize (-2, 0); geo.OffsetPosition (4, 0); GetPainter().PaintShape (GfxContext, geo, TABLE_HEADER_BASE_COLOR, eSHAPE_CORNER_ROUND4/*, eCornerTopLeft|eCornerTopRight*/); } } } GfxContext.PopClippingRectangle(); }
void nux::TableCtrl::EmptyTable | ( | ) |
Delete all elements of the tabled below the root node.
Definition at line 2353 of file TableCtrl.cpp.
References QueueDraw().
{ m_TableItemHead->DeleteTree(); QueueDraw(); }
void nux::TableCtrl::EnableApplyItemBestHeight | ( | bool | b | ) |
Enable row to have a height fixed by the contained item.
Definition at line 2343 of file TableCtrl.cpp.
{ m_bEnableItemBestHeight = b; }
virtual void nux::TableCtrl::EnableColumnResizing | ( | bool | b | ) | [inline, virtual] |
EnableResizing the width of column headers.
Enable the resizing to column headers by dragging the line at the right of the column.
Definition at line 145 of file TableCtrl.h.
{ m_bEnableColumnResizing = b; }
void nux::TableCtrl::EnableMouseOverColor | ( | bool | b | ) | [inline] |
Enable the use of a user defined color when the mouse is over the item.
b | If b is True the user defined color replaces the background color when the mouse is over the item. |
Definition at line 235 of file TableCtrl.h.
{ m_IsEnableMouseOverColor = b; }
virtual void nux::TableCtrl::EnableRowResizing | ( | bool | b | ) | [inline, virtual] |
EnableResizing the height of row headers.
Enable the resizing to row headers by dragging the line at the bottom of the row.
Definition at line 136 of file TableCtrl.h.
{ m_bEnableRowResizing = b; }
int nux::TableCtrl::FormatHeader | ( | ) |
Definition at line 1250 of file TableCtrl.cpp.
References nux::ScrollView::m_ViewY.
{ int x = m_TableArea->GetBaseX(); int y = m_TableArea->GetBaseY(); int totalWidth = (m_bShowRowHeader ? ROWHEADERWIDTH : 0); std::vector<sizehandler2 *>::iterator size_it; std::vector<ColumnHeader>::iterator column_it; for (column_it = m_column_header.begin(), size_it = m_column_sizehandler.begin(); (column_it != m_column_header.end() ) && (size_it != m_column_sizehandler.end() ); column_it++, size_it++) { (*column_it).m_header_area->SetBaseX (x - m_TableArea->GetBaseX() + (m_bShowRowHeader ? ROWHEADERWIDTH : 0) ); (*column_it).m_header_area->SetBaseY (y - m_TableArea->GetBaseY() ); int w = (*column_it).m_header_area->GetBaseWidth(); if ( (column_it + 1) == m_column_header.end() ) { // This is the last column //int w = (*column_it)->header.GetWidth(); } x += w; totalWidth += w; (*size_it)->SetBaseXY (x + (m_bShowRowHeader ? ROWHEADERWIDTH : 0) - HANDLERSIZE / 2, m_ViewY); } return totalWidth; }
Color nux::TableCtrl::GetMouseOverColor | ( | ) | [inline] |
Return the user defined color used as background color when the mouse is over the item.
Definition at line 227 of file TableCtrl.h.
Referenced by PushItemBackground().
{
return m_MouseOverColor;
}
t_s32 nux::TableCtrl::GetNumColumn | ( | ) |
Get the number of column in the table.
Get the number of column in the table.
Definition at line 2333 of file TableCtrl.cpp.
Referenced by PushItemBackground().
{
return (t_u32) m_column_header.size();
}
int nux::TableCtrl::GetNumRootChild | ( | ) | const [inline] |
Get number of child element of the root node.
Definition at line 416 of file TableCtrl.h.
{
return m_TableItemHead->NumChild();
}
t_s32 nux::TableCtrl::GetNumRow | ( | ) |
Get the number of row in the table.
Get the number of row in the table.
Definition at line 2338 of file TableCtrl.cpp.
{
return (t_u32) m_row_header.size();
}
const TableItem* nux::TableCtrl::GetRootNode | ( | ) | const [inline] |
Get Root Node.
Definition at line 400 of file TableCtrl.h.
{
return m_TableItemHead;
}
TableItem* nux::TableCtrl::GetRootNode | ( | ) | [inline] |
Get Root Node.
Definition at line 408 of file TableCtrl.h.
{
return m_TableItemHead;
}
bool nux::TableCtrl::isFloatingColumn | ( | ) |
Return true if the columns are floating.
Return true if the columns are floating.
Definition at line 2328 of file TableCtrl.cpp.
Referenced by DrawHeader().
{
return m_FloatingColumn;
}
void nux::TableCtrl::PaintDecoration | ( | GraphicsEngine & | GfxContext, |
TableItem * | item | ||
) | [virtual] |
Paint Decoration.
Paint the item hierarchy, open/close decoration in the first column.
item | The item whose decoration must be drawn. |
Definition at line 515 of file TableCtrl.cpp.
References nux::ComputeGeometryPositioning(), nux::TableItem::isOpen(), and nux::TableItem::m_ItemGeometryVector.
Referenced by PushItemBackground().
{ //int ItemOffsetY = (m_bShowColumnHeader? COLUMNHEADERHEIGHT : 0); Geometry geo = item->m_ItemGeometryVector[0]; if ( (item->FirstChildNode() != 0) /* || item->AlwaysShowOpeningButton()*/) { geo.SetX (m_TableArea->GetBaseX() + (m_bShowRowHeader ? ROWHEADERWIDTH : 0) + ITEM_DEPTH_MARGIN * item->m_depth + OPENCLOSE_BTN_WIDTH); //geo.SetY(m_TableArea->GetY() + ItemOffsetY); geo.SetWidth (m_column_header[0].m_header_area->GetBaseWidth() - ITEM_DEPTH_MARGIN * item->m_depth - OPENCLOSE_BTN_WIDTH); } else { geo.SetX (m_TableArea->GetBaseX() + (m_bShowRowHeader ? ROWHEADERWIDTH : 0) + ITEM_DEPTH_MARGIN * item->m_depth); //geo.SetY(m_TableArea->GetY() + ItemOffsetY); geo.SetWidth (m_column_header[0].m_header_area->GetBaseWidth() - ITEM_DEPTH_MARGIN * item->m_depth); } if ( (item->FirstChildNode() != 0) /* || item->AlwaysShowOpeningButton()*/) { if (item->isOpen() ) { GfxContext.PushClippingRectangle (item->m_ItemGeometryVector[0]); geo.OffsetPosition (-OPENCLOSE_BTN_WIDTH, 0); geo.SetWidth (OPENCLOSE_BTN_WIDTH); GeometryPositioning gp (eHACenter, eVACenter); Geometry GeoPo = ComputeGeometryPositioning (geo, GetTheme().GetImageGeometry (eTREE_NODE_OPEN), gp); GetPainter().PaintShape (GfxContext, GeoPo, Color (0xFF000000), eTREE_NODE_OPEN); GfxContext.PopClippingRectangle(); } else { GfxContext.PushClippingRectangle (item->m_ItemGeometryVector[0]); geo.OffsetPosition (-OPENCLOSE_BTN_WIDTH, 0); geo.SetWidth (OPENCLOSE_BTN_WIDTH); GeometryPositioning gp (eHACenter, eVACenter); Geometry GeoPo = ComputeGeometryPositioning (geo, GetTheme().GetImageGeometry (eTREE_NODE_CLOSE), gp); GetPainter().PaintShape (GfxContext, GeoPo, Color (0xFF000000), eTREE_NODE_CLOSE); GfxContext.PopClippingRectangle(); } } }
void nux::TableCtrl::PaintRowDecoration | ( | GraphicsEngine & | GfxContext, |
TableItem * | item, | ||
Color | color | ||
) | [virtual] |
Paint Item row header decoration.
item | The item whose row header must be drawn. |
Definition at line 563 of file TableCtrl.cpp.
{ if (m_bShowRowHeader) { Geometry geo = item->m_RowHeaderGeometry; GetPainter().Paint2DQuadColor (GfxContext, geo, color); GetPainter().PaintTextLineStatic (GfxContext, GetFont (), geo, "i"); } }
void nux::TableCtrl::PopItemBackground | ( | GraphicsEngine & | GfxContext, |
t_u32 | NumBackground | ||
) |
Pop the item background pushed on the painter stack.
Pop the item background pushed on the painter stack.
NumBackground | The number of background to pop of the painter stack. |
Definition at line 741 of file TableCtrl.cpp.
References nux::BasePainter::PopBackground().
{ GetPainter().PopBackground (NumBackground); }
t_u32 nux::TableCtrl::PushItemBackground | ( | GraphicsEngine & | GfxContext, |
TableItem * | item, | ||
bool | MouseOver = false |
||
) |
Paint Item Background.
Paint Item Background. Also push the background on the painter background stack.
Definition at line 573 of file TableCtrl.cpp.
References GetMouseOverColor(), GetNumColumn(), nux::TableItem::m_ItemGeometryVector, nux::ScrollView::m_ViewHeight, nux::ScrollView::m_ViewWidth, nux::ScrollView::m_ViewX, nux::ScrollView::m_ViewY, and PaintDecoration().
{ Geometry row_geometry = item->m_TotalGeometry; Color BackgroundColor = item->m_ItemBackgroundColor; if (MouseOver && m_IsEnableMouseOverColor) BackgroundColor = GetMouseOverColor(); t_u32 NumBackground = 0; GetPainter().PushShapeLayer (GfxContext, Geometry (m_ViewX, m_ViewY, m_ViewWidth, m_ViewHeight), eSHAPE_CORNER_ROUND2, Color (0xFF4D4D4D), eAllCorners); NumBackground++; if (item->m_bIsFirstVisibleItem && item->m_bIsLastVisibleItem) { if (m_bShowColumnHeader) { GetPainter().PushDrawShapeLayer (GfxContext, row_geometry, eSHAPE_CORNER_ROUND2, BackgroundColor, eCornerBottomLeft | eCornerBottomRight); NumBackground++; } else { GetPainter().PushDrawShapeLayer (GfxContext, row_geometry, eSHAPE_CORNER_ROUND2, BackgroundColor, eAllCorners); NumBackground++; } } else if (item->m_bIsFirstVisibleItem) { if (m_bShowColumnHeader) { GetPainter().PushDrawColorLayer (GfxContext, row_geometry, BackgroundColor); NumBackground++; } else { GetPainter().PushDrawShapeLayer (GfxContext, row_geometry, eSHAPE_CORNER_ROUND2, BackgroundColor, eCornerTopLeft | eCornerTopRight); NumBackground++; } } else if (item->m_bIsLastVisibleItem) { GetPainter().PushDrawShapeLayer (GfxContext, row_geometry, eSHAPE_CORNER_ROUND2, BackgroundColor, eCornerBottomLeft | eCornerBottomRight); NumBackground++; } else { GetPainter().PushDrawColorLayer (GfxContext, row_geometry, BackgroundColor); NumBackground++; } bool isSelected = (item == GetSelectedItem() ); Color SelectionColor = GetSelectionColor(); if (MouseOver && m_IsEnableMouseOverColor) SelectionColor = GetMouseOverColor(); int SelectedColumn = GetSelectedColumn(); for (t_s32 Column = 0; Column < GetNumColumn(); Column++) { if (isSelected && (SelectedColumn == Column) ) { if (item->m_bIsFirstVisibleItem && item->m_bIsLastVisibleItem) { if (m_bShowColumnHeader) { t_s32 corners = 0L; if (Column == 0 && !m_bShowRowHeader) corners |= eCornerBottomLeft; if (Column == GetNumColumn() - 1) corners |= eCornerBottomRight; GetPainter().PushDrawShapeLayer (GfxContext, item->m_ItemGeometryVector[Column], eSHAPE_CORNER_ROUND2, SelectionColor, corners); NumBackground++; } else { GetPainter().PushDrawShapeLayer (GfxContext, item->m_ItemGeometryVector[Column], eSHAPE_CORNER_ROUND2, SelectionColor, eAllCorners); NumBackground++; } } else if (item->m_bIsFirstVisibleItem) { if (m_bShowColumnHeader) { GetPainter().PushDrawColorLayer (GfxContext, item->m_ItemGeometryVector[Column], SelectionColor); NumBackground++; } else { t_s32 corners = 0L; if (Column == 0 && !m_bShowRowHeader) corners |= eCornerTopLeft; if (Column == GetNumColumn() - 1) corners |= eCornerTopRight; GetPainter().PushDrawShapeLayer (GfxContext, item->m_ItemGeometryVector[Column], eSHAPE_CORNER_ROUND2, SelectionColor, corners); NumBackground++; } } else if (item->m_bIsLastVisibleItem) { if (Column == 0) { if (m_bShowRowHeader == false) { GetPainter().PushDrawShapeLayer (GfxContext, item->m_ItemGeometryVector[Column], eSHAPE_CORNER_ROUND2, SelectionColor, eCornerBottomLeft); NumBackground++; } else { GetPainter().PushDrawColorLayer (GfxContext, item->m_ItemGeometryVector[Column], SelectionColor); NumBackground++; } } else if (Column == GetNumColumn() - 1) { GetPainter().PushDrawShapeLayer (GfxContext, item->m_ItemGeometryVector[Column], eSHAPE_CORNER_ROUND2, SelectionColor, eCornerBottomRight); NumBackground++; } else { GetPainter().PushDrawColorLayer (GfxContext, item->m_ItemGeometryVector[Column], SelectionColor); NumBackground++; } } else { GetPainter().PushDrawColorLayer (GfxContext, item->m_ItemGeometryVector[Column], SelectionColor); NumBackground++; } } if (m_bShowRowHeader == true || Column != 0) { if (m_bShowVerticalSeparationLine) { GetPainter().Draw2DLine (GfxContext, item->m_ItemGeometryVector[Column].x, item->m_ItemGeometryVector[Column].y, item->m_ItemGeometryVector[Column].x, item->m_ItemGeometryVector[Column].y + item->m_ItemGeometryVector[Column].GetHeight(), GetVerticalSeparationLineColor() ); } } if (Column == 0) PaintDecoration (GfxContext, item); } // Draw horizontal line if (item->m_bIsLastVisibleItem == false) if (m_bShowHorizontalSeparationLine) GetPainter().Draw2DLine (GfxContext, row_geometry.x, row_geometry.y + row_geometry.GetHeight() - 1, row_geometry.x + row_geometry.GetWidth(), row_geometry.y + row_geometry.GetHeight() - 1, GetHorizontalSeparationLineColor() ); return NumBackground; }
void nux::TableCtrl::QueueDraw | ( | ) | [protected, virtual] |
Causes a redraw. The widget parameter _need_redraw is set to true. The widget Draw(), DrawContent() and PostDraw() are called.
Emits the signal OnQueueDraw.
Reimplemented from nux::View.
Definition at line 2359 of file TableCtrl.cpp.
Referenced by EmptyTable().
{ nuxAssertNoRecursion(); View::QueueDraw(); }
void nux::TableCtrl::ResetItems | ( | ) |
reset Items flags.
Reset the dirty flag of items.
Definition at line 1515 of file TableCtrl.cpp.
{ std::vector<RowHeader *>::iterator it; // position the visible parts of m_row_header and m_row_sizehandler only according to m_row_header[i]->_table_item->IsParentOpen() for (it = m_row_header.begin(); it != m_row_header.end(); it++) { (*it)->_table_item->setDirtyItem (false); (*it)->_table_item->m_bIsMouseInside = false; } m_selectedColumn = -1; m_selectedRow = -1; m_selectedTableItem = 0; }
void nux::TableCtrl::ResetTable | ( | ) |
Repopulate the table starting at the root node. Recreate the m_row_header.
Definition at line 1554 of file TableCtrl.cpp.
References DeleteRowHeader(), DeleteRowSizeHandler(), nux::TableItem::isOpen(), and nux::TableItem::Show().
Referenced by nux::TableItem::Unlink().
{ DeleteRowSizeHandler(); DeleteRowHeader(); m_tableNumRow = 0; m_selectedRow = -1; m_selectedColumn = -1; m_selectedTableItem = 0; TableItem *child = (TableItem *) m_TableItemHead->FirstChildNode(); if (child == 0) return; while (child) { if (child->isOpen() ) OpOpenItem (child); else OpCloseItem (child); child->Show(); child = (TableItem *) child->Next(); } child = (TableItem *) m_TableItemHead->FirstChildNode(); TraverseItem (child, false, &TableCtrl::OpAddItem); OpBuildItemDepth (child, 0); FormatTable(); ComputeChildLayout(); }
void nux::TableCtrl::SetFloatingColumn | ( | bool | b | ) |
set Floating column.
Set if the header have floating columns or not. With floating column, the total width of the headers may be greater that the width of the content view area (the horizontal scrollbar will reflect that). With non floating columns, the sum of all headers width is exactly equal to the width of the content view area.
Definition at line 2316 of file TableCtrl.cpp.
References ComputeNonFloatingColumn().
{ m_FloatingColumn = b; if (m_FloatingColumn == false) { ComputeNonFloatingColumn(); } FormatTable(); }
void nux::TableCtrl::SetMouseOverColor | ( | Color | color | ) | [inline] |
Set ItemBackgroundColor when the mouse is over the Item.
Set ItemBackgroundColor when the mouse is over the Item. This color supersedes other background colors.
Definition at line 219 of file TableCtrl.h.
{ m_MouseOverColor = color; }
void nux::TableCtrl::setTableItems | ( | TableItem * | item, |
bool | isOpen = false |
||
) |
Add an item has a direct child of the Root of the Table. The root of the Table is never displayed. Only its children are displayed.
item | The item to add. |
isOpen | If TRUE, the item will . |
Definition at line 1533 of file TableCtrl.cpp.
References nux::TableItem::Show().
{ if (item == 0) return; m_TableItemHead->PushChildBack (item); if (isOpen) OpOpenItem (item); else OpCloseItem (item); item->Show(); TraverseItem (item, false, &TableCtrl::OpAddItem); OpBuildItemDepth (item, 0); FormatTable(); ComputeChildLayout(); }
void nux::TableCtrl::ShowColumnHeader | ( | bool | b | ) | [virtual] |
Show the column headers.
Show the column headers. Columns are titled according to the name given when addColumn() is called.
Definition at line 2291 of file TableCtrl.cpp.
Referenced by TableCtrl().
{ m_bShowColumnHeader = b; FormatTable(); }
void nux::TableCtrl::ShowHorizontalSeparationLine | ( | bool | b | ) |
Show the rows horizontal separation lines.
Show the rows horizontal separation lines.
b | If b is true the horizontal separation lines are visible. |
Definition at line 2303 of file TableCtrl.cpp.
{ m_bShowHorizontalSeparationLine = b; FormatTable(); }
void nux::TableCtrl::ShowRowHeader | ( | bool | b | ) | [virtual] |
Show the row headers.
Show the row headers. Rows are numbered from 0 to the number of row - 1.
Definition at line 2285 of file TableCtrl.cpp.
Referenced by TableCtrl().
{ m_bShowRowHeader = b; FormatTable(); }
void nux::TableCtrl::ShowVerticalSeparationLine | ( | bool | b | ) |
Show the columns vertical separation lines.
Show the columns vertical separation lines.
b | If b is true the vertical separation lines are visible. |
Definition at line 2297 of file TableCtrl.cpp.
{ m_bShowVerticalSeparationLine = b; FormatTable(); }