]> Creatis software - bbtk.git/blob - packages/wx/src/bbwxDropFiles.cxx
#2924 BBTK Feature New Normal - DropFiles box package wx #2804 BBTK Featur...
[bbtk.git] / packages / wx / src / bbwxDropFiles.cxx
1 //===== 
2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
3 //===== 
4 #include "bbwxDropFiles.h"
5 #include "bbwxPackage.h"
6
7 #include "bbtkWx.h"
8 #include <wx/dnd.h>
9
10 namespace bbwx
11 {
12
13
14 class WxDropFiles: public wxFileDropTarget
15 {
16 public:
17         WxDropFiles(DropFiles *box): mbox(box){}
18     bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& arrFilenames);
19 private:
20         DropFiles *mbox;
21 };
22
23 bool WxDropFiles::OnDropFiles(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxArrayString& arrFilenames)
24 {
25         std::vector<std::string> tmpLst;
26         int i,sizeArrFilenames=arrFilenames.GetCount();
27         for( i=0 ; i<sizeArrFilenames ; i++ )
28         {
29                 std::string ss=bbtk::wx2std( arrFilenames.Item(i) );
30                 tmpLst.push_back( bbtk::wx2std( arrFilenames.Item(i) )  );
31         }
32
33         mbox->bbSetOutputLstPaths( tmpLst );
34         mbox->bbSignalOutputModification(  );
35     return true;
36 }
37
38
39 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,DropFiles)
40 BBTK_BLACK_BOX_IMPLEMENTATION(DropFiles,bbtk::AtomicBlackBox);
41 //===== 
42 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
43 //===== 
44 void DropFiles::Process()
45 {
46
47 // THE MAIN PROCESSING METHOD BODY
48 //   Here we simply set the input 'In' value to the output 'Out'
49 //   And print out the output value
50 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
51 //    void bbSet{Input|Output}NAME(const TYPE&)
52 //    const TYPE& bbGet{Input|Output}NAME() const 
53 //    Where :
54 //    * NAME is the name of the input/output
55 //      (the one provided in the attribute 'name' of the tag 'input')
56 //    * TYPE is the C++ type of the input/output
57 //      (the one provided in the attribute 'type' of the tag 'input')
58
59 //    bbSetOutputOut( bbGetInputIn() );
60 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
61
62         if (bbGetInputWidget()!=NULL)
63         { 
64                 bbGetInputWidget()->SetDropTarget( new WxDropFiles(this) );
65         }
66   
67 }
68 //===== 
69 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
70 //===== 
71 void DropFiles::bbUserSetDefaultValues()
72 {
73
74 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
75 //    Here we initialize the input 'In' to 0
76    bbSetInputWidget(NULL);
77   
78 }
79 //===== 
80 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
81 //===== 
82 void DropFiles::bbUserInitializeProcessing()
83 {
84
85 //  THE INITIALIZATION METHOD BODY :
86 //    Here does nothing 
87 //    but this is where you should allocate the internal/output pointers 
88 //    if any 
89
90   
91 }
92 //===== 
93 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
94 //===== 
95 void DropFiles::bbUserFinalizeProcessing()
96 {
97
98 //  THE FINALIZATION METHOD BODY :
99 //    Here does nothing 
100 //    but this is where you should desallocate the internal/output pointers 
101 //    if any
102   
103 }
104 }
105 // EO namespace bbwx
106
107