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;
return true;
}
-wxControl* wxDataViewTextRenderer::CreateEditorCtrl( wxWindow *parent,
+wxWindow* wxDataViewTextRenderer::CreateEditorCtrl( wxWindow *parent,
wxRect labelRect, const wxVariant &value )
{
wxTextCtrl* ctrl = new wxTextCtrl( parent, wxID_ANY, value,
return ctrl;
}
-bool wxDataViewTextRenderer::GetValueFromEditorCtrl( wxControl *editor, wxVariant &value )
+bool wxDataViewTextRenderer::GetValueFromEditorCtrl( wxWindow *editor, wxVariant &value )
{
wxTextCtrl *text = (wxTextCtrl*) editor;
value = text->GetValue();
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);
return true;
}
-bool wxDataViewToggleRenderer::WXOnLeftClick(wxPoint WXUNUSED(cursor),
- wxRect WXUNUSED(cell),
+bool wxDataViewToggleRenderer::WXOnLeftClick(const wxPoint& cursor,
+ const wxRect& WXUNUSED(cell),
wxDataViewModel *model,
const wxDataViewItem& item,
unsigned int col)
{
+ // only react to clicks directly on the checkbox, not elsewhere in the same cell:
+ if (!wxRect(GetSize()).Contains(cursor))
+ return false;
+
if (model->IsEnabled(item, col))
{
model->ChangeValue(!m_toggle, item, col);
return GetTextExtent(m_date.FormatDate());
}
-bool wxDataViewDateRenderer::WXOnActivate(wxRect WXUNUSED(cell),
+bool wxDataViewDateRenderer::WXOnActivate(const wxRect& WXUNUSED(cell),
wxDataViewModel *model,
const wxDataViewItem& item,
unsigned int col)
return wxSize(80,20);
}
-wxControl* wxDataViewIconTextRenderer::CreateEditorCtrl(wxWindow *parent, wxRect labelRect, const wxVariant& value)
+wxWindow* wxDataViewIconTextRenderer::CreateEditorCtrl(wxWindow *parent, wxRect labelRect, const wxVariant& value)
{
wxDataViewIconText iconText;
iconText << value;
return ctrl;
}
-bool wxDataViewIconTextRenderer::GetValueFromEditorCtrl( wxControl *editor, wxVariant& value )
+bool wxDataViewIconTextRenderer::GetValueFromEditorCtrl( wxWindow *editor, wxVariant& value )
{
wxTextCtrl *text = (wxTextCtrl*) editor;
dc.DrawRectangle(GetClientSize());
#endif
+ if ( IsEmpty() )
+ {
+ // No items to draw.
+ return;
+ }
+
// prepare the DC
GetOwner()->PrepareDC( dc );
dc.SetFont( GetFont() );
wxMin( (int)( GetLineAt( wxMax(0,update.y+update.height) ) - item_start + 1),
(int)(GetRowCount( ) - item_start));
unsigned int item_last = item_start + item_count;
- // Get the parent of DataViewCtrl
- wxWindow *parent = GetParent()->GetParent();
+
+ // Send the event to wxDataViewCtrl itself.
+ wxWindow * const parent = GetParent();
wxDataViewEvent cache_event(wxEVT_COMMAND_DATAVIEW_CACHE_HINT, parent->GetId());
- cache_event.SetEventObject(GetParent());
+ cache_event.SetEventObject(parent);
cache_event.SetCache(item_start, item_last - 1);
parent->ProcessWindowEvent(cache_event);
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];