comparison include/dndfile.h @ 6:9c85d71cad7c

implement drag&drop.
author pyon@macmini
date Tue, 18 Oct 2011 22:43:46 +0900
parents 52697c869ce8
children dfa5cae8c992
comparison
equal deleted inserted replaced
5:52697c869ce8 6:9c85d71cad7c
1 #include "wx/wxprec.h" 1 // Filename : param.cpp
2 2 // Last Change: 18-Oct-2011.
3 #ifndef WX_PRECOMP 3 //
4 #include "wx/wx.h"
5 #include "wx/arrstr.h"
6 #include "wx/textctrl.h"
7 #include "wx/dnd.h"
8 #endif
9 4
10 class DnDFile : public wxFileDropTarget 5 class DnDFile : public wxFileDropTarget
11 { 6 {
12 public: 7 public:
13 DnDFile( wxTextCtrl *owner ) { m_owner = owner; } 8 DnDFile( wxDirPickerCtrl *dir )
14 virtual bool OnDropFiles( wxCoord x, wxCoord y, const wxArrayString& finenames )
15 { 9 {
16 m_owner->SetValue( finenames[0] ); 10 m_workdir = dir->GetPath();
11 }
12 virtual bool OnDropFiles( wxCoord x, wxCoord y, const wxArrayString& filenames )
13 {
14 size_t nFiles = filenames.GetCount();
15 for ( size_t n=0; n<nFiles; n++ ) {
16 wxFileName filename( filenames[n] );
17 wxString from = filenames[n];
18 wxString to = m_workdir + wxFILE_SEP_PATH + filename.GetFullName();
19 wxRenameFile( from, to, true );
20 //wxMessageBox( wxT("move ") + filenames[n] + to );
21 }
17 return true; 22 return true;
18 } 23 }
19 24
20 private: 25 private:
21 wxTextCtrl *m_owner; 26 wxString m_workdir;
22 }; 27 };
23 28