Jul 2, 2010

Simple Extension for wxFileDropTarget of wxWidgets


//--------------------------------------------------------------------------
class CWxDnDSink
{
public:
CWxDnDSink();
virtual ~CWxDnDSink() = 0;

virtual Result OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& rFile);
};

//--------------------------------------------------------------------------
class CWxFileDropTarget : public wxFileDropTarget
{
CWxDnDSink* pDnDSink;

public:
CWxFileDropTarget(CWxDnDSink* pSink);
virtual ~CWxFileDropTarget();

virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& rFile);
};


Then every wxWindow can inherit CWxDnDSink, and SetDropTarget with a CWxFileDropTarget object. Quite simple and useful for me since I don`t want to write new drop target every time (like the dnd sample).

No comments: