]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/dnd/dnd.cpp
Merged in latest changes from Mahogany. Untested.
[wxWidgets.git] / samples / dnd / dnd.cpp
index a2e20c79924e1bdb6c4e4bf6bdd76ed627f712c7..6a424109219c4ea331aab57d64d82b381f823ec2 100644 (file)
@@ -9,20 +9,20 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#include "wx/wxprec.h"
+#include <wx/wxprec.h>
 
 #ifdef __BORLANDC__
 #pragma hdrstop
 #endif
 
 #ifndef WX_PRECOMP
-#include "wx/wx.h"
+#include <wx/wx.h>
 #endif
 
-#include  "wx/intl.h"
-#include  "wx/log.h"
+#include <wx/intl.h>
+#include <wx/log.h>
 
-#include  "wx/dnd.h"
+#include <wx/dnd.h>
 
 #ifdef __WXMOTIF__
 #error Sorry, drag and drop is not yet implemented on wxMotif.
 // file names) we drop on them
 // ----------------------------------------------------------------------------
 
+// FIXME this is ugly and should be fixed in the library itself
+#ifdef __WXMSW__
+    typedef long wxDropPointCoord;
+#else // wxGTK
+    typedef int wxDropPointCoord;
+#endif // MSW/GTK
+
 class DnDText : public wxTextDropTarget
 {
 public:
   DnDText(wxListBox *pOwner) { m_pOwner = pOwner; }
 
-  virtual bool OnDropText(long x, long y, const char *psz );
+  virtual bool OnDropText(wxDropPointCoord x, wxDropPointCoord y, const wxChar* psz );
 
 private:
   wxListBox *m_pOwner;
@@ -53,8 +60,8 @@ class DnDFile : public wxFileDropTarget
 public:
   DnDFile(wxListBox *pOwner) { m_pOwner = pOwner; }
 
-  virtual bool OnDropFiles(long x, long y,
-                           size_t nFiles, const char * const aszFiles[] );
+  virtual bool OnDropFiles(wxDropPointCoord x, wxDropPointCoord y,
+                           size_t nFiles, const wxChar* const aszFiles[] );
 
 private:
   wxListBox *m_pOwner;
@@ -195,7 +202,7 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h)
 
   // associate drop targets with 2 text controls
   m_ctrlFile->SetDropTarget(new DnDFile(m_ctrlFile));
-  m_ctrlText->SetDropTarget( new DnDText(m_ctrlText) );
+  m_ctrlText->SetDropTarget(new DnDText(m_ctrlText));
 
   wxLayoutConstraints *c;
 
@@ -239,7 +246,7 @@ void DnDFrame::OnPaint(wxPaintEvent& /*event*/)
 
   wxPaintDC dc(this);
   dc.SetFont( wxFont( 24, wxDECORATIVE, wxNORMAL, wxNORMAL, FALSE, "charter" ) );
-  dc.DrawText( "Drag text from here!", 20, h-22 );
+  dc.DrawText( "Drag text from here!", 20, h-35 );
 }
 
 void DnDFrame::OnDrag(wxCommandEvent& /* event */)
@@ -309,7 +316,7 @@ void DnDFrame::OnLeftDown(wxMouseEvent &WXUNUSED(event) )
     wxTextDataObject textData(m_strText);
     wxDropSource dragSource( textData, this );
 #else
-    wxDropSource dragSource( new wxTextDataObject (m_strText), this );
+    wxDropSource dragSource( new wxTextDataObject (m_strText), this, wxIcon(mondrian_xpm) );
 #endif
     const char *pc;
 
@@ -349,18 +356,18 @@ DnDFrame::~DnDFrame()
 // ----------------------------------------------------------------------------
 // Notifications called by the base class
 // ----------------------------------------------------------------------------
-bool DnDText::OnDropText(long, long, const char *psz)
+bool DnDText::OnDropText( wxDropPointCoord, wxDropPointCoord, const wxChar *psz )
 {
   m_pOwner->Append(psz);
 
   return TRUE;
 }
 
-bool DnDFile::OnDropFiles(long, long, size_t nFiles,
-                          const char * const aszFiles[])
+bool DnDFile::OnDropFiles( wxDropPointCoord, wxDropPointCoord, size_t nFiles,
+                           const wxChar* const aszFiles[])
 {
   wxString str;
-  str.Printf("%d files dropped", nFiles);
+  str.Printf( _T("%d files dropped"), nFiles);
   m_pOwner->Append(str);
   for ( size_t n = 0; n < nFiles; n++ ) {
     m_pOwner->Append(aszFiles[n]);