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") },
16 { wxCMD_LINE_SWITCH, _T("d"), _T("debug"), _T("Message all 9") },
22 class wxBBIApp : public wxApp
26 int OnExit() { return true; }
27 void OnInitCmdLine(wxCmdLineParser& parser);
28 bool OnCmdLineParsed(wxCmdLineParser& parser);
31 std::vector<std::string> input_file;
34 IMPLEMENT_APP(wxBBIApp);
36 void wxBBIApp::OnInitCmdLine(wxCmdLineParser& parser)
38 // std::cout << "OnInitCmdLine"<<std::endl;
39 parser.SetDesc(cmdLineDesc);
42 bool wxBBIApp::OnCmdLineParsed(wxCmdLineParser& parser)
44 int argc = parser.GetParamCount();
45 for (int i=0; i<argc; ++i)
47 std::string s = bbtk::wx2std(parser.GetParam(i));
48 input_file.push_back(s);
51 bool help = ( parser.Found(_T("h")) );
52 usage = (help && (input_file.size()==0));
54 std::cout << "bbStudio (The Black Box Development Studio) - bbtk "
55 << bbtk::GetVersion() << " - (c) Creatis 2007-2008"
61 if ( parser.Found(_T("d")) )
63 bbtk::MessageManager::SetMessageLevel("all",9);
73 // ----------------------------------------------------------------------------
74 // The `main program' equivalent, creating the windows and returning the
76 bool wxBBIApp::OnInit( )
78 // std::cout << "OnInit"<<std::endl;
81 //See http://www.wxwindows.org/faqgtk.htm#locale
82 setlocale(LC_NUMERIC, "C");
84 if (usage) return false;
86 bbtk::WxGUIScriptingInterface *I =
87 new bbtk::WxGUIScriptingInterface(0);
91 std::vector<std::string>::const_iterator i;
93 if (i!=input_file.end()) I->Open(*i);
101 // How to have a Console and wxWidgets
102 // http://www.wxwidgets.org/wiki/index.php/MSVC_Setup_Guide
103 // In Visual C++ 6 (7 should be similar), to create an application that is both a console application
104 // (cout's to the console are visible) and has a wxWidgets GUI,
105 // you need to use the linker option "/subsystem:console" and the following code:
106 int main(int argc, char* argv[])
108 return WinMain(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), SW_SHOWNORMAL);
111 #endif // defined(_WIN32)
115 //==========================================================================
117 //==========================================================================
119 int main(int argc, char* argv[])
121 std::cout << "bbStudio was not compiled with wxWidgets : ciao !" <<std::endl;
126 #endif //#ifdef _USE_WXWIDGETS_