From 19c417267166f0ca43d6183cfccfb6be3360e22c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 24 Nov 2017 23:10:47 +0100 Subject: [PATCH] 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. --- interface/wx/dataobj.h | 53 +++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/interface/wx/dataobj.h b/interface/wx/dataobj.h index 8da5c8f237..2647306b31 100644 --- a/interface/wx/dataobj.h +++ b/interface/wx/dataobj.h @@ -427,40 +427,39 @@ public: wxDragResult MyDropTarget::OnData(wxCoord x, wxCoord y, wxDragResult defaultDragResult) { - wxDragResult dragResult = wxDropTarget::OnData(x, y, defaultDragResult); - if ( dragResult == defaultDragResult ) + if ( !GetData() ) + return wxDragNone; + + wxDataObjectComposite * + dataobjComp = static_cast(GetDataObject()); + + wxDataFormat format = dataobjComp->GetReceivedFormat(); + wxDataObject *dataobj = dataobjComp->GetObject(format); + switch ( format.GetType() ) { - wxDataObjectComposite * - dataobjComp = static_cast(GetDataObject()); + case wxDF_BITMAP: + { + wxBitmapDataObject * + dataobjBitmap = static_cast(dataobj); - wxDataFormat format = dataObjects->GetReceivedFormat(); - wxDataObject *dataobj = dataobjComp->GetObject(format); - switch ( format.GetType() ) - { - case wxDF_BITMAP: - { - wxBitmapDataObject * - dataobjBitmap = static_cast(dataobj); + ... use dataobj->GetBitmap() ... + } + break; - ... use dataobj->GetBitmap() ... - } - break; + case wxDF_FILENAME: + { + wxFileDataObject * + dataobjFile = static_cast(dataobj); - case wxDF_FILENAME: - { - wxFileDataObject * - dataobjFile = static_cast(dataobj); + ... use dataobj->GetFilenames() ... + } + break; - ... use dataobj->GetFilenames() ... - } - break; - - default: - wxFAIL_MSG( "unexpected data object format" ); - } + default: + wxFAIL_MSG( "unexpected data object format" ); } - return dragResult; + return defaultDragResult; } @endcode