creaImageIOWxGimmickReaderDialog.cpp

Go to the documentation of this file.
00001 #include <creaImageIOWxGimmickReaderDialog.h>
00002 #include <creaImageIOSystem.h>
00003 #include <creaImageIOGimmick.h>
00004 #ifdef _DEBUG
00005 #define new DEBUG_NEW
00006 #endif
00007 namespace creaImageIO
00008 {
00009   // CTor
00010   WxGimmickReaderDialog::WxGimmickReaderDialog(wxWindow *parent, 
00011                                                wxWindowID id,
00012                                                const std::string i_namedescp, 
00013                                                const std::string i_namedb,
00014                                                wxString title,
00015                                                const wxPoint& pos,
00016                                                const wxSize& size,
00017                                                int min_dim,
00018                                                int max_dim,
00019                                                int output_dim,  // never used ?!? // JPR
00020                                                int threads)
00021  :   wxDialog( parent, 
00022                   id, 
00023                   title,
00024                   pos,
00025                   size,
00026                   wxRESIZE_BORDER | 
00027                   wxSYSTEM_MENU   |
00028                   wxCLOSE_BOX     |
00029                   wxMAXIMIZE_BOX  | 
00030                   wxMINIMIZE_BOX  | 
00031                   wxCAPTION  
00032                ),
00033  //   mGimmick(0),
00034      mView(0)
00035   {
00036     GimmickDebugMessage(1,"WxGimmickReaderDialog::WxGimmickReaderDialog"
00037                         <<std::endl);
00038     mtopsizer = new wxBoxSizer(wxVERTICAL);
00039 
00040     try {
00041 
00042           mGimmick = boost::shared_ptr<Gimmick>(new Gimmick());
00043       mGimmick->Initialize(i_namedescp,i_namedb);
00044 
00045       mView = new WxGimmickView(mGimmick,
00046                                 this,
00047                                 TVID,
00048                                 wxDefaultPosition,
00049                                 size,
00050                                 min_dim,
00051                                 max_dim,
00052                                 threads);
00053       mView->Initialize();
00054            // Connect the AddProgress callback
00055       mView->ConnectValidationObserver
00056                 ( boost::bind( &WxGimmickReaderDialog::OnValid , this, _1 ) );
00057     }
00058     catch (crea::Exception e)
00059     {
00060       e.Print();
00061       return;
00062     }
00063 
00064     mtopsizer->Add( mView,1,wxGROW,0);
00065 
00066     wxSizer* bsizer = this->CreateSeparatedButtonSizer(wxOK|wxCANCEL);
00067         /*mOkButton = new wxButton(this, wxID_OK, _T("OK"), wxPoint(170,50));
00068         mCancelButton = new wxButton(this, wxID_CANCEL, _T("CANCEL"), wxPoint(210,50));
00069         */      mOkButton = (wxButton*)FindWindowById(GetAffirmativeId(), this);
00070     mCancelButton = (wxButton*)FindWindowById(GetEscapeId(),      this);
00071 
00072     mOkButton->Enable(false);
00073     mtopsizer->Add ( bsizer, 0, wxGROW );
00074 
00075     SetSizer( mtopsizer );     
00076  
00077     Layout(); 
00078   }
00079 
00081   WxGimmickReaderDialog::~WxGimmickReaderDialog()
00082   {
00083     GimmickDebugMessage(1,"WxGimmickReaderDialog::~WxGimmickReaderDialog"
00084                         <<std::endl);
00085     if (mView) 
00086       {
00087         delete mView;
00088       }
00089     if (mGimmick) 
00090       {
00091                 mGimmick->Finalize();
00092       }
00093 
00094   }
00095 
00097   void WxGimmickReaderDialog::OnValid(bool t)
00098   {
00099     mOkButton->Enable(t);
00100   }
00101 
00102   //================================================================
00103   //BEGIN_EVENT_TABLE(WxGimmickReaderDialog, wxDialog)
00104   //END_EVENT_TABLE()
00105   //================================================================
00106 
00107 } // EO namespace creaImageIO
00108