]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/carbon/dataview.cpp
Correct format specifiers used to show wxIPV4address.
[wxWidgets.git] / src / osx / carbon / dataview.cpp
index c3724b00489c9d45729a259ebfc22f4ba0eee139..ef441c892d00491683da82fb74af52c033b08289 100644 (file)
@@ -1183,7 +1183,7 @@ wxDataViewColumn* wxMacDataViewDataBrowserListViewControl::GetSortingColumn() co
 
 void wxMacDataViewDataBrowserListViewControl::Resort()
 {
-  (void) Resort();
+    (void) wxMacDataBrowserListViewControl::Resort();
 }
 
 //
@@ -1318,8 +1318,7 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(
                // variable definition and initialization:
                 wxVariant modifiedData(true);
 
-                if (dataViewCtrlPtr->GetModel()->SetValue(modifiedData, dvItem, col) &&
-                    dataViewCtrlPtr->GetModel()->ValueChanged(dvItem, col))
+                if (dataViewCtrlPtr->GetModel()->ChangeValue(modifiedData, dvItem, col))
                     return noErr;
                 else
                     return errDataBrowserInvalidPropertyData;
@@ -1329,8 +1328,7 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(
                // variable definition and initialization:
                 wxVariant modifiedData(false);
 
-                if (dataViewCtrlPtr->GetModel()->SetValue(modifiedData, dvItem, col) &&
-                    dataViewCtrlPtr->GetModel()->ValueChanged(dvItem, col))
+                if (dataViewCtrlPtr->GetModel()->ChangeValue(modifiedData, dvItem, col))
                     return noErr;
                 else
                     return errDataBrowserInvalidPropertyData;
@@ -1357,8 +1355,7 @@ OSStatus wxMacDataViewDataBrowserListViewControl::DataBrowserGetSetItemDataProc(
 #endif
               wxVariant           modifiedData(modifiedString.AsString());
 
-                if (dataViewCtrlPtr->GetModel()->SetValue(modifiedData, dvItem, col) &&
-                    dataViewCtrlPtr->GetModel()->ValueChanged(dvItem, col))
+                if (dataViewCtrlPtr->GetModel()->ChangeValue(modifiedData, dvItem, col))
                     return noErr;
                 else
                     return errDataBrowserInvalidPropertyData;
@@ -1704,7 +1701,7 @@ wxMacDataViewDataBrowserListViewControl::DataBrowserDrawItemProc(DataBrowserItem
   {
       // 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->WXCallRender( cellrect, dc,
                                             ((state == kDataBrowserItemIsSelected) ? wxDATAVIEW_CELL_SELECTED : 0)));
       dc->DestroyClippingRegion(); // probably not necessary
   }
@@ -2095,8 +2092,7 @@ wxDataObjectComposite* wxMacDataViewDataBrowserListViewControl::GetDnDDataObject
                   dataObject->Add(textDataObject);
                 else
                 {
-                  delete textDataObject;
-                  textDataObject = NULL;
+                  wxDELETE(textDataObject);
                 }
               }
             } /* block */
@@ -2127,8 +2123,7 @@ wxDataObjectComposite* wxMacDataViewDataBrowserListViewControl::GetDnDDataObject
                       dataObject->Add(textDataObject);
                     else
                     {
-                      delete textDataObject;
-                      textDataObject = NULL;
+                      wxDELETE(textDataObject);
                     }
                   }
                   else // overwrite data because the 'utxt' flavor has priority over the 'TEXT' flavor
@@ -2186,35 +2181,111 @@ void wxDataViewRenderer::SetAlignment(int align)
   m_alignment = align;
 }
 
+namespace
+{
+
+// get the browser control or NULL if anything went wrong (it's not supposed to
+// so we assert if it did)
+wxMacDataViewDataBrowserListViewControl *
+GetBrowserFromCol(wxDataViewColumn *col)
+{
+    wxCHECK_MSG( col, NULL, "should have a valid column" );
+
+    wxDataViewCtrl * const dvc = col->GetOwner();
+    wxCHECK_MSG( dvc, NULL, "column must be associated with the control" );
+
+    return static_cast<wxMacDataViewDataBrowserListViewControl *>(dvc->GetPeer());
+}
+
+} // anonymous namespace
+
 void wxDataViewRenderer::SetMode(wxDataViewCellMode mode)
 {
-  wxDataViewColumn* dataViewColumnPtr;
+    wxDataViewColumn * const col = GetOwner();
+    wxMacDataViewDataBrowserListViewControl * const
+        browser = GetBrowserFromCol(col);
+    wxCHECK_RET( browser, "must be fully initialized" );
 
+    const DataBrowserPropertyID colID = col->GetNativeData()->GetPropertyID();
 
-  m_mode = mode;
-  dataViewColumnPtr = GetOwner();
-  if (dataViewColumnPtr != NULL)
-  {
-    wxDataViewCtrl* dataViewCtrlPtr(dataViewColumnPtr->GetOwner());
+    DataBrowserPropertyFlags flags;
+    verify_noerr( browser->GetPropertyFlags(colID, &flags) );
 
-    if (dataViewCtrlPtr != NULL)
+    if ( (mode == wxDATAVIEW_CELL_EDITABLE) ||
+            (mode == wxDATAVIEW_CELL_ACTIVATABLE) )
+        flags |= kDataBrowserPropertyIsEditable;
+    else
+        flags &= ~kDataBrowserPropertyIsEditable;
+
+    verify_noerr( browser->SetPropertyFlags(colID, flags) );
+}
+
+void wxDataViewRenderer::EnableEllipsize(wxEllipsizeMode mode)
+{
+    wxDataViewColumn * const col = GetOwner();
+
+    wxMacDataViewDataBrowserListViewControl * const
+        browser = GetBrowserFromCol(col);
+    wxCHECK_RET( browser, "must be fully initialized" );
+
+    const DataBrowserPropertyID colID = col->GetNativeData()->GetPropertyID();
+
+    DataBrowserPropertyFlags flags;
+    browser->GetPropertyFlags(colID, &flags);
+
+    flags &= ~(kDataBrowserDoNotTruncateText |
+               kDataBrowserTruncateTextAtStart |
+               kDataBrowserTruncateTextMiddle |
+               kDataBrowserTruncateTextAtEnd);
+
+    int flagToSet = 0;
+    switch ( mode )
     {
-      wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
+        case wxELLIPSIZE_NONE:
+            flagToSet = kDataBrowserDoNotTruncateText;
+            break;
 
-      if (macDataViewListCtrlPtr != NULL)
-      {
-        DataBrowserPropertyFlags flags;
-
-        verify_noerr(macDataViewListCtrlPtr->GetPropertyFlags(dataViewColumnPtr->GetNativeData()->GetPropertyID(),&flags));
-        if ((mode == wxDATAVIEW_CELL_EDITABLE) ||
-            (mode == wxDATAVIEW_CELL_ACTIVATABLE))
-          flags |= kDataBrowserPropertyIsEditable;
-        else
-          flags &= ~kDataBrowserPropertyIsEditable;
-        verify_noerr(macDataViewListCtrlPtr->SetPropertyFlags(dataViewColumnPtr->GetNativeData()->GetPropertyID(),flags));
-      }
+        case wxELLIPSIZE_START:
+            flagToSet = kDataBrowserTruncateTextAtStart;
+            break;
+
+        case wxELLIPSIZE_MIDDLE:
+            flagToSet = kDataBrowserTruncateTextMiddle;
+            break;
+
+        case wxELLIPSIZE_END:
+            flagToSet = kDataBrowserTruncateTextAtEnd;
+            break;
     }
-  }
+
+    wxCHECK_RET( flagToSet, "unknown wxEllipsizeMode value" );
+
+    flags |= flagToSet;
+    verify_noerr( browser->SetPropertyFlags(colID, flags) );
+}
+
+wxEllipsizeMode wxDataViewRenderer::GetEllipsizeMode() const
+{
+    wxDataViewColumn * const col = GetOwner();
+
+    wxMacDataViewDataBrowserListViewControl * const
+        browser = GetBrowserFromCol(col);
+    wxCHECK_MSG( browser, wxELLIPSIZE_NONE, "must be fully initialized" );
+
+    const DataBrowserPropertyID colID = col->GetNativeData()->GetPropertyID();
+
+    DataBrowserPropertyFlags flags;
+    browser->GetPropertyFlags(colID, &flags);
+
+    if ( flags & kDataBrowserDoNotTruncateText )
+        return wxELLIPSIZE_NONE;
+    if ( flags & kDataBrowserTruncateTextAtStart )
+        return wxELLIPSIZE_START;
+    if ( flags & kDataBrowserTruncateTextAtEnd )
+        return wxELLIPSIZE_END;
+
+    // kDataBrowserTruncateTextMiddle == 0 so there is no need to test for it
+    return wxELLIPSIZE_MIDDLE;
 }
 
 void wxDataViewRenderer::SetNativeData(wxDataViewRendererNativeData* newNativeDataPtr)
@@ -2229,7 +2300,9 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer,wxDataViewRendererBase)
 // wxDataViewCustomRenderer
 // ---------------------------------------------------------
 wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
-                         :wxDataViewRenderer(varianttype,mode,align), m_editorCtrlPtr(NULL), m_DCPtr(NULL)
+                         :wxDataViewCustomRendererBase(varianttype,mode,align),
+                          m_editorCtrlPtr(NULL),
+                          m_DCPtr(NULL)
 {
   SetNativeData(new wxDataViewRendererNativeData(kDataBrowserCustomType));
 }
@@ -2400,6 +2473,13 @@ wxDataViewColumn::~wxDataViewColumn()
   delete m_NativeDataPtr;
 }
 
+int wxDataViewColumn::GetWidth() const
+{
+    // FIXME: This returns the last programatically set width and will not work if
+    //        the user changes the column's width by dragging it with the mouse.
+    return m_width;
+}
+
 bool wxDataViewColumn::IsSortKey() const
 {
     wxDataViewCtrl * const dataViewCtrlPtr(GetOwner());
@@ -2668,6 +2748,17 @@ void wxDataViewColumn::SetWidth(int width)
   }
 }
 
+void wxDataViewColumn::SetHidden(bool WXUNUSED(hidden))
+{
+    // How to do that?
+}
+
+bool wxDataViewColumn::IsHidden() const
+{
+    return true;
+}
+
+
 void wxDataViewColumn::SetAsSortKey(bool WXUNUSED(sort))
 {
     // see wxGTK native wxDataViewColumn implementation