]> Creatis software - creaImageIO.git/blob - src2/creaImageIOWxGimmickTools.cpp
*** empty log message ***
[creaImageIO.git] / src2 / creaImageIOWxGimmickTools.cpp
1 #include <creaImageIOWxGimmickTools.h>
2
3 namespace creaImageIO
4 {
5         /**
6         ** Begin of the threshold panel
7         **/
8         WxGimmickTools::WxGimmickTools(wxWindow* parent, wxString mCurrentDirectory)
9         : wxPanel(parent, -1, wxDefaultPosition, wxSize(300,200), wxBORDER_SUNKEN)
10         {
11                 _currentDir = mCurrentDirectory;
12                 _addFiles = true;
13                 
14                 _inputPath = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxSize(150,30));
15                 _outputPath = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxSize(150,30));
16                 _addCheckBox = new wxCheckBox(this, -1, _T("Add Images to Database?") );
17                 _addCheckBox->SetValue(_addFiles);
18
19                 wxButton *inputDir = new wxButton(this,wxID_ANY,_T("Input Directory"), wxDefaultPosition, wxSize(150,30) );
20                 wxButton *outputDir = new wxButton(this,wxID_ANY,_T("Output Directory"), wxDefaultPosition, wxSize(150,30) );
21
22                 
23                 Connect( inputDir->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxGimmickTools::onInputDir ); 
24                 Connect( outputDir->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxGimmickTools::onOutputDir );
25                 Connect( _addCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WxGimmickTools::onAddToDatabase );
26
27                 wxFlexGridSizer * sizer         = new wxFlexGridSizer(2,5);
28                 sizer -> Add( _inputPath, 1, wxGROW, 10 );
29                 sizer -> Add( inputDir, 1, wxGROW, 10 );
30                 sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW, 10 );
31                 sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW, 10 );
32                 sizer -> Add( _outputPath, 1, wxGROW, 10 );
33                 sizer -> Add( outputDir, 1, wxGROW, 10 );
34                 sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW, 10 );
35                 sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW, 10 );
36                 sizer -> Add( _addCheckBox, 1, wxGROW, 10 );
37
38                 this->SetSizer( sizer );
39                 this->SetAutoLayout( true );
40                 this->Layout();
41         }
42
43         WxGimmickTools::~WxGimmickTools(){
44         }
45
46         wxString WxGimmickTools::getInputDir()
47         {
48                 return _inputPath->GetLabel();
49         }
50                 
51         wxString WxGimmickTools::getOutputDir()
52         {
53                 return _outputPath->GetLabel();
54         }
55                 
56         bool WxGimmickTools::getCheckBoxValue()
57         {
58                 return _addCheckBox->GetValue();
59         }
60                 
61         void WxGimmickTools::onInputDir(wxCommandEvent& event)
62         {
63                 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
64                 wxDirDialog* FD = new wxDirDialog( 0, _T("Select the Input Directory"), _currentDir, style);
65             
66                 if (FD->ShowModal()==wxID_OK)
67                 {
68                         _inputPath->SetLabel(FD->GetPath());
69                 }
70         }
71
72         void WxGimmickTools::onOutputDir(wxCommandEvent& event)
73         {
74                 long style = wxDD_DEFAULT_STYLE;
75                 wxDirDialog* FD = new wxDirDialog( 0, _T("Select the Output Directory"), _currentDir, style);
76             
77                 if (FD->ShowModal()==wxID_OK)
78                 {
79                         _outputPath->SetLabel(FD->GetPath());
80                 }
81         }
82
83         void WxGimmickTools::onAddToDatabase(wxCommandEvent& event)
84         {
85                 _addFiles = _addCheckBox->GetValue();
86         }
87
88 } // EO namespace creaImageIO
89
90