]> Creatis software - bbtk.git/blob - packages/wx/src/bbwxFileSelector.cxx
*** empty log message ***
[bbtk.git] / packages / wx / src / bbwxFileSelector.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbwxFileSelector.cxx,v $
5   Language:  C++
6   Date:      $Date: 2008/07/24 14:37:06 $
7   Version:   $Revision: 1.4 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18 /**
19  *  \file 
20  *  \brief 
21  */
22
23
24 #ifdef _USE_WXWIDGETS_
25
26
27 #include "bbwxFileSelector.h"
28 #include "bbwxPackage.h"
29 #include "bbtkWx.h"
30
31 #include <wx/filedlg.h>
32
33
34 namespace bbwx
35 {
36
37   BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,FileSelector);
38   
39
40   BBTK_BLACK_BOX_IMPLEMENTATION(FileSelector,bbtk::AtomicBlackBox);
41
42
43   void FileSelector::Process() 
44   { 
45     bbtkDebugMessageInc("Core",9,"FileSelector::Process() ["
46                         <<bbGetFullName()<<"]"<<std::endl);
47
48     long style;
49     if (bbGetInputOpenSave()=="Save") 
50       {
51         style = wxSAVE | wxOVERWRITE_PROMPT;
52       }
53     else 
54       {
55         style = wxOPEN | wxFILE_MUST_EXIST;
56       }
57     
58     std::string wc(bbGetInputWildcard());
59     if (wc=="") 
60       {
61         wc = "*.*";
62       }
63     
64     
65     wxFileDialog* FD = new wxFileDialog( 0, 
66                                          bbtk::std2wx(bbGetInputMessage()),
67                                          bbtk::std2wx(bbGetInputDefaultDir()),
68                                          bbtk::std2wx(bbGetInputDefaultFile()),
69                                          bbtk::std2wx(wc),
70                                          style,
71                                          wxDefaultPosition);
72 //EED
73
74     int result_FD = FD->ShowModal();
75
76         // This line is need it by windows //EED
77         FD->SetReturnCode( result_FD );
78
79     if (FD->GetReturnCode()==wxID_OK)
80       {
81         bbSetOutputOut( bbtk::wx2std (FD->GetPath()) );
82       }
83     else
84       { 
85         bbSetOutputOut("");
86       }
87     
88     bbtkDebugDecTab("Core",9); 
89   }
90   
91
92   void FileSelector::bbUserConstructor()
93   {
94           bbSetInputOpenSave("Open");
95   }
96         
97
98
99 }//namespace bbtk
100
101 #endif // _USE_WXWIDGETS_ 
102