2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
8 # This software is governed by the CeCILL-B license under French law and
9 # abiding by the rules of distribution of free software. You can use,
10 # modify and/ or redistribute the software under the terms of the CeCILL-B
11 # license as circulated by CEA, CNRS and INRIA at the following URL
12 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
13 # or in the file LICENSE.txt.
15 # As a counterpart to the access to the source code and rights to copy,
16 # modify and redistribute granted by the license, users are provided only
17 # with a limited warranty and the software's author, the holder of the
18 # economic rights, and the successive licensors have only limited
21 # The fact that you are presently reading this means that you have had
22 # knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------
26 #ifdef _USE_WXWIDGETS_
28 //==========================================================================
30 //==========================================================================
32 #include "bbtkwxGUIEditorGraphicBBS.h"
34 #include <wx/cmdline.h>
36 #include <wx/sysopt.h>
39 #include "vtkOutputWindow.h"
41 class vtkOutputWindowbbGEditor : public vtkOutputWindow
44 vtkOutputWindowbbGEditor() {}
45 static vtkOutputWindowbbGEditor* New() { return new vtkOutputWindowbbGEditor;}
46 virtual void DisplayDebugText (const char *) {}
47 virtual void DisplayText (const char *) {}
48 virtual void DisplayErrorText (const char *) {}
49 virtual void DisplayWarningText (const char *) {}
50 virtual void DisplayGenericWarningText (const char *) {}
58 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
59 #if wxMAJOR_VERSION <= 2
60 static const wxCmdLineEntryDesc cmdLineDesc[] =
62 { wxCMD_LINE_PARAM, NULL, NULL, _T("file"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
63 { wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("Prints this help") },
64 //{ wxCMD_LINE_SWITCH, _T("d"), _T("debug"), _T("Message all 9") },
68 static const wxCmdLineEntryDesc cmdLineDesc[] =
70 { wxCMD_LINE_PARAM, NULL, NULL, "file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
71 { wxCMD_LINE_SWITCH, "h", "help", "Prints this help" },
72 //{ wxCMD_LINE_SWITCH, _T("d"), _T("debug"), _T("Message all 9") },
80 class wxBBEditorApp : public wxApp
84 int OnExit() { return true; }
87 bool OnCmdLineParsed(wxCmdLineParser& parser);
88 void OnInitCmdLine(wxCmdLineParser& parser);
90 std::vector<std::string> input_file;
94 IMPLEMENT_APP(wxBBEditorApp);
98 void wxBBEditorApp::OnInitCmdLine(wxCmdLineParser& parser)
100 // std::cout << "wxBBEditorApp::OnInitCmdLine"<<std::endl;
101 parser.SetDesc(cmdLineDesc);
105 bool wxBBEditorApp::OnCmdLineParsed(wxCmdLineParser& parser)
107 int argc = parser.GetParamCount();
108 for (int i=0; i<argc; ++i)
110 std::string s = bbtk::wx2std(parser.GetParam(i));
111 input_file.push_back(s);
114 bool help = ( parser.Found(_T("h")) );
115 usage = (help && (input_file.size()==0));
117 std::cout << "bbEditor (The Black Box Development Graphic Editor) - bbtk "
118 << bbtk::GetVersion() << " - (c) Creatis 2013"
128 // ----------------------------------------------------------------------------
129 // The `main program' equivalent, creating the windows and returning the
131 bool wxBBEditorApp::OnInit( )
134 vtkOutputWindowbbGEditor *vtkoutputwindowbbgeditor= vtkOutputWindowbbGEditor::New();
135 vtkOutputWindow::SetInstance( vtkoutputwindowbbgeditor );
136 vtkoutputwindowbbgeditor->Delete();
140 /* assume this is OSX */
141 wxSystemOptions::SetOption("mac.listctrl.always_use_generic", 1);
146 //See http://www.wxwindows.org/faqgtk.htm#locale
147 setlocale(LC_NUMERIC, "C");
150 bbtk::wxGUIEditorGraphicBBS *iegbbs;
151 iegbbs = new bbtk::wxGUIEditorGraphicBBS(NULL);
152 SetTopWindow(iegbbs);
157 // 1. This block have to be mooved to the library
158 // 2. We have to verifiy if the file is a good bbg or a good bbs
159 // 3. Clean the path to pout just the name of the file in the second parameter (information of the tabPanel)
160 // OpenDiagram(<PATH+Filename>, <Filena>);
161 for(int i=0;i<input_file.size();i++)
163 int strsize=input_file[i].size()-1;
164 if ((input_file[i])[strsize]=='g')
166 iegbbs->OpenDiagram(input_file[i], input_file[i]);
168 if ((input_file[i])[strsize]=='s')
170 iegbbs->OpenBBS(input_file[i], input_file[i]);
181 // How to have a Console and wxWidgets
182 // http://www.wxwidgets.org/wiki/index.php/MSVC_Setup_Guide
183 // In Visual C++ 6 (7 should be similar), to create an application that is both a console application
184 // (cout's to the console are visible) and has a wxWidgets GUI,
185 // you need to use the linker option "/subsystem:console" and the following code:
186 int main(int argc, char* argv[])
188 return WinMain(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), SW_SHOWNORMAL);
191 #endif // defined(_WIN32)
195 //==========================================================================
197 //==========================================================================
199 int main(int argc, char* argv[])
201 std::cout << "bbStudio was not compiled with wxWidgets : ciao !" <<std::endl;
206 #endif //#ifdef _USE_WXWIDGETS_