const wxString &name = wxT("wxdataviewctrlmainwindow") );
virtual ~wxDataViewMainWindow();
- bool IsList() const { return GetOwner()->GetModel()->IsListModel(); }
+ bool IsList() const { return GetModel()->IsListModel(); }
bool IsVirtualList() const { return m_root == NULL; }
// notifications from wxDataViewModel
void SortPrepare()
{
- g_model = GetOwner()->GetModel();
+ g_model = GetModel();
wxDataViewColumn* col = GetOwner()->GetSortingColumn();
if( !col )
{
wxDataViewCtrl *GetOwner() { return m_owner; }
const wxDataViewCtrl *GetOwner() const { return m_owner; }
+ wxDataViewModel* GetModel() { return GetOwner()->GetModel(); }
+ const wxDataViewModel* GetModel() const { return GetOwner()->GetModel(); }
+
#if wxUSE_DRAG_AND_DROP
wxBitmap CreateItemBitmap( unsigned int row, int &indent );
#endif // wxUSE_DRAG_AND_DROP
wxDataViewItem item = GetItemByRow( row );
- wxDataViewModel *model = GetOwner()->GetModel();
+ wxDataViewModel *model = GetModel();
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE, m_owner->GetId() );
event.SetEventObject( m_owner );
wxDataViewItem item = GetItemByRow( row );
- wxDataViewModel *model = GetOwner()->GetModel();
+ wxDataViewModel *model = GetModel();
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE, m_owner->GetId() );
event.SetEventObject( m_owner );
wxDataViewItem item = GetItemByRow( row );
- wxDataViewModel *model = GetOwner()->GetModel();
+ wxDataViewModel *model = GetModel();
wxCustomDataObject *obj = (wxCustomDataObject *) GetDropTarget()->GetDataObject();
void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
{
- wxDataViewModel *model = GetOwner()->GetModel();
+ wxDataViewModel *model = GetModel();
wxAutoBufferedPaintDC dc( this );
#ifdef __WXMSW__
if (IsVirtualList())
{
wxDataViewVirtualListModel *list_model =
- (wxDataViewVirtualListModel*) GetOwner()->GetModel();
+ (wxDataViewVirtualListModel*) GetModel();
m_count = list_model->GetCount();
}
else
return false;
wxDataViewTreeNode *itemNode = new wxDataViewTreeNode(parentNode, item);
- itemNode->SetHasChildren(GetOwner()->GetModel()->IsContainer(item));
+ itemNode->SetHasChildren(GetModel()->IsContainer(item));
parentNode->SetHasChildren(true);
parentNode->AddChild(itemNode);
if (IsVirtualList())
{
wxDataViewVirtualListModel *list_model =
- (wxDataViewVirtualListModel*) GetOwner()->GetModel();
+ (wxDataViewVirtualListModel*) GetModel();
m_count = list_model->GetCount();
if ( !m_selection.empty() )
// If this was the last child to be removed, it's possible the parent
// node became a leaf. Let's ask the model about it.
if ( parentNode->GetChildNodes().empty() )
- parentNode->SetHasChildren(GetOwner()->GetModel()->IsContainer(parent));
+ parentNode->SetHasChildren(GetModel()->IsContainer(parent));
return false;
}
// If this was the last child to be removed, it's possible the parent
// node became a leaf. Let's ask the model about it.
if ( parentNode->GetChildNodes().empty() )
- parentNode->SetHasChildren(GetOwner()->GetModel()->IsContainer(parent));
+ parentNode->SetHasChildren(GetModel()->IsContainer(parent));
// Update selection by removing 'item' and its entire children tree from the selection.
if ( !m_selection.empty() )
wxWindow *parent = GetParent();
wxDataViewEvent le(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, parent->GetId());
le.SetEventObject(parent);
- le.SetModel(GetOwner()->GetModel());
+ le.SetModel(GetModel());
le.SetItem(item);
parent->GetEventHandler()->ProcessEvent(le);
wxWindow *parent = GetParent();
wxDataViewEvent le(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, parent->GetId());
le.SetEventObject(parent);
- le.SetModel(GetOwner()->GetModel());
+ le.SetModel(GetModel());
le.SetItem(item);
le.SetColumn(view_column);
le.SetDataViewColumn(GetOwner()->GetColumn(view_column));
m_selection.Clear();
SortPrepare();
- BuildTree( GetOwner()->GetModel() );
+ BuildTree( GetModel() );
GetOwner()->UpdateColBestWidths();
UpdateDisplay();
void wxDataViewMainWindow::RecalculateDisplay()
{
- wxDataViewModel *model = GetOwner()->GetModel();
+ wxDataViewModel *model = GetModel();
if (!model)
{
Refresh();
wxDataViewEvent le(wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, parent->GetId());
le.SetEventObject(parent);
- le.SetModel(GetOwner()->GetModel());
+ le.SetModel(GetModel());
le.SetItem( item );
parent->GetEventHandler()->ProcessEvent(le);
int wxDataViewMainWindow::GetLineStart( unsigned int row ) const
{
- const wxDataViewModel *model = GetOwner()->GetModel();
+ const wxDataViewModel *model = GetModel();
if (GetOwner()->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT)
{
int wxDataViewMainWindow::GetLineAt( unsigned int y ) const
{
- const wxDataViewModel *model = GetOwner()->GetModel();
+ const wxDataViewModel *model = GetModel();
// check for the easy case first
if ( !GetOwner()->HasFlag(wxDV_VARIABLE_LINE_HEIGHT) )
int wxDataViewMainWindow::GetLineHeight( unsigned int row ) const
{
- const wxDataViewModel *model = GetOwner()->GetModel();
+ const wxDataViewModel *model = GetModel();
if (GetOwner()->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT)
{
wxDataViewEvent le(type, parent->GetId());
le.SetEventObject(parent);
- le.SetModel(GetOwner()->GetModel());
+ le.SetModel(GetModel());
le.SetItem( item );
return !parent->ProcessWindowEvent(le) || le.IsAllowed();
if( node->GetChildNodes().empty() )
{
SortPrepare();
- ::BuildTreeHelper(GetOwner()->GetModel(), node->GetItem(), node);
+ ::BuildTreeHelper(GetModel(), node->GetItem(), node);
}
// By expanding the node all row indices that are currently in the selection list
wxDataViewTreeNode * wxDataViewMainWindow::FindNode( const wxDataViewItem & item )
{
- const wxDataViewModel * model = GetOwner()->GetModel();
+ const wxDataViewModel * model = GetModel();
if( model == NULL )
return NULL;
if (IsVirtualList())
{
wxDataViewVirtualListModel *list_model =
- (wxDataViewVirtualListModel*) GetOwner()->GetModel();
+ (wxDataViewVirtualListModel*) GetModel();
return list_model->GetCount();
}
int wxDataViewMainWindow::GetRowByItem(const wxDataViewItem & item) const
{
- const wxDataViewModel * model = GetOwner()->GetModel();
+ const wxDataViewModel * model = GetModel();
if( model == NULL )
return -1;
{
DestroyTree();
- if (GetOwner()->GetModel()->IsVirtualListModel())
+ if (GetModel()->IsVirtualListModel())
{
m_count = -1;
return;
parent->GetId());
le.SetItem( GetItemByRow(m_currentRow) );
le.SetEventObject(parent);
- le.SetModel(GetOwner()->GetModel());
+ le.SetModel(GetModel());
parent->GetEventHandler()->ProcessEvent(le);
}
}
}
- wxDataViewModel *model = GetOwner()->GetModel();
+ wxDataViewModel *model = GetModel();
#if wxUSE_DRAG_AND_DROP
if (event.Dragging())
le.SetColumn( col->GetModelColumn() );
le.SetDataViewColumn( col );
le.SetEventObject(parent);
- le.SetModel(GetOwner()->GetModel());
+ le.SetModel(GetModel());
parent->GetEventHandler()->ProcessEvent(le);
}
le.SetColumn( col->GetModelColumn() );
le.SetDataViewColumn( col );
le.SetEventObject(parent);
- le.SetModel(GetOwner()->GetModel());
+ le.SetModel(GetModel());
le.SetValue(value);
parent->GetEventHandler()->ProcessEvent(le);
}