+ 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));
+ }
+ }
+ }
+}
+
+void wxDataViewRenderer::SetNativeData(wxDataViewRendererNativeData* newNativeDataPtr)
+{
+ delete this->m_NativeDataPtr;
+ this->m_NativeDataPtr = newNativeDataPtr;
+}
+
+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)
+{
+ this->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)
+{
+ this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserTextType));
+}
+
+bool wxDataViewTextRenderer::MacRender()
+{
+ wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Text renderer cannot render value; value type: ")) << this->GetValue().GetType());
+
+ wxCFStringRef cfString(this->GetValue().GetString(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
+ return (::SetDataBrowserItemDataText(this->GetNativeData()->GetItemDataRef(),cfString) == noErr);
+}
+
+IMPLEMENT_CLASS(wxDataViewTextRenderer,wxDataViewRenderer)
+
+// ---------------------------------------------------------
+// wxDataViewBitmapRenderer
+// ---------------------------------------------------------
+wxDataViewBitmapRenderer::wxDataViewBitmapRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
+ :wxDataViewRenderer(varianttype,mode,align)
+{
+ this->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(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Bitmap renderer cannot render value; value type: ")) << this->GetValue().GetType());
+
+ wxBitmap bitmap;
+
+ bitmap << this->GetValue();
+ return (!(bitmap.Ok()) || (::SetDataBrowserItemDataIcon(this->GetNativeData()->GetItemDataRef(),bitmap.GetIconRef()) == noErr));
+}
+
+IMPLEMENT_CLASS(wxDataViewBitmapRenderer,wxDataViewRenderer)
+
+// ---------------------------------------------------------
+// wxDataViewIconTextRenderer
+// ---------------------------------------------------------
+wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(
+ const wxString& varianttype,
+ wxDataViewCellMode mode,
+ int WXUNUSED(align))
+ :wxDataViewRenderer(varianttype,mode)
+{
+ this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserIconAndTextType));
+}
+
+bool wxDataViewIconTextRenderer::MacRender()
+{
+ wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Icon & text renderer cannot render value; value type: ")) << this->GetValue().GetType());
+
+ wxDataViewIconText iconText;
+
+ iconText << this->GetValue();
+
+ wxCFStringRef cfString(iconText.GetText(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
+
+ if (iconText.GetIcon().IsOk())
+ if (::SetDataBrowserItemDataIcon(this->GetNativeData()->GetItemDataRef(),MAC_WXHICON(iconText.GetIcon().GetHICON())) != noErr)
+ return false;
+ return (::SetDataBrowserItemDataText(this->GetNativeData()->GetItemDataRef(),cfString) == noErr);
+}
+
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewIconTextRenderer,wxDataViewRenderer)
+
+
+// ---------------------------------------------------------
+// wxDataViewToggleRenderer
+// ---------------------------------------------------------
+wxDataViewToggleRenderer::wxDataViewToggleRenderer(
+ const wxString& varianttype,
+ wxDataViewCellMode mode,
+ int WXUNUSED(align))
+ :wxDataViewRenderer(varianttype,mode)
+{
+ this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserCheckboxType));
+}
+
+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);
+}
+
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer,wxDataViewRenderer)
+
+// ---------------------------------------------------------
+// wxDataViewProgressRenderer
+// ---------------------------------------------------------
+wxDataViewProgressRenderer::wxDataViewProgressRenderer(
+ const wxString& WXUNUSED(label),
+ wxString const& varianttype,
+ wxDataViewCellMode mode,
+ int align)
+ :wxDataViewRenderer(varianttype,mode,align)
+{
+ this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserProgressBarType));
+}
+
+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) &&
+ (::SetDataBrowserItemDataMaximum(this->GetNativeData()->GetItemDataRef(),100) == noErr) &&
+ (::SetDataBrowserItemDataValue (this->GetNativeData()->GetItemDataRef(),this->GetValue().GetLong()) == noErr));
+}
+
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer,wxDataViewRenderer)
+
+// ---------------------------------------------------------
+// wxDataViewDateRenderer
+// ---------------------------------------------------------
+wxDataViewDateRenderer::wxDataViewDateRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
+ :wxDataViewRenderer(varianttype,mode,align)
+{
+ this->SetNativeData(new wxDataViewRendererNativeData(kDataBrowserDateTimeType));
+}
+
+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);
+}
+
+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)
+{
+ this->InitCommon(width, align, flags);
+ if ((renderer != NULL) && (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())
+{
+ this->InitCommon(width, align, flags);
+ if ((renderer != NULL) && (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
+ renderer->SetAlignment(align);
+}
+
+wxDataViewColumn::~wxDataViewColumn(void)
+{
+ delete this->m_NativeDataPtr;
+}
+
+bool wxDataViewColumn::IsSortKey() const
+{
+ wxDataViewCtrl * const dataViewCtrlPtr(GetOwner());
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(
+ dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(
+ dataViewCtrlPtr->GetPeer()));
+
+ DataBrowserPropertyID propertyID;
+ return (macDataViewListCtrlPtr->GetSortProperty(&propertyID) == noErr) &&
+ (propertyID == this->GetNativeData()->GetPropertyID());
+}
+
+void wxDataViewColumn::SetAlignment(wxAlignment align)
+{
+ wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
+
+
+ m_alignment = align;
+ if (dataViewCtrlPtr != NULL)
+ {
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
+
+ if (macDataViewListCtrlPtr != NULL)
+ {
+ DataBrowserListViewHeaderDesc headerDescription;
+
+ wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->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(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set alignment."));
+ }
+ }
+}
+
+void wxDataViewColumn::SetBitmap(wxBitmap const& bitmap)
+{
+ wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
+
+
+ wxDataViewColumnBase::SetBitmap(bitmap);
+ if (dataViewCtrlPtr != NULL)
+ {
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
+
+ if (macDataViewListCtrlPtr != NULL)
+ {
+ DataBrowserListViewHeaderDesc headerDescription;
+
+ wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description."));
+ if (this->GetBitmap().Ok())
+ headerDescription.btnContentInfo.u.iconRef = this->GetBitmap().GetIconRef();
+ else
+ headerDescription.btnContentInfo.u.iconRef = NULL;
+ wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set icon."));
+ }
+ }
+}
+
+void wxDataViewColumn::SetMaxWidth(int maxWidth)
+{
+ wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
+
+
+ m_maxWidth = maxWidth;
+ if (dataViewCtrlPtr != NULL)
+ {
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
+
+ if (macDataViewListCtrlPtr != NULL)
+ {
+ DataBrowserListViewHeaderDesc headerDescription;
+
+ wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description."));
+ headerDescription.maximumWidth = static_cast<UInt16>(maxWidth);
+ wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set maximum width."));
+ }
+ }
+}
+
+void wxDataViewColumn::SetMinWidth(int minWidth)
+{
+ wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
+
+
+ m_minWidth = minWidth;
+ if (dataViewCtrlPtr != NULL)
+ {
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
+
+ if (macDataViewListCtrlPtr != NULL)
+ {
+ DataBrowserListViewHeaderDesc headerDescription;
+
+ wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description."));
+ headerDescription.minimumWidth = static_cast<UInt16>(minWidth);
+ wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->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(this->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(this->GetNativeData()->GetPropertyID(),&flags) == noErr,_("Could not get property flags."));
+ if (reorderable)
+ flags |= kDataBrowserListViewMovableColumn;
+ else
+ flags &= ~kDataBrowserListViewMovableColumn;
+ wxCHECK_RET(macDataViewListCtrlPtr->SetPropertyFlags(this->GetNativeData()->GetPropertyID(),flags) == noErr,_("Could not set property flags."));
+ }
+}
+
+void wxDataViewColumn::SetResizeable(bool resizeable)
+{
+ // first set the internal flag of the column:
+ if (resizeable)
+ 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(this->GetOwner());
+
+ if (dataViewCtrlPtr != NULL)
+ {
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
+
+ if (macDataViewListCtrlPtr != NULL)
+ {
+ DataBrowserListViewHeaderDesc headerDescription;
+
+ verify_noerr(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription));
+ if (resizeable)
+ {
+ if (this->GetMinWidth() >= this->GetMaxWidth())
+ {
+ this->m_minWidth = 0;
+ this->m_maxWidth = 30000;
+ }
+ headerDescription.minimumWidth = this->m_minWidth;
+ headerDescription.maximumWidth = this->m_maxWidth;
+ }
+ else
+ {
+ headerDescription.minimumWidth = this->m_width;
+ headerDescription.maximumWidth = this->m_width;
+ }
+ verify_noerr(macDataViewListCtrlPtr->SetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription));
+ macDataViewListCtrlPtr->SetSortProperty(this->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(this->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(this->GetNativeData()->GetPropertyID(),&flags) == noErr,_("Could not get property flags."));
+ if (sortable)
+ flags |= kDataBrowserListViewSortableColumn;
+ else
+ flags &= ~kDataBrowserListViewSortableColumn;
+ wxCHECK_RET(macDataViewListCtrlPtr->SetPropertyFlags(this->GetNativeData()->GetPropertyID(),flags) == noErr,_("Could not set property flags."));
+ }
+}
+
+void wxDataViewColumn::SetSortOrder(bool ascending)
+{
+ wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
+
+
+ m_ascending = ascending;
+ if (dataViewCtrlPtr != NULL)
+ {
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
+
+ if (macDataViewListCtrlPtr != NULL)
+ {
+ DataBrowserListViewHeaderDesc headerDescription;
+
+ verify_noerr(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription));
+ if (ascending)
+ headerDescription.initialOrder = kDataBrowserOrderIncreasing;
+ else
+ headerDescription.initialOrder = kDataBrowserOrderDecreasing;
+ verify_noerr(macDataViewListCtrlPtr->SetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription));
+ macDataViewListCtrlPtr->SetSortProperty(this->GetNativeData()->GetPropertyID());
+ }
+ }
+}
+
+void wxDataViewColumn::SetTitle(wxString const& title)
+{
+ wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
+
+
+ m_title = title;
+ if (dataViewCtrlPtr != NULL)
+ {
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
+
+ if (macDataViewListCtrlPtr != NULL)
+ {
+ DataBrowserListViewHeaderDesc headerDescription;
+ wxCFStringRef cfTitle(title,(dataViewCtrlPtr->GetFont().Ok() ? dataViewCtrlPtr->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
+
+ wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description."));
+ headerDescription.titleString = cfTitle;
+ wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->GetNativeData()->GetPropertyID(),&headerDescription) == noErr,_("Could not set header description."));
+ }
+ }
+}
+
+void wxDataViewColumn::SetWidth(int width)
+{
+ wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
+
+
+ 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(this->GetNativeData()->GetPropertyID(),static_cast<UInt16>(width)) == noErr,_("Could not set column width."));
+ }
+ }
+}
+
+void wxDataViewColumn::SetAsSortKey(bool WXUNUSED(sort))
+{
+ // see wxGTK native wxDataViewColumn implementation
+ wxFAIL_MSG( "not implemented" );
+}
+
+void wxDataViewColumn::SetNativeData(wxDataViewColumnNativeData* newNativeDataPtr)
+{
+ delete this->m_NativeDataPtr;
+ this->m_NativeDataPtr = newNativeDataPtr;
+}