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_NONE }
00017 };
00018
00019
00020
00021 class wxBBIApp : public wxApp
00022 {
00023 public:
00024 bool OnInit( );
00025 int OnExit() { return true; }
00026 void OnInitCmdLine(wxCmdLineParser& parser);
00027 bool OnCmdLineParsed(wxCmdLineParser& parser);
00028
00029 bool usage;
00030 std::vector<std::string> input_file;
00031 };
00032
00033 IMPLEMENT_APP(wxBBIApp);
00034
00035 void wxBBIApp::OnInitCmdLine(wxCmdLineParser& parser)
00036 {
00037
00038 parser.SetDesc(cmdLineDesc);
00039 }
00040
00041 bool wxBBIApp::OnCmdLineParsed(wxCmdLineParser& parser)
00042 {
00043 int argc = parser.GetParamCount();
00044 for (int i=0; i<argc; ++i)
00045 {
00046 std::string s = bbtk::wx2std(parser.GetParam(i));
00047 input_file.push_back(s);
00048 }
00049
00050 bool help = ( parser.Found(_T("h")) );
00051 usage = (help && (input_file.size()==0));
00052 if (usage) {
00053 std::cout << "bbStudio (The Black Box Development Studio) - bbtk "
00054 << bbtk::GetVersion() << " - (c) Creatis 2007-2008"
00055 << std::endl;
00056 parser.Usage();
00057 }
00058
00059 return true;
00060 }
00061
00062
00063
00064
00065
00066
00067 bool wxBBIApp::OnInit( )
00068 {
00069
00070 wxApp::OnInit();
00071 #ifdef __WXGTK__
00072
00073 setlocale(LC_NUMERIC, "C");
00074 #endif
00075 if (usage) return false;
00076
00077 bbtk::WxGUIScriptingInterface *I =
00078 new bbtk::WxGUIScriptingInterface(0);
00079 SetTopWindow(I);
00080 I->Show(true);
00081
00082 std::vector<std::string>::const_iterator i;
00083 i=input_file.begin();
00084 if (i!=input_file.end()) I->Open(*i);
00085
00086 return true;
00087 }
00088
00089
00090 #if defined(_WIN32)
00091
00092
00093
00094
00095
00096
00097 int main(int argc, char* argv[])
00098 {
00099 return WinMain(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), SW_SHOWNORMAL);
00100 }
00101
00102 #endif // defined(_WIN32)
00103
00104
00105 #else
00106
00107
00108
00109 int main(int argc, char* argv[])
00110 {
00111 std::cout << "bbStudio was not compiled with wxWidgets : ciao !" <<std::endl;
00112 return 0;
00113 }
00114
00115
00116 #endif //#ifdef _USE_WXWIDGETS_
00117
00118
00119