]> Creatis software - bbtk.git/blob - packages/wx/src/bbwxDropFiles.cxx
CompareImages
[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 // THE MAIN PROCESSING METHOD BODY
47 //   Here we simply set the input 'In' value to the output 'Out'
48 //   And print out the output value
49 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
50 //    void bbSet{Input|Output}NAME(const TYPE&)
51 //    const TYPE& bbGet{Input|Output}NAME() const 
52 //    Where :
53 //    * NAME is the name of the input/output
54 //      (the one provided in the attribute 'name' of the tag 'input')
55 //    * TYPE is the C++ type of the input/output
56 //      (the one provided in the attribute 'type' of the tag 'input')
57
58 //    bbSetOutputOut( bbGetInputIn() );
59 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
60         if (bbGetInputWidget()!=NULL)
61         { 
62                 bbGetInputWidget()->SetDropTarget( new WxDropFiles(this) );
63         }
64     bbSetOutputLstPaths( bbGetInputLstPaths() );
65 }
66
67 //=====
68 // 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)
69 //===== 
70 void DropFiles::bbUserSetDefaultValues()
71 {
72 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
73 //    Here we initialize the input 'In' to 0
74    bbSetInputWidget(NULL);
75 }
76
77 //=====
78 // 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)
79 //===== 
80 void DropFiles::bbUserInitializeProcessing()
81 {
82 //  THE INITIALIZATION METHOD BODY :
83 //    Here does nothing 
84 //    but this is where you should allocate the internal/output pointers 
85 //    if any
86 }
87
88 //=====
89 // 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)
90 //===== 
91 void DropFiles::bbUserFinalizeProcessing()
92 {
93 //  THE FINALIZATION METHOD BODY :
94 //    Here does nothing 
95 //    but this is where you should desallocate the internal/output pointers 
96 //    if any
97 }
98
99 }// EO namespace bbwx
100
101