+ wxDataViewColumn* dataViewColumnPtr;
+
+ wxDataViewCtrl* dataViewCtrlPtr;
+
+ wxDataViewCustomRenderer* dataViewCustomRendererPtr;
+
+ wxVariant dataToRender;
+
+ dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetPeer());
+ wxCHECK_RET(dataViewCtrlPtr != NULL, _("Pointer to data view control not set correctly."));
+ wxCHECK_RET(dataViewCtrlPtr->GetModel() != NULL,_("Pointer to model not set correctly."));
+ wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex) == noErr,_("Could not determine column index."));
+ dataViewColumnPtr = dataViewCtrlPtr->GetColumnPtr(propertyID);
+ wxCHECK_RET(dataViewColumnPtr != NULL,_("No column for the specified column index existing."));
+ dataViewCustomRendererPtr = dynamic_cast<wxDataViewCustomRenderer*>(dataViewColumnPtr->GetRenderer());
+ wxCHECK_RET(dataViewCustomRendererPtr != NULL,_("No renderer or invalid renderer type specified for custom data column."));
+ dataViewCtrlPtr->GetModel()->GetValue(dataToRender,wxDataViewItem(reinterpret_cast<void*>(itemID)),dataViewColumnPtr->GetModelColumn());
+ dataViewCustomRendererPtr->SetValue(dataToRender);
+
+ wxDataViewItem dataitem( reinterpret_cast<void*>(itemID) );
+ dataViewCtrlPtr->GetModel()->GetValue(dataToRender,dataitem,columnIndex);
+ dataViewCustomRendererPtr->SetValue(dataToRender);
+
+ // try to determine the content's size (drawable part):
+ Rect content;
+ RgnHandle rgn(NewRgn());
+ UInt16 headerHeight;
+
+ if (this->GetRegion(kControlContentMetaPart,rgn) == noErr)
+ GetRegionBounds(rgn,&content);
+ else
+ this->GetRect(&content);
+ ::DisposeRgn(rgn);
+ // space for the header
+ this->GetHeaderButtonHeight(&headerHeight);
+ content.top += headerHeight;
+ // extra space for the frame (todo: do not how to determine the space automatically from the control)
+ content.top += 5;
+ content.left += 5;
+ content.right -= 3;
+ content.bottom -= 3;
+ // extra space for the scrollbars:
+ content.bottom -= wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y);
+ content.right -= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
+
+ wxDC *dc = dataViewCustomRendererPtr->GetDC();
+
+ wxRect cellrect( static_cast<int>(rectangle->left),
+ static_cast<int>(rectangle->top+2),
+ static_cast<int>(1+rectangle->right-rectangle->left),
+ static_cast<int>(rectangle->bottom-rectangle->top) );
+
+ bool is_active = IsControlActive( this->m_controlRef );
+ if (state == kDataBrowserItemIsSelected)
+ {
+
+ wxColour col( wxMacCreateCGColorFromHITheme( (is_active) ?
+ kThemeBrushAlternatePrimaryHighlightColor
+ : kThemeBrushSecondaryHighlightColor ) );
+
+ wxRect rect = cellrect;
+ Rect itemrect;
+ GetDataBrowserItemPartBounds( this->m_controlRef, itemID, propertyID,
+ kDataBrowserPropertyEnclosingPart, &itemrect );
+ rect.x = itemrect.left;
+ rect.width = itemrect.right-itemrect.left+1;
+
+ wxBrush selBrush( col );
+ wxPen oldpen( dc->GetPen() );
+ wxBrush oldbrush( dc->GetBrush() );
+ dc->SetPen( *wxTRANSPARENT_PEN );
+ dc->SetBrush( selBrush );
+ dc->DrawRectangle(rect);
+ dc->SetBrush( oldbrush );
+ dc->SetPen( oldpen );
+ }
+
+ wxDataViewModel *model = dataViewCtrlPtr->GetModel();
+ if ((columnIndex == 0) || !model->IsContainer(dataitem) || model->HasContainerColumns(dataitem))
+ {
+ // make sure that 'Render' can draw only in the allowed area:
+ dc->SetClippingRegion(content.left,content.top,content.right-content.left+1,content.bottom-content.top+1);
+ (void) (dataViewCustomRendererPtr->Render( cellrect, dc,
+ ((state == kDataBrowserItemIsSelected) ? wxDATAVIEW_CELL_SELECTED : 0)));
+ dc->DestroyClippingRegion(); // probably not necessary
+ }
+
+ dataViewCustomRendererPtr->SetDC(NULL);
+} /* wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemState, Rect const*, SInt16, Boolean) */
+
+Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserEditItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, CFStringRef theString, Rect* maxEditTextRect, Boolean* shrinkToFit)
+{
+ return false;
+} /* wxMacDataViewDataBrowserListViewControl::DataBrowserEditItemProc(DataBrowserItemID, DataBrowserPropertyID, CFStringRef, Rect*, Boolean*) */
+
+Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserHitTestProc(DataBrowserItemID WXUNUSED(itemID), DataBrowserPropertyID WXUNUSED(property), Rect const* WXUNUSED(theRect), Rect const* WXUNUSED(mouseRect))
+{
+ return true;
+} /* wxMacDataViewDataBrowserListViewControl::DataBrowserHitTestProc(DataBrowserItemID, DataBrowserPropertyID, Rect const*, Rect const*) */
+
+DataBrowserTrackingResult wxMacDataViewDataBrowserListViewControl::DataBrowserTrackingProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, Rect const* theRect, Point WXUNUSED(startPt), EventModifiers WXUNUSED(modifiers))
+{
+ wxDataViewColumn* dataViewColumnPtr;
+
+ wxDataViewCtrl* dataViewCtrlPtr;
+
+ wxDataViewCustomRenderer* dataViewCustomRendererPtr;
+
+ wxDataViewItem dataViewCustomRendererItem;
+
+
+ dataViewCustomRendererItem = reinterpret_cast<void*>(itemID);
+ wxCHECK_MSG(dataViewCustomRendererItem.IsOk(),kDataBrowserNothingHit,_("Invalid data view item"));
+ dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetPeer());
+ wxCHECK_MSG(dataViewCtrlPtr != NULL,kDataBrowserNothingHit,_("Pointer to data view control not set correctly."));
+ dataViewColumnPtr = dataViewCtrlPtr->GetColumnPtr(propertyID);
+ wxCHECK_MSG(dataViewColumnPtr != NULL,kDataBrowserNothingHit,_("No column existing."));
+ dataViewCustomRendererPtr = dynamic_cast<wxDataViewCustomRenderer*>(dataViewColumnPtr->GetRenderer());
+ wxCHECK_MSG(dataViewCustomRendererPtr != NULL,kDataBrowserNothingHit,_("No renderer or invalid renderer type specified for custom data column."));
+ // if the currently edited item is identical to the to be edited nothing is done (this hit should only be handled in the control itself):
+ if (dataViewCtrlPtr->GetCustomRendererItem() == dataViewCustomRendererItem)
+ return kDataBrowserContentHit;
+ // an(other) item is going to be edited and therefore the current editing - if existing - has to be finished:
+ if (dataViewCtrlPtr->GetCustomRendererPtr() != NULL)
+ {
+ dataViewCtrlPtr->GetCustomRendererPtr()->FinishEditing();
+ dataViewCtrlPtr->SetCustomRendererItem(wxDataViewItem());
+ dataViewCtrlPtr->SetCustomRendererPtr (NULL);
+ } /* if */
+ // check if renderer has got a valid editor control for editing; if this is the case start editing of the new item:
+ if (dataViewCustomRendererPtr->HasEditorCtrl())
+ {
+ // variable definition:
+ wxRect wxRectangle;
+
+ ::wxMacNativeToRect(theRect,&wxRectangle);
+ dataViewCustomRendererPtr->StartEditing(dataViewCustomRendererItem,wxRectangle);
+ dataViewCtrlPtr->SetCustomRendererItem(dataViewCustomRendererItem);
+ dataViewCtrlPtr->SetCustomRendererPtr (dataViewCustomRendererPtr);
+ } /* if */
+ return kDataBrowserContentHit;
+} /* wxMacDataViewDataBrowserListViewControl::DataBrowserTrackingProc(DataBrowserItemID, DataBrowserPropertyID, Rect const*, Point, EventModifiers) */
+
+#endif // wxUSE_GENERICDATAVIEWCTRL
+#endif // wxUSE_DATAVIEWCTRL