X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FwxCDMLibDescriptionPanel.cpp;h=6167c17ac1fa2a17253d453e531ae2dae3bc25c7;hb=752294dd30e2ee94f38be513d441f4716509ce13;hp=88d598bc6141a0cc585a30a426c198735bee3c95;hpb=036496dbec6fb28a616b9fa5b4d5b80f72fb040f;p=crea.git diff --git a/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp index 88d598b..6167c17 100644 --- a/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp @@ -36,6 +36,8 @@ #include "wxCDMMainFrame.h" +#include "wxCDMLibHelpDialog.h" + #include "creaDevManagerIds.h" #include "images/LbIcon64.xpm" @@ -88,12 +90,17 @@ void wxCDMLibDescriptionPanel::CreateControls() 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); - - //Image - sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(LbIcon64)),0, wxALIGN_CENTER, 0); + //Header + wxBoxSizer* headerSizer = new wxBoxSizer(wxHORIZONTAL); + { + //Image + headerSizer->Add(new wxStaticBitmap(this, -1, wxBitmap(LbIcon64)),0, wxALIGN_CENTER, 0); + wxBoxSizer* textSizer = new wxBoxSizer(wxVERTICAL); + //Title + textSizer->Add(new wxStaticText(this, -1, _("Library Management")),0, wxALIGN_LEFT, 0); + headerSizer->Add(textSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); + } + sizer->Add(headerSizer, 0, wxALIGN_CENTER); //Libraries wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("A&vailable Libraries")); @@ -105,17 +112,18 @@ void wxCDMLibDescriptionPanel::CreateControls() for (int i = 0; i < libraries.size(); i++) { wxHyperlinkCtrl* pLibrarylk = new wxHyperlinkCtrl(propertiesPanel, ID_LINK_SELECT_LIBRARY, crea::std2wx(libraries[i]->GetName().c_str()), crea::std2wx(libraries[i]->GetName().c_str())); + pLibrarylk->SetWindowStyle(wxALIGN_LEFT); 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); + propertiesPanelSizer -> Add(pLibrarylk, 0, wxEXPAND | wxALL, 5); } propertiesPanel->SetSizer(propertiesPanelSizer); propertiesPanelSizer->Fit(propertiesPanel); - propertiesBox->Add(propertiesPanel, 0, wxALL, 5); + propertiesBox->Add(propertiesPanel, 1, wxALL | wxEXPAND, 5); sizer -> Add(propertiesBox, 0, wxEXPAND | wxALL, 10); //Actions @@ -124,15 +132,25 @@ void wxCDMLibDescriptionPanel::CreateControls() wxPanel* actionsPanel = new wxPanel(this); wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL); - wxButton* createLibrarybt = new wxButton(actionsPanel, ID_BUTTON_CREATE_LIBRARY, _T("Create Library")); + //actionsGrid Sizer + wxFlexGridSizer* actionsGridSizer = new wxFlexGridSizer(2, 2, 9, 15); + + wxButton* createLibrarybt = new wxButton(actionsPanel, ID_BUTTON_CREATE_LIBRARY, _T("A. 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")); + actionsGridSizer->Add(createLibrarybt, 1, wxALL | wxEXPAND, 5); + wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("B. Edit CMakeLists File")); editCMakebt->SetToolTip(wxT("Open the system default text editor to edit the Lib's CMakeLists.txt file.")); - actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5); - wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Libraries Folder")); + editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnCMakeMouseEnter,NULL,this); + editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnCMakeMouseExit,NULL,this); + actionsGridSizer->Add(editCMakebt, 1, wxALL | wxEXPAND, 5); + wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("C. Open Libraries Folder")); openFolderbt->SetToolTip(wxT("Open the lib folder in the file explorer.")); - actionsPanelSizer->Add(openFolderbt, 0, wxALL, 5); + actionsGridSizer->Add(openFolderbt, 1, wxALL | wxEXPAND, 5); + + actionsGridSizer->AddGrowableCol(0,1); + actionsGridSizer->AddGrowableCol(1,1); + + actionsPanelSizer->Add(actionsGridSizer, 1, wxEXPAND, 0); actionsPanel->SetSizer(actionsPanelSizer); actionsPanelSizer->Fit(actionsPanel); @@ -142,6 +160,12 @@ void wxCDMLibDescriptionPanel::CreateControls() //Assign sizer SetSizer(sizer); sizer->SetSizeHints(this); + + if (((wxCDMMainFrame*)this->GetParent())->isHelp()) + { + wxCDMLibHelpDialog* helpDialog = new wxCDMLibHelpDialog(this->GetParent(), this->lib, wxID_ANY); + helpDialog->Show(true); + } } void wxCDMLibDescriptionPanel::OnBtnCreateLibrary(wxCommandEvent& event) @@ -179,9 +203,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) @@ -202,6 +236,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) @@ -214,9 +253,9 @@ void wxCDMLibDescriptionPanel::OnBtnReturn(wxCommandEvent& event) void wxCDMLibDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl; - event.Skip(); + std::string* result; + if(!this->lib->OpenInFileExplorer(result)) + wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR); } void wxCDMLibDescriptionPanel::OnMouseEnter(wxMouseEvent& event) @@ -258,3 +297,31 @@ void wxCDMLibDescriptionPanel::OnMouseExit(wxMouseEvent& event) 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(); +}