+ draggedData = ::CFDataCreateMutable(kCFAllocatorDefault,nativeDataSize);
+ ::CFDataSetLength(draggedData,nativeDataSize);
+ if (::GetFlavorData(dragRef,itemRef,'utxt',::CFDataGetMutableBytePtr(draggedData),&nativeDataSize,0) == noErr)
+ {
+ // 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)
+ {
+ textDataObject = new wxTextDataObject();
+ if (textDataObject->SetData(::CFDataGetLength(osxData),::CFDataGetBytePtr(osxData)))
+ dataObject->Add(textDataObject);
+ else
+ {
+ wxDELETE(textDataObject);
+ }
+ }
+ else // overwrite data because the 'utxt' flavor has priority over the 'TEXT' flavor
+ (void) textDataObject->SetData(::CFDataGetLength(osxData),::CFDataGetBytePtr(osxData));
+ // clean up:
+ ::CFRelease(osxData);
+ ::CFRelease(osxString);
+ }
+ // clean up:
+ ::CFRelease(draggedData);
+ }
+ } /* block */
+ break;
+ }
+ }
+ }
+ else
+ dataObject = NULL;
+ return dataObject;
+}
+
+//
+// other methods
+//
+wxDataViewColumn* wxMacDataViewDataBrowserListViewControl::GetColumnPtr(DataBrowserPropertyID propertyID) const
+{
+ wxDataViewCtrl* dataViewCtrlPtr(dynamic_cast<wxDataViewCtrl*>(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);
+ }
+ return NULL;
+}
+
+// ---------------------------------------------------------
+// wxDataViewRenderer
+// ---------------------------------------------------------
+wxDataViewRenderer::wxDataViewRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
+ :wxDataViewRendererBase(varianttype,mode,align), m_alignment(align), m_mode(mode), m_NativeDataPtr(NULL)
+{
+}
+
+wxDataViewRenderer::~wxDataViewRenderer()
+{
+ delete m_NativeDataPtr;
+}
+
+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 * const col = GetOwner();
+ wxMacDataViewDataBrowserListViewControl * const
+ browser = GetBrowserFromCol(col);
+ wxCHECK_RET( browser, "must be fully initialized" );
+
+ const DataBrowserPropertyID colID = col->GetNativeData()->GetPropertyID();
+
+ DataBrowserPropertyFlags flags;
+ verify_noerr( browser->GetPropertyFlags(colID, &flags) );
+
+ 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 )
+ {
+ case wxELLIPSIZE_NONE:
+ flagToSet = kDataBrowserDoNotTruncateText;
+ break;
+
+ 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)
+{
+ delete m_NativeDataPtr;
+ m_NativeDataPtr = newNativeDataPtr;
+}
+
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer,wxDataViewRendererBase)
+
+// ---------------------------------------------------------
+// wxDataViewCustomRenderer
+// ---------------------------------------------------------
+wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
+ :wxDataViewCustomRendererBase(varianttype,mode,align),
+ m_editorCtrlPtr(NULL),
+ m_DCPtr(NULL)
+{
+ SetNativeData(new wxDataViewRendererNativeData(kDataBrowserCustomType));
+}
+
+bool wxDataViewCustomRenderer::MacRender()
+{
+ return true;
+}
+
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer, wxDataViewRenderer)
+
+// ---------------------------------------------------------
+// wxDataViewTextRenderer
+// ---------------------------------------------------------
+wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
+ :wxDataViewRenderer(varianttype,mode,align)
+{
+ SetNativeData(new wxDataViewRendererNativeData(kDataBrowserTextType));
+}
+
+bool wxDataViewTextRenderer::MacRender()
+{
+ wxCHECK_MSG(GetValue().GetType() == GetVariantType(),false,wxString(_("Text renderer cannot render value; value type: ")) << GetValue().GetType());
+
+ wxCFStringRef cfString(GetValue().GetString(),(GetView()->GetFont().IsOk() ? GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
+ return (::SetDataBrowserItemDataText(GetNativeData()->GetItemDataRef(),cfString) == noErr);
+}
+
+IMPLEMENT_CLASS(wxDataViewTextRenderer,wxDataViewRenderer)
+
+// ---------------------------------------------------------
+// wxDataViewBitmapRenderer
+// ---------------------------------------------------------
+wxDataViewBitmapRenderer::wxDataViewBitmapRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
+ :wxDataViewRenderer(varianttype,mode,align)
+{
+ SetNativeData(new wxDataViewRendererNativeData(kDataBrowserIconType));
+}
+
+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.
+ // In all other cases the method returns 'false'.
+{
+ wxCHECK_MSG(GetValue().GetType() == GetVariantType(),false,wxString(_("Bitmap renderer cannot render value; value type: ")) << GetValue().GetType());
+
+ wxBitmap bitmap;
+
+ bitmap << GetValue();
+ return (!(bitmap.IsOk()) || (::SetDataBrowserItemDataIcon(GetNativeData()->GetItemDataRef(),bitmap.GetIconRef()) == noErr));
+}
+
+IMPLEMENT_CLASS(wxDataViewBitmapRenderer,wxDataViewRenderer)
+
+// ---------------------------------------------------------
+// wxDataViewIconTextRenderer
+// ---------------------------------------------------------
+wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(
+ const wxString& varianttype,
+ wxDataViewCellMode mode,
+ int WXUNUSED(align))
+ :wxDataViewRenderer(varianttype,mode)
+{
+ SetNativeData(new wxDataViewRendererNativeData(kDataBrowserIconAndTextType));
+}
+
+bool wxDataViewIconTextRenderer::MacRender()
+{
+ wxCHECK_MSG(GetValue().GetType() == GetVariantType(),false,wxString(_("Icon & text renderer cannot render value; value type: ")) << GetValue().GetType());
+
+ wxDataViewIconText iconText;
+
+ iconText << GetValue();
+
+ wxCFStringRef cfString(iconText.GetText(),(GetView()->GetFont().IsOk() ? GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
+
+ if (iconText.GetIcon().IsOk())
+ if (::SetDataBrowserItemDataIcon(GetNativeData()->GetItemDataRef(),MAC_WXHICON(iconText.GetIcon().GetHICON())) != noErr)
+ return false;
+ return (::SetDataBrowserItemDataText(GetNativeData()->GetItemDataRef(),cfString) == noErr);
+}
+
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewIconTextRenderer,wxDataViewRenderer)
+
+
+// ---------------------------------------------------------
+// wxDataViewToggleRenderer
+// ---------------------------------------------------------
+wxDataViewToggleRenderer::wxDataViewToggleRenderer(
+ const wxString& varianttype,
+ wxDataViewCellMode mode,
+ int WXUNUSED(align))
+ :wxDataViewRenderer(varianttype,mode)
+{
+ SetNativeData(new wxDataViewRendererNativeData(kDataBrowserCheckboxType));
+}
+
+bool wxDataViewToggleRenderer::MacRender()
+{
+ wxCHECK_MSG(GetValue().GetType() == GetVariantType(),false,wxString(_("Toggle renderer cannot render value; value type: ")) << GetValue().GetType());
+ return (::SetDataBrowserItemDataButtonValue(GetNativeData()->GetItemDataRef(),GetValue().GetBool()) == noErr);
+}
+
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer,wxDataViewRenderer)
+
+// ---------------------------------------------------------
+// wxDataViewProgressRenderer
+// ---------------------------------------------------------
+wxDataViewProgressRenderer::wxDataViewProgressRenderer(
+ const wxString& WXUNUSED(label),
+ wxString const& varianttype,
+ wxDataViewCellMode mode,
+ int align)
+ :wxDataViewRenderer(varianttype,mode,align)
+{
+ SetNativeData(new wxDataViewRendererNativeData(kDataBrowserProgressBarType));
+}
+
+bool wxDataViewProgressRenderer::MacRender()
+{
+ wxCHECK_MSG(GetValue().GetType() == GetVariantType(),false,wxString(_("Progress renderer cannot render value type; value type: ")) << GetValue().GetType());
+ return ((::SetDataBrowserItemDataMinimum(GetNativeData()->GetItemDataRef(), 0) == noErr) &&
+ (::SetDataBrowserItemDataMaximum(GetNativeData()->GetItemDataRef(),100) == noErr) &&
+ (::SetDataBrowserItemDataValue (GetNativeData()->GetItemDataRef(),GetValue().GetLong()) == noErr));
+}
+
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer,wxDataViewRenderer)
+
+// ---------------------------------------------------------
+// wxDataViewDateRenderer
+// ---------------------------------------------------------
+wxDataViewDateRenderer::wxDataViewDateRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
+ :wxDataViewRenderer(varianttype,mode,align)
+{
+ SetNativeData(new wxDataViewRendererNativeData(kDataBrowserDateTimeType));
+}
+
+bool wxDataViewDateRenderer::MacRender()
+{
+ wxCHECK_MSG(GetValue().GetType() == GetVariantType(),false,wxString(_("Date renderer cannot render value; value type: ")) << GetValue().GetType());
+ return (::SetDataBrowserItemDataDateTime(GetNativeData()->GetItemDataRef(),GetValue().GetDateTime().Subtract(wxDateTime(1,wxDateTime::Jan,1904)).GetSeconds().GetLo()) == noErr);
+}
+
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer,wxDataViewRenderer)
+
+// ---------------------------------------------------------
+// wxDataViewColumn
+// ---------------------------------------------------------
+wxDataViewColumn::wxDataViewColumn(const wxString& title, wxDataViewRenderer* renderer, unsigned int model_column, int width, wxAlignment align, int flags)
+ :wxDataViewColumnBase(renderer, model_column), m_NativeDataPtr(new wxDataViewColumnNativeData()), m_title(title)
+{
+ InitCommon(width, align, flags);
+ if ((renderer != NULL) && !renderer->IsCustomRenderer() &&
+ (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
+ renderer->SetAlignment(align);
+}
+
+wxDataViewColumn::wxDataViewColumn(const wxBitmap& bitmap, wxDataViewRenderer* renderer, unsigned int model_column, int width, wxAlignment align, int flags)
+ :wxDataViewColumnBase(bitmap, renderer, model_column), m_NativeDataPtr(new wxDataViewColumnNativeData())
+{
+ InitCommon(width, align, flags);
+ if ((renderer != NULL) && !renderer->IsCustomRenderer() &&
+ (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
+ renderer->SetAlignment(align);
+}
+
+wxDataViewColumn::~wxDataViewColumn()
+{
+ delete m_NativeDataPtr;
+}
+
+int wxDataViewColumn::GetWidth() const
+{
+ // FIXME: This returns the last programmatically 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());
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(
+ dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(
+ dataViewCtrlPtr->GetPeer()));
+
+ DataBrowserPropertyID propertyID;
+ return (macDataViewListCtrlPtr->GetSortProperty(&propertyID) == noErr) &&
+ (propertyID == GetNativeData()->GetPropertyID());
+}
+
+void wxDataViewColumn::SetAlignment(wxAlignment align)
+{
+ wxDataViewCtrl* dataViewCtrlPtr(GetOwner());
+
+
+ m_alignment = align;
+ if (dataViewCtrlPtr != NULL)
+ {
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
+
+ if (macDataViewListCtrlPtr != NULL)
+ {
+ DataBrowserListViewHeaderDesc headerDescription;
+
+ wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description."));
+ switch (align)
+ {
+ case wxALIGN_CENTER:
+ case wxALIGN_CENTER_HORIZONTAL:
+ headerDescription.btnFontStyle.just = teCenter;
+ break;
+ case wxALIGN_LEFT:
+ headerDescription.btnFontStyle.just = teFlushLeft;
+ break;
+ case wxALIGN_RIGHT:
+ headerDescription.btnFontStyle.just = teFlushRight;
+ break;
+ default:
+ headerDescription.btnFontStyle.just = teFlushDefault;
+ }
+ wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set alignment."));
+ }
+ }
+}
+
+void wxDataViewColumn::SetBitmap(wxBitmap const& bitmap)
+{
+ wxDataViewCtrl* dataViewCtrlPtr(GetOwner());
+
+
+ wxDataViewColumnBase::SetBitmap(bitmap);
+ if (dataViewCtrlPtr != NULL)
+ {
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
+
+ if (macDataViewListCtrlPtr != NULL)
+ {
+ DataBrowserListViewHeaderDesc headerDescription;
+
+ wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description."));
+ if (GetBitmap().IsOk())
+ headerDescription.btnContentInfo.u.iconRef = GetBitmap().GetIconRef();
+ else
+ headerDescription.btnContentInfo.u.iconRef = NULL;
+ wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set icon."));
+ }
+ }
+}
+
+void wxDataViewColumn::SetMaxWidth(int maxWidth)
+{
+ wxDataViewCtrl* dataViewCtrlPtr(GetOwner());
+
+
+ m_maxWidth = maxWidth;
+ if (dataViewCtrlPtr != NULL)
+ {
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
+
+ if (macDataViewListCtrlPtr != NULL)
+ {
+ DataBrowserListViewHeaderDesc headerDescription;
+
+ wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description."));
+ headerDescription.maximumWidth = static_cast<UInt16>(maxWidth);
+ wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set maximum width."));
+ }
+ }
+}
+
+void wxDataViewColumn::SetMinWidth(int minWidth)
+{
+ wxDataViewCtrl* dataViewCtrlPtr(GetOwner());
+
+
+ m_minWidth = minWidth;
+ if (dataViewCtrlPtr != NULL)
+ {
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
+
+ if (macDataViewListCtrlPtr != NULL)
+ {
+ DataBrowserListViewHeaderDesc headerDescription;
+
+ wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description."));
+ headerDescription.minimumWidth = static_cast<UInt16>(minWidth);
+ wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set minimum width."));
+ }
+ }
+}
+
+void wxDataViewColumn::SetReorderable(bool reorderable)
+{
+ // first set the internal flag of the column:
+ if (reorderable)
+ m_flags |= wxDATAVIEW_COL_REORDERABLE;
+ else
+ m_flags &= ~wxDATAVIEW_COL_REORDERABLE;
+ // if the column is associated with a control change also immediately the flags of the control:
+ wxDataViewCtrl* dataViewCtrlPtr(GetOwner());
+
+ if (dataViewCtrlPtr != NULL)
+ {
+ DataBrowserPropertyFlags flags;
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
+
+ wxCHECK_RET(macDataViewListCtrlPtr != NULL, _("Valid pointer to native data view control does not exist"));
+ wxCHECK_RET(macDataViewListCtrlPtr->GetPropertyFlags(GetNativeData()->GetPropertyID(),&flags) == noErr,_("Could not get property flags."));
+ if (reorderable)
+ flags |= kDataBrowserListViewMovableColumn;
+ else
+ flags &= ~kDataBrowserListViewMovableColumn;
+ wxCHECK_RET(macDataViewListCtrlPtr->SetPropertyFlags(GetNativeData()->GetPropertyID(),flags) == noErr,_("Could not set property flags."));
+ }
+}
+
+void wxDataViewColumn::SetResizeable(bool resizable)
+{
+ // first set the internal flag of the column:
+ if (resizable)
+ m_flags |= wxDATAVIEW_COL_RESIZABLE;
+ else
+ m_flags &= ~wxDATAVIEW_COL_RESIZABLE;
+ // if the column is associated with a control change also immediately the flags of the control:
+ wxDataViewCtrl* dataViewCtrlPtr(GetOwner());
+
+ if (dataViewCtrlPtr != NULL)
+ {
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
+
+ if (macDataViewListCtrlPtr != NULL)
+ {
+ DataBrowserListViewHeaderDesc headerDescription;
+
+ verify_noerr(macDataViewListCtrlPtr->GetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription));
+ if (resizable)
+ {
+ if (GetMinWidth() >= GetMaxWidth())
+ {
+ m_minWidth = 0;
+ m_maxWidth = 30000;
+ }
+ headerDescription.minimumWidth = m_minWidth;
+ headerDescription.maximumWidth = m_maxWidth;
+ }
+ else
+ {
+ headerDescription.minimumWidth = m_width;
+ headerDescription.maximumWidth = m_width;
+ }
+ verify_noerr(macDataViewListCtrlPtr->SetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription));
+ macDataViewListCtrlPtr->SetSortProperty(GetNativeData()->GetPropertyID());
+ }
+ }
+}
+
+void wxDataViewColumn::SetSortable(bool sortable)
+{
+ // first set the internal flag of the column:
+ if (sortable)
+ m_flags |= wxDATAVIEW_COL_SORTABLE;
+ else
+ m_flags &= ~wxDATAVIEW_COL_SORTABLE;
+ // if the column is associated with a control change also immediately the flags of the control:
+ wxDataViewCtrl* dataViewCtrlPtr(GetOwner());
+
+ if (dataViewCtrlPtr != NULL)
+ {
+ DataBrowserPropertyFlags flags;
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
+
+ wxCHECK_RET(macDataViewListCtrlPtr != NULL, _("Valid pointer to native data view control does not exist"));
+ wxCHECK_RET(macDataViewListCtrlPtr->GetPropertyFlags(GetNativeData()->GetPropertyID(),&flags) == noErr,_("Could not get property flags."));
+ if (sortable)
+ flags |= kDataBrowserListViewSortableColumn;
+ else
+ flags &= ~kDataBrowserListViewSortableColumn;
+ wxCHECK_RET(macDataViewListCtrlPtr->SetPropertyFlags(GetNativeData()->GetPropertyID(),flags) == noErr,_("Could not set property flags."));
+ }
+}
+
+void wxDataViewColumn::SetSortOrder(bool ascending)
+{
+ wxDataViewCtrl* dataViewCtrlPtr(GetOwner());
+
+
+ m_ascending = ascending;
+ if (dataViewCtrlPtr != NULL)
+ {
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
+
+ if (macDataViewListCtrlPtr != NULL)
+ {
+ DataBrowserListViewHeaderDesc headerDescription;
+
+ verify_noerr(macDataViewListCtrlPtr->GetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription));
+ if (ascending)
+ headerDescription.initialOrder = kDataBrowserOrderIncreasing;
+ else
+ headerDescription.initialOrder = kDataBrowserOrderDecreasing;
+ verify_noerr(macDataViewListCtrlPtr->SetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription));
+ macDataViewListCtrlPtr->SetSortProperty(GetNativeData()->GetPropertyID());
+ }
+ }
+}
+
+void wxDataViewColumn::SetTitle(wxString const& title)
+{
+ wxDataViewCtrl* dataViewCtrlPtr(GetOwner());
+
+
+ m_title = title;
+ if (dataViewCtrlPtr != NULL)
+ {
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
+
+ if (macDataViewListCtrlPtr != NULL)
+ {
+ DataBrowserListViewHeaderDesc headerDescription;
+ wxCFStringRef cfTitle(title,(dataViewCtrlPtr->GetFont().IsOk() ? dataViewCtrlPtr->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
+
+ wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description."));
+ headerDescription.titleString = cfTitle;
+ wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set header description."));
+ }
+ }
+}
+
+void wxDataViewColumn::SetWidth(int width)
+{
+ wxDataViewCtrl* dataViewCtrlPtr(GetOwner());
+
+ switch ( width )
+ {
+ case wxCOL_WIDTH_AUTOSIZE:
+ // not implemented, fall through
+ case wxCOL_WIDTH_DEFAULT:
+ width = wxDVC_DEFAULT_WIDTH;
+ break;
+ default:
+ break;
+ }
+
+ if ((width >= m_minWidth) && (width <= m_maxWidth))
+ {
+ m_width = width;
+ if (dataViewCtrlPtr != NULL)
+ {
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
+
+ if (macDataViewListCtrlPtr != NULL)
+ wxCHECK_RET(macDataViewListCtrlPtr->SetColumnWidth(GetNativeData()->GetPropertyID(),static_cast<UInt16>(width)) == noErr,_("Could not set column width."));
+ }
+ }
+}
+
+void wxDataViewColumn::SetHidden(bool WXUNUSED(hidden))
+{
+ // How to do that?
+}
+
+bool wxDataViewColumn::IsHidden() const
+{
+ return true;
+}
+
+
+void wxDataViewColumn::SetNativeData(wxDataViewColumnNativeData* newNativeDataPtr)
+{
+ delete m_NativeDataPtr;
+ m_NativeDataPtr = newNativeDataPtr;
+}