]> Creatis software - creaImageIO.git/blob - appli/TestWxGimmickDialog/main.cxx
Initial revision
[creaImageIO.git] / appli / TestWxGimmickDialog / main.cxx
1 #include <creaImageIOSystem.h>
2 #include <creaWx.h>
3 #include <creaImageIOWxGimmickDialog.h>
4
5 class myApp : public wxApp
6 {
7 public:
8   bool OnInit( );
9   int  OnExit() { return true; }
10 };
11
12 IMPLEMENT_APP(myApp);
13
14 #if defined(_WIN32) 
15
16 //  How to have a Console and wxWidgets
17 //  http://www.wxwidgets.org/wiki/index.php/MSVC_Setup_Guide
18 //   In Visual C++ 6 (7 should be similar), to create an application that is both a console application 
19 //  (cout's to the console are visible) and has a wxWidgets GUI, 
20 //  you need to use the linker option "/subsystem:console" and the following code:
21 int main(int argc, char* argv[])
22 {
23         return WinMain(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), SW_SHOWNORMAL);
24 }
25
26 #endif // defined(_WIN32) 
27
28
29 bool myApp::OnInit( )
30 {        
31   wxApp::OnInit();
32 #ifdef __WXGTK__
33   //See http://www.wxwindows.org/faqgtk.htm#locale
34   setlocale(LC_NUMERIC, "C");
35 #endif
36    wxInitAllImageHandlers();
37
38    int threads = 1;
39
40    creaImageIO::WxGimmickDialog w(0,
41                            -1,
42                            _T("WxGimmickDialog test"),
43                            wxDefaultPosition,
44                            wxSize(1200,800),
45                            threads);
46    w.ShowModal();
47    
48    if (w.GetReturnCode() == wxID_OK)
49      {
50        std::cout << "$$$$ main : user clicked 'OK' $$$$"<<std::endl;
51        std::cout << "$$$$ selected files : "<<std::endl;
52        std::vector<std::string> s;
53        w.GetSelectedImages(s);
54        std::vector<std::string>::iterator i;
55        for (i=s.begin();i!=s.end();++i) 
56          {
57            std::cout << *i << std::endl;
58          }
59        std::cout << "$$$$ "<<std::endl;
60      }
61    else if (w.GetReturnCode() == wxID_CANCEL)
62      {
63        std::cout << "$$$$ main : user clicked 'CANCEL' $$$$"<<std::endl;
64      }
65    else 
66      {
67         std::cout << "$$$$ main : dialog ended without return code ! $$$$"
68                   <<std::endl;
69       
70      }
71
72    //   std::cout << "$$$$ main : deleting dialog"<<std::endl;
73    //   delete w;
74    std::cout << "$$$$$$$$$$$$$$$$$$$$ main ended "<<std::endl;
75    return false;
76 }
77
78