]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/wxCDMMainFrame.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / wxCDMMainFrame.cpp
index f26d9568dd3992a9852cc46b7c94b4249045d6d9..6f0af4608e0acb5e93b494ab0e1ad4d6d540c9b0 100755 (executable)
@@ -54,6 +54,7 @@
 #include "wxCDMNewProjectDialog.h"
 
 
+
 BEGIN_EVENT_TABLE(wxCDMMainFrame, wxFrame)
 EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject)
 EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject)
@@ -74,16 +75,23 @@ EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEdito
 EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools)
 EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor)
 EVT_MENU(ID_MENU_COMMAND_LINE, wxCDMMainFrame::OnMenuCommandLine)
+EVT_MENU(ID_MENU_TOGGLE_HELP, wxCDMMainFrame::OnMenuToggleHelp)
 EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp)
 EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug)
 EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager)
 EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis)
+
 EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject)
 EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject)
-EVT_TREE_SEL_CHANGING(ID_TREE_PROJECTS, wxCDMMainFrame::OnTreeSelectionChanged)
+
+EVT_TREE_SEL_CHANGED(ID_TREE_PROJECTS, wxCDMMainFrame::OnTreeSelectionChanged)
+
 EVT_COMMAND(wxID_ANY, wxEVT_DISPLAY_CHANGED, wxCDMMainFrame::OnCreationComplete)
 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LIST_ITEM_SELECTED, wxCDMMainFrame::OnElementSelected)
 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxCDMMainFrame::OnElementDeselected)
+
+
+EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMMainFrame::OnDisableHelp)
 END_EVENT_TABLE()
 
 wxCDMMainFrame::wxCDMMainFrame(
@@ -114,6 +122,7 @@ bool wxCDMMainFrame::Create(
 {
   wxFrame::Create(parent, id, caption, pos, size, style);
   this->model = new modelCDMMain();
+  this->help = true;
   CreateMenus();
   CreateControls();
   return TRUE;
@@ -124,6 +133,16 @@ modelCDMMain* wxCDMMainFrame::GetModel() const
   return this->model;
 }
 
+wxPanel* wxCDMMainFrame::GetPropertiesPanel() const
+{
+  return this->panel_Properties;
+}
+
+bool wxCDMMainFrame::isHelp() const
+{
+  return this->help;
+}
+
 void wxCDMMainFrame::RefreshProject()
 {
   std::string* result;
@@ -178,6 +197,8 @@ void wxCDMMainFrame::CreateMenus()
 
   //HelpMenu
   menu_Help = new wxMenu();
+  menu_Help->AppendCheckItem(ID_MENU_TOGGLE_HELP, wxT("He&lp Dialogs"));
+  menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
   menu_Help->Append(ID_MENU_HELP, wxT("&Help"));
   menu_Help->Append(ID_MENU_REPORT_BUG, wxT("Report &Bug"));
   menu_Help->Append(ID_MENU_ABOUT_CREADEVMANAGER, wxT("&About CreaDevManager"));
@@ -274,25 +295,11 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
 
       //populate tree control
       tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject());
-      tree_Projects->SelectItem(this->model->GetProject()->GetId());
+      tree_Projects->SelectItem(this->model->GetProject()->GetId(), false);
+      tree_Projects->SelectItem(this->model->GetProject()->GetId(), true);
 
-      //change description panel
-      if(this->panel_Properties != NULL)
-        {
-          auiManager.DetachPane(this->panel_Properties);
-          this->panel_Properties->Destroy();
-          this->panel_Properties = NULL;
-        }
 
-      this->panel_Properties = new wxCDMProjectDescriptionPanel(
-          this,
-          this->model->GetProject(),
-          ID_WINDOW_PROPERTIES,
-          wxT("Description Panel"),
-          wxDefaultPosition,
-          wxSize(600, 400),
-          0);
-      //show projectactions panel
+      //show project actions panel
       if(this->panel_ProjectActions != NULL)
         {
           auiManager.DetachPane(this->panel_Properties);
@@ -312,12 +319,12 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
       panel_ProjectActions->SetMinSize(wxSize(500, 100));
 
 
-      auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
       auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
 
       auiManager.Update();
 
-      wxMessageBox(_T("New Project created!"),_T("New Project - Success!"), wxOK | wxICON_INFORMATION);
+      //wxMessageBox(_T("New Project created!"),_T("New Project - Success!"), wxOK | wxICON_INFORMATION);
+
     }
 
   event.Skip();
@@ -364,25 +371,9 @@ void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
 
       //populate tree control
       tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
-      tree_Projects->SelectItem(this->model->GetProject()->GetId());
+      tree_Projects->SelectItem(this->model->GetProject()->GetId(), false);
+      tree_Projects->SelectItem(this->model->GetProject()->GetId(), true);
 
-      //change description panel
-      if(this->panel_Properties != NULL)
-        {
-          auiManager.DetachPane(this->panel_Properties);
-          this->panel_Properties->Destroy();
-          this->panel_Properties = NULL;
-        }
-
-      this->panel_Properties = new wxCDMProjectDescriptionPanel(
-          this,
-          this->model->GetProject(),
-          ID_WINDOW_PROPERTIES,
-          wxT("Description Panel"),
-          wxDefaultPosition,
-          wxSize(600, 400),
-          0
-      );
 
       //change project's actions panel
       if(this->panel_ProjectActions!= NULL)
@@ -403,10 +394,11 @@ void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
       panel_ProjectActions->SetMinSize(wxSize(500, 100));
 
 
-      auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
       auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false));
 
       auiManager.Update();
+
+
     }
 
   event.Skip();
@@ -637,75 +629,62 @@ void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event)
 
 void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
 {
+
   //get selected element
   wxTreeItemId elementId = event.GetItem();
-
-  //get element from model
-  modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId];
-  std::cout << "Tree Selection: " << element->GetName() << std::endl;
-
-  //TODO get element type
-  //project
-  modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
-  wxPanel* description;
-  if(elementProject != NULL)
+  if(this->tree_Projects->IsSelected(elementId))
     {
-      //create element description
-      description = new wxCDMProjectDescriptionPanel(
-          this,
-          elementProject,
-          ID_WINDOW_PROPERTIES,
-          wxT("Description Panel"),
-          wxDefaultPosition,
-          wxSize(600, 400),
-          0
-      );
-
-    }
-  else
-    {
-      //appli
-      modelCDMAppli* elementAppli = dynamic_cast<modelCDMAppli*>(element);
-      if(elementAppli != NULL)
+      std::cout << "Tree Selection id: " << elementId << std::endl;
+      //get element from model
+      modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId];
+      std::cout << "Tree Selection: " << element->GetName() << std::endl;
+
+      //TODO get element type
+      //project
+      modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
+      wxPanel* description;
+      if(elementProject != NULL)
         {
           //create element description
-          description = new wxCDMAppliDescriptionPanel(
+          description = new wxCDMProjectDescriptionPanel(
               this,
-              elementAppli,
+              elementProject,
               ID_WINDOW_PROPERTIES,
               wxT("Description Panel"),
               wxDefaultPosition,
               wxSize(600, 400),
               0
           );
+
         }
       else
         {
-          //application
-          modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
-          if(elementApplication != NULL)
+          //appli
+          modelCDMAppli* elementAppli = dynamic_cast<modelCDMAppli*>(element);
+          if(elementAppli != NULL)
             {
               //create element description
-              description = new wxCDMApplicationDescriptionPanel(
+              description = new wxCDMAppliDescriptionPanel(
                   this,
-                  elementApplication,
+                  elementAppli,
                   ID_WINDOW_PROPERTIES,
                   wxT("Description Panel"),
                   wxDefaultPosition,
                   wxSize(600, 400),
                   0
               );
+
             }
           else
             {
-              //lib
-              modelCDMLib* elementLib = dynamic_cast<modelCDMLib*>(element);
-              if(elementLib != NULL)
+              //application
+              modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
+              if(elementApplication != NULL)
                 {
                   //create element description
-                  description = new wxCDMLibDescriptionPanel(
+                  description = new wxCDMApplicationDescriptionPanel(
                       this,
-                      elementLib,
+                      elementApplication,
                       ID_WINDOW_PROPERTIES,
                       wxT("Description Panel"),
                       wxDefaultPosition,
@@ -715,14 +694,14 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
                 }
               else
                 {
-                  //library
-                  modelCDMLibrary* elementLibrary = dynamic_cast<modelCDMLibrary*>(element);
-                  if(elementLibrary != NULL)
+                  //lib
+                  modelCDMLib* elementLib = dynamic_cast<modelCDMLib*>(element);
+                  if(elementLib != NULL)
                     {
                       //create element description
-                      description = new wxCDMLibraryDescriptionPanel(
+                      description = new wxCDMLibDescriptionPanel(
                           this,
-                          elementLibrary,
+                          elementLib,
                           ID_WINDOW_PROPERTIES,
                           wxT("Description Panel"),
                           wxDefaultPosition,
@@ -732,14 +711,14 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
                     }
                   else
                     {
-                      //package
-                      modelCDMPackage* elementPackage = dynamic_cast<modelCDMPackage*>(element);
-                      if(elementPackage != NULL)
+                      //library
+                      modelCDMLibrary* elementLibrary = dynamic_cast<modelCDMLibrary*>(element);
+                      if(elementLibrary != NULL)
                         {
                           //create element description
-                          description = new wxCDMPackageDescriptionPanel(
+                          description = new wxCDMLibraryDescriptionPanel(
                               this,
-                              elementPackage,
+                              elementLibrary,
                               ID_WINDOW_PROPERTIES,
                               wxT("Description Panel"),
                               wxDefaultPosition,
@@ -749,14 +728,14 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
                         }
                       else
                         {
-                          //black box
-                          modelCDMBlackBox* elementBlackBox = dynamic_cast<modelCDMBlackBox*>(element);
-                          if(elementBlackBox != NULL)
+                          //package
+                          modelCDMPackage* elementPackage = dynamic_cast<modelCDMPackage*>(element);
+                          if(elementPackage != NULL)
                             {
                               //create element description
-                              description = new wxCDMBlackBoxDescriptionPanel(
+                              description = new wxCDMPackageDescriptionPanel(
                                   this,
-                                  elementBlackBox,
+                                  elementPackage,
                                   ID_WINDOW_PROPERTIES,
                                   wxT("Description Panel"),
                                   wxDefaultPosition,
@@ -766,14 +745,14 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
                             }
                           else
                             {
-                              //CMakeLists
-                              modelCDMCMakeListsFile* elementCMakeLists = dynamic_cast<modelCDMCMakeListsFile*>(element);
-                              if(elementCMakeLists != NULL)
+                              //black box
+                              modelCDMBlackBox* elementBlackBox = dynamic_cast<modelCDMBlackBox*>(element);
+                              if(elementBlackBox != NULL)
                                 {
                                   //create element description
-                                  description = new wxCDMCMakeListsDescriptionPanel(
+                                  description = new wxCDMBlackBoxDescriptionPanel(
                                       this,
-                                      elementCMakeLists,
+                                      elementBlackBox,
                                       ID_WINDOW_PROPERTIES,
                                       wxT("Description Panel"),
                                       wxDefaultPosition,
@@ -783,14 +762,14 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
                                 }
                               else
                                 {
-                                  //folder
-                                  modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(element);
-                                  if(elementFolder != NULL)
+                                  //CMakeLists
+                                  modelCDMCMakeListsFile* elementCMakeLists = dynamic_cast<modelCDMCMakeListsFile*>(element);
+                                  if(elementCMakeLists != NULL)
                                     {
                                       //create element description
-                                      description = new wxCDMFolderDescriptionPanel(
+                                      description = new wxCDMCMakeListsDescriptionPanel(
                                           this,
-                                          elementFolder,
+                                          elementCMakeLists,
                                           ID_WINDOW_PROPERTIES,
                                           wxT("Description Panel"),
                                           wxDefaultPosition,
@@ -800,14 +779,14 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
                                     }
                                   else
                                     {
-                                      //file
-                                      modelCDMFile* elementFile = dynamic_cast<modelCDMFile*>(element);
-                                      if(elementFile != NULL)
+                                      //folder
+                                      modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(element);
+                                      if(elementFolder != NULL)
                                         {
                                           //create element description
-                                          description = new wxCDMFileDescriptionPanel(
+                                          description = new wxCDMFolderDescriptionPanel(
                                               this,
-                                              elementFile,
+                                              elementFolder,
                                               ID_WINDOW_PROPERTIES,
                                               wxT("Description Panel"),
                                               wxDefaultPosition,
@@ -817,17 +796,35 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
                                         }
                                       else
                                         {
-
-                                          //main if not any
-                                          //create element description
-                                          description = new wxCDMMainDescriptionPanel(
-                                              this,
-                                              ID_WINDOW_PROPERTIES,
-                                              wxT("Description Panel"),
-                                              wxDefaultPosition,
-                                              wxSize(600, 400),
-                                              0
-                                          );
+                                          //file
+                                          modelCDMFile* elementFile = dynamic_cast<modelCDMFile*>(element);
+                                          if(elementFile != NULL)
+                                            {
+                                              //create element description
+                                              description = new wxCDMFileDescriptionPanel(
+                                                  this,
+                                                  elementFile,
+                                                  ID_WINDOW_PROPERTIES,
+                                                  wxT("Description Panel"),
+                                                  wxDefaultPosition,
+                                                  wxSize(600, 400),
+                                                  0
+                                              );
+                                            }
+                                          else
+                                            {
+
+                                              //main if not any
+                                              //create element description
+                                              description = new wxCDMMainDescriptionPanel(
+                                                  this,
+                                                  ID_WINDOW_PROPERTIES,
+                                                  wxT("Description Panel"),
+                                                  wxDefaultPosition,
+                                                  wxSize(600, 400),
+                                                  0
+                                              );
+                                            }
                                         }
                                     }
                                 }
@@ -837,27 +834,29 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
                 }
             }
         }
-    }
 
-  if(this->panel_Properties!= NULL)
-    this->panel_Properties->Hide();
+      if(this->panel_Properties!= NULL)
+        this->panel_Properties->Hide();
 
-  auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
-  auiManager.Update();
+      auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false));
+      auiManager.Update();
 
-  //delete old view
-  if(this->panel_Properties!= NULL)
-    {
-      auiManager.DetachPane(this->panel_Properties);
-      this->panel_Properties->Destroy();
-      this->panel_Properties = NULL;
+      //delete old view
+      if(this->panel_Properties!= NULL)
+        {
+          auiManager.DetachPane(this->panel_Properties);
+          this->panel_Properties->Destroy();
+          this->panel_Properties = NULL;
+        }
+      //set new view
+
+      this->panel_Properties = description;
+
+      //auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("Properties")).BestSize(600,400).CloseButton(false));
+      auiManager.Update();
+      event.Skip();
     }
-  //set new view
 
-  this->panel_Properties = description;
-  //auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("Properties")).BestSize(600,400).CloseButton(false));
-  auiManager.Update();
-  event.Skip();
   return;
 
 }
@@ -953,3 +952,19 @@ void wxCDMMainFrame::OnElementDeselected(wxCommandEvent& event)
   this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE);
   auiManager.Update();
 }
+
+void wxCDMMainFrame::OnMenuToggleHelp(wxCommandEvent& event)
+{
+  this->help = !this->help;
+  this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
+}
+
+void wxCDMMainFrame::OnDisableHelp(wxCommandEvent& event)
+{
+  if (event.GetInt())
+    this->help = false;
+  else
+    this->help = true;
+
+  this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
+}