]> Creatis software - creaImageIO.git/blob - src2/creaImageIOWxGimmickReaderDialog.cpp
bdf1f6687c34e65ccc308f1042d2e6eb7a652c81
[creaImageIO.git] / src2 / creaImageIOWxGimmickReaderDialog.cpp
1 #include <creaImageIOWxGimmickReaderDialog.h>
2 #include <creaImageIOSystem.h>
3 #include <creaImageIOGimmick.h>
4 #ifdef _DEBUG
5 #define new DEBUG_NEW
6 #endif
7
8 #ifdef _RELWITHDEBINFO
9 #define new DEBUG_NEW
10 #endif
11
12 namespace creaImageIO
13 {
14   // CTor
15   WxGimmickReaderDialog::WxGimmickReaderDialog(wxWindow *parent, 
16                                                wxWindowID id,
17                                                const std::string i_namedescp, 
18                                                const std::string i_namedb,
19                                                wxString title,
20                                                const wxPoint& pos,
21                                                const wxSize& size,
22                                                int min_dim,
23                                                int max_dim,
24                                                int output_dim,  // never used ?!? // JPR
25                                                int threads)
26  :   wxDialog( parent, 
27                   id, 
28                   title,
29                   pos,
30                   size,
31                   wxRESIZE_BORDER | 
32                   wxSYSTEM_MENU   |
33                   wxCLOSE_BOX     |
34                   wxMAXIMIZE_BOX  | 
35                   wxMINIMIZE_BOX  | 
36                   wxCAPTION  
37                ),
38  //   mGimmick(0),
39      mView(0)
40   {
41     GimmickDebugMessage(1,"WxGimmickReaderDialog::WxGimmickReaderDialog"
42                         <<std::endl);
43     wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL);
44
45     try {
46
47           mGimmick = boost::shared_ptr<Gimmick>(new Gimmick());
48       mGimmick->Initialize(i_namedescp,i_namedb);
49
50       mView = new WxGimmickView(mGimmick,
51                                 this,
52                                 TVID,
53                                 wxDefaultPosition,
54                                 size,
55                                 min_dim,
56                                 max_dim,
57                                 threads);
58       mView->Initialize();
59            // Connect the AddProgress callback
60       mView->ConnectValidationObserver
61                 ( boost::bind( &WxGimmickReaderDialog::OnValid , this, _1 ) );
62     }
63     catch (crea::Exception e)
64     {
65       e.Print();
66       return;
67     }
68
69     topsizer->Add( mView,1,wxGROW,0);
70
71     wxSizer* bsizer = this->CreateSeparatedButtonSizer(wxOK|wxCANCEL);
72         /*mOkButton = new wxButton(this, wxID_OK, _T("OK"), wxPoint(170,50));
73         mCancelButton = new wxButton(this, wxID_CANCEL, _T("CANCEL"), wxPoint(210,50));
74         */      mOkButton = (wxButton*)FindWindowById(GetAffirmativeId(), this);
75     mCancelButton = (wxButton*)FindWindowById(GetEscapeId(),      this);
76
77     mOkButton->Enable(false);
78
79 topsizer->Add(mOkButton, 0, wxGROW);
80 topsizer->Add(mCancelButton, 0, wxGROW);
81    topsizer->Add ( bsizer, 0, wxGROW );
82
83     SetSizer( topsizer );     
84  
85     Layout(); 
86   }
87
88   /// Destructor
89   WxGimmickReaderDialog::~WxGimmickReaderDialog()
90   {
91     GimmickDebugMessage(1,"WxGimmickReaderDialog::~WxGimmickReaderDialog"
92                         <<std::endl);
93     if (mView) 
94       {
95         delete mView;
96       }
97     if (mGimmick) 
98       {
99                 mGimmick->Finalize();
100       }
101   }
102
103   ///Callback method on a selection
104   void WxGimmickReaderDialog::OnValid(bool t)
105   {
106     mOkButton->Enable(t);
107   }
108
109   //================================================================
110   //BEGIN_EVENT_TABLE(WxGimmickReaderDialog, wxDialog)
111   //END_EVENT_TABLE()
112   //================================================================
113
114 } // EO namespace creaImageIO
115