- UInt16 items ;
- OSErr result;
- CountDragItems((DragReference)m_currentDrag, &items);
- for (UInt16 index = 1; index <= items; ++index)
- {
- 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' )
- dataSize++ ;
- theData = new char[dataSize];
- GetFlavorData((DragReference)m_currentDrag, theItem, theType, (void*) theData, &dataSize, 0L);
- if( theType == 'TEXT' )
- {
- theData[dataSize]=0 ;
- if ( wxApp::s_macDefaultEncodingIsPC )
- {
- wxMacConvertToPC((char*)theData) ;
- }
- m_dataObject->SetData( format, dataSize, theData );
- }
- else if ( theType == kDragFlavorTypeHFS )
- {
- HFSFlavor* theFile = (HFSFlavor*) theData ;
- wxString name = wxMacFSSpec2MacFilename( &theFile->fileSpec ) ;
- ((wxFileDataObject*)m_dataObject)->AddFile( name ) ;
- }
- else
- {
- m_dataObject->SetData( format, dataSize, theData );
- }
- delete[] theData;
- }
- break ;
- }
- }
- }