X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fc672a2aba52bee363e606707ce0e1848cfec79b..ab67e8874db324fab5223cc8d5dff8a8de3e2b77:/src/osx/cocoa/dataview.mm diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm index 873f621ffa..632af4b04b 100644 --- a/src/osx/cocoa/dataview.mm +++ b/src/osx/cocoa/dataview.mm @@ -753,7 +753,7 @@ outlineView:(NSOutlineView*)outlineView // send first the event to wxWidgets that the sorting has changed so that // the program can do special actions before the sorting actually starts: - wxDataViewEvent event(wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED,dvc->GetId()); // variable defintion + wxDataViewEvent event(wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED,dvc->GetId()); // variable definition event.SetEventObject(dvc); if (noOfDescriptors > 0) @@ -926,7 +926,8 @@ outlineView:(NSOutlineView*)outlineView size_t const dataSize = event.GetDataObject()->GetDataSize(idDataFormat); size_t const dataBufferSize = sizeof(wxDataFormatId)+dataSize; // variable definitions (used in all case statements): - wxMemoryBuffer dataBuffer(dataBufferSize); + // give additional headroom for trailing NULL + wxMemoryBuffer dataBuffer(dataBufferSize+4); dataBuffer.AppendData(&idDataFormat,sizeof(wxDataFormatId)); switch (idDataFormat) @@ -958,7 +959,6 @@ outlineView:(NSOutlineView*)outlineView break; default: wxFAIL_MSG("Data object has invalid or unsupported data format"); - [dataArray release]; return NO; } } @@ -976,7 +976,6 @@ outlineView:(NSOutlineView*)outlineView } else { - [dataArray release]; delete itemObject; return NO; // dragging was vetoed or no data available } @@ -1167,6 +1166,23 @@ outlineView:(NSOutlineView*)outlineView @implementation wxCustomCell +#if 0 // starting implementation for custom cell clicks + +- (id)init +{ + self = [super init]; + [self setAction:@selector(clickedAction)]; + [self setTarget:self]; + return self; +} + +- (void) clickedAction: (id) sender +{ + wxUnusedVar(sender); +} + +#endif + -(NSSize) cellSize { wxCustomRendererObject * const @@ -2287,6 +2303,14 @@ wxDataViewItem wxCocoaDataViewControl::GetCurrentItem() const return wxDataViewItem([[m_OutlineView itemAtRow:[m_OutlineView selectedRow]] pointer]); } +wxDataViewColumn *wxCocoaDataViewControl::GetCurrentColumn() const +{ + int col = [m_OutlineView selectedColumn]; + if ( col == -1 ) + return NULL; + return GetColumn(col); +} + void wxCocoaDataViewControl::SetCurrentItem(const wxDataViewItem& item) { // We can't have unselected current item in a NSTableView, as the @@ -2612,12 +2636,11 @@ 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 + // TODO: This code should really be removed and this function be made pure + // virtual. We just need to decide what to do with custom renderers + // (i.e. wxDataViewCustomRenderer), currently OS X "in place" editing + // which doesn't really create an editor control is not compatible + // with the in place editing under other platforms. wxVariant value; if ( [object isKindOfClass:[NSString class]] ) @@ -2690,7 +2713,7 @@ void wxDataViewRenderer::OSXApplyAttr(const wxDataViewItemAttr& attr) } const wxColour& c = attr.GetColour(); - colText = [NSColor colorWithDeviceRed:c.Red() / 255. + colText = [NSColor colorWithCalibratedRed:c.Red() / 255. green:c.Green() / 255. blue:c.Blue() / 255. alpha:c.Alpha() / 255.]; @@ -2848,6 +2871,17 @@ wxDataViewChoiceRenderer::wxDataViewChoiceRenderer(const wxArrayString& choices, [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. + wxDataViewModel *model = GetOwner()->GetOwner()->GetModel(); + model->ChangeValue(GetChoice(ObjectToLong(value)), item, col); +} + bool wxDataViewChoiceRenderer::MacRender() { if (GetValue().GetType() == GetVariantType()) @@ -2987,6 +3021,8 @@ bool wxDataViewIconTextRenderer::MacRender() iconText << GetValue(); if (iconText.GetIcon().IsOk()) [cell setImage:[[wxBitmap(iconText.GetIcon()).GetNSImage() retain] autorelease]]; + else + [cell setImage:nil]; [cell setStringValue:[[wxCFStringRef(iconText.GetText()).AsNSString() retain] autorelease]]; return true; }