Correct example of using wxDataObjectComposite in the docs
Don't call base class pure virtual method, but do call GetData() before using the data object. Also fix a typo in a variable name.
This commit is contained in:
@@ -427,40 +427,39 @@ public:
|
|||||||
wxDragResult MyDropTarget::OnData(wxCoord x, wxCoord y,
|
wxDragResult MyDropTarget::OnData(wxCoord x, wxCoord y,
|
||||||
wxDragResult defaultDragResult)
|
wxDragResult defaultDragResult)
|
||||||
{
|
{
|
||||||
wxDragResult dragResult = wxDropTarget::OnData(x, y, defaultDragResult);
|
if ( !GetData() )
|
||||||
if ( dragResult == defaultDragResult )
|
return wxDragNone;
|
||||||
|
|
||||||
|
wxDataObjectComposite *
|
||||||
|
dataobjComp = static_cast<wxDataObjectComposite *>(GetDataObject());
|
||||||
|
|
||||||
|
wxDataFormat format = dataobjComp->GetReceivedFormat();
|
||||||
|
wxDataObject *dataobj = dataobjComp->GetObject(format);
|
||||||
|
switch ( format.GetType() )
|
||||||
{
|
{
|
||||||
wxDataObjectComposite *
|
case wxDF_BITMAP:
|
||||||
dataobjComp = static_cast<wxDataObjectComposite *>(GetDataObject());
|
{
|
||||||
|
wxBitmapDataObject *
|
||||||
|
dataobjBitmap = static_cast<wxBitmapDataObject *>(dataobj);
|
||||||
|
|
||||||
wxDataFormat format = dataObjects->GetReceivedFormat();
|
... use dataobj->GetBitmap() ...
|
||||||
wxDataObject *dataobj = dataobjComp->GetObject(format);
|
}
|
||||||
switch ( format.GetType() )
|
break;
|
||||||
{
|
|
||||||
case wxDF_BITMAP:
|
|
||||||
{
|
|
||||||
wxBitmapDataObject *
|
|
||||||
dataobjBitmap = static_cast<wxBitmapDataObject *>(dataobj);
|
|
||||||
|
|
||||||
... use dataobj->GetBitmap() ...
|
case wxDF_FILENAME:
|
||||||
}
|
{
|
||||||
break;
|
wxFileDataObject *
|
||||||
|
dataobjFile = static_cast<wxFileDataObject *>(dataobj);
|
||||||
|
|
||||||
case wxDF_FILENAME:
|
... use dataobj->GetFilenames() ...
|
||||||
{
|
}
|
||||||
wxFileDataObject *
|
break;
|
||||||
dataobjFile = static_cast<wxFileDataObject *>(dataobj);
|
|
||||||
|
|
||||||
... use dataobj->GetFilenames() ...
|
default:
|
||||||
}
|
wxFAIL_MSG( "unexpected data object format" );
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
wxFAIL_MSG( "unexpected data object format" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return dragResult;
|
return defaultDragResult;
|
||||||
}
|
}
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user