#if defined(__WXGTK__) || defined(__WXMOTIF__)
#include "mondrian.xpm"
+
+ #include "dnd_copy.xpm"
+ #include "dnd_move.xpm"
+ #include "dnd_none.xpm"
#endif
// ----------------------------------------------------------------------------
wxListBox *m_pOwner;
};
+// ----------------------------------------------------------------------------
+// Define a custom dtop target accepting URLs
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT URLDropTarget : public wxDropTarget
+{
+public:
+ URLDropTarget() { SetDataObject(new wxURLDataObject); }
+
+ void OnDropURL(wxCoord x, wxCoord y, const wxString& text)
+ {
+ // of course, a real program would do something more useful here...
+ wxMessageBox(text, _T("wxDnD sample: got URL"),
+ wxICON_INFORMATION | wxOK);
+ }
+
+ // URLs can't be moved, only copied
+ virtual wxDragResult OnDragOver(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
+ wxDragResult def)
+ { return def == wxDragMove ? wxDragCopy : def; }
+
+ // translate this to calls to OnDropURL() just for convenience
+ virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def)
+ {
+ if ( !GetData() )
+ return wxDragNone;
+
+ OnDropURL(x, y, ((wxURLDataObject *)m_dataObject)->GetURL());
+
+ return def;
+ }
+};
+
// ----------------------------------------------------------------------------
// Define a new application type
// ----------------------------------------------------------------------------
m_pLog = new wxLogTextCtrl(m_ctrlLog);
m_pLogPrev = wxLog::SetActiveTarget(m_pLog);
- // associate drop targets with 2 text controls
+ // associate drop targets with the controls
m_ctrlFile->SetDropTarget(new DnDFile(m_ctrlFile));
m_ctrlText->SetDropTarget(new DnDText(m_ctrlText));
+ m_ctrlLog->SetDropTarget(new URLDropTarget);
wxLayoutConstraints *c;
textData.AddFile( "/file1.txt" );
textData.AddFile( "/file2.txt" );
*/
- wxDropSource source(textData, this
-
-#ifdef __WXMSW__
- ,wxCURSOR_PENCIL, // for copy
- wxCURSOR_SPRAYCAN, // for move
- wxCURSOR_QUESTION_ARROW // for nothing
-#endif
- );
+ wxDropSource source(textData, this,
+ wxDROP_ICON(dnd_copy),
+ wxDROP_ICON(dnd_move),
+ wxDROP_ICON(dnd_none));
const char *pc;
SetDropTarget(new DnDShapeDropTarget(this));
m_shape = NULL;
-
+
SetBackgroundColour(*wxWHITE);
}
DnDShapeFrame::~DnDShapeFrame()
{
- if (m_shape)
+ if (m_shape)
delete m_shape;
}
void DnDShapeFrame::SetShape(DnDShape *shape)
{
- if (m_shape)
+ if (m_shape)
delete m_shape;
m_shape = shape;
Refresh();
frame->SetStatusText(wxString::Format(_T("%dx%d"), w, h));
frame->SetClientSize(w > 100 ? 100 : w, h > 100 ? 100 : h);
- frame->Show();
+ frame->Show(TRUE);
}
#ifdef USE_METAFILES