#ifdef _USE_WXWIDGETS_ //========================================================================== // WITH WX //========================================================================== #include "bbtkInterpreter.h" #include "bbtkWxBlackBox.h" #include "bbtkWxGUIConsole.h" #include #include #include static const wxCmdLineEntryDesc cmdLineDesc[] = { { wxCMD_LINE_SWITCH, _T("d"), _T("debug"), _T("Debug messages on (message All 9)") }, { wxCMD_LINE_SWITCH, _T("c"), _T("command"), _T("turn to command line mode after file(s) processing") }, { wxCMD_LINE_SWITCH, _T("q"), _T("quiet"), _T("be quiet") }, { wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("print help") }, { wxCMD_LINE_SWITCH, _T("g"), _T("graphical-dialog"), _T("prompts the user for the parameters values using dialog boxes") }, { wxCMD_LINE_SWITCH, _T("t"), _T("text-dialog"), _T("prompts the user for the parameters values in text mode") }, { wxCMD_LINE_SWITCH, _T("n"), _T("no-command"), _T("do not show command window except on error") }, { wxCMD_LINE_SWITCH, _T("N"), _T("no-command-at-all"), _T("do not show command window even on error") }, { wxCMD_LINE_PARAM, NULL, NULL, _T("input_file"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE }, { wxCMD_LINE_NONE } }; class wxBBIApp : public wxApp { public: bool OnInit( ); int OnExit() { // std::cout << "wxBBIApp::OnExit()"< argv; bool command; bool debug; bool quiet; bool help; bool graphical_dialog; bool text_dialog; bool no_command; bool no_command_at_all; std::map param_map; std::vector input_file; }; IMPLEMENT_APP(wxBBIApp); void wxBBIApp::OnInitCmdLine(wxCmdLineParser& parser) { // std::cout << "OnInitCmdLine"<Show(true); I->SetInputs(param_map); bool help_on_script = help && (input_file.size() > 0); if (help_on_script) I->SetNoExecMode(true); if (graphical_dialog) I->SetDialogMode(bbtk::Executer::GraphicalDialog); if (text_dialog) I->SetDialogMode(bbtk::Executer::TextDialog); std::vector::const_iterator i; bool error = false; for (i=input_file.begin(); i!=input_file.end(); ++i) { error = ! I->InterpretFile(*i); if (error) break; } bool show_on_error = error && ! no_command_at_all; if (show_on_error) I->Show(); I->SetNoExecMode(false); if (help_on_script) { std::string package; I->GetInterpreter()->GetExecuter()->GetFactory()->HelpBlackBox("workspace",package,false); } if (!(show_on_error || command || bbtk::Wx::IsSomeWindowShown() )) { I->Close(); } return true; } #if defined(_WIN32) // How to have a Console and wxWidgets // http://www.wxwidgets.org/wiki/index.php/MSVC_Setup_Guide // In Visual C++ 6 (7 should be similar), to create an application that is both a console application // (cout's to the console are visible) and has a wxWidgets GUI, // you need to use the linker option "/subsystem:console" and the following code: int main(int argc, char* argv[]) { return WinMain(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), SW_SHOWNORMAL); } #endif // defined(_WIN32) #else //========================================================================== // WITHOUT WX //========================================================================== #include "bbtkInterpreter.h" int main(int argc, char* argv[]) { if (argc>2) return 0; std::cout << "BBI (Black Box Interpreter) - bbtk " << bbtk::GetVersion()<< " - (c) Creatis 2007" <