bbStudio.cxx
Go to the documentation of this file.00001 #ifdef _USE_WXWIDGETS_
00002
00003
00004
00005
00006 #include "bbtkWxGUIScriptingInterface.h"
00007
00008 #include <wx/cmdline.h>
00009 #include <vector>
00010
00011
00012 static const wxCmdLineEntryDesc cmdLineDesc[] =
00013 {
00014 { wxCMD_LINE_PARAM, NULL, NULL, _T("file1 [file2 [...]]"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
00015 { wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("Prints this help") },
00016 { wxCMD_LINE_SWITCH, _T("d"), _T("debug"), _T("Message all 9") },
00017 { wxCMD_LINE_NONE }
00018 };
00019
00020
00021
00022 class wxBBIApp : public wxApp
00023 {
00024 public:
00025 bool OnInit( );
00026 int OnExit() { return true; }
00027 void OnInitCmdLine(wxCmdLineParser& parser);
00028 bool OnCmdLineParsed(wxCmdLineParser& parser);
00029
00030 bool usage;
00031 std::vector<std::string> input_file;
00032 };
00033
00034 IMPLEMENT_APP(wxBBIApp);
00035
00036 void wxBBIApp::OnInitCmdLine(wxCmdLineParser& parser)
00037 {
00038
00039 parser.SetDesc(cmdLineDesc);
00040 }
00041
00042 bool wxBBIApp::OnCmdLineParsed(wxCmdLineParser& parser)
00043 {
00044 int argc = parser.GetParamCount();
00045 for (int i=0; i<argc; ++i)
00046 {
00047 std::string s = bbtk::wx2std(parser.GetParam(i));
00048 input_file.push_back(s);
00049 }
00050
00051 bool help = ( parser.Found(_T("h")) );
00052 usage = (help && (input_file.size()==0));
00053 if (usage) {
00054 std::cout << "bbStudio (The Black Box Development Studio) - bbtk "
00055 << bbtk::GetVersion() << " - (c) Creatis 2007-2008"
00056 << std::endl;
00057 parser.Usage();
00058 }
00059 else
00060 {
00061 if ( parser.Found(_T("d")) )
00062 {
00063 bbtk::MessageManager::SetMessageLevel("all",9);
00064 }
00065 }
00066
00067
00068 return true;
00069 }
00070
00071
00072
00073
00074
00075
00076 bool wxBBIApp::OnInit( )
00077 {
00078
00079 wxApp::OnInit();
00080 #ifdef __WXGTK__
00081
00082 setlocale(LC_NUMERIC, "C");
00083 #endif
00084 if (usage) return false;
00085
00086 bbtk::WxGUIScriptingInterface *I =
00087 new bbtk::WxGUIScriptingInterface(0);
00088 SetTopWindow(I);
00089 I->Show(true);
00090
00091 std::vector<std::string>::const_iterator i;
00092 i=input_file.begin();
00093 if (i!=input_file.end()) I->Open(*i);
00094
00095 return true;
00096 }
00097
00098
00099 #if defined(_WIN32)
00100
00101
00102
00103
00104
00105
00106 int main(int argc, char* argv[])
00107 {
00108 return WinMain(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), SW_SHOWNORMAL);
00109 }
00110
00111 #endif // defined(_WIN32)
00112
00113
00114 #else
00115
00116
00117
00118 #include <iostream>
00119 int main(int argc, char* argv[])
00120 {
00121 std::cout << "bbStudio was not compiled with wxWidgets : ciao !" <<std::endl;
00122 return 0;
00123 }
00124
00125
00126 #endif //#ifdef _USE_WXWIDGETS_
00127
00128
00129