3 //==========================================================================
5 //==========================================================================
6 #include "bbtkWxGUIScriptingInterface.h"
8 #include <wx/cmdline.h>
12 static const wxCmdLineEntryDesc cmdLineDesc[] =
14 { wxCMD_LINE_PARAM, NULL, NULL, _T("file1 [file2 [...]]"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
15 { wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("Prints this help") },
21 class wxBBIApp : public wxApp
25 int OnExit() { return true; }
26 void OnInitCmdLine(wxCmdLineParser& parser);
27 bool OnCmdLineParsed(wxCmdLineParser& parser);
30 std::vector<std::string> input_file;
33 IMPLEMENT_APP(wxBBIApp);
35 void wxBBIApp::OnInitCmdLine(wxCmdLineParser& parser)
37 // std::cout << "OnInitCmdLine"<<std::endl;
38 parser.SetDesc(cmdLineDesc);
41 bool wxBBIApp::OnCmdLineParsed(wxCmdLineParser& parser)
43 int argc = parser.GetParamCount();
44 for (int i=0; i<argc; ++i)
46 std::string s = bbtk::wx2std(parser.GetParam(i));
47 input_file.push_back(s);
50 bool help = ( parser.Found(_T("h")) );
51 usage = (help && (input_file.size()==0));
53 std::cout << "bbStudio (The Black Box Development Studio) - bbtk "
54 << bbtk::GetVersion() << " - (c) Creatis 2007-2008"
64 // ----------------------------------------------------------------------------
65 // The `main program' equivalent, creating the windows and returning the
67 bool wxBBIApp::OnInit( )
69 // std::cout << "OnInit"<<std::endl;
72 //See http://www.wxwindows.org/faqgtk.htm#locale
73 setlocale(LC_NUMERIC, "C");
75 if (usage) return false;
77 bbtk::WxGUIScriptingInterface *I =
78 new bbtk::WxGUIScriptingInterface(0);
82 std::vector<std::string>::const_iterator i;
84 if (i!=input_file.end()) I->Open(*i);
92 // How to have a Console and wxWidgets
93 // http://www.wxwidgets.org/wiki/index.php/MSVC_Setup_Guide
94 // In Visual C++ 6 (7 should be similar), to create an application that is both a console application
95 // (cout's to the console are visible) and has a wxWidgets GUI,
96 // you need to use the linker option "/subsystem:console" and the following code:
97 int main(int argc, char* argv[])
99 return WinMain(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), SW_SHOWNORMAL);
102 #endif // defined(_WIN32)
106 //==========================================================================
108 //==========================================================================
109 int main(int argc, char* argv[])
111 std::cout << "bbStudio was not compiled with wxWidgets : ciao !" <<std::endl;
116 #endif //#ifdef _USE_WXWIDGETS_