]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
#3249 Change FontSize - Box graphic scale
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / bbtkwxGUIEditorGraphicBBS.cxx
index 1376327ad2bea388f833aa242751243f2d530bec..dda5bce5d86da8aae7dd4e081701721cb86b6c3f 100644 (file)
@@ -96,8 +96,8 @@ wxGUIEditorGraphicBBS::wxGUIEditorGraphicBBS(wxFrame *parent)
        initToolbar();
        initPackageBrowser();
        initTabPanelsManager();
-        // JGGR & CM  initHelpHTMLBrowser();
-        _helpHtmlBrowser = NULL;
+    // JGGR & CM  initHelpHTMLBrowser();
+    _helpHtmlBrowser = NULL;
        CreateStatusBar();
        _frameAUIMgr->Update();
        _actualPkgBrowserBoxName = "";
@@ -107,26 +107,23 @@ wxGUIEditorGraphicBBS::wxGUIEditorGraphicBBS(wxFrame *parent)
        /////////////////////////////////
        /// IMPORTANT!! FOR SAVE&LOAD PROCESSES THE VERSION IS VERY IMPORTANT.
        /// RaC 2012 2nd Hackfest
-       _currentBBGversion="1.4";
+       _currentBBGversion="1.5";
 }
 
 //=========================================================================
-wxGUIEditorGraphicBBS::~wxGUIEditorGraphicBBS() {
-
-       printf("EED %p ~wxGUIEditorGraphicBBS()\n", this);
-
+wxGUIEditorGraphicBBS::~wxGUIEditorGraphicBBS() 
+{
        //EED02JUIN2010         delete _tabsMgr;
-
        _frameAUIMgr->UnInit();
        // FCY memory leaks
        delete _frameAUIMgr;
        delete _notebook;
        delete _tabsMgr;
-
 }
 
 //=========================================================================
-void wxGUIEditorGraphicBBS::initToolbar() {
+void wxGUIEditorGraphicBBS::initToolbar() 
+{
        wxBitmap bmp_new(new_xpm);
        wxBitmap bmp_open(open_xpm);
        wxBitmap bmp_save(save_xpm);
@@ -142,13 +139,17 @@ void wxGUIEditorGraphicBBS::initToolbar() {
        wxBitmap bmp_redo(redo_xpm);
        wxBitmap bmp_editProperties(editProperties_xpm);
        wxBitmap bmp_showTree(showTree_xpm);
-       wxToolBar *toolbar = new wxToolBar(this, wxID_ANY);
+       
+//     wxToolBar *toolbar = new wxToolBar(this, wxID_ANY);
+       wxToolBar *toolbar =    CreateToolBar();
 
        //Adds a tool btn to the toolbar
        toolbar->AddTool(ID_NEW, _T("New"), bmp_new, wxNullBitmap, wxITEM_NORMAL,
                        _T("New tab"), _T("Create a new panel tab"));
+
        toolbar->AddTool(ID_OPEN, _T("Open diagram"), bmp_open, wxNullBitmap,
                        wxITEM_NORMAL, _T("Open a diagram"), _T("Open a diagram"));
+
        toolbar->AddTool(ID_SAVE_DIAGRAM, _T("Save Diagram"), bmp_save,
                        wxNullBitmap, wxITEM_NORMAL, _T("Saves the current diagram"),
                        _T("Saves the current diagram")); //DFCH
@@ -169,7 +170,14 @@ void wxGUIEditorGraphicBBS::initToolbar() {
        toolbar->AddSeparator();
        toolbar->AddTool(ID_BTNCOMPLEXBOX, _T("Complex box"), complexbox_xpm,
                        wxNullBitmap, wxITEM_NORMAL, _T("Complex box"), _T("Complex box"));
+
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
        toolbar->SetToggle(ID_BTNCOMPLEXBOX, true);
+#else
+       printf ("EED Warnning. wxGUIEditorGraphicBBS::initToolbar       >>>   toolbar->SetToggle  \n ");
+       // ..
+#endif
 
        // RaC 2012 2nd HackFest - Now Complex inputs are any external input
        //              toolbar->AddTool(ID_ADDCOMPLEXBOXINPUT, _T("Add input to Complex box"),
@@ -195,6 +203,7 @@ void wxGUIEditorGraphicBBS::initToolbar() {
        toolbar->EnableTool(ID_EDITPROPERTIES, false);
 
        toolbar->AddTool(ID_SHOWTREE, _T("Show tree"),bmp_showTree, wxNullBitmap, wxITEM_NORMAL,        _T("Show tree"), _T("Show tree"));
+
        
        toolbar->EnableTool(ID_UNDO, false);
        toolbar->EnableTool(ID_REDO, false);
@@ -202,6 +211,7 @@ void wxGUIEditorGraphicBBS::initToolbar() {
        toolbar->Realize();
        SetToolBar(toolbar);
 
+
        
        // connect command event handlers
 
@@ -243,6 +253,7 @@ void wxGUIEditorGraphicBBS::initToolbar() {
        Connect(ID_EDITPROPERTIES,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnEditDiagramProperties));
        Connect(ID_SHOWTREE,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnShowTree));
 
+
 }
 //=========================================================================
 void wxGUIEditorGraphicBBS::initHelpHTMLBrowser() {
@@ -557,6 +568,11 @@ void wxGUIEditorGraphicBBS::executeScript(std::string script) {
        command += " & ";
 #endif
 
+#ifdef __APPLE__
+    command = "source ~/.bbtk/profile_creatools; "+command;
+#endif
+
+
        printf("RaC wxGUIEditorGraphicBBS::executeScript %s \n", command.c_str());
        system(command.c_str());
 }
@@ -666,18 +682,16 @@ void wxGUIEditorGraphicBBS::OnEditDiagramProperties(wxCommandEvent& event)
 }
 
 //=========================================================================
-
-void wxGUIEditorGraphicBBS::OnExecuteActualDiagram(wxCommandEvent& event) {
+void wxGUIEditorGraphicBBS::OnExecuteActualDiagram(wxCommandEvent& event)
+{
        std::string script1 = _tabsMgr->getActualDiagramBBS(true);
        cout << endl << "RaC wxGUIEditorGraphicBBS::executeActualDiagram SCRIPT"
                        << endl << endl;
        cout << script1 << endl;
-
        std::string script2 = _tabsMgr->getActualDiagramBBS(false);
        executeScript(script2);
 }
 
-       
 //=========================================================================
 void wxGUIEditorGraphicBBS::OpenBBS(std::string filePathName, std::string fileName) 
 {
@@ -695,7 +709,12 @@ void wxGUIEditorGraphicBBS::OpenBBS(std::string filePathName, std::string fileNa
 //=========================================================================
 void wxGUIEditorGraphicBBS::OnOpenBBS(wxCommandEvent& event) 
 {
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
        wxFileDialog * openFileDialog = new wxFileDialog(this, wxT("Open BBS"), wxEmptyString, wxT("NewBBS"), wxT("*.bbs"), wxOPEN);
+#else
+       wxFileDialog * openFileDialog = new wxFileDialog(this, wxT("Open BBS"), wxEmptyString, wxT("NewBBS"), wxT("*.bbs"), wxFD_OPEN);
+#endif
 
        if (openFileDialog->ShowModal() == wxID_OK) 
        {
@@ -740,9 +759,18 @@ void wxGUIEditorGraphicBBS::SaveActualBBS(std::string filename) {
 }
 
 void wxGUIEditorGraphicBBS::OnSaveActualBBS(wxCommandEvent& event) {
+
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
        wxFileDialog * saveFileDialog = new wxFileDialog(this,
                        wxT("Save  actual BBS"), wxEmptyString, wxT("NewBBS"),
                        wxT("*.bbs"), wxSAVE | wxOVERWRITE_PROMPT);
+#else
+       wxFileDialog * saveFileDialog = new wxFileDialog(this,
+                       wxT("Save  actual BBS"), wxEmptyString, wxT("NewBBS"),
+                       wxT("*.bbs"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
+#endif
+
        if (saveFileDialog->ShowModal() == wxID_OK) {
                wxString fileName = saveFileDialog->GetPath();
                std::string filename = (const char*) (fileName.mb_str());
@@ -803,11 +831,21 @@ void wxGUIEditorGraphicBBS::SaveActualComplexBox(std::string filename) {
 
 //=========================================================================
 
-void wxGUIEditorGraphicBBS::OnSaveActualComplexBox(wxCommandEvent& event) {
+void wxGUIEditorGraphicBBS::OnSaveActualComplexBox(wxCommandEvent& event) 
+{
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
        wxFileDialog * saveFileDialog = new wxFileDialog(this,
                        wxT("Save Complex Box BBS"), wxEmptyString,
                        _T("ComplexBoxName"), wxT("*.bbs"), wxSAVE
                                        | wxOVERWRITE_PROMPT);
+#else
+       wxFileDialog * saveFileDialog = new wxFileDialog(this,
+                       wxT("Save Complex Box BBS"), wxEmptyString,
+                       _T("ComplexBoxName"), wxT("*.bbs"), wxFD_SAVE
+                                       | wxFD_OVERWRITE_PROMPT);
+#endif
+
        if (saveFileDialog->ShowModal() == wxID_OK) {
                wxString fileName = saveFileDialog->GetPath();
                std::string filename = (const char*) (fileName.mb_str());
@@ -862,10 +900,20 @@ void wxGUIEditorGraphicBBS::SaveTempActualDiagram(const std::string &action)
 
 //The following method allows to save the current diagram asking the filename
 //DFCH
-void wxGUIEditorGraphicBBS::SaveCurrentDiagramAs() {
+void wxGUIEditorGraphicBBS::SaveCurrentDiagramAs() 
+{
+
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
        wxFileDialog * saveFileDialog = new wxFileDialog(this,
                        wxT("Save current diagram"), wxEmptyString, wxT("NewDiagram"),
                        wxT("*.bbg"), wxSAVE | wxOVERWRITE_PROMPT);
+#else
+       wxFileDialog * saveFileDialog = new wxFileDialog(this,
+                       wxT("Save current diagram"), wxEmptyString, wxT("NewDiagram"),
+                       wxT("*.bbg"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
+#endif
+
        if (saveFileDialog->ShowModal() == wxID_OK) {
                //_tabsMgr->SetNameTabPanel(saveFileDialog->GetFilename());
                wxString pathfileName = saveFileDialog->GetPath();
@@ -925,9 +973,17 @@ void wxGUIEditorGraphicBBS::OnSaveAsActualDiagram(wxCommandEvent& event) {
 //=========================================================================
 void wxGUIEditorGraphicBBS::OnExportConsoleExecCommand(wxCommandEvent& event)
 {
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
        wxFileDialog * saveFileDialog = new wxFileDialog(this,
                        wxT("Export console command"), wxEmptyString, wxT("ConsoleApp.txt"),
                        wxT("*.txt;*.bbs;*.bbg;*.sh;*.bat"), wxSAVE | wxOVERWRITE_PROMPT);
+#else
+       wxFileDialog * saveFileDialog = new wxFileDialog(this,
+                       wxT("Export console command"), wxEmptyString, wxT("ConsoleApp.txt"),
+                       wxT("*.txt;*.bbs;*.bbg;*.sh;*.bat"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
+#endif
+
 
        if (saveFileDialog->ShowModal() == wxID_OK)
        {
@@ -1017,12 +1073,14 @@ void wxGUIEditorGraphicBBS::OnExportConsoleExecCommand(wxCommandEvent& event)
 
 //=========================================================================
 
-void wxGUIEditorGraphicBBS::refreshGUIControls() {
+void wxGUIEditorGraphicBBS::refreshGUIControls() 
+{
        std::string stundo;
        std::string stredo;
        //RaC2012 2ndHackFest Next line seems weird ... To keep in mind for other devels
        wxToolBar* toolbar = GetToolBar();
-       if (_tabsMgr->isActualDiagramComplexBox()) {
+       if (_tabsMgr->isActualDiagramComplexBox()) 
+       {
                toolbar->ToggleTool(ID_BTNCOMPLEXBOX, true);
                //toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, true); RaC2012 2nd HackFest
                toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT, true);
@@ -1102,7 +1160,14 @@ void wxGUIEditorGraphicBBS::OpenDiagram(std::string filePathName, std::string fi
 
 void wxGUIEditorGraphicBBS::OnOpenDiagram(wxCommandEvent& event) 
 {
+
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
        wxFileDialog * openFileDialog = new wxFileDialog(this, wxT("Open diagram"), wxEmptyString, wxT(""), wxT("*.bbg"), wxOPEN | wxFILE_MUST_EXIST);
+#else
+       wxFileDialog * openFileDialog = new wxFileDialog(this, wxT("Open diagram"), wxEmptyString, wxT(""), wxT("*.bbg"), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
+#endif
+
        if (openFileDialog->ShowModal() == wxID_OK) 
        {
                wxString filePath = openFileDialog->GetPath();
@@ -1498,16 +1563,21 @@ bool wxGUIEditorGraphicBBS::TryToOpenScript(std::string packageName ,std::string
        descriptor      = mapDesc[boxType];
 
        bool result=false;
-       
-       if (
-               ((descriptor->IsTypeOfScript_Application()==true) && (scriptApplication==true))
-               ||
-               ((descriptor->IsTypeOfScript_ComplexBox()==true) && (scriptComplexBox==true))           
-               )
+    descriptor->IsTypeOfScript_Application();  
+       if (descriptor!=NULL)
        {
-               result=true;
-               OpenScript(descriptor->GetScriptFileName(),boxType);
-       }
+               if ( 
+                       ((descriptor->IsTypeOfScript_Application()==true) && (scriptApplication==true))
+                       ||
+                       ((descriptor->IsTypeOfScript_ComplexBox()==true) && (scriptComplexBox==true))           
+                       )
+               {
+                       result=true;
+                       OpenScript(descriptor->GetScriptFileName(),boxType);
+               } // if descriptor Type
+       } else {
+               printf("EED ERROR wxGUIEditorGraphicBBS::TryToOpenScript >> The descriptor of this box not exists (packageName:%s  boxType:%s) this is not normal\n",packageName.c_str(), boxType.c_str() );
+       }  // if descriptor NULL
        
        return result;
 }