wxRect wxDataViewCtrl::GetItemRect(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) const { if (item.IsOk() && (columnPtr != NULL)) return GetDataViewPeer()->GetRectangle(item,columnPtr); else return wxRect(); }
void wxDataViewCtrl::SetSelections(wxDataViewItemArray const& sel) { size_t const noOfSelections = sel.GetCount(); size_t i; wxDataViewItem last_parent; // make sure that all to be selected items are visible in the control: for (i = 0; i < noOfSelections; i++) { wxDataViewItem item = sel[i]; wxDataViewItem parent = GetModel()->GetParent( item ); if (parent.IsOk() && (parent != last_parent)) ExpandAncestors(item); last_parent = parent; } // finally select the items: wxDataViewWidgetImpl* dataViewWidgetPtr(GetDataViewPeer()); // variable definition for abbreviational purposes for (i=0; i<noOfSelections; ++i) dataViewWidgetPtr->Select(sel[i]); }
void wxDataViewCtrl::EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) { if (item.IsOk()) { ExpandAncestors(item); // make sure that the item exists in the control GetDataViewPeer()->EnsureVisible(item,columnPtr); } }
void wxDataViewCtrl::Select(wxDataViewItem const& item) { if (item.IsOk()) { ExpandAncestors(item); // make sure that the item exists in the control GetDataViewPeer()->Select(item); } }
bool wxDataViewCtrl::ClearColumns() { if (GetDataViewPeer()->ClearColumns()) { WX_CLEAR_ARRAY(m_ColumnPtrs); return true; } else return false; }
wxDataViewItem wxDataViewCtrl::GetSelection() const { wxDataViewItemArray itemIDs; if (GetDataViewPeer()->GetSelections(itemIDs) > 0) return itemIDs[0]; else return wxDataViewItem(); }
bool wxDataViewCtrl::DeleteColumn(wxDataViewColumn* columnPtr) { if (GetDataViewPeer()->DeleteColumn(columnPtr)) { m_ColumnPtrs.Remove(columnPtr); delete columnPtr; return true; } else return false; }
bool wxDataViewCtrl::AssociateModel(wxDataViewModel* model) { wxDataViewWidgetImpl* dataViewWidgetPtr(GetDataViewPeer()); wxCHECK_MSG(dataViewWidgetPtr != NULL,false,"Pointer to native control must not be NULL."); if (wxDataViewCtrlBase::AssociateModel(model) && dataViewWidgetPtr->AssociateModel(model)) { if (model != NULL) model->AddNotifier(new wxOSXDataViewModelNotifier(this)); return true; } else return false; }
bool wxDataViewCtrl::InsertColumn(unsigned int pos, wxDataViewColumn* columnPtr) { wxDataViewWidgetImpl* dataViewWidgetPtr(GetDataViewPeer()); // first, some error checking: wxCHECK_MSG(dataViewWidgetPtr != NULL, false,"Pointer to native control must not be NULL."); wxCHECK_MSG(columnPtr != NULL, false,"Column pointer must not be NULL."); wxCHECK_MSG(columnPtr->GetRenderer() != NULL, false,"Column does not have a renderer."); wxCHECK_MSG(GetModel() != NULL, false,"No model associated with control."); wxCHECK_MSG(columnPtr->GetModelColumn() < GetModel()->GetColumnCount(),false,"Column's model column has no equivalent in the associated model."); // add column to wxWidget's internal structure: if (wxDataViewCtrlBase::InsertColumn(pos,columnPtr)) { m_ColumnPtrs.Add(columnPtr); // if the insertion in the native control is successful the rest can also be initialized: if (dataViewWidgetPtr->InsertColumn(pos,columnPtr)) { // make sure that the data is up-to-date... // if the newly appended column is the first column add the initial data to the control and mark the column as an expander column, // otherwise ask the control to 'update' the data in the newly appended column: if (GetColumnCount() == 1) SetExpanderColumn(columnPtr); // done: return true; } else { // clean-up: m_ColumnPtrs.Remove(columnPtr); delete columnPtr; // and send a message in debug mode: wxFAIL_MSG("Column could not be added to native control."); // failed: return false; } } else { // clean-up: delete columnPtr; wxFAIL_MSG("Could not add column to internal structures."); // failed: return false; } }
// event handling: void wxDataViewCtrl::OnSize(wxSizeEvent& event) { unsigned int const noOfColumns = GetColumnCount(); // reset DC of all custom renderers because DC has changed: for (unsigned int i=0; i<noOfColumns; ++i) { wxDataViewColumn* dataViewColumnPtr(GetColumn(i)); if (dataViewColumnPtr != NULL) { wxDataViewCustomRenderer* dataViewCustomRendererPtr(dynamic_cast<wxDataViewCustomRenderer*>(dataViewColumnPtr->GetRenderer())); if (dataViewCustomRendererPtr != NULL) dataViewCustomRendererPtr->SetDC(NULL); } } // update the layout of the native control after a size event: GetDataViewPeer()->OnSize(); event.Skip(); }
bool wxDataViewCtrl::AssociateModel(wxDataViewModel* model) { wxDataViewWidgetImpl* dataViewWidgetPtr(GetDataViewPeer()); wxCHECK_MSG(dataViewWidgetPtr != NULL,false,"Pointer to native control must not be NULL."); // We could have been associated with another model previously, break the // association in this case. if ( m_ModelNotifier ) m_ModelNotifier->GetOwner()->RemoveNotifier(m_ModelNotifier); if (wxDataViewCtrlBase::AssociateModel(model) && dataViewWidgetPtr->AssociateModel(model)) { if (model != NULL) { m_ModelNotifier = new wxOSXDataViewModelNotifier(this); model->AddNotifier(m_ModelNotifier); } return true; } else return false; }
void wxDataViewCtrl::UnselectAll() { GetDataViewPeer()->UnselectAll(); }
void wxDataViewCtrl::Unselect(wxDataViewItem const& item) { if (item.IsOk()) GetDataViewPeer()->Unselect(item); }
int wxDataViewCtrl::GetColumnPosition(wxDataViewColumn const* columnPtr) const { return GetDataViewPeer()->GetColumnPosition(columnPtr); }
void wxDataViewCtrl::SelectAll() { GetDataViewPeer()->SelectAll(); }
void wxDataViewCtrl::Collapse(wxDataViewItem const& item) { GetDataViewPeer()->Collapse(item); }
wxDataViewColumn* wxDataViewCtrl::GetSortingColumn() const { return GetDataViewPeer()->GetSortingColumn(); }
void wxDataViewCtrl::DoSetIndent() { GetDataViewPeer()->DoSetIndent(GetIndent()); }
int wxDataViewCtrl::GetSelections(wxDataViewItemArray& sel) const { return GetDataViewPeer()->GetSelections(sel); }
int wxDataViewCtrl::GetSelectedItemsCount() const { return GetDataViewPeer()->GetSelectedItemsCount(); }
void wxDataViewCtrl::Expand(wxDataViewItem const& item) { return GetDataViewPeer()->Expand(item); }
void wxDataViewCtrl::DoSetCurrentItem(const wxDataViewItem& item) { GetDataViewPeer()->SetCurrentItem(item); }
wxDataViewItem wxDataViewCtrl::DoGetCurrentItem() const { return GetDataViewPeer()->GetCurrentItem(); }
unsigned int wxDataViewCtrl::GetCount() const { return GetDataViewPeer()->GetCount(); }
void wxDataViewCtrl::EditItem(const wxDataViewItem& item, const wxDataViewColumn *column) { GetDataViewPeer()->StartEditor(item, GetColumnPosition(column)); }
void wxDataViewCtrl::HitTest(wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const { return GetDataViewPeer()->HitTest(point,item,columnPtr); }
// inherited methods from wxDataViewCtrlBase void wxDataViewCtrl::DoSetExpanderColumn() { if (GetExpanderColumn() != NULL) GetDataViewPeer()->DoSetExpanderColumn(GetExpanderColumn()); }
bool wxDataViewCtrl::IsSelected(wxDataViewItem const& item) const { return GetDataViewPeer()->IsSelected(item); }
wxDataViewColumn *wxDataViewCtrl::GetCurrentColumn() const { return GetDataViewPeer()->GetCurrentColumn(); }
bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const { return (item.IsOk() && GetDataViewPeer()->IsExpanded(item)); }