X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FwxCDMLibDescriptionPanel.cpp;h=d31f2b2ba51f399fdd306e3d6e8588085510ecfd;hb=311bdcc514f85386f3bbbef9ff6a88bf69fd930f;hp=653c769e1baaeb3fc62ff1ab86b5484f00fbcba1;hpb=5413640f931dc9bc9b3c24a27f42c3cf40c35072;p=crea.git diff --git a/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp index 653c769..d31f2b2 100644 --- a/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp @@ -44,6 +44,7 @@ EVT_BUTTON(ID_BUTTON_PREV, wxCDMLibDescriptionPanel::OnBtnReturn) EVT_HYPERLINK(ID_LINK_SELECT_LIBRARY, wxCDMLibDescriptionPanel::OnLnkLibrarySelect) EVT_BUTTON(ID_BUTTON_CREATE_LIBRARY, wxCDMLibDescriptionPanel::OnBtnCreateLibrary) EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMLibDescriptionPanel::OnBtnEditCMakeLists) +EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMLibDescriptionPanel::OnBtnOpenFolder) END_EVENT_TABLE() wxCDMLibDescriptionPanel::wxCDMLibDescriptionPanel( @@ -84,7 +85,9 @@ void wxCDMLibDescriptionPanel::CreateControls() wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); //Link to return - sizer->Add(new wxButton(this, ID_BUTTON_PREV, wxT("Return to project")), 0, wxALIGN_CENTER | wxALL, 5); + wxButton* returnbt = new wxButton(this, ID_BUTTON_PREV, wxT("Return to project")); + returnbt->SetToolTip(wxT("Return to the active project description.")); + sizer->Add(returnbt, 0, wxALIGN_CENTER | wxALL, 5); //Title sizer->Add(new wxStaticText(this, -1, _("Library Management")),0, wxALIGN_CENTER, 0); @@ -93,29 +96,52 @@ void wxCDMLibDescriptionPanel::CreateControls() sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(LbIcon64)),0, wxALIGN_CENTER, 0); //Libraries - wxStaticBox* propertiesBox = new wxStaticBox(this, -1, _T("&Available Libraries")); - wxStaticBoxSizer* propertiesBoxInnerSizer = new wxStaticBoxSizer(propertiesBox, wxVERTICAL); + wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("A&vailable Libraries")); + propertiesBox->GetStaticBox()->SetToolTip(wxT("Select any of the available libraries to see its details or modify them.")); + wxPanel* propertiesPanel = new wxPanel(this); + wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL); std::vector libraries = this->lib->GetLibraries(); for (int i = 0; i < libraries.size(); i++) { - wxHyperlinkCtrl* pLibrarylk = new wxHyperlinkCtrl(this,ID_LINK_SELECT_LIBRARY, crea::std2wx(libraries[i]->GetName().c_str()), crea::std2wx(libraries[i]->GetName().c_str())); - propertiesBoxInnerSizer -> Add(pLibrarylk, 0, wxALIGN_LEFT | wxALL, 5); + wxHyperlinkCtrl* pLibrarylk = new wxHyperlinkCtrl(propertiesPanel, ID_LINK_SELECT_LIBRARY, crea::std2wx(libraries[i]->GetName().c_str()), crea::std2wx(libraries[i]->GetName().c_str())); + std::string tt = "Name: " + libraries[i]->GetName() + "\n"; + tt += "Location: " + libraries[i]->GetPath(); + pLibrarylk->SetToolTip(crea::std2wx(tt.c_str())); + pLibrarylk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnMouseEnter,NULL,this); + pLibrarylk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnMouseExit,NULL,this); + propertiesPanelSizer -> Add(pLibrarylk, 0, wxALIGN_LEFT | wxALL, 5); } - sizer -> Add(propertiesBoxInnerSizer, 0, wxEXPAND | wxALL, 10); + propertiesPanel->SetSizer(propertiesPanelSizer); + propertiesPanelSizer->Fit(propertiesPanel); + propertiesBox->Add(propertiesPanel, 0, wxALL, 5); + sizer -> Add(propertiesBox, 0, wxEXPAND | wxALL, 10); //Actions - wxStaticBox* actionsBox = new wxStaticBox(this, -1, _T("&Actions")); - wxStaticBoxSizer* actionsBoxInnerSizer = new wxStaticBoxSizer(actionsBox, wxVERTICAL); - sizer -> Add(actionsBoxInnerSizer, 1, wxEXPAND | wxALL, 20); + wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("&Actions")); + actionsBox->GetStaticBox()->SetToolTip(wxT("Create a new library or make any change to the lib's CMakeLists.txt file by selecting the desired action.")); + wxPanel* actionsPanel = new wxPanel(this); + wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL); - actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_CREATE_LIBRARY, _T("Create Library")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20); - actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20); + wxButton* createLibrarybt = new wxButton(actionsPanel, ID_BUTTON_CREATE_LIBRARY, _T("Create Library")); + createLibrarybt->SetToolTip(wxT("Create a new library for this project.")); + actionsPanelSizer->Add(createLibrarybt, 0, wxALL, 5); + wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")); + editCMakebt->SetToolTip(wxT("Open the system default text editor to edit the Lib's CMakeLists.txt file.")); + editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnCMakeMouseEnter,NULL,this); + editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnCMakeMouseExit,NULL,this); + actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5); + wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Libraries Folder")); + openFolderbt->SetToolTip(wxT("Open the lib folder in the file explorer.")); + actionsPanelSizer->Add(openFolderbt, 0, wxALL, 5); - //Assign sizer - actionsBoxInnerSizer->SetSizeHints(this); + actionsPanel->SetSizer(actionsPanelSizer); + actionsPanelSizer->Fit(actionsPanel); + actionsBox->Add(actionsPanel, 0, wxALL, 5); + sizer -> Add(actionsBox, 0, wxEXPAND | wxALL, 10); + //Assign sizer SetSizer(sizer); sizer->SetSizeHints(this); } @@ -155,9 +181,19 @@ void wxCDMLibDescriptionPanel::OnBtnCreateLibrary(wxCommandEvent& event) void wxCDMLibDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnEditCMakeLists not implemented" << std::endl; - event.Skip(); + std::string* result; + if(!this->lib->OpenCMakeListsFile(result)) + wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(this->lib->GetCMakeLists() != NULL) + { + int CMId = this->lib->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } } void wxCDMLibDescriptionPanel::OnLnkLibrarySelect(wxHyperlinkEvent& event) @@ -178,6 +214,11 @@ void wxCDMLibDescriptionPanel::OnLnkLibrarySelect(wxHyperlinkEvent& event) newEvent->SetId(0); wxPostEvent(this->GetParent(), *newEvent); + wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + newEvent1->SetInt(libraryId); + newEvent1->SetId(0); + wxPostEvent(this->GetParent(), *newEvent1); + } void wxCDMLibDescriptionPanel::OnBtnReturn(wxCommandEvent& event) @@ -187,3 +228,78 @@ void wxCDMLibDescriptionPanel::OnBtnReturn(wxCommandEvent& event) newEvent->SetId(0); wxPostEvent(this->GetParent(), *newEvent); } + +void wxCDMLibDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) +{ + std::string* result; + if(!this->lib->OpenInFileExplorer(result)) + wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR); +} + +void wxCDMLibDescriptionPanel::OnMouseEnter(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + std::string LibName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL()); + int lbId = 0; + std::vector libraries = this->lib->GetLibraries(); + for (int i = 0; i < libraries.size(); i++) + { + if(libraries[i]->GetName() == LibName) + { + lbId = libraries[i]->GetId(); + break; + } + } + newEvent->SetInt(lbId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + event.Skip(); +} + +void wxCDMLibDescriptionPanel::OnMouseExit(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + std::string LibName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL()); + int lbId = 0; + std::vector libraries = this->lib->GetLibraries(); + for (int i = 0; i < libraries.size(); i++) + { + if(libraries[i]->GetName() == LibName) + { + lbId = libraries[i]->GetId(); + break; + } + } + newEvent->SetInt(lbId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + event.Skip(); +} + +void wxCDMLibDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + + if(this->lib->GetCMakeLists() != NULL) + { + int CMId = this->lib->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + event.Skip(); +} + +void wxCDMLibDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(this->lib->GetCMakeLists() != NULL) + { + int CMId = this->lib->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + event.Skip(); +}