#ifdef _USE_WXWIDGETS_ //========================================================================== // WITH WX //========================================================================== #include "bbtkInterpreter.h" #include "bbtkWxBlackBox.h" #include "bbtkWxGUIConsole.h" #include #include #include #include "EXEC_FUNCTION.h" static const wxCmdLineEntryDesc cmdLineDesc[] = { { wxCMD_LINE_SWITCH, _T("d"), _T("debug"), _T("Debug messages on (message All 9)") }, { 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_PARAM, NULL, NULL, _T("Input=Value"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE }, { wxCMD_LINE_NONE } }; class wxBBIApp : public wxApp { public: bool OnInit( ); int OnExit() { delete mExecuter; return true; } void OnInitCmdLine(wxCmdLineParser& parser); bool OnCmdLineParsed(wxCmdLineParser& parser); void Run(bbtk::Interpreter*); bbtk::Executer::Pointer mExecuter; // int argc; // std::vector argv; bool command; bool debug; bool quiet; bool help; bool graphical_dialog; bool text_dialog; std::map param_map; }; IMPLEMENT_APP(wxBBIApp); void wxBBIApp::OnInitCmdLine(wxCmdLineParser& parser) { parser.SetDesc(cmdLineDesc); } bool wxBBIApp::OnCmdLineParsed(wxCmdLineParser& parser) { debug = ( parser.Found(_T("d")) ); quiet = ( parser.Found(_T("q")) ); help = ( parser.Found(_T("h")) ); graphical_dialog = ( parser.Found(_T("g")) ); text_dialog = ( parser.Found(_T("t")) ); // parse the arguments and consider those which contain a "=" // as set input commands int argc = parser.GetParamCount(); for (int i=0; iSetInputs(param_map); if (help) mExecuter->SetNoExecMode(true); if (graphical_dialog) mExecuter->SetDialogMode(bbtk::VirtualExec::GraphicalDialog); if (text_dialog) mExecuter->SetDialogMode(bbtk::VirtualExec::TextDialog); EXEC_FUNCTION(mExecuter); mExecuter->SetNoExecMode(false); if (help) { std::string package; mExecuter->GetFactory()->HelpBlackBox("workspace",package,false); } } catch (bbtk::Exception e) { wxString mess; mess += bbtk::std2wx ( e.GetMessage() ); wxMessageBox(mess,_T("Error"),wxOK | wxICON_ERROR); bbtk::Wx::GetTopWindow()->Close(); return false; } if (help || !bbtk::Wx::IsSomeWindowAlive()) { return false; } 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" <