- ItemReference theItem;
- FlavorType theType ;
- UInt16 flavors = 0 ;
- GetDragItemReferenceNumber((DragReference)m_currentDrag, index, &theItem);
- CountDragItemFlavors( (DragReference)m_currentDrag, theItem , &flavors ) ;
- for ( UInt16 flavor = 1 ; flavor <= flavors ; ++flavor )
- {
- result = GetFlavorType((DragReference)m_currentDrag, theItem, flavor , &theType);
- wxDataFormat format(theType) ;
- if ( m_dataObject->IsSupportedFormat( format ) )
- {
- FlavorFlags theFlags;
- result = GetFlavorFlags((DragReference)m_currentDrag, theItem, theType, &theFlags);
- if (result == noErr)
- {
- Size dataSize ;
- Ptr theData ;
- GetFlavorDataSize((DragReference)m_currentDrag, theItem, theType, &dataSize);
- if ( theType == 'TEXT' )
- {
- // this increment is only valid for allocating, on the next GetFlavorData
- // call it is reset again to the original value
- dataSize++ ;
- }
- theData = new char[dataSize];
- GetFlavorData((DragReference)m_currentDrag, theItem, theType, (void*) theData, &dataSize, 0L);
- if( theType == 'TEXT' )
- {
- theData[dataSize]=0 ;
- wxString convert( theData , wxConvLocal ) ;
- m_dataObject->SetData( format, convert.Length() * sizeof(wxChar), (const wxChar*) convert );
- }
- else if ( theType == kDragFlavorTypeHFS )
- {
- HFSFlavor* theFile = (HFSFlavor*) theData ;
- wxString name = wxMacFSSpec2MacFilename( &theFile->fileSpec ) ;
- if ( firstFileAdded )
- ((wxFileDataObject*)m_dataObject)->AddFile( name ) ;
- else
- {
- ((wxFileDataObject*)m_dataObject)->SetData( 0 , name.c_str() ) ;
- firstFileAdded = true ;
- }
- }
- else
- {
- m_dataObject->SetData( format, dataSize, theData );
- }
- delete[] theData;
- }
- break ;
- }
- }