]> Creatis software - crea.git/blob - appli/creaNewProject/creaNewProject.cpp
* creaNewProject executable
[crea.git] / appli / creaNewProject / creaNewProject.cpp
1 #include <creaWx.h>
2 #include <wx/dirdlg.h>
3 class myApp : public wxApp
4 {
5 public:
6   bool OnInit( );
7   int  OnExit() { return true; }
8 };
9
10 IMPLEMENT_APP(myApp);
11 CREA_WXMAIN_WITH_CONSOLE
12
13 bool myApp::OnInit( )
14 {        
15   wxApp::OnInit();
16 #ifdef __WXGTK__
17   //See http://www.wxwindows.org/faqgtk.htm#locale
18   setlocale(LC_NUMERIC, "C");
19 #endif
20    wxInitAllImageHandlers();
21
22    wxString dir = wxDirSelector(_T("Select directory in which to create the project"), _T(""), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
23                                 
24    if (dir.IsEmpty()) return false;
25
26    wxString name = wxGetTextFromUser(_T("Enter project name"),
27                                      _T("creaNewProject"),
28                                      _T("New"));
29    if (name.IsEmpty()) return false;
30    
31 #if(_WIN32)
32    std::string command("creaNewProject.bat ");
33 #else
34    std::string command("creaNewProject.sh ");
35 #endif
36    command += crea::wx2std(dir) + " " + crea::wx2std(name);
37
38    if ( ! system ( command.c_str() ) )
39      {
40        wxMessageBox(_T("Done !"),_T("creaNewProject"),
41                     wxOK | wxICON_INFORMATION);
42      }
43    else 
44      {
45        wxString err("An error occured while running '");
46        err +=  crea::std2wx(command) + _T("'");
47        wxMessageBox(err,_T("creaNewProject"),wxOK | wxICON_ERROR);      
48      }
49
50    return false;
51 }
52