]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/databrow.cpp
made Blur() methods const (bug 180914)
[wxWidgets.git] / src / mac / carbon / databrow.cpp
index 9e8236b740eb7e5d337a9b5d9a7d013d428e68ad..7152558b24108c1d6141f00888bef45a728ddf02 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "wx/wxprec.h"
 
+#if wxUSE_DATAVIEWCTRL
+
 #include "wx/utils.h"
 
 #ifndef WX_PRECOMP
@@ -273,20 +275,25 @@ OSStatus wxMacDataBrowserTableViewControl::SetDefaultRowHeight(UInt16 height)
   return ::SetDataBrowserTableViewRowHeight(this->m_controlRef,height);
 }
 
-OSStatus wxMacDataBrowserTableViewControl::SetHasScrollBars( bool horiz, bool vert )
+OSStatus wxMacDataBrowserTableViewControl::SetHasScrollBars(bool horiz, bool vert)
 {
-    return SetDataBrowserHasScrollBars(this->m_controlRef, horiz, vert );
-}
+  return ::SetDataBrowserHasScrollBars(this->m_controlRef,horiz,vert);
+} /* wxMacDataBrowserTableViewControl::SetHasScrollBars(bool, bool) */
 
 OSStatus wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16 height)
 {
-    return SetDataBrowserListViewHeaderBtnHeight(this->m_controlRef, height );
-}
+  return ::SetDataBrowserListViewHeaderBtnHeight(this->m_controlRef,height);
+} /* wxMacDataBrowserTableViewControl::SetHeaderButtonHeight(UInt16) */
 
-OSStatus wxMacDataBrowserTableViewControl::SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle )
+OSStatus wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle hiliteStyle)
 {
-    return SetDataBrowserTableViewHiliteStyle(this->m_controlRef, hiliteStyle );
-}
+  return ::SetDataBrowserTableViewHiliteStyle(this->m_controlRef,hiliteStyle);
+} /*wxMacDataBrowserTableViewControl::SetHiliteStyle(DataBrowserTableViewHiliteStyle)  */
+
+OSStatus wxMacDataBrowserTableViewControl::SetIndent(float Indent)
+{
+  return ::DataBrowserSetMetric(this->m_controlRef,kDataBrowserMetricDisclosureColumnPerDepthGap,true,Indent);
+} /* wxMacDataBrowserTableViewControl::SetIndent(float* Indent) */
 
 OSStatus wxMacDataBrowserTableViewControl::SetRowHeight(DataBrowserItemID item, UInt16 height)
 {
@@ -344,14 +351,19 @@ OSStatus wxMacDataBrowserTableViewControl::IsUsedPropertyID(DataBrowserPropertyI
   return ::GetDataBrowserTableViewColumnPosition(this->m_controlRef,propertyID,&index);
 } /* wxMacDataBrowserTableViewControl::IsUsedPropertyId(DataBrowserPropertyID) const */
 
-OSStatus wxMacDataBrowserTableViewControl::RemoveColumn(DataBrowserTableViewColumnIndex index)
+OSStatus wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID propertyID)
+{
+  return ::RemoveDataBrowserTableViewColumn(this->m_controlRef,propertyID);
+} /* wxMacDataBrowserTableViewControl::RemoveColumnByProperty(DataBrowserTableViewColumnID) */
+
+OSStatus wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex index)
 {
   DataBrowserTableViewColumnID propertyID;
 
 
   this->GetPropertyID(index,&propertyID);
   return ::RemoveDataBrowserTableViewColumn(this->m_controlRef,propertyID);
-} /* wxMacDataBrowserTableViewControl::RemoveColumn(DataBrowserTableViewColumnIndex) */
+} /* wxMacDataBrowserTableViewControl::RemoveColumnByIndex(DataBrowserTableViewColumnIndex) */
 
 OSStatus wxMacDataBrowserTableViewControl::SetColumnIndex(DataBrowserPropertyID propertyID, DataBrowserTableViewColumnIndex index)
 {
@@ -526,6 +538,19 @@ OSStatus wxMacDataBrowserTableViewControl::SetSortProperty(DataBrowserPropertyID
   return ::SetDataBrowserSortProperty(this->m_controlRef,propertyID);
 }
 
+//
+// container handling
+//
+OSStatus wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID containerID)
+{
+  return ::CloseDataBrowserContainer(this->m_controlRef,containerID);
+} /* wxMacDataBrowserTableViewControl::CloseContainer(DataBrowserItemID) */
+
+OSStatus wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID containerID)
+{
+  return ::OpenDataBrowserContainer(this->m_controlRef,containerID);
+} /* wxMacDataBrowserTableViewControl::OpenContainer(DataBrowserItemID) */
+
 IMPLEMENT_ABSTRACT_CLASS(wxMacDataBrowserTableViewControl,wxMacControl)
 
 // ============================================================================
@@ -714,27 +739,27 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(
     if (propertyID >= kMinPropertyID) // in case data columns set the data
     {
      // variable definitions:
-      DataBrowserTableViewColumnIndex columnIndex;
-      OSStatus                        errorStatus;
-      wxVariant                       variant;
-      wxDataViewColumn*               dataViewColumnPtr;
-      wxDataViewCtrl*                 dataViewCtrlPtr;
+      wxVariant         variant;
+      wxDataViewColumn* dataViewColumnPtr;
+      wxDataViewCtrl*   dataViewCtrlPtr;
       
       dataViewCtrlPtr = dynamic_cast<wxDataViewCtrl*>(this->GetPeer());
       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."));
-      errorStatus = this->GetColumnIndex(propertyID,&columnIndex);
-      wxCHECK_MSG(errorStatus == noErr,errorStatus,_("Column index does not exist."));
-      dataViewColumnPtr = dataViewCtrlPtr->GetColumn(columnIndex);
+      dataViewColumnPtr = dataViewCtrlPtr->GetColumnPtr(propertyID);
       wxCHECK_MSG(dataViewColumnPtr                != NULL,errDataBrowserNotConfigured,_("No column for the specified column position existing."));
       wxCHECK_MSG(dataViewColumnPtr->GetRenderer() != NULL,errDataBrowserNotConfigured,_("No renderer specified for column."));
       dataViewCtrlPtr->GetModel()->GetValue(variant,wxDataViewItem(reinterpret_cast<void*>(itemID)),dataViewColumnPtr->GetModelColumn());
-      dataViewColumnPtr->GetRenderer()->SetDataReference(itemData);
-      dataViewColumnPtr->GetRenderer()->SetValue(variant);
-      wxCHECK_MSG(dataViewColumnPtr->GetRenderer()->Render(),errDataBrowserNotConfigured,_("Rendering failed."));
+      if (!(variant.IsNull()))
+      {
+        dataViewColumnPtr->GetRenderer()->SetDataReference(itemData);
+        dataViewColumnPtr->GetRenderer()->SetValue(variant);
+        wxCHECK_MSG(dataViewColumnPtr->GetRenderer()->Render(),errDataBrowserNotConfigured,_("Rendering failed."));
+      } /* if */
       return noErr;
     } /* if */
     else // react on special system requests
+    {
       switch (propertyID)
       {
         case kDataBrowserContainerIsClosableProperty:
@@ -753,7 +778,6 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(
            // opening the container is allowed if not vetoed:
             return ::SetDataBrowserItemDataBooleanValue(itemData,dataViewEvent.IsAllowed());
           } /* block */
-          return noErr;
         case kDataBrowserContainerIsOpenableProperty:
           {
            // variable definitions:
@@ -782,11 +806,12 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(
         case kDataBrowserItemIsEditableProperty:
           return ::SetDataBrowserItemDataBooleanValue(itemData,true);
       } /* switch */
+    } /* if */
   } /* if */
   return errDataBrowserPropertyNotSupported;
 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(DataBrowserItemID, DataBrowserPropertyID, DataBrowserItemDataRef, Boolean) */
 
-void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef WXUNUSED(itemData))
+void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID itemID, DataBrowserItemNotification message, DataBrowserItemDataRef itemData)
 {
   switch (message)
   {
@@ -823,6 +848,60 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da
         dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
       } /* block */
       break;
+    case kDataBrowserEditStarted:
+      {
+       // variable definitions:
+        wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
+        
+        if (dataViewCtrlPtr != NULL)
+        {
+         // initialize wxWidget event:
+          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(dataViewCtrlPtr->GetColumnPtr(propertyID));          
+          } /* if */
+         // finally send the equivalent wxWidget event:
+          dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
+        } /* if */
+      } /* block */
+      break;
+    case kDataBrowserEditStopped:
+    {
+     // variable definitions:
+      wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
+      
+      if (dataViewCtrlPtr != NULL)
+      {
+       // initialize wxWidget event:
+        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)
+        {
+         // variable definition and initialization:
+          DataBrowserTableViewColumnIndex columnIndex;
+
+          wxCHECK_RET(this->GetColumnIndex(propertyID,&columnIndex),_("Column index not found."));
+          dataViewEvent.SetColumn(columnIndex);
+          dataViewEvent.SetDataViewColumn(dataViewCtrlPtr->GetColumnPtr(propertyID));          
+        } /* if */
+       // finally send the equivalent wxWidget event:
+        dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
+      } /* if */
+    } /* block */
+      break;
     case kDataBrowserItemAdded:
       {
        // variable definitions:
@@ -838,6 +917,8 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da
         dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
       } /* block */
       break;
+    case kDataBrowserItemDeselected:
+      break; // not implemented by wxWidgets; see kDataBrowserSelectionSetChanged
     case kDataBrowserItemDoubleClicked:
       {
        // variable definitions:
@@ -871,24 +952,41 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da
       } /* block */
       break;
     case kDataBrowserItemSelected:
+      break; // not implemented by wxWidgets; see kDataBrowserSelectionSetChanged
+    case kDataBrowserSelectionSetChanged:
       {
        // variable definitions:
         wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
         
         wxCHECK_RET(dataViewCtrlPtr != NULL,_("Pointer to data view control not set correctly."));
        // initialize wxWidget event:
-        wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_SELECTED,dataViewCtrlPtr->GetId()); // variable definition
+        wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED,dataViewCtrlPtr->GetId()); // variable definition
 
         dataViewEvent.SetEventObject(dataViewCtrlPtr);
-        dataViewEvent.SetItem(wxDataViewItem(reinterpret_cast<void*>(itemID)));
+        dataViewEvent.SetModel      (dataViewCtrlPtr->GetModel());
        // finally send the equivalent wxWidget event:
         dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
       } /* block */
       break;
     case kDataBrowserUserStateChanged:
       {
+       // variable definitions and initialization:
         DataBrowserPropertyID propertyID;
-        
+        wxDataViewCtrl*       dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
+
+        wxCHECK_RET(dataViewCtrlPtr != NULL,_("Pointer to data view control not set correctly"));
+       // update column widths:
+        for (size_t i=0; i<dataViewCtrlPtr->GetColumnCount(); ++i)
+        {
+         // constant definition for abbreviational purposes:
+          wxDataViewColumn* const columnPtr = dataViewCtrlPtr->GetColumn(i);
+         // variable definition:
+          UInt16 columnWidth;
+          
+          wxCHECK_RET(this->GetColumnWidth(columnPtr->GetPropertyID(),&columnWidth) == noErr,_("Column width could not be determined"));
+          columnPtr->SetWidthVariable(columnWidth);
+        } /* for */
+       // update order status:
         if ((this->GetSortProperty(&propertyID) == noErr) && (propertyID >= kMinPropertyID))
         {
           DataBrowserSortOrder            sortOrder;
@@ -898,9 +996,6 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da
           {
            // variable definition and initialization:
             wxDataViewColumn* columnPtr;
-            wxDataViewCtrl*   dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(this->GetPeer()));
-
-            wxCHECK_RET(dataViewCtrlPtr != NULL,_("Pointer to data vie wcontrol not set correctly."));
             columnPtr = dataViewCtrlPtr->GetColumn(columnIndex);
            // check if the sort order has changed:
             if (  columnPtr->IsSortOrderAscending()  && (sortOrder == kDataBrowserOrderDecreasing) ||
@@ -924,5 +1019,5 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da
 } /* wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(DataBrowserItemID, DataBrowserItemNotification, DataBrowserItemDataRef) */
 
 
-#endif
- // wxUSE_GENERICDATAVIEWCTRL
+#endif // wxUSE_DATAVIEWCTRL
+#endif // wxUSE_GENERICDATAVIEWCTRL