minor cleanup

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38349 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Surovell 2006-03-24 17:19:35 +00:00
parent 6fa9383b57
commit de5e599c8a

View File

@ -188,9 +188,7 @@ bool wxDropTarget::GetData()
FlavorType theType; FlavorType theType;
FlavorFlags theFlags; FlavorFlags theFlags;
UInt16 flavors; UInt16 flavors;
bool firstFileAdded = false; wxString filenamesPassed;
wxString filenamesPassed ;
CountDragItems( (DragReference)m_currentDrag, &items ); CountDragItems( (DragReference)m_currentDrag, &items );
for (UInt16 index = 1; index <= items; ++index) for (UInt16 index = 1; index <= items; ++index)
@ -201,22 +199,22 @@ bool wxDropTarget::GetData()
wxDataFormat preferredFormat = m_dataObject->GetPreferredFormat( wxDataObject::Set ); wxDataFormat preferredFormat = m_dataObject->GetPreferredFormat( wxDataObject::Set );
bool hasPreferredFormat = false; bool hasPreferredFormat = false;
for ( UInt16 flavor = 1; flavor <= flavors; ++flavor ) for (UInt16 flavor = 1; flavor <= flavors; ++flavor)
{ {
result = GetFlavorType( (DragReference)m_currentDrag, theItem, flavor, &theType ); result = GetFlavorType( (DragReference)m_currentDrag, theItem, flavor, &theType );
wxDataFormat format( theType ); wxDataFormat format( theType );
if ( preferredFormat == format ) if (preferredFormat == format)
{ {
hasPreferredFormat = true; hasPreferredFormat = true;
break; break;
} }
} }
for ( UInt16 flavor = 1; flavor <= flavors; ++flavor ) for (UInt16 flavor = 1; flavor <= flavors; ++flavor)
{ {
result = GetFlavorType( (DragReference)m_currentDrag, theItem, flavor, &theType ); result = GetFlavorType( (DragReference)m_currentDrag, theItem, flavor, &theType );
wxDataFormat format( theType ); wxDataFormat format( theType );
if ( (hasPreferredFormat && format == preferredFormat) if ((hasPreferredFormat && format == preferredFormat)
|| (!hasPreferredFormat && m_dataObject->IsSupportedFormat( format ))) || (!hasPreferredFormat && m_dataObject->IsSupportedFormat( format )))
{ {
result = GetFlavorFlags( (DragReference)m_currentDrag, theItem, theType, &theFlags ); result = GetFlavorFlags( (DragReference)m_currentDrag, theItem, theType, &theFlags );
@ -226,13 +224,13 @@ bool wxDropTarget::GetData()
Ptr theData; Ptr theData;
GetFlavorDataSize( (DragReference)m_currentDrag, theItem, theType, &dataSize ); GetFlavorDataSize( (DragReference)m_currentDrag, theItem, theType, &dataSize );
if ( theType == kScrapFlavorTypeText ) if (theType == kScrapFlavorTypeText)
{ {
// this increment is only valid for allocating: // this increment is only valid for allocating:
// on the next GetFlavorData call it is reset again to the original value // on the next GetFlavorData call it is reset again to the original value
dataSize++; dataSize++;
} }
else if ( theType == kScrapFlavorTypeUnicode ) else if (theType == kScrapFlavorTypeUnicode)
{ {
// this increment is only valid for allocating: // this increment is only valid for allocating:
// on the next GetFlavorData call it is reset again to the original value // on the next GetFlavorData call it is reset again to the original value
@ -245,7 +243,7 @@ bool wxDropTarget::GetData()
else else
theData = NULL; theData = NULL;
GetFlavorData( (DragReference)m_currentDrag, theItem, theType, (void*) theData, &dataSize, 0L ); GetFlavorData( (DragReference)m_currentDrag, theItem, theType, (void*)theData, &dataSize, 0L );
switch (theType) switch (theType)
{ {
case kScrapFlavorTypeText: case kScrapFlavorTypeText:
@ -262,18 +260,16 @@ bool wxDropTarget::GetData()
#endif #endif
case kDragFlavorTypeHFS: case kDragFlavorTypeHFS:
if (theData != NULL)
{ {
if (theData != NULL) HFSFlavor* theFile = (HFSFlavor*)theData;
{ wxString name = wxMacFSSpec2MacFilename( &theFile->fileSpec );
HFSFlavor* theFile = (HFSFlavor*) theData;
wxString name = wxMacFSSpec2MacFilename( &theFile->fileSpec );
if (!name.IsEmpty()) if (!name.IsEmpty())
filenamesPassed += name + wxT("\n"); filenamesPassed += name + wxT("\n");
}
} }
break; break;
default: default:
m_dataObject->SetData( format, dataSize, theData ); m_dataObject->SetData( format, dataSize, theData );
break; break;
@ -285,10 +281,11 @@ bool wxDropTarget::GetData()
} }
} }
} }
if ( filenamesPassed.Len() > 0 )
if (filenamesPassed.Len() > 0)
{ {
wxCharBuffer buf = filenamesPassed.fn_str(); wxCharBuffer buf = filenamesPassed.fn_str();
m_dataObject->SetData( wxDataFormat( wxDF_FILENAME ) , strlen( buf ) , (const char*) buf ); m_dataObject->SetData( wxDataFormat(wxDF_FILENAME), strlen( buf ), (const char*)buf );
} }
} }
@ -334,15 +331,14 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
{ {
wxASSERT_MSG( m_data, wxT("Drop source: no data") ); wxASSERT_MSG( m_data, wxT("Drop source: no data") );
if (!m_data) if ((m_data == NULL) || (m_data->GetFormatCount() == 0))
return (wxDragResult) wxDragNone; return (wxDragResult)wxDragNone;
if (m_data->GetFormatCount() == 0)
return (wxDragResult) wxDragNone;
OSStatus result; OSStatus result;
DragReference theDrag; DragReference theDrag;
RgnHandle dragRegion; RgnHandle dragRegion;
if ((result = NewDrag(&theDrag)) != noErr)
if ((result = NewDrag( &theDrag )) != noErr)
return wxDragNone; return wxDragNone;
// add data to drag // add data to drag
@ -619,27 +615,20 @@ pascal OSErr wxMacWindowDragTrackingHandler(
{ {
if ( !trackingGlobals->m_currentSource->MacInstallDefaultCursor( result ) ) if ( !trackingGlobals->m_currentSource->MacInstallDefaultCursor( result ) )
{ {
switch ( result ) int cursorID = wxCURSOR_NONE;
switch (result)
{ {
case wxDragCopy: case wxDragCopy:
{ cursorID = wxCURSOR_COPY_ARROW;
wxCursor cursor(wxCURSOR_COPY_ARROW);
cursor.MacInstall();
}
break; break;
case wxDragMove: case wxDragMove:
{ cursorID = wxCURSOR_ARROW;
wxCursor cursor(wxCURSOR_ARROW);
cursor.MacInstall();
}
break; break;
case wxDragNone: case wxDragNone:
{ cursorID = wxCURSOR_NO_ENTRY;
wxCursor cursor(wxCURSOR_NO_ENTRY);
cursor.MacInstall();
}
break; break;
case wxDragError: case wxDragError:
@ -649,6 +638,12 @@ pascal OSErr wxMacWindowDragTrackingHandler(
// put these here to make gcc happy // put these here to make gcc happy
; ;
} }
if (cursorID != wxCURSOR_NONE)
{
wxCursor cursor( cursorID );
cursor.MacInstall();
}
} }
} }
} }