00001 #ifndef __DRAGANDDROP_H__
00002 #define __DRAGANDDROP_H__
00003
00004 #include "wx/dnd.h"
00005
00006 namespace VRUT
00007 {
00009 class DropTarget: public wxDropTarget
00010 {
00011 public:
00012 bool render;
00014 DropTarget(bool _render=true): render(_render)
00015 {
00016 SetDataObject(new wxFileDataObject);
00017 }
00018
00020 virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def)
00021 {
00022 if ( !GetData() )
00023 return wxDragNone;
00024
00025
00026 if (m_dataObject->IsSupported( wxDF_FILENAME ))
00027 {
00028 std::vector<SCENE_ID> IDlist;
00029 SCENE_ID maxSceneID=0;
00030 if (render)
00031 {
00032 KERNEL->sceneManager->GetSceneIDs(IDlist);
00033 maxSceneID = (IDlist.size()>0)? IDlist.at(IDlist.size()-1)+1: 0;
00034 }
00035 wxArrayString fileNames=((wxFileDataObject *)m_dataObject)->GetFilenames();
00036 for (size_t i=0; i<fileNames.size(); i++)
00037 {
00038 wxCommandEvent ev = Event::GET_EVT_IO_SCENE_IMPORT(fileNames[i]);
00039 KERNEL->GetMessageSink()->PostEvent(ev);
00040 if (render)
00041 {
00042 wxCommandEvent ev1 = Event::GET_EVT_RENDER_SCENE(SCENE_ID(maxSceneID+i));
00043 KERNEL->GetMessageSink()->PostEvent(ev1);
00044 }
00045 }
00046 }
00047 return def;
00048 }
00049 };
00050 }
00051
00052 #endif //__DRAGANDDROP_H__