2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 #ifdef _USE_WXWIDGETS_
30 //==========================================================================
32 //==========================================================================
33 #include "bbtkWxGUIScriptingInterface.h"
35 #include <wx/cmdline.h>
39 static const wxCmdLineEntryDesc cmdLineDesc[] =
41 { wxCMD_LINE_PARAM, NULL, NULL, _T("file1 [file2 [...]]"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
42 { wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("Prints this help") },
43 { wxCMD_LINE_SWITCH, _T("d"), _T("debug"), _T("Message all 9") },
49 class wxBBIApp : public wxApp
53 int OnExit() { return true; }
54 void OnInitCmdLine(wxCmdLineParser& parser);
55 bool OnCmdLineParsed(wxCmdLineParser& parser);
58 std::vector<std::string> input_file;
61 IMPLEMENT_APP(wxBBIApp);
63 void wxBBIApp::OnInitCmdLine(wxCmdLineParser& parser)
65 // std::cout << "OnInitCmdLine"<<std::endl;
66 parser.SetDesc(cmdLineDesc);
69 bool wxBBIApp::OnCmdLineParsed(wxCmdLineParser& parser)
71 int argc = parser.GetParamCount();
72 for (int i=0; i<argc; ++i)
74 std::string s = bbtk::wx2std(parser.GetParam(i));
75 input_file.push_back(s);
78 bool help = ( parser.Found(_T("h")) );
79 usage = (help && (input_file.size()==0));
81 std::cout << "bbStudio (The Black Box Development Studio) - bbtk "
82 << bbtk::GetVersion() << " - (c) Creatis 2007-2008"
88 if ( parser.Found(_T("d")) )
90 bbtk::MessageManager::SetMessageLevel("all",9);
100 // ----------------------------------------------------------------------------
101 // The `main program' equivalent, creating the windows and returning the
103 bool wxBBIApp::OnInit( )
105 // std::cout << "OnInit"<<std::endl;
108 //See http://www.wxwindows.org/faqgtk.htm#locale
109 setlocale(LC_NUMERIC, "C");
111 if (usage) return false;
113 bbtk::WxGUIScriptingInterface *I =
114 new bbtk::WxGUIScriptingInterface(0);
118 std::vector<std::string>::const_iterator i;
119 i=input_file.begin();
120 if (i!=input_file.end()) I->Open(*i);
128 // How to have a Console and wxWidgets
129 // http://www.wxwidgets.org/wiki/index.php/MSVC_Setup_Guide
130 // In Visual C++ 6 (7 should be similar), to create an application that is both a console application
131 // (cout's to the console are visible) and has a wxWidgets GUI,
132 // you need to use the linker option "/subsystem:console" and the following code:
133 int main(int argc, char* argv[])
135 return WinMain(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), SW_SHOWNORMAL);
138 #endif // defined(_WIN32)
142 //==========================================================================
144 //==========================================================================
146 int main(int argc, char* argv[])
148 std::cout << "bbStudio was not compiled with wxWidgets : ciao !" <<std::endl;
153 #endif //#ifdef _USE_WXWIDGETS_