X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e86edab05be77792498289f0605b49629bb912af..a02a5cfcf33bb2c0edae246c1b19e286bf86d422:/src/osx/dataview_osx.cpp diff --git a/src/osx/dataview_osx.cpp b/src/osx/dataview_osx.cpp index 7fd68d183c..bde6716c21 100644 --- a/src/osx/dataview_osx.cpp +++ b/src/osx/dataview_osx.cpp @@ -12,7 +12,6 @@ #if (wxUSE_DATAVIEWCTRL != 0) && (!defined(wxUSE_GENERICDATAVIEWCTRL) || (wxUSE_GENERICDATAVIEWCTRL == 0)) -#include #include #ifndef WX_PRECOMP @@ -38,7 +37,7 @@ wxString ConcatenateDataViewItemValues(wxDataViewCtrl const* dataViewCtrlPtr, wx { // variable definition: wxVariant dataValue; - + dataViewCtrlPtr->GetModel()->GetValue(dataValue,dataViewItem,dataViewCtrlPtr->GetColumn(i)->GetModelColumn()); if (i > 0) dataString << wxT('\t'); @@ -98,8 +97,8 @@ bool wxOSXDataViewModelNotifier::ItemAdded(wxDataViewItem const& parent, wxDataV wxCHECK_MSG(item.IsOk(),false,_("Added item is invalid.")); - noFailureFlag = this->m_DataViewCtrlPtr->GetDataViewPeer()->Add(parent,item); - this->AdjustRowHeight(item); + noFailureFlag = m_DataViewCtrlPtr->GetDataViewPeer()->Add(parent,item); + AdjustRowHeight(item); return noFailureFlag; } @@ -109,9 +108,9 @@ bool wxOSXDataViewModelNotifier::ItemsAdded(wxDataViewItem const& parent, wxData // insert all valid items into control: - noFailureFlag = this->m_DataViewCtrlPtr->GetDataViewPeer()->Add(parent,items); + noFailureFlag = m_DataViewCtrlPtr->GetDataViewPeer()->Add(parent,items); // adjust row heights: - this->AdjustRowHeights(items); + AdjustRowHeights(items); // done: return noFailureFlag; } @@ -119,18 +118,18 @@ bool wxOSXDataViewModelNotifier::ItemsAdded(wxDataViewItem const& parent, wxData bool wxOSXDataViewModelNotifier::ItemChanged(wxDataViewItem const& item) { wxCHECK_MSG(item.IsOk(), false,_("Changed item is invalid.")); - wxCHECK_MSG(this->GetOwner() != NULL,false,_("Owner not initialized.")); - if (this->m_DataViewCtrlPtr->GetDataViewPeer()->Update(this->GetOwner()->GetParent(item),item)) + wxCHECK_MSG(GetOwner() != NULL,false,_("Owner not initialized.")); + if (m_DataViewCtrlPtr->GetDataViewPeer()->Update(GetOwner()->GetParent(item),item)) { // sent the equivalent wxWidget event: - wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,this->m_DataViewCtrlPtr->GetId()); + wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId()); - dataViewEvent.SetEventObject(this->m_DataViewCtrlPtr); + dataViewEvent.SetEventObject(m_DataViewCtrlPtr); dataViewEvent.SetItem(item); // sent the equivalent wxWidget event: - this->m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent); + m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent); // row height may have to be adjusted: - this->AdjustRowHeight(item); + AdjustRowHeight(item); // done return true; } @@ -142,21 +141,21 @@ bool wxOSXDataViewModelNotifier::ItemsChanged(wxDataViewItemArray const& items) { size_t const noOfItems = items.GetCount(); - wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,this->m_DataViewCtrlPtr->GetId()); + wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId()); - dataViewEvent.SetEventObject(this->m_DataViewCtrlPtr); + dataViewEvent.SetEventObject(m_DataViewCtrlPtr); for (size_t indexItem=0; indexItemm_DataViewCtrlPtr->GetDataViewPeer()->Update(this->GetOwner()->GetParent(items[indexItem]),items[indexItem])) + if (m_DataViewCtrlPtr->GetDataViewPeer()->Update(GetOwner()->GetParent(items[indexItem]),items[indexItem])) { // send for all changed items a wxWidget event: dataViewEvent.SetItem(items[indexItem]); - this->m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent); + m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent); } else return false; // if this location is reached all items have been updated: - this->AdjustRowHeights(items); + AdjustRowHeights(items); // done: return true; } @@ -171,10 +170,10 @@ bool wxOSXDataViewModelNotifier::ItemDeleted(wxDataViewItem const& parent, wxDat // not to be identical because the being edited item might be below the passed item in the hierarchy); // to prevent the control trying to ask the model to update an already deleted item the control is informed that currently a deleting process // has been started and that variables can currently not be updated even when requested by the system: - this->m_DataViewCtrlPtr->SetDeleting(true); - noFailureFlag = this->m_DataViewCtrlPtr->GetDataViewPeer()->Remove(parent,item); + m_DataViewCtrlPtr->SetDeleting(true); + noFailureFlag = m_DataViewCtrlPtr->GetDataViewPeer()->Remove(parent,item); // enable automatic updating again: - this->m_DataViewCtrlPtr->SetDeleting(false); + m_DataViewCtrlPtr->SetDeleting(false); // done: return noFailureFlag; } @@ -188,11 +187,11 @@ bool wxOSXDataViewModelNotifier::ItemsDeleted(wxDataViewItem const& parent, wxDa // not to be identical because the being edited item might be below the passed item in the hierarchy); // to prevent the control trying to ask the model to update an already deleted item the control is informed that currently a deleting process // has been started and that variables can currently not be updated even when requested by the system: - this->m_DataViewCtrlPtr->SetDeleting(true); + m_DataViewCtrlPtr->SetDeleting(true); // delete all specified items: - noFailureFlag = this->m_DataViewCtrlPtr->GetDataViewPeer()->Remove(parent,items); + noFailureFlag = m_DataViewCtrlPtr->GetDataViewPeer()->Remove(parent,items); // enable automatic updating again: - this->m_DataViewCtrlPtr->SetDeleting(false); + m_DataViewCtrlPtr->SetDeleting(false); // done: return noFailureFlag; } @@ -200,16 +199,16 @@ bool wxOSXDataViewModelNotifier::ItemsDeleted(wxDataViewItem const& parent, wxDa bool wxOSXDataViewModelNotifier::ValueChanged(wxDataViewItem const& item, unsigned int col) { wxCHECK_MSG(item.IsOk(), false,_("Passed item is invalid.")); - wxCHECK_MSG(this->GetOwner() != NULL,false,_("Owner not initialized.")); - if (this->m_DataViewCtrlPtr->GetDataViewPeer()->Update(this->GetOwner()->GetParent(item),item)) + wxCHECK_MSG(GetOwner() != NULL,false,_("Owner not initialized.")); + if (m_DataViewCtrlPtr->GetDataViewPeer()->Update(GetOwner()->GetParent(item),item)) { - wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,this->m_DataViewCtrlPtr->GetId()); + wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId()); - dataViewEvent.SetEventObject(this->m_DataViewCtrlPtr); + dataViewEvent.SetEventObject(m_DataViewCtrlPtr); dataViewEvent.SetColumn(col); dataViewEvent.SetItem(item); // send the equivalent wxWidget event: - this->m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent); + m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent); // done return true; } @@ -219,27 +218,27 @@ bool wxOSXDataViewModelNotifier::ValueChanged(wxDataViewItem const& item, unsign bool wxOSXDataViewModelNotifier::Cleared() { - return this->m_DataViewCtrlPtr->GetDataViewPeer()->Reload(); + return m_DataViewCtrlPtr->GetDataViewPeer()->Reload(); } void wxOSXDataViewModelNotifier::Resort() { - this->m_DataViewCtrlPtr->GetDataViewPeer()->Resort(); + m_DataViewCtrlPtr->GetDataViewPeer()->Resort(); } void wxOSXDataViewModelNotifier::AdjustRowHeight(wxDataViewItem const& item) { - if ((this->m_DataViewCtrlPtr->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) != 0) + if ((m_DataViewCtrlPtr->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) != 0) { - wxDataViewModel *model = this->GetOwner(); + wxDataViewModel *model = GetOwner(); int height = 20; // TODO find out standard height - unsigned int num = this->m_DataViewCtrlPtr->GetColumnCount(); + unsigned int num = m_DataViewCtrlPtr->GetColumnCount(); unsigned int col; for (col = 0; col < num; col++) { - wxDataViewColumn* column(this->m_DataViewCtrlPtr->GetColumnPtr(col)); - + wxDataViewColumn* column(m_DataViewCtrlPtr->GetColumnPtr(col)); + if (!(column->IsHidden())) { wxDataViewCustomRenderer *renderer = dynamic_cast(column->GetRenderer()); @@ -253,28 +252,28 @@ void wxOSXDataViewModelNotifier::AdjustRowHeight(wxDataViewItem const& item) } } if (height > 20) - this->m_DataViewCtrlPtr->GetDataViewPeer()->SetRowHeight(item,height); + m_DataViewCtrlPtr->GetDataViewPeer()->SetRowHeight(item,height); } } void wxOSXDataViewModelNotifier::AdjustRowHeights(wxDataViewItemArray const& items) { - if ((this->m_DataViewCtrlPtr->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) != 0) + if ((m_DataViewCtrlPtr->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) != 0) { size_t const noOfItems = items.GetCount(); - wxDataViewModel *model = this->GetOwner(); + wxDataViewModel *model = GetOwner(); for (size_t itemIndex=0; itemIndexm_DataViewCtrlPtr->GetColumnCount(); + unsigned int num = m_DataViewCtrlPtr->GetColumnCount(); unsigned int col; for (col = 0; col < num; col++) { - wxDataViewColumn* column(this->m_DataViewCtrlPtr->GetColumnPtr(col)); - + wxDataViewColumn* column(m_DataViewCtrlPtr->GetColumnPtr(col)); + if (!(column->IsHidden())) { wxDataViewCustomRenderer *renderer = dynamic_cast(column->GetRenderer()); @@ -288,7 +287,7 @@ void wxOSXDataViewModelNotifier::AdjustRowHeights(wxDataViewItemArray const& ite } } if (height > 20) - this->m_DataViewCtrlPtr->GetDataViewPeer()->SetRowHeight(items[itemIndex],height); + m_DataViewCtrlPtr->GetDataViewPeer()->SetRowHeight(items[itemIndex],height); } } } @@ -299,25 +298,16 @@ void wxOSXDataViewModelNotifier::AdjustRowHeights(wxDataViewItemArray const& ite // dependent methods can be found in the environment's // source file. // --------------------------------------------------------- -wxDataViewCustomRenderer::~wxDataViewCustomRenderer(void) -{ - delete this->m_DCPtr; -} - -void wxDataViewCustomRenderer::RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state ) +wxDataViewCustomRenderer::~wxDataViewCustomRenderer() { - wxDataViewCtrl *view = GetOwner()->GetOwner(); - - wxColour col = (state & wxDATAVIEW_CELL_SELECTED) ? *wxWHITE : view->GetForegroundColour(); - dc->SetTextForeground(col); - dc->DrawText( text, cell.x + xoffset, cell.y + ((cell.height - dc->GetCharHeight()) / 2)); + delete m_DCPtr; } wxDC* wxDataViewCustomRenderer::GetDC() { - if ((this->m_DCPtr == NULL) && (this->GetOwner() != NULL) && (this->GetOwner()->GetOwner() != NULL)) - this->m_DCPtr = new wxClientDC(this->GetOwner()->GetOwner()); - return this->m_DCPtr; + if ((m_DCPtr == NULL) && (GetOwner() != NULL) && (GetOwner()->GetOwner() != NULL)) + m_DCPtr = new wxClientDC(GetOwner()->GetOwner()); + return m_DCPtr; } void wxDataViewCustomRenderer::SetDC(wxDC* newDCPtr) @@ -326,23 +316,13 @@ void wxDataViewCustomRenderer::SetDC(wxDC* newDCPtr) m_DCPtr = newDCPtr; } -// --------------------------------------------------------- -// wxDataViewTextRendererAttr -// --------------------------------------------------------- -wxDataViewTextRendererAttr::wxDataViewTextRendererAttr(wxString const& varianttype, wxDataViewCellMode mode, int align) - :wxDataViewTextRenderer(varianttype,mode,align) -{ -} - -IMPLEMENT_CLASS(wxDataViewTextRendererAttr,wxDataViewTextRenderer) - //----------------------------------------------------------------------------- // wxDataViewCtrl //----------------------------------------------------------------------------- wxDataViewCtrl::~wxDataViewCtrl() { - this->ClearColumns(); + ClearColumns(); } void wxDataViewCtrl::Init() @@ -355,18 +335,18 @@ void wxDataViewCtrl::Init() bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator ) { - if (!(this->wxControl::Create(parent,id,pos,size,style & ~(wxHSCROLL | wxVSCROLL),validator))) + if (!(wxControl::Create(parent,id,pos,size,style & ~(wxHSCROLL | wxVSCROLL),validator))) return false; - m_peer = ::CreateDataView(this,parent,id,pos,size,style,this->GetExtraStyle()); + m_peer = ::CreateDataView(this,parent,id,pos,size,style,GetExtraStyle()); - this->MacPostControlCreate(pos,size); + MacPostControlCreate(pos,size); return true; } bool wxDataViewCtrl::AssociateModel(wxDataViewModel* model) { - wxDataViewWidgetImpl* dataViewWidgetPtr(this->GetDataViewPeer()); + wxDataViewWidgetImpl* dataViewWidgetPtr(GetDataViewPeer()); wxCHECK_MSG(dataViewWidgetPtr != NULL,false,_("Pointer to native control must not be NULL.")); @@ -392,35 +372,35 @@ bool wxDataViewCtrl::PrependColumn(wxDataViewColumn* columnPtr) bool wxDataViewCtrl::InsertColumn(unsigned int pos, wxDataViewColumn* columnPtr) { - wxDataViewWidgetImpl* dataViewWidgetPtr(this->GetDataViewPeer()); + 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(this->GetModel() != NULL, false,_("No model associated with control.")); + wxCHECK_MSG(GetModel() != NULL, false,_("No model associated with control.")); wxCHECK_MSG((columnPtr->GetModelColumn() >= 0) && - (columnPtr->GetModelColumn() < this->GetModel()->GetColumnCount()),false,_("Column's model column has no equivalent in the associated model.")); + (columnPtr->GetModelColumn() < GetModel()->GetColumnCount()),false,_("Column's model column has no equivalent in the associated model.")); // add column to wxWidget's internal structure: - if (this->wxDataViewCtrlBase::InsertColumn(pos,columnPtr)) + if (wxDataViewCtrlBase::InsertColumn(pos,columnPtr)) { - this->m_ColumnPtrs.Add(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 (this->GetColumnCount() == 1) - this->SetExpanderColumn(columnPtr); + if (GetColumnCount() == 1) + SetExpanderColumn(columnPtr); // done: return true; } else { // clean-up: - this->m_ColumnPtrs.Remove(columnPtr); + m_ColumnPtrs.Remove(columnPtr); delete columnPtr; // and send a message in debug mode: wxFAIL_MSG(_("Column could not be added to native control.")); @@ -440,9 +420,9 @@ bool wxDataViewCtrl::InsertColumn(unsigned int pos, wxDataViewColumn* columnPtr) bool wxDataViewCtrl::ClearColumns() { - if (this->GetDataViewPeer()->ClearColumns()) + if (GetDataViewPeer()->ClearColumns()) { - WX_CLEAR_ARRAY(this->m_ColumnPtrs); + WX_CLEAR_ARRAY(m_ColumnPtrs); return true; } else @@ -451,9 +431,9 @@ bool wxDataViewCtrl::ClearColumns() bool wxDataViewCtrl::DeleteColumn(wxDataViewColumn* columnPtr) { - if (this->GetDataViewPeer()->DeleteColumn(columnPtr)) + if (GetDataViewPeer()->DeleteColumn(columnPtr)) { - this->m_ColumnPtrs.Remove(columnPtr); + m_ColumnPtrs.Remove(columnPtr); delete columnPtr; return true; } @@ -463,57 +443,57 @@ bool wxDataViewCtrl::DeleteColumn(wxDataViewColumn* columnPtr) wxDataViewColumn* wxDataViewCtrl::GetColumn(unsigned int pos) const { - return this->GetDataViewPeer()->GetColumn(pos); + return GetDataViewPeer()->GetColumn(pos); } unsigned int wxDataViewCtrl::GetColumnCount() const { - return this->m_ColumnPtrs.GetCount(); + return m_ColumnPtrs.GetCount(); } int wxDataViewCtrl::GetColumnPosition(wxDataViewColumn const* columnPtr) const { - return this->GetDataViewPeer()->GetColumnPosition(columnPtr); + return GetDataViewPeer()->GetColumnPosition(columnPtr); } void wxDataViewCtrl::Collapse(wxDataViewItem const& item) { - this->GetDataViewPeer()->Collapse(item); + GetDataViewPeer()->Collapse(item); } void wxDataViewCtrl::EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) { if (item.IsOk()) { - this->ExpandAncestors(item); // make sure that the item exists in the control - this->GetDataViewPeer()->EnsureVisible(item,columnPtr); + ExpandAncestors(item); // make sure that the item exists in the control + GetDataViewPeer()->EnsureVisible(item,columnPtr); } } void wxDataViewCtrl::Expand(wxDataViewItem const& item) { - return this->GetDataViewPeer()->Expand(item); + return GetDataViewPeer()->Expand(item); } bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const { - return (item.IsOk() && this->GetDataViewPeer()->IsExpanded(item)); + return (item.IsOk() && GetDataViewPeer()->IsExpanded(item)); } wxDataViewColumn* wxDataViewCtrl::GetSortingColumn() const { - return this->GetDataViewPeer()->GetSortingColumn(); + return GetDataViewPeer()->GetSortingColumn(); } unsigned int wxDataViewCtrl::GetCount() const { - return this->GetDataViewPeer()->GetCount(); + return GetDataViewPeer()->GetCount(); } wxRect wxDataViewCtrl::GetItemRect(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) const { if (item.IsOk() && (columnPtr != NULL)) - return this->GetDataViewPeer()->GetRectangle(item,columnPtr); + return GetDataViewPeer()->GetRectangle(item,columnPtr); else return wxRect(); } @@ -523,7 +503,7 @@ wxDataViewItem wxDataViewCtrl::GetSelection() const wxDataViewItemArray itemIDs; - if (this->GetDataViewPeer()->GetSelections(itemIDs) > 0) + if (GetDataViewPeer()->GetSelections(itemIDs) > 0) return itemIDs[0]; else return wxDataViewItem(); @@ -531,31 +511,31 @@ wxDataViewItem wxDataViewCtrl::GetSelection() const int wxDataViewCtrl::GetSelections(wxDataViewItemArray& sel) const { - return this->GetDataViewPeer()->GetSelections(sel); + return GetDataViewPeer()->GetSelections(sel); } void wxDataViewCtrl::HitTest(wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const { - return this->GetDataViewPeer()->HitTest(point,item,columnPtr); + return GetDataViewPeer()->HitTest(point,item,columnPtr); } bool wxDataViewCtrl::IsSelected(wxDataViewItem const& item) const { - return this->GetDataViewPeer()->IsSelected(item); + return GetDataViewPeer()->IsSelected(item); } void wxDataViewCtrl::Select(wxDataViewItem const& item) { if (item.IsOk()) { - this->ExpandAncestors(item); // make sure that the item exists in the control - this->GetDataViewPeer()->Select(item); + ExpandAncestors(item); // make sure that the item exists in the control + GetDataViewPeer()->Select(item); } } -void wxDataViewCtrl::SelectAll(void) +void wxDataViewCtrl::SelectAll() { - this->GetDataViewPeer()->SelectAll(); + GetDataViewPeer()->SelectAll(); } void wxDataViewCtrl::SetSelections(wxDataViewItemArray const& sel) @@ -571,15 +551,15 @@ void wxDataViewCtrl::SetSelections(wxDataViewItemArray const& sel) for (i = 0; i < noOfSelections; i++) { wxDataViewItem item = sel[i]; - wxDataViewItem parent = this->GetModel()->GetParent( item ); + wxDataViewItem parent = GetModel()->GetParent( item ); if (parent.IsOk() && (parent != last_parent)) - this->ExpandAncestors(item); + ExpandAncestors(item); last_parent = parent; } // finally select the items: - wxDataViewWidgetImpl* dataViewWidgetPtr(this->GetDataViewPeer()); // variable definition for abbreviational purposes + wxDataViewWidgetImpl* dataViewWidgetPtr(GetDataViewPeer()); // variable definition for abbreviational purposes for (i=0; iSelect(sel[i]); @@ -588,20 +568,20 @@ void wxDataViewCtrl::SetSelections(wxDataViewItemArray const& sel) void wxDataViewCtrl::Unselect(wxDataViewItem const& item) { if (item.IsOk()) - this->GetDataViewPeer()->Unselect(item); + GetDataViewPeer()->Unselect(item); } -void wxDataViewCtrl::UnselectAll(void) +void wxDataViewCtrl::UnselectAll() { - this->GetDataViewPeer()->UnselectAll(); + GetDataViewPeer()->UnselectAll(); } // // implementation // -wxDataViewWidgetImpl* wxDataViewCtrl::GetDataViewPeer(void) const +wxDataViewWidgetImpl* wxDataViewCtrl::GetDataViewPeer() const { - return dynamic_cast(this->GetPeer()); + return dynamic_cast(GetPeer()); } void wxDataViewCtrl::AddChildren(wxDataViewItem const& parentItem) @@ -611,29 +591,30 @@ void wxDataViewCtrl::AddChildren(wxDataViewItem const& parentItem) wxDataViewItemArray items; - wxCHECK_RET(this->GetModel() != NULL,_("Model pointer not initialized.")); - noOfChildren = this->GetModel()->GetChildren(parentItem,items); - (void) this->GetModel()->ItemsAdded(parentItem,items); + wxCHECK_RET(GetModel() != NULL,_("Model pointer not initialized.")); + noOfChildren = GetModel()->GetChildren(parentItem,items); + (void) GetModel()->ItemsAdded(parentItem,items); } -void wxDataViewCtrl::FinishCustomItemEditing(void) +void wxDataViewCtrl::FinishCustomItemEditing() { - if (this->GetCustomRendererItem().IsOk()) + if (GetCustomRendererItem().IsOk()) { - this->GetCustomRendererPtr()->FinishEditing(); - this->SetCustomRendererItem(wxDataViewItem()); - this->SetCustomRendererPtr (NULL); + GetCustomRendererPtr()->FinishEditing(); + SetCustomRendererItem(wxDataViewItem()); + SetCustomRendererPtr (NULL); } } /*static*/ -wxVisualAttributes wxDataViewCtrl::GetClassDefaultAttributes(wxWindowVariant variant) +wxVisualAttributes +wxDataViewCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) { wxVisualAttributes attr; attr.colFg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ); attr.colBg = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX ); - attr.font.MacCreateFromThemeFont(kThemeViewsFont); + attr.font.CreateSystemFont(wxOSX_SYSTEM_FONT_VIEWS); return attr; } @@ -641,25 +622,25 @@ wxVisualAttributes wxDataViewCtrl::GetClassDefaultAttributes(wxWindowVariant var // inherited methods from wxDataViewCtrlBase void wxDataViewCtrl::DoSetExpanderColumn() { - if (this->GetExpanderColumn() != NULL) - this->GetDataViewPeer()->DoSetExpanderColumn(this->GetExpanderColumn()); + if (GetExpanderColumn() != NULL) + GetDataViewPeer()->DoSetExpanderColumn(GetExpanderColumn()); } void wxDataViewCtrl::DoSetIndent() { - this->GetDataViewPeer()->DoSetIndent(this->GetIndent()); + GetDataViewPeer()->DoSetIndent(GetIndent()); } // event handling: void wxDataViewCtrl::OnSize(wxSizeEvent& event) { - unsigned int const noOfColumns = this->GetColumnCount(); + unsigned int const noOfColumns = GetColumnCount(); // reset DC of all custom renderers because DC has changed: for (unsigned int i=0; iGetColumn(i)); + wxDataViewColumn* dataViewColumnPtr(GetColumn(i)); if (dataViewColumnPtr != NULL) { @@ -671,15 +652,77 @@ void wxDataViewCtrl::OnSize(wxSizeEvent& event) } // update the layout of the native control after a size event: - this->GetDataViewPeer()->OnSize(); + GetDataViewPeer()->OnSize(); event.Skip(); } +wxSize wxDataViewCtrl::DoGetBestSize() const +{ + wxSize best = wxControl::DoGetBestSize(); + best.y = 80; + + return best; +} + +void wxDataViewCtrl::OnMouse(wxMouseEvent& event) +{ + event.Skip(); + + if (GetModel() == NULL) + return; + +#if 0 + // Doesn't compile anymore + wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast(m_peer)); + + int NoOfChildren; + wxDataViewItemArray items; + NoOfChildren = GetModel()->GetChildren( wxDataViewItem(), items); + if (NoOfChildren == 0) + return; + wxDataViewItem firstChild = items[0]; + + UInt16 headerHeight = 0; + MacDataViewListCtrlPtr->GetHeaderButtonHeight(&headerHeight); + + + if (event.GetY() < headerHeight) + { + unsigned int col_count = GetColumnCount(); + unsigned int col; + for (col = 0; col < col_count; col++) + { + wxDataViewColumn *column = GetColumn( col ); + if (column->IsHidden()) + continue; + + Rect itemrect; + ::GetDataBrowserItemPartBounds( MacDataViewListCtrlPtr->GetControlRef(), + reinterpret_cast(firstChild.GetID()), column->GetPropertyID(), + kDataBrowserPropertyEnclosingPart, &itemrect ); + + if (abs( event.GetX() - itemrect.right) < 3) + { + if (column->GetFlags() & wxDATAVIEW_COL_RESIZABLE) + SetCursor( wxCursor( wxCURSOR_SIZEWE ) ); + else + SetCursor( *wxSTANDARD_CURSOR ); + return; + } + } + + } + + SetCursor( *wxSTANDARD_CURSOR ); +#endif +} + IMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl,wxDataViewCtrlBase) BEGIN_EVENT_TABLE(wxDataViewCtrl,wxDataViewCtrlBase) EVT_SIZE(wxDataViewCtrl::OnSize) + EVT_MOTION(wxDataViewCtrl::OnMouse) END_EVENT_TABLE() #endif // (wxUSE_DATAVIEWCTRL != 0) && (!defined(wxUSE_GENERICDATAVIEWCTRL) || (wxUSE_GENERICDATAVIEWCTRL == 0))