]> Creatis software - bbtk.git/blob - packages/wx/src/bbwxFileSelector.cxx
=== MAJOR RELEASE ====
[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/04/18 12:59:52 $
7   Version:   $Revision: 1.2 $
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
30 #include <wx/filedlg.h>
31
32
33 namespace bbwx
34 {
35
36   BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,FileSelector);
37   
38
39   BBTK_BLACK_BOX_IMPLEMENTATION(FileSelector,bbtk::AtomicBlackBox);
40
41
42   void FileSelector::Process() 
43   { 
44     bbtkDebugMessageInc("Core",9,"FileSelector::Process() ["
45                         <<bbGetFullName()<<"]"<<std::endl);
46
47     long style;
48     if (bbGetInputOpenSave()=="Save") 
49       {
50         style = wxSAVE | wxOVERWRITE_PROMPT;
51       }
52     else 
53       {
54         style = wxOPEN | wxFILE_MUST_EXIST;
55       }
56     
57     std::string wc(bbGetInputWildcard());
58     if (wc=="") 
59       {
60         wc = "*.*";
61       }
62     
63     
64     wxFileDialog* FD = new wxFileDialog( 0, 
65                                          bbtk::std2wx(bbGetInputMessage()),
66                                          bbtk::std2wx(bbGetInputDefaultDir()),
67                                          bbtk::std2wx(bbGetInputDefaultFile()),
68                                          bbtk::std2wx(wc),
69                                          style,
70                                          wxDefaultPosition);
71
72     FD->ShowModal();
73     
74     if (FD->GetReturnCode()==wxID_OK)
75       {
76         bbSetOutputOut( bbtk::wx2std (FD->GetPath()) );
77       }
78     else
79       { 
80         bbSetOutputOut("");
81       }
82     
83     bbtkDebugDecTab("Core",9); 
84   }
85   
86
87
88 }//namespace bbtk
89
90 #endif // _USE_WXWIDGETS_ 
91