+ delete m_NativeDataPtr;
+ m_NativeDataPtr = newNativeDataPtr;
+}
+
+void wxDataViewRenderer::EnableEllipsize(wxEllipsizeMode mode)
+{
+ // we need to store this value to apply it to the columns headerCell in
+ // CreateNativeColumn()
+ GetNativeData()->SetEllipsizeMode(mode);
+
+ // but we may already apply it to the column cell which will be used for
+ // this column
+ GetNativeData()->ApplyLineBreakMode(GetNativeData()->GetColumnCell());
+}
+
+wxEllipsizeMode wxDataViewRenderer::GetEllipsizeMode() const
+{
+ return GetNativeData()->GetEllipsizeMode();
+}
+
+void
+wxDataViewRenderer::OSXOnCellChanged(NSObject *object,
+ const wxDataViewItem& item,
+ unsigned col)
+{
+ // TODO: we probably should get rid of this code entirely and make this
+ // function pure virtual, but currently we still have some native
+ // renderers (wxDataViewChoiceRenderer) which don't override it and
+ // there is also wxDataViewCustomRenderer for which it's not obvious
+ // how it should be implemented so keep this "auto-deduction" of
+ // variant type from NSObject for now
+
+ wxVariant value;
+ if ( [object isKindOfClass:[NSString class]] )
+ value = ObjectToString(object);
+ else if ( [object isKindOfClass:[NSNumber class]] )
+ value = ObjectToLong(object);
+ else if ( [object isKindOfClass:[NSDate class]] )
+ value = ObjectToDate(object);
+ else
+ {
+ wxFAIL_MSG( wxString::Format
+ (
+ "unknown value type %s",
+ wxCFStringRef::AsString([object className])
+ ));
+ return;
+ }
+
+ wxDataViewModel *model = GetOwner()->GetOwner()->GetModel();
+ model->ChangeValue(value, item, col);
+}
+
+void wxDataViewRenderer::OSXApplyAttr(const wxDataViewItemAttr& attr)
+{
+ wxDataViewRendererNativeData * const data = GetNativeData();
+ NSCell * const cell = data->GetItemCell();
+
+ // set the font and text colour to use: we need to do it if we had ever
+ // changed them before, even if this item itself doesn't have any special
+ // attributes as otherwise it would reuse the attributes from the previous
+ // cell rendered using the same renderer
+ NSFont *font = NULL;
+ NSColor *colText = NULL;
+
+ if ( attr.HasFont() )
+ {
+ font = data->GetOriginalFont();
+ if ( !font )
+ {
+ // this is the first time we're setting the font, remember the
+ // original one before changing it
+ font = [cell font];
+ data->SaveOriginalFont(font);
+ }
+
+ if ( font )
+ {
+ // FIXME: using wxFont methods here doesn't work for some reason
+ NSFontManager * const fm = [NSFontManager sharedFontManager];
+ if ( attr.GetBold() )
+ font = [fm convertFont:font toHaveTrait:NSBoldFontMask];
+ if ( attr.GetItalic() )
+ font = [fm convertFont:font toHaveTrait:NSItalicFontMask];
+ }
+ //else: can't change font if the cell doesn't have any
+ }
+
+ if ( attr.HasColour() )
+ {
+ // we can set font for any cell but only NSTextFieldCell provides
+ // a method for setting text colour so check that this method is
+ // available before using it
+ if ( [cell respondsToSelector:@selector(setTextColor:)] &&
+ [cell respondsToSelector:@selector(textColor)] )
+ {
+ if ( !data->GetOriginalTextColour() )
+ {
+ // the cast to (untyped) id is safe because of the check above
+ data->SaveOriginalTextColour([(id)cell textColor]);
+ }
+
+ const wxColour& c = attr.GetColour();
+ colText = [NSColor colorWithDeviceRed:c.Red() / 255.
+ green:c.Green() / 255.
+ blue:c.Blue() / 255.
+ alpha:c.Alpha() / 255.];
+ }
+ }
+
+ if ( !font )
+ font = data->GetOriginalFont();
+ if ( !colText )
+ colText = data->GetOriginalTextColour();
+
+ if ( font )
+ [cell setFont:font];
+
+ if ( colText )
+ [(id)cell setTextColor:colText];
+}
+
+void wxDataViewRenderer::OSXApplyEnabled(bool enabled)
+{
+ [GetNativeData()->GetItemCell() setEnabled:enabled];