]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/databrow.cpp
ignore WinCE projects and build directories
[wxWidgets.git] / src / mac / carbon / databrow.cpp
index 8bd705589d9f173fa878cd28c155a7292b56bd6f..a4485f8bc5a0c514014e9dc14dacbe3fa1e81e60 100644 (file)
@@ -982,6 +982,8 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da
 
 void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice)
 {
+  DataBrowserTableViewColumnIndex columnIndex;
+
   wxDataViewColumn* dataViewColumnPtr;
 
   wxDataViewCtrl* dataViewCtrlPtr;
@@ -990,10 +992,10 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowse
 
   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());
@@ -1001,6 +1003,10 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowse
   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());
@@ -1019,16 +1025,53 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowse
   content.left   += 5;
   content.right  -= 3;
   content.bottom -= 3;
- // extra space for the scrollbars: 
+ // extra space for the scrollbars:
   content.bottom -= wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y);
   content.right  -= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
 
- // make sure that 'Render' can draw only in the allowed area:  
-  dataViewCustomRendererPtr->GetDC()->SetClippingRegion(content.left,content.top,content.right-content.left+1,content.bottom-content.top+1);
-  (void) (dataViewCustomRendererPtr->Render(wxRect(static_cast<int>(rectangle->left),static_cast<int>(rectangle->top),
-                                                   static_cast<int>(1+rectangle->right-rectangle->left),static_cast<int>(1+rectangle->bottom-rectangle->top)),
-                                            dataViewCustomRendererPtr->GetDC(),((state == kDataBrowserItemIsSelected) ? wxDATAVIEW_CELL_SELECTED : 0)));
-  dataViewCustomRendererPtr->GetDC()->DestroyClippingRegion(); // probably not necessary
+  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)