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>
38 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
39 #if wxMAJOR_VERSION <= 2
40 static const wxCmdLineEntryDesc cmdLineDesc[] =
42 { wxCMD_LINE_PARAM, NULL, NULL, _T("file1 [file2 [...]]"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
43 { wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("Prints this help") },
44 { wxCMD_LINE_SWITCH, _T("d"), _T("debug"), _T("Message all 9") },
48 static const wxCmdLineEntryDesc cmdLineDesc[] =
50 { wxCMD_LINE_PARAM, NULL, NULL, "file1 [file2 [...]]", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
51 { wxCMD_LINE_SWITCH, "h", "help", "Prints this help" },
52 { wxCMD_LINE_SWITCH, "d", "debug", "Message all 9" },
60 class wxBBIApp : public wxApp
64 int OnExit() { return true; }
65 void OnInitCmdLine(wxCmdLineParser& parser);
66 bool OnCmdLineParsed(wxCmdLineParser& parser);
69 std::vector<std::string> input_file;
72 IMPLEMENT_APP(wxBBIApp);
74 void wxBBIApp::OnInitCmdLine(wxCmdLineParser& parser)
76 // std::cout << "OnInitCmdLine"<<std::endl;
77 parser.SetDesc(cmdLineDesc);
80 bool wxBBIApp::OnCmdLineParsed(wxCmdLineParser& parser)
82 int argc = parser.GetParamCount();
83 for (int i=0; i<argc; ++i)
85 std::string s = bbtk::wx2std(parser.GetParam(i));
86 input_file.push_back(s);
89 bool help = ( parser.Found(_T("h")) );
90 usage = (help && (input_file.size()==0));
92 std::cout << "bbStudio (The Black Box Development Studio) - bbtk "
93 << bbtk::GetVersion() << " - (c) Creatis 2007-2008"
99 if ( parser.Found(_T("d")) )
101 bbtk::MessageManager::SetMessageLevel("all",9);
111 // ----------------------------------------------------------------------------
112 // The `main program' equivalent, creating the windows and returning the
114 bool wxBBIApp::OnInit( )
116 // std::cout << "OnInit"<<std::endl;
119 //See http://www.wxwindows.org/faqgtk.htm#locale
120 setlocale(LC_NUMERIC, "C");
122 if (usage) return false;
124 bbtk::WxGUIScriptingInterface *I =
125 new bbtk::WxGUIScriptingInterface(0);
129 std::vector<std::string>::const_iterator i;
130 i=input_file.begin();
131 if (i!=input_file.end()) I->Open(*i);
139 // How to have a Console and wxWidgets
140 // http://www.wxwidgets.org/wiki/index.php/MSVC_Setup_Guide
141 // In Visual C++ 6 (7 should be similar), to create an application that is both a console application
142 // (cout's to the console are visible) and has a wxWidgets GUI,
143 // you need to use the linker option "/subsystem:console" and the following code:
144 int main(int argc, char* argv[])
148 wcstombs(buffer , ::GetCommandLine() , 1500 );
149 return WinMain(::GetModuleHandle(NULL), NULL, buffer , SW_SHOWNORMAL);
150 // return WinMain(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), SW_SHOWNORMAL);
153 #endif // defined(_WIN32)
157 //==========================================================================
159 //==========================================================================
161 int main(int argc, char* argv[])
163 std::cout << "bbStudio was not compiled with wxWidgets : ciao !" <<std::endl;
168 #endif //#ifdef _USE_WXWIDGETS_