]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/carbon/dataview.cpp
Return smaller images for wxART_MENU/BUTTON under OS X.
[wxWidgets.git] / src / osx / carbon / dataview.cpp
index ecacdf72b1e33c4341e2bcf62ead3504e408d540..a08481951fa4d2bcd2b4918d7412188fc7ed035c 100644 (file)
@@ -66,6 +66,12 @@ static DataBrowserItemID* CreateDataBrowserItemIDArray(size_t& noOfEntries, wxDa
   return itemIDs;
 }
 
+static const EventTypeSpec eventList[] =
+{
+    { kEventClassControl, kEventControlHit },
+    { kEventClassControl, kEventControlDraw }
+};
+
 static pascal OSStatus DataBrowserCtrlEventHandler(EventHandlerCallRef handler, EventRef EventReference, void* Data)
 {
   wxDataViewCtrl* DataViewCtrlPtr((wxDataViewCtrl*) Data); // the 'Data' variable always contains a pointer to the data view control that installed the handler
@@ -89,7 +95,9 @@ static pascal OSStatus DataBrowserCtrlEventHandler(EventHandlerCallRef handler,
       {
         ControlRef            controlReference;
         DataBrowserPropertyID columnPropertyID;
+        DataBrowserSortOrder  order;
         unsigned long         columnIndex;
+        wxDataViewColumn*     column;
         OSStatus              status;
         wxDataViewEvent       DataViewEvent(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK,DataViewCtrlPtr->GetId());
 
@@ -101,10 +109,15 @@ static pascal OSStatus DataBrowserCtrlEventHandler(EventHandlerCallRef handler,
         if (status == errDataBrowserPropertyNotFound) // user clicked into part of the header that does not have a property
           return ::CallNextEventHandler(handler,EventReference);
         wxCHECK(status == noErr,status);
+        column = DataViewCtrlPtr->GetColumn(columnIndex);
+       // set the column sort order:
+        status = ::GetDataBrowserSortOrder(controlReference,&order);
+        wxCHECK(status == noErr,status);
+        column->SetSortOrderVariable(order == kDataBrowserOrderIncreasing);
        // initialize wxWidget event handler:
         DataViewEvent.SetEventObject(DataViewCtrlPtr);
         DataViewEvent.SetColumn(columnIndex);
-        DataViewEvent.SetDataViewColumn(DataViewCtrlPtr->GetColumn(columnIndex));
+        DataViewEvent.SetDataViewColumn(column);
        // finally sent the equivalent wxWidget event:
         DataViewCtrlPtr->HandleWindowEvent(DataViewEvent);
         return ::CallNextEventHandler(handler,EventReference);
@@ -211,7 +224,7 @@ pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserCompareProc(ControlR
   if (ControlPtr != NULL)
     return ControlPtr->DataBrowserCompareProc(itemOneID,itemTwoID,sortProperty);
   else
-    return errDataBrowserPropertyNotSupported;
+    return FALSE;
 } /* wxMacDataBrowserTableViewControl::DataBrowserCompareProc(ControlRef, DataBrowserItemID, DataBrowserItemID, DataBrowserPropertyID) */
 
 pascal void wxMacDataBrowserTableViewControl::DataBrowserGetContextualMenuProc(ControlRef browser, MenuRef* menu, UInt32* helpType, CFStringRef* helpItemString, AEDesc* selection)
@@ -276,30 +289,30 @@ pascal DataBrowserTrackingResult wxMacDataBrowserTableViewControl::DataBrowserTr
   if (ControlPtr != NULL)
     return ControlPtr->DataBrowserTrackingProc(itemID,propertyID,theRect,startPt,modifiers);
   else
-    return kDataBrowserNothingHit; 
+    return kDataBrowserNothingHit;
 } /* wxMacDataBrowserTableViewControl::DataBrowserTrackingProc(ControlRef, DataBrowserItemID, DataBrowserPropertyID, Rect const*, Point, EventModifiers) */
 
 pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserAcceptDragProc(ControlRef browser, DragReference dragRef, DataBrowserItemID itemID)
 {
   wxMacDataBrowserTableViewControl* controlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
-  
-  
+
+
   return ((controlPtr != NULL) && controlPtr->DataBrowserAcceptDragProc(dragRef,itemID));
 } /* wxMacDataBrowserTableViewControl::DataBrowserAcceptDragProc(ControlRef, DragReference, DataBrowserItemID) */
 
 pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserAddDragItemProc(ControlRef browser, DragReference dragRef, DataBrowserItemID itemID, ItemReference* itemRef)
 {
   wxMacDataBrowserTableViewControl* controlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
-  
-  
+
+
   return ((controlPtr != NULL) && controlPtr->DataBrowserAddDragItemProc(dragRef,itemID,itemRef));
 } /* wxMacDataBrowserTableViewControl::DataBrowserAddDragItemProc(ControlRef, DragReference, DataBrowserItemID, ItemReference*) */
 
 pascal Boolean wxMacDataBrowserTableViewControl::DataBrowserReceiveDragProc(ControlRef browser, DragReference dragRef, DataBrowserItemID itemID)
 {
   wxMacDataBrowserTableViewControl* controlPtr(dynamic_cast<wxMacDataBrowserTableViewControl*>(wxMacControl::GetReferenceFromNativeControl(browser)));
-  
-  
+
+
   return ((controlPtr != NULL) && controlPtr->DataBrowserReceiveDragProc(dragRef,itemID));
 } /* wxMacDataBrowserTableViewControl::DataBrowserReceiveDragProc(ControlRef, DragReference, DataBrowserItemID) */
 
@@ -312,6 +325,9 @@ wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow* pee
 
   SetReferenceInNativeControl();
   verify_noerr(err);
+
+  ::InstallControlEventHandler(this->m_controlRef, GetDataBrowserCtrlEventHandlerUPP(), GetEventTypeCount(eventList), eventList, peer, (EventHandlerRef *)&m_macDataViewCtrlEventHandler);
+
  // setup standard callbacks:
   if (gDataBrowserTableViewGetContextualMenuUPP == NULL) gDataBrowserTableViewGetContextualMenuUPP = NewDataBrowserGetContextualMenuUPP(wxMacDataBrowserTableViewControl::DataBrowserGetContextualMenuProc);
   if (gDataBrowserTableViewItemCompareUPP       == NULL) gDataBrowserTableViewItemCompareUPP       = NewDataBrowserItemCompareUPP      (wxMacDataBrowserTableViewControl::DataBrowserCompareProc);
@@ -337,9 +353,9 @@ wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow* pee
   callbacks.u.v1.itemDataCallback          = gDataBrowserTableViewItemDataUPP;
   callbacks.u.v1.itemCompareCallback       = gDataBrowserTableViewItemCompareUPP;
   callbacks.u.v1.itemNotificationCallback  = gDataBrowserTableViewItemNotificationUPP;
-       callbacks.u.v1.acceptDragCallback        = gDataBrowserTableViewAcceptDragUPP;
-       callbacks.u.v1.addDragItemCallback       = gDataBrowserTableViewAddDragItemUPP;
-       callbacks.u.v1.receiveDragCallback       = gDataBrowserTableViewReceiveDragUPP;
+  callbacks.u.v1.acceptDragCallback        = gDataBrowserTableViewAcceptDragUPP;
+  callbacks.u.v1.addDragItemCallback       = gDataBrowserTableViewAddDragItemUPP;
+  callbacks.u.v1.receiveDragCallback       = gDataBrowserTableViewReceiveDragUPP;
   this->SetCallbacks(&callbacks);
 
  // setup callbacks for customized items:
@@ -372,7 +388,7 @@ wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow* pee
   }
 
   OptionBits attributes; // variable definition
-  
+
   if (this->GetAttributes(&attributes) == noErr) // get default settings
   {
     if ((style & wxDV_VERT_RULES) != 0)
@@ -390,6 +406,11 @@ wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow* pee
     this->SetHeaderButtonHeight(0);
 } /* wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow*, wxPoint const&, wxSize const&, long) */
 
+wxMacDataBrowserTableViewControl::~wxMacDataBrowserTableViewControl(void)
+{
+  ::RemoveEventHandler((EventHandlerRef) m_macDataViewCtrlEventHandler);
+} /* wxMacDataBrowserTableViewControl::~wxMacDataBrowserTableViewControl(void) */
+
 //
 // callback handling
 //
@@ -570,7 +591,7 @@ OSStatus wxMacDataBrowserTableViewControl::IsUsedPropertyID(DataBrowserPropertyI
  // lead to a large overhead for the call but returns an error code if the property id does not exist, here we use the function that returns
  // the column position for the property id:
   DataBrowserTableViewColumnIndex index;
-  
+
   return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef,propertyID,&index);
 } /* wxMacDataBrowserTableViewControl::IsUsedPropertyId(DataBrowserPropertyID) const */
 
@@ -614,10 +635,10 @@ OSStatus wxMacDataBrowserTableViewControl::AddItems(DataBrowserItemID container,
 OSStatus wxMacDataBrowserTableViewControl::GetFreeItemID(DataBrowserItemID* id) const
 {
   ItemCount noOfItems;
+
   OSStatus status;
-  
-  
+
+
   status = this->GetItemCount(&noOfItems);
   wxCHECK_MSG(status == noErr,status,_("Could not retrieve number of items"));
   if (noOfItems == 0)
@@ -672,7 +693,7 @@ OSStatus wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID itemID
  // lead to a large overhead for the call but returns an error code if the property id does not exist, here we use the function that returns
  // the column position for the property id:
   DataBrowserTableViewColumnIndex index;
-  
+
   return ::GetDataBrowserTableViewItemRow(this->m_controlRef,itemID,&index);
 } /* wxMacDataBrowserTableViewControl::IsUsedItemID(DataBrowserItemID) const */
 
@@ -699,7 +720,7 @@ size_t wxMacDataBrowserTableViewControl::GetSelectedItemIDs(wxArrayDataBrowserIt
 {
   DataBrowserItemID* itemIDPtr;
   Handle handle(::NewHandle(0));
-  
+
   size_t noOfItems;
 
 
@@ -818,8 +839,8 @@ wxMacDataViewDataBrowserListViewControl::wxMacDataViewDataBrowserListViewControl
 bool wxMacDataViewDataBrowserListViewControl::ClearColumns(void)
 {
   UInt32 noOfColumns;
-  
-  
+
+
   wxCHECK_MSG(this->GetColumnCount(&noOfColumns) == noErr,false,_("Could not determine number of columns."));
   for (UInt32 i=0; i<noOfColumns; ++i)
     wxCHECK_MSG(this->RemoveColumnByIndex(0) == noErr,false,_("Could not remove column."));
@@ -883,7 +904,7 @@ bool wxMacDataViewDataBrowserListViewControl::InsertColumn(unsigned int pos, wxD
   if (noOfColumns == 1)
   {
     wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
-    
+
     wxCHECK_MSG(dataViewCtrlPtr != NULL,false,_("wxWidget's control not initialized."));
     dataViewCtrlPtr->AddChildren(wxDataViewItem());
     return true;
@@ -974,11 +995,12 @@ wxRect wxMacDataViewDataBrowserListViewControl::GetRectangle(wxDataViewItem cons
 
 bool wxMacDataViewDataBrowserListViewControl::IsExpanded(wxDataViewItem const& item) const
 {
-  DataBrowserItemState state;
+  DataBrowserItemState state = 0;
 
+  if (this->GetItemState(reinterpret_cast<DataBrowserItemID>(item.GetID()),&state) != noErr)
+     return false;
 
-  return ((this->GetItemState(reinterpret_cast<DataBrowserItemID>(item.GetID()),&state) == noErr) &&
-          (state & kDataBrowserContainerIsOpen != 0));
+  return ((state & kDataBrowserContainerIsOpen) != 0);
 }
 
 bool wxMacDataViewDataBrowserListViewControl::Reload(void)
@@ -1167,7 +1189,10 @@ void wxMacDataViewDataBrowserListViewControl::Resort(void)
 //
 // other methods (inherited from wxDataViewWidgetImpl)
 //
-void wxMacDataViewDataBrowserListViewControl::HitTest(wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const
+void
+wxMacDataViewDataBrowserListViewControl::HitTest(const wxPoint& WXUNUSED(point),
+                                                 wxDataViewItem& item,
+                                                 wxDataViewColumn*& columnPtr) const
 {
  // not yet implemented:
   item = wxDataViewItem();
@@ -1187,8 +1212,8 @@ void wxMacDataViewDataBrowserListViewControl::SetRowHeight(wxDataViewItem const&
 void wxMacDataViewDataBrowserListViewControl::OnSize(void)
 {
   UInt32 noOfColumns;
-  
-  
+
+
   this->GetColumnCount(&noOfColumns);
   if (noOfColumns <= 1) // no horizontal scroll bar and the only column expands to the width of the whole control
   {
@@ -1207,9 +1232,9 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrow
   DataBrowserSortOrder sortOrder;
 
   DataBrowserTableViewColumnIndex modelColumnIndex;
-  
+
   wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
-  
+
 
   wxCHECK_MSG(dataViewCtrlPtr != NULL,            false,_("Pointer to data view control not set correctly."));
   wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,false,_("Pointer to model not set correctly."));
@@ -1217,7 +1242,7 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserCompareProc(DataBrow
   {
    // variable definition and initialization:
     wxDataViewColumn* ColumnPtr(this->GetColumnPtr(sortProperty));
-    
+
     wxCHECK_MSG(ColumnPtr != NULL,false,_("Could not determine column index."));
     modelColumnIndex = ColumnPtr->GetModelColumn();
   }
@@ -1260,7 +1285,7 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(
   {
    // variable definitions:
     wxDataViewCtrl* dataViewCtrlPtr;
-    
+
     dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer());
     wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
     if (dataViewCtrlPtr->IsDeleting())
@@ -1270,14 +1295,14 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(
      // variable definitions:
       OSStatus          errorStatus;
       wxDataViewColumn* dataViewColumnPtr;
-      
+
       wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,errDataBrowserNotConfigured,_("Pointer to model not set correctly."));
       dataViewColumnPtr = this->GetColumnPtr(propertyID);
       wxCHECK_MSG((dataViewColumnPtr != NULL) && (dataViewColumnPtr->GetRenderer() != NULL),errDataBrowserNotConfigured,_("There is no column or renderer for the specified column index."));
 
       wxDataViewItem dvItem(reinterpret_cast<void*>(itemID));
       unsigned int   col = dataViewColumnPtr->GetModelColumn();
-            
+
       switch (dataViewColumnPtr->GetRenderer()->GetNativeData()->GetPropertyType())
       {
         case kDataBrowserCheckboxType:
@@ -1331,7 +1356,7 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(
               wxMacCFStringHolder modifiedString(stringReference);
 #endif
               wxVariant           modifiedData(modifiedString.AsString());
-              
+
                 if (dataViewCtrlPtr->GetModel()->SetValue(modifiedData, dvItem, col) &&
                     dataViewCtrlPtr->GetModel()->ValueChanged(dvItem, col))
                     return noErr;
@@ -1354,7 +1379,7 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(
       wxVariant         variant;
       wxDataViewColumn* dataViewColumnPtr;
       wxDataViewCtrl*   dataViewCtrlPtr;
-      
+
       dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer());
       wxCHECK_MSG(dataViewCtrlPtr             != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
       wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,errDataBrowserNotConfigured,_("Pointer to model not set correctly."));
@@ -1366,7 +1391,7 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(
       {
         dataViewColumnPtr->GetRenderer()->GetNativeData()->SetItemDataRef(itemData);
         dataViewColumnPtr->GetRenderer()->SetValue(variant);
-        wxCHECK_MSG(dataViewColumnPtr->GetRenderer()->Render(),errDataBrowserNotConfigured,_("Rendering failed."));
+        wxCHECK_MSG(dataViewColumnPtr->GetRenderer()->MacRender(),errDataBrowserNotConfigured,_("Rendering failed."));
       }
       return noErr;
     }
@@ -1378,11 +1403,11 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(
           {
            // variable definitions:
             wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
-            
+
             wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
            // initialize wxWidget event:
             wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING,dataViewCtrlPtr->GetId()); // variable definition
-            
+
             dataViewEvent.SetEventObject(dataViewCtrlPtr);
             dataViewEvent.SetItem       (wxDataViewItem(reinterpret_cast<void*>(itemID)));
             dataViewEvent.SetModel      (dataViewCtrlPtr->GetModel());
@@ -1395,7 +1420,7 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(
           {
            // variable definitions:
             wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
-            
+
             wxCHECK_MSG(dataViewCtrlPtr != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
            // initialize wxWidget event:
             wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING,dataViewCtrlPtr->GetId()); // variable definition
@@ -1412,7 +1437,7 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(
           {
            // variable definition:
             wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
-            
+
             wxCHECK_MSG(dataViewCtrlPtr             != NULL,errDataBrowserNotConfigured,_("Pointer to data view control not set correctly."));
             wxCHECK_MSG(dataViewCtrlPtr->GetModel() != NULL,errDataBrowserNotConfigured,_("Pointer to model not set correctly."));
             return ::SetDataBrowserItemDataBooleanValue(itemData,dataViewCtrlPtr->GetModel()->IsContainer(wxDataViewItem(reinterpret_cast<void*>(itemID))));
@@ -1439,7 +1464,7 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da
         {
          // initialize wxWidget event:
           wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED,dataViewCtrlPtr->GetId()); // variable definition
-          
+
           dataViewEvent.SetEventObject(dataViewCtrlPtr);
           dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
          // finally send the equivalent wxWidget event:
@@ -1451,7 +1476,7 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da
         {
          // initialize wxWidget event:
           wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED,dataViewCtrlPtr->GetId()); // variable definition
-          
+
           dataViewEvent.SetEventObject(dataViewCtrlPtr);
           dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
          // finally send the equivalent wxWidget event:
@@ -1464,19 +1489,19 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da
         dataViewCtrlPtr->FinishCustomItemEditing(); // stop editing of a custom item first (if necessary)
         {
          // initialize wxWidget event:
-          DataBrowserPropertyID propertyID;  
+          DataBrowserPropertyID propertyID;
           wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED,dataViewCtrlPtr->GetId()); // variable definition
-          
+
           dataViewEvent.SetEventObject(dataViewCtrlPtr);
           dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
           if (this->GetPropertyID(itemData,&propertyID) == noErr)
           {
            // variable definition and initialization:
             DataBrowserTableViewColumnIndex columnIndex;
-            
+
             wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex),_("Column index not found."));
             dataViewEvent.SetColumn(columnIndex);
-            dataViewEvent.SetDataViewColumn(this->GetColumnPtr(propertyID));          
+            dataViewEvent.SetDataViewColumn(this->GetColumnPtr(propertyID));
           }
          // finally send the equivalent wxWidget event:
           dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
@@ -1485,9 +1510,9 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da
       case kDataBrowserEditStopped:
         {
          // initialize wxWidget event:
-          DataBrowserPropertyID propertyID;  
+          DataBrowserPropertyID propertyID;
           wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE,dataViewCtrlPtr->GetId()); // variable definition
-          
+
           dataViewEvent.SetEventObject(dataViewCtrlPtr);
           dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
           if (this->GetPropertyID(itemData,&propertyID) == noErr)
@@ -1497,7 +1522,7 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da
 
             wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex),_("Column index not found."));
             dataViewEvent.SetColumn(columnIndex);
-            dataViewEvent.SetDataViewColumn(this->GetColumnPtr(propertyID));          
+            dataViewEvent.SetDataViewColumn(this->GetColumnPtr(propertyID));
           }
          // finally send the equivalent wxWidget event:
           dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
@@ -1549,7 +1574,7 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da
             wxDataViewColumn* const columnPtr = dataViewCtrlPtr->GetColumnPtr(i);
            // variable definition:
             UInt16 columnWidth;
-            
+
             wxCHECK_RET(this->GetColumnWidth(columnPtr->GetNativeData()->GetPropertyID(),&columnWidth) == noErr,_("Column width could not be determined"));
             columnPtr->SetWidthVariable(columnWidth);
           }
@@ -1560,7 +1585,7 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da
           {
             DataBrowserSortOrder            sortOrder;
             DataBrowserTableViewColumnIndex columnIndex;
-            
+
             if ((this->GetSortOrder(&sortOrder) == noErr) && (this->GetColumnIndex(propertyID,&columnIndex) == noErr))
             {
              // variable definition and initialization:
@@ -1587,14 +1612,20 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da
     }
 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */
 
-void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID itemID, DataBrowserPropertyID propertyID, DataBrowserItemState state, Rect const* rectangle, SInt16 bitDepth, Boolean colorDevice)
+void
+wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItemID itemID,
+        DataBrowserPropertyID propertyID,
+        DataBrowserItemState state,
+        Rect const* rectangle,
+        SInt16 WXUNUSED(bitDepth),
+        Boolean WXUNUSED(colorDevice))
 {
   DataBrowserTableViewColumnIndex columnIndex;
 
   wxDataViewColumn* dataViewColumnPtr;
 
   wxDataViewCtrl* dataViewCtrlPtr;
-  
+
   wxDataViewCustomRenderer* dataViewCustomRendererPtr;
 
   wxVariant dataToRender;
@@ -1637,57 +1668,57 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowse
   content.right  -= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
 
   wxDC *dc = dataViewCustomRendererPtr->GetDC();
-  
+
   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<int>(rectangle->left + active_border_fudge),
                    static_cast<int>(rectangle->top + active_border_fudge),
                    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) ? 
+      wxColour col( wxMacCreateCGColorFromHITheme( (is_active) ?
                              kThemeBrushAlternatePrimaryHighlightColor
                              : kThemeBrushSecondaryHighlightColor ) );
-      
+
       wxRect rect = cellrect;
       Rect itemrect;
       GetDataBrowserItemPartBounds( this->m_controlRef, itemID, propertyID,
          kDataBrowserPropertyEnclosingPart, &itemrect );
       rect.x = itemrect.left-2;
       rect.width = itemrect.right-itemrect.left+3;
-      
-      wxBrush selBrush( col );
-      wxPen oldpen( dc->GetPen() );
-      wxBrush oldbrush( dc->GetBrush() );
-      dc->SetPen( *wxTRANSPARENT_PEN );
-      dc->SetBrush( selBrush );
+
+      wxDCPenChanger setPen(*dc, *wxTRANSPARENT_PEN);
+      wxDCBrushChanger setBrush(*dc, col);
       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, 
+      (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)
+Boolean
+wxMacDataViewDataBrowserListViewControl::DataBrowserEditItemProc(
+    DataBrowserItemID WXUNUSED(itemID),
+    DataBrowserPropertyID WXUNUSED(propertyID),
+    CFStringRef WXUNUSED(theString),
+    Rect* WXUNUSED(maxEditTextRect),
+    Boolean* WXUNUSED(shrinkToFit))
 {
   return false;
 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserEditItemProc(DataBrowserItemID, DataBrowserPropertyID, CFStringRef, Rect*, Boolean*) */
@@ -1702,9 +1733,9 @@ DataBrowserTrackingResult wxMacDataViewDataBrowserListViewControl::DataBrowserTr
   wxDataViewColumn* dataViewColumnPtr;
 
   wxDataViewCtrl* dataViewCtrlPtr;
-  
+
   wxDataViewCustomRenderer* dataViewCustomRendererPtr;
-  
+
   wxDataViewItem dataViewCustomRendererItem;
 
 
@@ -1732,7 +1763,7 @@ DataBrowserTrackingResult wxMacDataViewDataBrowserListViewControl::DataBrowserTr
   {
    // variable definition:
     wxRect wxRectangle;
-    
+
     ::wxMacNativeToRect(theRect,&wxRectangle);
     dataViewCustomRendererPtr->StartEditing(dataViewCustomRendererItem,wxRectangle);
     dataViewCtrlPtr->SetCustomRendererItem(dataViewCustomRendererItem);
@@ -1762,7 +1793,7 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAcceptDragProc(DragR
     ItemReference          itemRef;
     wxDataObjectComposite* dataObjects;
     wxMemoryBuffer         buffer;
-    
+
     ::GetDragItemReferenceNumber(dragRef,indexDraggedItem,&itemRef); // the index begins with 1!
     dataObjects = this->GetDnDDataObjects(dragRef,itemRef);
    // create wxWidget's event:
@@ -1796,7 +1827,7 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAddDragItemProc(Drag
   Boolean addDragItem;
 
   wxDataViewCtrl* dataViewCtrlPtr;
-  
+
   wxDataViewItem dataViewItem;
 
 
@@ -1816,7 +1847,7 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAddDragItemProc(Drag
  // the object a wxDataObjectComposite object is used;
  // currently, the composite object only contains a TAB concatenated string of all data:
   wxDataObjectComposite* dataObject(new wxDataObjectComposite());
-  
+
   dataObject->Add(new wxTextDataObject(::ConcatenateDataViewItemValues(dataViewCtrlPtr,dataViewItem)));
   dataViewEvent.SetDataObject(dataObject);
  // check if event has not been vetoed:
@@ -1836,12 +1867,12 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAddDragItemProc(Drag
     {
      // constant definition for abbreviational purposes:
       size_t const noOfFormats = dataViewEvent.GetDataObject()->GetFormatCount();
-      
+
       if (noOfFormats > 0)
       {
        // variable definition:
         wxDataFormat* dataFormats;
-        
+
         dataFormats = new wxDataFormat[noOfFormats];
         dataViewEvent.GetDataObject()->GetAllFormats(dataFormats,wxDataObject::Get);
         for (size_t i=0; i<noOfFormats; ++i)
@@ -1856,7 +1887,7 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAddDragItemProc(Drag
                 size_t const dataSize = dataViewEvent.GetDataObject()->GetDataSize(wxDF_TEXT);
                // variable definition and initialization:
                 wxMemoryBuffer dataObject(dataSize);
-                
+
                 dataViewEvent.GetDataObject()->GetDataHere(wxDF_TEXT,dataObject.GetWriteBuf(dataSize));
                 dataObject.UngetWriteBuf(dataSize);
                 if (::AddDragItemFlavor(dragRef,*itemRef,'TEXT',dataObject.GetData(),dataSize,0) != noErr)
@@ -1869,14 +1900,14 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserAddDragItemProc(Drag
                 size_t const dataSize = dataViewEvent.GetDataObject()->GetDataSize(wxDF_TEXT);
                // as there is no direct access to the data copy it to a memory buffer:
                 wxMemoryBuffer dataObject(dataSize);
-                
+
                 dataViewEvent.GetDataObject()->GetDataHere(wxDF_TEXT,dataObject.GetWriteBuf(dataSize));
                 dataObject.UngetWriteBuf(dataSize);
                // if the data is stored in unicode format the internal representation is utf-8 (not mentioned in the documentation but in the source code);
                // DnD uses fixed utf-16 representation -> use the OSX functions for a conversion:
                 CFDataRef   osxData  (::CFDataCreateWithBytesNoCopy(kCFAllocatorDefault,reinterpret_cast<UInt8*>(dataObject.GetData()),dataSize,kCFAllocatorNull));
                 CFStringRef osxString(::CFStringCreateFromExternalRepresentation(kCFAllocatorDefault,osxData,kCFStringEncodingUTF8));
-                
+
                // the osxString contains now the data and therefore the previously occupied memory can be released and re-used:
                 ::CFRelease(osxData);
                 osxData = ::CFStringCreateExternalRepresentation(kCFAllocatorDefault,osxString,kCFStringEncodingUTF16,32);
@@ -1935,7 +1966,7 @@ Boolean wxMacDataViewDataBrowserListViewControl::DataBrowserReceiveDragProc(Drag
     ItemReference          itemRef;
     wxDataObjectComposite* dataObjects;
     wxMemoryBuffer         buffer;
-    
+
    // collect native information:
     ::GetDragItemReferenceNumber(dragRef,indexDraggedItem,&itemRef); // the index begins with 1!
     dataObjects = this->GetDnDDataObjects(dragRef,itemRef);
@@ -1981,7 +2012,7 @@ wxDataFormat wxMacDataViewDataBrowserListViewControl::GetDnDDataFormat(wxDataObj
     size_t       indexFormat;
 
     wxDataFormat* formats;
-    
+
    // get all formats and check afterwards if the formats are compatible; if they are compatible the preferred format is returned otherwise
    // wxDF_INVALID is returned;
    // currently compatible types (ordered by priority are):
@@ -2044,7 +2075,7 @@ wxDataObjectComposite* wxMacDataViewDataBrowserListViewControl::GetDnDDataObject
     {
      // variable definition:
       FlavorType flavorDataObject;
-      
+
       if (::GetFlavorType(dragRef,itemRef,indexFlavor,&flavorDataObject) == noErr) // GetFlavorType uses a 1 based index!
         switch (flavorDataObject)
         {
@@ -2054,7 +2085,7 @@ wxDataObjectComposite* wxMacDataViewDataBrowserListViewControl::GetDnDDataObject
              // variable definitions:
               Size           nativeDataSize;
               wxMemoryBuffer nativeData;
-              
+
               if ((::GetFlavorDataSize(dragRef,itemRef,'TEXT',&nativeDataSize) == noErr) &&
                   (::GetFlavorData(dragRef,itemRef,'TEXT',nativeData.GetWriteBuf(nativeDataSize),&nativeDataSize,0) == noErr))
               {
@@ -2074,11 +2105,11 @@ wxDataObjectComposite* wxMacDataViewDataBrowserListViewControl::GetDnDDataObject
             {
              // variable definition:
               Size nativeDataSize;
-              
+
               if (::GetFlavorDataSize(dragRef,itemRef,'utxt',&nativeDataSize) == noErr)
               {
                 CFMutableDataRef draggedData;
-                
+
                 draggedData = ::CFDataCreateMutable(kCFAllocatorDefault,nativeDataSize);
                 ::CFDataSetLength(draggedData,nativeDataSize);
                 if (::GetFlavorData(dragRef,itemRef,'utxt',::CFDataGetMutableBytePtr(draggedData),&nativeDataSize,0) == noErr)
@@ -2086,7 +2117,7 @@ wxDataObjectComposite* wxMacDataViewDataBrowserListViewControl::GetDnDDataObject
                  // convert internally used UTF-16 representation to a UTF-8 representation:
                   CFDataRef   osxData;
                   CFStringRef osxString;
-                  
+
                   osxString = ::CFStringCreateFromExternalRepresentation(kCFAllocatorDefault,draggedData,kCFStringEncodingUTF16); // BOM character is handled by this function automatically
                   osxData   = ::CFStringCreateExternalRepresentation(kCFAllocatorDefault,osxString,kCFStringEncodingUTF8,32);
                   if (textDataObject == NULL)
@@ -2125,11 +2156,11 @@ wxDataObjectComposite* wxMacDataViewDataBrowserListViewControl::GetDnDDataObject
 wxDataViewColumn* wxMacDataViewDataBrowserListViewControl::GetColumnPtr(DataBrowserPropertyID propertyID) const
 {
   wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetWXPeer()));
-  
+
   if (dataViewCtrlPtr != NULL)
   {
     size_t const noOfColumns = dataViewCtrlPtr->GetColumnCount();
-    
+
     for (size_t i=0; i<noOfColumns; ++i)
       if (dataViewCtrlPtr->GetColumnPtr(i)->GetNativeData()->GetPropertyID() == propertyID)
         return dataViewCtrlPtr->GetColumnPtr(i);
@@ -2203,7 +2234,7 @@ wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const& varianttype,
   this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserCustomType));
 }
 
-bool wxDataViewCustomRenderer::Render()
+bool wxDataViewCustomRenderer::MacRender()
 {
   return true;
 }
@@ -2219,7 +2250,7 @@ wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const& varianttype, wxDa
   this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserTextType));
 }
 
-bool wxDataViewTextRenderer::Render()
+bool wxDataViewTextRenderer::MacRender()
 {
   wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Text renderer cannot render value; value type: ")) << this->GetValue().GetType());
 
@@ -2238,7 +2269,7 @@ wxDataViewBitmapRenderer::wxDataViewBitmapRenderer(wxString const& varianttype,
   this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserIconType));
 }
 
-bool wxDataViewBitmapRenderer::Render()
+bool wxDataViewBitmapRenderer::MacRender()
  // This method returns 'true' if
  //  - the passed bitmap is valid and it could be assigned to the native data browser;
  //  - the passed bitmap is invalid (or is not initialized); this case simulates a non-existing bitmap.
@@ -2257,13 +2288,16 @@ IMPLEMENT_CLASS(wxDataViewBitmapRenderer,wxDataViewRenderer)
 // ---------------------------------------------------------
 // wxDataViewIconTextRenderer
 // ---------------------------------------------------------
-wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
+wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(
+    const wxString& varianttype,
+    wxDataViewCellMode mode,
+    int WXUNUSED(align))
                            :wxDataViewRenderer(varianttype,mode)
 {
   this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserIconAndTextType));
 }
 
-bool wxDataViewIconTextRenderer::Render()
+bool wxDataViewIconTextRenderer::MacRender()
 {
   wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Icon & text renderer cannot render value; value type: ")) << this->GetValue().GetType());
 
@@ -2285,13 +2319,16 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewIconTextRenderer,wxDataViewRenderer)
 // ---------------------------------------------------------
 // wxDataViewToggleRenderer
 // ---------------------------------------------------------
-wxDataViewToggleRenderer::wxDataViewToggleRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
+wxDataViewToggleRenderer::wxDataViewToggleRenderer(
+    const wxString& varianttype,
+    wxDataViewCellMode mode,
+    int WXUNUSED(align))
                          :wxDataViewRenderer(varianttype,mode)
 {
   this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserCheckboxType));
 }
 
-bool wxDataViewToggleRenderer::Render()
+bool wxDataViewToggleRenderer::MacRender()
 {
   wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Toggle renderer cannot render value; value type: ")) << this->GetValue().GetType());
   return (::SetDataBrowserItemDataButtonValue(this->GetNativeData()->GetItemDataRef(),this->GetValue().GetBool()) == noErr);
@@ -2302,13 +2339,17 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer,wxDataViewRenderer)
 // ---------------------------------------------------------
 // wxDataViewProgressRenderer
 // ---------------------------------------------------------
-wxDataViewProgressRenderer::wxDataViewProgressRenderer(wxString const& label, wxString const& varianttype, wxDataViewCellMode mode, int align)
+wxDataViewProgressRenderer::wxDataViewProgressRenderer(
+    const wxString& WXUNUSED(label),
+    wxString const& varianttype,
+    wxDataViewCellMode mode,
+    int align)
                            :wxDataViewRenderer(varianttype,mode,align)
 {
   this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserProgressBarType));
 }
 
-bool wxDataViewProgressRenderer::Render()
+bool wxDataViewProgressRenderer::MacRender()
 {
   wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Progress renderer cannot render value type; value type: ")) << this->GetValue().GetType());
   return ((::SetDataBrowserItemDataMinimum(this->GetNativeData()->GetItemDataRef(),  0)                        == noErr) &&
@@ -2327,7 +2368,7 @@ wxDataViewDateRenderer::wxDataViewDateRenderer(wxString const& varianttype, wxDa
   this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserDateTimeType));
 }
 
-bool wxDataViewDateRenderer::Render()
+bool wxDataViewDateRenderer::MacRender()
 {
   wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Date renderer cannot render value; value type: ")) << this->GetValue().GetType());
   return (::SetDataBrowserItemDataDateTime(this->GetNativeData()->GetItemDataRef(),this->GetValue().GetDateTime().Subtract(wxDateTime(1,wxDateTime::Jan,1904)).GetSeconds().GetLo()) == noErr);