model->Resort();
owner->OnColumnChange(idx);
+
+ SendEvent(wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, idx);
}
void OnRClick(wxHeaderCtrlEvent& event)
int GetLineHeight( unsigned int row ) const; // m_lineHeight in fixed mode
int GetLineAt( unsigned int y ) const; // y / m_lineHeight in fixed mode
+ void SetRowHeight( int lineHeight ) { m_lineHeight = lineHeight; }
+
// Some useful functions for row and item mapping
wxDataViewItem GetItemByRow( unsigned int row ) const;
int GetRowByItem( const wxDataViewItem & item ) const;
bool wxDataViewBitmapRenderer::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
{
- if (m_bitmap.Ok())
+ if (m_bitmap.IsOk())
dc->DrawBitmap( m_bitmap, cell.x, cell.y );
- else if (m_icon.Ok())
+ else if (m_icon.IsOk())
dc->DrawIcon( m_icon, cell.x, cell.y );
return true;
wxSize wxDataViewBitmapRenderer::GetSize() const
{
- if (m_bitmap.Ok())
+ if (m_bitmap.IsOk())
return wxSize( m_bitmap.GetWidth(), m_bitmap.GetHeight() );
- else if (m_icon.Ok())
+ else if (m_icon.IsOk())
return wxSize( m_icon.GetWidth(), m_icon.GetHeight() );
return wxSize(wxDVC_DEFAULT_RENDERER_SIZE,wxDVC_DEFAULT_RENDERER_SIZE);
dc.DrawRectangle(GetClientSize());
#endif
+ if ( IsEmpty() )
+ {
+ // No items to draw.
+ return;
+ }
+
// prepare the DC
GetOwner()->PrepareDC( dc );
dc.SetFont( GetFont() );
dataitem = node->GetItem();
- if ((i > 0) && model->IsContainer(dataitem) &&
- !model->HasContainerColumns(dataitem))
+ // Skip all columns of "container" rows except the expander
+ // column itself unless HasContainerColumns() overrides this.
+ if ( col != GetOwner()->GetExpanderColumn() &&
+ model->IsContainer(dataitem) &&
+ !model->HasContainerColumns(dataitem) )
continue;
}
else
// Find the item along the parent-chain.
// This algorithm is designed to speed up the node-finding method
wxDataViewTreeNode* node = m_root;
- for( unsigned iter = parentChain.size()-1; iter>=0; --iter )
+ for( unsigned iter = parentChain.size()-1; ; --iter )
{
if( node->HasChildren() )
{
}
else
return NULL;
+
+ if ( !iter )
+ break;
}
return NULL;
}
break;
case WXK_DOWN:
- if ( m_currentRow < GetRowCount() - 1 )
+ if ( m_currentRow + 1 < GetRowCount() )
OnArrowChar( m_currentRow + 1, event );
break;
// Add the process for tree expanding/collapsing
if (!IsRowSelected(current))
{
SelectAllRows(false);
+ const unsigned oldCurrent = m_currentRow;
ChangeCurrentRow(current);
SelectRow(m_currentRow,true);
+ RefreshRow(oldCurrent);
SendSelectionChangedEvent(GetItemByRow( m_currentRow ) );
}
}
Layout();
AdjustScrollbars();
+
+ // We must redraw the headers if their height changed. Normally this
+ // shouldn't happen as the control shouldn't let itself be resized beneath
+ // its minimal height but avoid the display artefacts that appear if it
+ // does happen, e.g. because there is really not enough vertical space.
+ if ( !HasFlag(wxDV_NO_HEADER) && m_headerArea &&
+ m_headerArea->GetSize().y <= m_headerArea->GetBestSize(). y )
+ {
+ m_headerArea->Refresh();
+ }
}
void wxDataViewCtrl::SetFocus()
return m_cols.GetCount();
}
+bool wxDataViewCtrl::SetRowHeight( int lineHeight )
+{
+ if ( !m_clientArea )
+ return false;
+
+ m_clientArea->SetRowHeight(lineHeight);
+
+ return true;
+}
+
wxDataViewColumn* wxDataViewCtrl::GetColumn( unsigned int idx ) const
{
return m_cols[idx];