From 35d85392ff011bc8d24b036ede54e69ab557ed32 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 11 May 2009 11:28:55 +0000 Subject: [PATCH] Reapplied some previous patches that got lost while merging the Cocoa implementation git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60586 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/carbon/dataview.cpp | 20 ++++++++---- src/osx/dataview_osx.cpp | 62 +++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 6 deletions(-) diff --git a/src/osx/carbon/dataview.cpp b/src/osx/carbon/dataview.cpp index c92f3f1ec3..ecacdf72b1 100644 --- a/src/osx/carbon/dataview.cpp +++ b/src/osx/carbon/dataview.cpp @@ -135,7 +135,8 @@ static bool InitializeColumnDescription(DataBrowserListViewColumnDesc& columnDes } if (columnPtr->IsSortable()) columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewSortableColumn; - if (columnPtr->GetRenderer()->GetMode() == wxDATAVIEW_CELL_EDITABLE) + if ((columnPtr->GetRenderer()->GetMode() == wxDATAVIEW_CELL_EDITABLE) || + (columnPtr->GetRenderer()->GetMode() == wxDATAVIEW_CELL_ACTIVATABLE)) columnDescription.propertyDesc.propertyFlags |= kDataBrowserPropertyIsEditable; if ((columnDescription.propertyDesc.propertyType == kDataBrowserCustomType) || (columnDescription.propertyDesc.propertyType == kDataBrowserDateTimeType) || @@ -1637,8 +1638,14 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowse wxDC *dc = dataViewCustomRendererPtr->GetDC(); - wxRect cellrect( static_cast(rectangle->left), - static_cast(rectangle->top), + int active_border_fudge = 0; + if (dataViewCtrlPtr->HasFocus() && !dataViewCtrlPtr->HasFlag( wxBORDER_NONE )) + active_border_fudge = 1; + else + active_border_fudge = -2; + + wxRect cellrect( static_cast(rectangle->left + active_border_fudge), + static_cast(rectangle->top + active_border_fudge), static_cast(1+rectangle->right-rectangle->left), static_cast(rectangle->bottom-rectangle->top) ); @@ -1654,8 +1661,8 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowse Rect itemrect; GetDataBrowserItemPartBounds( this->m_controlRef, itemID, propertyID, kDataBrowserPropertyEnclosingPart, &itemrect ); - rect.x = itemrect.left; - rect.width = itemrect.right-itemrect.left+1; + rect.x = itemrect.left-2; + rect.width = itemrect.right-itemrect.left+3; wxBrush selBrush( col ); wxPen oldpen( dc->GetPen() ); @@ -2168,7 +2175,8 @@ void wxDataViewRenderer::SetMode(wxDataViewCellMode mode) DataBrowserPropertyFlags flags; verify_noerr(macDataViewListCtrlPtr->GetPropertyFlags(dataViewColumnPtr->GetNativeData()->GetPropertyID(),&flags)); - if (mode == wxDATAVIEW_CELL_EDITABLE) + if ((mode == wxDATAVIEW_CELL_EDITABLE) || + (mode == wxDATAVIEW_CELL_ACTIVATABLE)) flags |= kDataBrowserPropertyIsEditable; else flags &= ~kDataBrowserPropertyIsEditable; diff --git a/src/osx/dataview_osx.cpp b/src/osx/dataview_osx.cpp index f8a6889e1e..69e1b27925 100644 --- a/src/osx/dataview_osx.cpp +++ b/src/osx/dataview_osx.cpp @@ -676,10 +676,72 @@ void wxDataViewCtrl::OnSize(wxSizeEvent& event) 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)) -- 2.47.2