X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=lib%2FcreaDevManagerLib%2FwxCDMLibraryHelpDialog.cpp;h=e027d60d9eecd5685a1e149e4f3278d0d3cb6479;hb=9f11db34cb1acacf545f819d6b552a95835d93bd;hp=455b55935f7b20bbed87cde23c27fb5bc72397a0;hpb=4e0312091408bc9bd77f3f70ade44d207365cdbe;p=crea.git diff --git a/lib/creaDevManagerLib/wxCDMLibraryHelpDialog.cpp b/lib/creaDevManagerLib/wxCDMLibraryHelpDialog.cpp index 455b559..e027d60 100644 --- a/lib/creaDevManagerLib/wxCDMLibraryHelpDialog.cpp +++ b/lib/creaDevManagerLib/wxCDMLibraryHelpDialog.cpp @@ -37,6 +37,8 @@ #include "creaDevManagerIds.h" +#include "modelCDMLib.h" + BEGIN_EVENT_TABLE(wxCDMLibraryHelpDialog, wxDialog) EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMLibraryHelpDialog::OnFinish) EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMLibraryHelpDialog::OnCMakeLists) @@ -101,8 +103,12 @@ void wxCDMLibraryHelpDialog::CreateControls() "functionalities of your project inside the created files.\n" "If you need to separate classes in folders you can do it by creating a folder with the \"Create Folder\" button.\n" "Then, in order to include your libraries in the project correctly you must include them in the lib's folder " - "\"CMakeLists.txt\" file. Also, if you create additional folders in your library you should include them in the library's " - "\"CMakeLists.txt\" file.\n" + "\"CMakeLists.txt\" file by using the \"ADD_SUBDIRECTORY([libraryName])\". Also, if you use third party libraries in your " + "library you must include them in the library's \"CMakeLists.txt\" file by uncommenting them in the " + "\"SET ( ${LIBRARY_NAME}_LINK_LIBRARIES\" command; if you use custom libraries in your library you must also include them " + "in the library's \"CMakeLists.txt\" file by including them in the \"SET ( ${LIBRARY_NAME}_LINK_LIBRARIES\" command. Or, " + "if you create additional folders in your library you must include them in the library's \"CMakeLists.txt\" file by using " + "the \"ADD_SUBDIRECTORY([folderName])\" command.\n" "\n" "You can easily edit the CMakeLists files previously mentioned by clicking on the following buttons."), wxDefaultPosition, @@ -111,11 +117,15 @@ void wxCDMLibraryHelpDialog::CreateControls() ); v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5); - wxButton* editCMakePKGBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Open Library's directory CMakeLists file")); - wxButton* editCMakePRJBtn= new wxButton(this, ID_BUTTON_OPENPROJECT, wxT("Open Lib's directory CMakeLists file")); + wxButton* editCMakeLibraryBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Open Library's directory CMakeLists file")); + editCMakeLibraryBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibraryHelpDialog::OnCMakeListsEnter,NULL,this); + editCMakeLibraryBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibraryHelpDialog::OnCMakeListsExit,NULL,this); + wxButton* editCMakeLibBtn= new wxButton(this, ID_BUTTON_OPENPROJECT, wxT("Open Lib's directory CMakeLists file")); + editCMakeLibBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibraryHelpDialog::OnCMakeListsEnter,NULL,this); + editCMakeLibBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibraryHelpDialog::OnCMakeListsExit,NULL,this); - v_sizer1->Add(editCMakePKGBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); - v_sizer1->Add(editCMakePRJBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); + v_sizer1->Add(editCMakeLibraryBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); + v_sizer1->Add(editCMakeLibBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); v_sizer1->Add(new wxCheckBox(this, ID_CHECKBOX_DISABLE_HELP, wxT("&Disable help")), 0, wxALIGN_RIGHT | wxRIGHT, 10); @@ -132,23 +142,119 @@ void wxCDMLibraryHelpDialog::OnFinish(wxCommandEvent& event) void wxCDMLibraryHelpDialog::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->library->OpenCMakeListsFile(result)) + wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED); + + if(this->library->GetCMakeLists() != NULL) + { + newEvent->SetClientData(this->library->GetCMakeLists()); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT) + { + modelCDMIProjectTreeNode* node = this->library; + while (node != NULL && dynamic_cast(node) == NULL) + { + node = node->GetParent(); + } + if (node != NULL) + { + if(!((modelCDMLib*)node)->OpenCMakeListsFile(result)) + wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED); + + if(((modelCDMLib*)node)->GetCMakeLists() != NULL) + { + newEvent->SetClientData(((modelCDMLib*)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 wxCDMLibraryHelpDialog::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->library->GetCMakeLists() != NULL) + { + newEvent->SetClientData(this->library->GetCMakeLists()); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT) + { + modelCDMIProjectTreeNode* node = this->library; + while (node != NULL && dynamic_cast(node) == NULL) + { + node = node->GetParent(); + } + if (node != NULL) + { + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED); + + if(((modelCDMLib*)node)->GetCMakeLists() != NULL) + { + newEvent->SetClientData(((modelCDMLib*)node)->GetCMakeLists()); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + } event.Skip(); } void wxCDMLibraryHelpDialog::OnCMakeListsExit(wxMouseEvent& event) { - //TODO: implement method - std::cout << "OnCMakeListsExit not implemented yet." << std::endl; - event.Skip(); + if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_EDIT_CMAKELISTSFILE) + { + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED); + + if(this->library->GetCMakeLists() != NULL) + { + newEvent->SetClientData(this->library->GetCMakeLists()); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT) + { + modelCDMIProjectTreeNode* node = this->library; + while (node != NULL && dynamic_cast(node) == NULL) + { + node = node->GetParent(); + } + if (node != NULL) + { + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED); + + if(((modelCDMLib*)node)->GetCMakeLists() != NULL) + { + newEvent->SetClientData(((modelCDMLib*)node)->GetCMakeLists()); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + } + } + event.Skip(); } void wxCDMLibraryHelpDialog::OnDisableHelp(wxCommandEvent& event)