Skip to content

Commit

Permalink
Delete more wxDataView stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
tgoyne committed Jan 31, 2015
1 parent 009eacb commit ce3185d
Showing 1 changed file with 0 additions and 270 deletions.
270 changes: 0 additions & 270 deletions src/osx/cocoa/dataview.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2646,71 +2646,6 @@ void UpdateWithRow(int row)

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 colorWithCalibratedRed: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)
Expand Down Expand Up @@ -2801,144 +2736,6 @@ void UpdateWithRow(int row)

IMPLEMENT_CLASS(wxDataViewTextRenderer,wxDataViewRenderer)

// ---------------------------------------------------------
// wxDataViewBitmapRenderer
// ---------------------------------------------------------
wxDataViewBitmapRenderer::wxDataViewBitmapRenderer(const wxString& varianttype,
wxDataViewCellMode mode,
int align)
: wxDataViewRenderer(varianttype,mode,align)
{
NSImageCell* cell;


cell = [[NSImageCell alloc] init];
SetNativeData(new wxDataViewRendererNativeData(cell));
[cell release];
}

// 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'.
bool wxDataViewBitmapRenderer::MacRender()
{
wxCHECK_MSG(GetValue().GetType() == GetVariantType(),false,wxString("Bitmap renderer cannot render value; value type: ") << GetValue().GetType());

wxBitmap bitmap;

bitmap << GetValue();
if (bitmap.IsOk())
[GetNativeData()->GetItemCell() setObjectValue:[[bitmap.GetNSImage() retain] autorelease]];
return true;
}

IMPLEMENT_CLASS(wxDataViewBitmapRenderer,wxDataViewRenderer)

// -------------------------------------
// wxDataViewChoiceRenderer
// -------------------------------------
wxDataViewChoiceRenderer::wxDataViewChoiceRenderer(const wxArrayString& choices,
wxDataViewCellMode mode,
int alignment)
: wxDataViewRenderer(wxT("string"), mode, alignment),
m_choices(choices)
{
NSPopUpButtonCell* cell;


cell = [[NSPopUpButtonCell alloc] init];
[cell setControlSize:NSMiniControlSize];
[cell setFont:[NSFont fontWithName:[[cell font] fontName] size:[NSFont systemFontSizeForControlSize:NSMiniControlSize]]];
for (size_t i=0; i<choices.GetCount(); ++i)
[cell addItemWithTitle:wxCFStringRef(choices[i]).AsNSString()];
SetNativeData(new wxDataViewRendererNativeData(cell));
[cell release];
}

void
wxDataViewChoiceRenderer::OSXOnCellChanged(NSObject *value,
const wxDataViewItem& item,
unsigned col)
{
// At least under OS X 10.7 we get the index of the item selected and not
// its string.
const long choiceIndex = ObjectToLong(value);

// We can receive -1 if the selection was cancelled, just ignore it.
if ( choiceIndex == -1 )
return;

// If it's not -1, it must be valid, but avoid crashing in GetChoice()
// below if it isn't, for some reason.
wxCHECK_RET( choiceIndex >= 0 && (size_t)choiceIndex < GetChoices().size(),
wxS("Choice index out of range.") );

wxVariant valueChoice(GetChoice(choiceIndex));
if ( !Validate(valueChoice) )
return;

wxDataViewModel *model = GetOwner()->GetOwner()->GetModel();
model->ChangeValue(valueChoice, item, col);
}

bool wxDataViewChoiceRenderer::MacRender()
{
if (GetValue().GetType() == GetVariantType())
{
[((NSPopUpButtonCell*) GetNativeData()->GetItemCell()) selectItemWithTitle:[[wxCFStringRef(GetValue().GetString()).AsNSString() retain] autorelease]];
return true;
}
else
{
wxFAIL_MSG(wxString("Choice renderer cannot render value because of wrong value type; value type: ") << GetValue().GetType());
return false;
}
}

IMPLEMENT_CLASS(wxDataViewChoiceRenderer,wxDataViewRenderer)

// ---------------------------------------------------------
// wxDataViewDateRenderer
// ---------------------------------------------------------

wxDataViewDateRenderer::wxDataViewDateRenderer(const wxString& varianttype,
wxDataViewCellMode mode,
int align)
: wxDataViewRenderer(varianttype,mode,align)
{
NSTextFieldCell* cell;

NSDateFormatter* dateFormatter;


dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
cell = [[NSTextFieldCell alloc] init];
[cell setFormatter:dateFormatter];
SetNativeData(new wxDataViewRendererNativeData(cell,[NSDate dateWithString:@"2000-12-30 20:00:00 +0000"]));
[cell release];
[dateFormatter release];
}

bool wxDataViewDateRenderer::MacRender()
{
wxFAIL_MSG(wxString("Date renderer cannot render value because of wrong value type; value type: ") << GetValue().GetType());
return false;
}

void
wxDataViewDateRenderer::OSXOnCellChanged(NSObject *value,
const wxDataViewItem& item,
unsigned col)
{
}

IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer,wxDataViewRenderer)

// ---------------------------------------------------------
// wxDataViewIconTextRenderer
// ---------------------------------------------------------
Expand Down Expand Up @@ -2997,73 +2794,6 @@ void UpdateWithRow(int row)

IMPLEMENT_ABSTRACT_CLASS(wxDataViewIconTextRenderer,wxDataViewRenderer)

// ---------------------------------------------------------
// wxDataViewToggleRenderer
// ---------------------------------------------------------
wxDataViewToggleRenderer::wxDataViewToggleRenderer(const wxString& varianttype,
wxDataViewCellMode mode,
int align)
: wxDataViewRenderer(varianttype,mode)
{
NSButtonCell* cell;


cell = [[NSButtonCell alloc] init];
[cell setAlignment:ConvertToNativeHorizontalTextAlignment(align)];
[cell setButtonType:NSSwitchButton];
[cell setImagePosition:NSImageOnly];
SetNativeData(new wxDataViewRendererNativeData(cell));
[cell release];
}

bool wxDataViewToggleRenderer::MacRender()
{
return false;
}

void
wxDataViewToggleRenderer::OSXOnCellChanged(NSObject *value,
const wxDataViewItem& item,
unsigned col)
{
}

IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer,wxDataViewRenderer)

// ---------------------------------------------------------
// wxDataViewProgressRenderer
// ---------------------------------------------------------
wxDataViewProgressRenderer::wxDataViewProgressRenderer(const wxString& label,
const wxString& varianttype,
wxDataViewCellMode mode,
int align)
: wxDataViewRenderer(varianttype,mode,align)
{
wxUnusedVar(label);

NSLevelIndicatorCell* cell;

cell = [[NSLevelIndicatorCell alloc] initWithLevelIndicatorStyle:NSContinuousCapacityLevelIndicatorStyle];
[cell setMinValue:0];
[cell setMaxValue:100];
SetNativeData(new wxDataViewRendererNativeData(cell));
[cell release];
}

bool wxDataViewProgressRenderer::MacRender()
{
return false;
}

void
wxDataViewProgressRenderer::OSXOnCellChanged(NSObject *value,
const wxDataViewItem& item,
unsigned col)
{
}

IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer,wxDataViewRenderer)

// ---------------------------------------------------------
// wxDataViewColumn
// ---------------------------------------------------------
Expand Down

0 comments on commit ce3185d

Please sign in to comment.