- // constant definitions for abbreviational purposes:
- wxDataFormatId const idDataFormat = dataFormats[formatCounter].GetType();
- size_t const dataSize = dataViewEvent.GetDataObject()->GetDataSize(idDataFormat);
- size_t const dataBufferSize = sizeof(wxDataFormatId)+dataSize;
- // variable definitions (used in all case statements):
- wxMemoryBuffer dataBuffer(dataBufferSize);
-
- dataBuffer.AppendData(&idDataFormat,sizeof(wxDataFormatId));
- switch (idDataFormat)
- {
- case wxDF_TEXT:
- if (!itemStringAvailable) // otherwise wxDF_UNICODETEXT already filled up the string; and the UNICODE representation has priority
- {
- dataViewEvent.GetDataObject()->GetDataHere(wxDF_TEXT,dataBuffer.GetAppendBuf(dataSize));
- dataBuffer.UngetAppendBuf(dataSize);
- [dataArray addObject:[NSData dataWithBytes:dataBuffer.GetData() length:dataBufferSize]];
- itemString = wxString(reinterpret_cast<char const*>(dataBuffer.GetData())+sizeof(wxDataFormatId),wxConvLocal);
- itemStringAvailable = true;
- }
- break;
- case wxDF_UNICODETEXT:
- {
- dataViewEvent.GetDataObject()->GetDataHere(wxDF_UNICODETEXT,dataBuffer.GetAppendBuf(dataSize));
- dataBuffer.UngetAppendBuf(dataSize);
- if (itemStringAvailable) // does an object already exist as an ASCII text (see wxDF_TEXT case statement)?
- [dataArray replaceObjectAtIndex:itemCounter withObject:[NSData dataWithBytes:dataBuffer.GetData() length:dataBufferSize]];
- else
- [dataArray addObject:[NSData dataWithBytes:dataBuffer.GetData() length:dataBufferSize]];
- itemString = wxString::FromUTF8(reinterpret_cast<char const*>(dataBuffer.GetData())+sizeof(wxDataFormatId),dataSize);
- itemStringAvailable = true;
- } /* block */
- break;
- default:
- wxFAIL_MSG(_("Data object has invalid or unsupported data format"));
- [dataArray release];
- return NO;
- }
+ bool itemStringAvailable(false); // a flag indicating if for the current item a string is available
+ wxDataObjectComposite* itemObject(new wxDataObjectComposite()); // data object for current item
+ wxString itemString; // contains the TAB concatenated data of an item
+
+ event.SetItem(wxDataViewItem([((wxPointerObject*) [writeItems objectAtIndex:itemCounter]) pointer]));
+ itemString = ::ConcatenateDataViewItemValues(dvc,event.GetItem());
+ itemObject->Add(new wxTextDataObject(itemString));
+ event.SetDataObject(itemObject);
+ // check if event has not been vetoed:
+ if (dvc->HandleWindowEvent(event) && event.IsAllowed() && (event.GetDataObject()->GetFormatCount() > 0))
+ {
+ // constant definition for abbreviational purposes:
+ size_t const noOfFormats = event.GetDataObject()->GetFormatCount();
+ // variable definition and initialization:
+ wxDataFormat* dataFormats(new wxDataFormat[noOfFormats]);
+
+ event.GetDataObject()->GetAllFormats(dataFormats,wxDataObject::Get);
+ for (size_t formatCounter=0; formatCounter<noOfFormats; ++formatCounter)
+ {
+ // constant definitions for abbreviational purposes:
+ wxDataFormatId const idDataFormat = dataFormats[formatCounter].GetType();
+ 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);
+
+ dataBuffer.AppendData(&idDataFormat,sizeof(wxDataFormatId));
+ switch (idDataFormat)
+ {
+ case wxDF_TEXT:
+ if (!itemStringAvailable) // otherwise wxDF_UNICODETEXT already filled up the string; and the UNICODE representation has priority
+ {
+ event.GetDataObject()->GetDataHere(wxDF_TEXT,dataBuffer.GetAppendBuf(dataSize));
+ dataBuffer.UngetAppendBuf(dataSize);
+ [dataArray addObject:[NSData dataWithBytes:dataBuffer.GetData() length:dataBufferSize]];
+ itemString = wxString(static_cast<char const*>(dataBuffer.GetData())+sizeof(wxDataFormatId),wxConvLocal);
+ itemStringAvailable = true;
+ }
+ break;
+ case wxDF_UNICODETEXT:
+ {
+ event.GetDataObject()->GetDataHere(wxDF_UNICODETEXT,dataBuffer.GetAppendBuf(dataSize));
+ dataBuffer.UngetAppendBuf(dataSize);
+ if (itemStringAvailable) // does an object already exist as an ASCII text (see wxDF_TEXT case statement)?
+ [dataArray replaceObjectAtIndex:itemCounter withObject:[NSData dataWithBytes:dataBuffer.GetData() length:dataBufferSize]];
+ else
+ [dataArray addObject:[NSData dataWithBytes:dataBuffer.GetData() length:dataBufferSize]];
+ itemString = wxString::FromUTF8(static_cast<char const*>(dataBuffer.GetData())+sizeof(wxDataFormatId),dataSize);
+ itemStringAvailable = true;
+ } /* block */
+ break;
+ default:
+ wxFAIL_MSG("Data object has invalid or unsupported data format");
+ [dataArray release];
+ return NO;
+ }
+ }
+ delete[] dataFormats;
+ delete itemObject;
+ if (dataStringAvailable)
+ if (itemStringAvailable)
+ {
+ if (itemCounter > 0)
+ dataString << wxT('\n');
+ dataString << itemString;
+ }
+ else
+ dataStringAvailable = false;
+ }
+ else
+ {
+ [dataArray release];
+ delete itemObject;
+ return NO; // dragging was vetoed or no data available
+ }