]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/wxCDMApplicationHelpDialog.cpp
Fixes:
[crea.git] / lib / creaDevManagerLib / wxCDMApplicationHelpDialog.cpp
index d9ff03a26a613f23c9c649a2643b24e1fd41a8a0..df47d8a59f0b213cc2df95269ea228d99fdc7281 100644 (file)
@@ -37,6 +37,8 @@
 
 #include "creaDevManagerIds.h"
 
+#include "modelCDMAppli.h"
+
 BEGIN_EVENT_TABLE(wxCDMApplicationHelpDialog, wxDialog)
 EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMApplicationHelpDialog::OnFinish)
 EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMApplicationHelpDialog::OnCMakeLists)
@@ -101,8 +103,12 @@ void wxCDMApplicationHelpDialog::CreateControls()
           "If you need to create separate classes in the application folder, or inside an specific folders you can do it by "
           "creating a new class with the \"Create Class\" button or by creating a folder with the \"Create Folder\" button.\n"
           "Then, in order to include your applications in the project correctly you must include them in the appli's folder "
-          "\"CMakeLists.txt\" file. Also, if you create additional folders in your library you should include them in the application's "
-          "\"CMakeLists.txt\" file.\n"
+          "\"CMakeLists.txt\" file using the command \"ADD_SUBDIRECTORY([applicationName])\". Also, if you create additional "
+          "folders in your application you should include them in the application's \"CMakeLists.txt\" file using the command "
+          "\"ADD_SUBDIRECTORY([folderName])\". If you use a third party library in your application you must include it by "
+          "uncommenting its inclusion in the application's \"CMakeLists.txt\" file. If you use a custom library in your "
+          "application you must include it by including the library path inside the \"INCLUDE_DIRECTORIES\" command, and its "
+          "name inside the \"SET ( ${EXE_NAME}_LINK_LIBRARIES...\"command.\n"
           "\n"
           "You can easily edit the CMakeLists files previously mentioned by clicking on the following buttons."),
           wxDefaultPosition,
@@ -111,11 +117,15 @@ void wxCDMApplicationHelpDialog::CreateControls()
   );
   v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5);
 
-  wxButton* editCMakePKGBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Open Application's directory CMakeLists file"));
-  wxButton* editCMakePRJBtn= new wxButton(this, ID_BUTTON_OPENPROJECT, wxT("Open Appli's directory CMakeLists file"));
+  wxButton* editCMakeApplicationBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Open Application's directory CMakeLists file"));
+  editCMakeApplicationBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationHelpDialog::OnCMakeListsEnter,NULL,this);
+  editCMakeApplicationBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationHelpDialog::OnCMakeListsExit,NULL,this);
+  wxButton* editCMakeAppliBtn= new wxButton(this, ID_BUTTON_OPENPROJECT, wxT("Open Appli's directory CMakeLists file"));
+  editCMakeAppliBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationHelpDialog::OnCMakeListsEnter,NULL,this);
+  editCMakeAppliBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationHelpDialog::OnCMakeListsExit,NULL,this);
 
-  v_sizer1->Add(editCMakePKGBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15);
-  v_sizer1->Add(editCMakePRJBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15);
+  v_sizer1->Add(editCMakeApplicationBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15);
+  v_sizer1->Add(editCMakeAppliBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15);
 
   v_sizer1->Add(new wxCheckBox(this, ID_CHECKBOX_DISABLE_HELP, wxT("&Disable help")), 0, wxALIGN_RIGHT | wxRIGHT, 10);
 
@@ -132,22 +142,118 @@ void wxCDMApplicationHelpDialog::OnFinish(wxCommandEvent& event)
 
 void wxCDMApplicationHelpDialog::OnCMakeLists(wxCommandEvent& event)
 {
-  //TODO: implement method
-  std::cout << "OnCMakeLists not implemented yet." << std::endl;
-  event.Skip();
+  std::string* result;
+
+  if((int)((wxButton*)event.GetEventObject())->GetId() == (int)ID_BUTTON_EDIT_CMAKELISTSFILE)
+    {
+
+      if(!this->application->OpenCMakeListsFile(result))
+        wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
+
+      wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
+
+      if(this->application->GetCMakeLists() != NULL)
+        {
+          newEvent->SetClientData(this->application->GetCMakeLists());
+          newEvent->SetId(0);
+          wxPostEvent(this->GetParent(), *newEvent);
+        }
+    }
+  else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT)
+    {
+      modelCDMIProjectTreeNode* node = this->application;
+      while (node != NULL && dynamic_cast<modelCDMAppli*>(node) == NULL)
+        {
+          node = node->GetParent();
+        }
+      if (node != NULL)
+        {
+          if(!((modelCDMAppli*)node)->OpenCMakeListsFile(result))
+            wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
+
+          wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
+
+          if(((modelCDMAppli*)node)->GetCMakeLists() != NULL)
+            {
+              newEvent->SetClientData(((modelCDMAppli*)node)->GetCMakeLists());
+              newEvent->SetId(0);
+              wxPostEvent(this->GetParent(), *newEvent);
+            }
+        }
+      else
+        {
+          wxMessageBox(crea::std2wx("No project CMakeLists file was found."),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
+        }
+    }
 }
 
 void wxCDMApplicationHelpDialog::OnCMakeListsEnter(wxMouseEvent& event)
 {
-  //TODO: implement method
-  std::cout << "OnCMakeListsEnter not implemented yet." << std::endl;
+  if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_EDIT_CMAKELISTSFILE)
+    {
+      wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
+
+      if(this->application->GetCMakeLists() != NULL)
+        {
+          newEvent->SetClientData(this->application->GetCMakeLists());
+          newEvent->SetId(0);
+          wxPostEvent(this->GetParent(), *newEvent);
+        }
+    }
+  else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT)
+    {
+      modelCDMIProjectTreeNode* node = this->application;
+      while (node != NULL && dynamic_cast<modelCDMAppli*>(node) == NULL)
+        {
+          node = node->GetParent();
+        }
+      if (node != NULL)
+        {
+          wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
+
+          if(((modelCDMAppli*)node)->GetCMakeLists() != NULL)
+            {
+              newEvent->SetClientData(((modelCDMAppli*)node)->GetCMakeLists());
+              newEvent->SetId(0);
+              wxPostEvent(this->GetParent(), *newEvent);
+            }
+        }
+    }
   event.Skip();
 }
 
 void wxCDMApplicationHelpDialog::OnCMakeListsExit(wxMouseEvent& event)
 {
-  //TODO: implement method
-  std::cout << "OnCMakeListsExit not implemented yet." << std::endl;
+  if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_EDIT_CMAKELISTSFILE)
+    {
+      wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
+
+      if(this->application->GetCMakeLists() != NULL)
+        {
+          newEvent->SetClientData(this->application->GetCMakeLists());
+          newEvent->SetId(0);
+          wxPostEvent(this->GetParent(), *newEvent);
+        }
+    }
+  else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT)
+    {
+      modelCDMIProjectTreeNode* node = this->application;
+      while (node != NULL && dynamic_cast<modelCDMAppli*>(node) == NULL)
+        {
+          node = node->GetParent();
+        }
+      if (node != NULL)
+        {
+          wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
+
+          if(((modelCDMAppli*)node)->GetCMakeLists() != NULL)
+            {
+              newEvent->SetClientData(((modelCDMAppli*)node)->GetCMakeLists());
+              newEvent->SetId(0);
+              wxPostEvent(this->GetParent(), *newEvent);
+            }
+        }
+    }
   event.Skip();
 }