X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FwxCDMPackageManagerPanel.cpp;h=d7a28be83fcd02f4e64d4289fc6c4b9ddf67fa99;hb=0cc6a7e002ad79de9453517108d7456fd44ddfdb;hp=cc6b9fcf4d6b0033b9d6c8f8c7df71f69c908d99;hpb=11150e550ff03ee658e90cda4b475b4c24da0a7f;p=crea.git diff --git a/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp b/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp index cc6b9fc..d7a28be 100644 --- a/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp @@ -49,6 +49,7 @@ EVT_BUTTON(ID_BUTTON_CREATE_PACKAGE, wxCDMPackageManagerPanel::OnBtnCreatePackag EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_TOOL_CLICKED, wxCDMPackageManagerPanel::OnBtnCreatePackage) EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMPackageManagerPanel::OnBtnEditCMakeLists) EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_TOOL_ENTER, wxCDMPackageManagerPanel::OnBtnEditCMakeLists) +EVT_CHECKBOX(ID_CHECK_INCLUDE_PACKAGE, wxCDMPackageManagerPanel::OnChBPackageChange) END_EVENT_TABLE() wxCDMPackageManagerPanel::wxCDMPackageManagerPanel( @@ -81,6 +82,9 @@ bool wxCDMPackageManagerPanel::Create( wxPanel::Create(parent, id, pos, size, style); this->project = project; CreateControls(); + // this part makes the scrollbars show up + this->FitInside(); // ask the sizer about the needed size + this->SetScrollRate(5, 5); return TRUE; } @@ -89,7 +93,8 @@ void wxCDMPackageManagerPanel::CreateControls() wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); //Link to return - wxHyperlinkCtrl* returnLnk = new wxHyperlinkCtrl(this, ID_BUTTON_PREV, crea::std2wx(this->project->GetName()), crea::std2wx(this->project->GetPath())); + wxHyperlinkCtrl* returnLnk = new wxHyperlinkCtrl(this, ID_BUTTON_PREV, crea::std2wx(this->project->GetName()), crea::std2wx(this->project->GetPath()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE); + returnLnk->SetWindowStyle(wxNO_BORDER); returnLnk->SetToolTip(wxT("Return to the active project description.")); sizer->Add(returnLnk, 0, wxALIGN_CENTER | wxALL, 5); @@ -110,22 +115,54 @@ void wxCDMPackageManagerPanel::CreateControls() wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("A&vailable Packages")); propertiesBox->GetStaticBox()->SetToolTip(wxT("Select any of the available packages to see its details or modify them. Remember that black boxes are created inside packages, any of these packages is available.")); wxPanel* propertiesPanel = new wxPanel(this); - wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL); std::vector packages = this->project->GetPackages(); - for (int i = 0; i < packages.size(); i++) + wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(packages.size()+1, 3, 9, 5); + + wxStaticText* ChBTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Include in\nCMake"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL); + wxStaticText* LkTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Package Name"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL); + wxStaticText* HlpTitle = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Help"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL); + + propertiesGridSizer -> Add(ChBTitle, 0, wxEXPAND | wxALL, 5); + propertiesGridSizer -> Add(LkTitle, 0, wxEXPAND | wxALL, 5); + propertiesGridSizer -> Add(HlpTitle, 0, wxEXPAND | wxALL, 5); + + for (int i = 0; i < (int)(packages.size()); i++) { - wxHyperlinkCtrl* pPackagelk = new wxHyperlinkCtrl(propertiesPanel,ID_LINK_SELECT_PACKAGE, crea::std2wx(packages[i]->GetName().c_str()), crea::std2wx(packages[i]->GetName().c_str())); - pPackagelk->SetWindowStyle(wxALIGN_LEFT); - std::string tt = "Author: " + packages[i]->GetAuthors() + "\nDescription: " + packages[i]->GetDescription(); + //checkbox for cmake inclusion + wxCheckBox* pPackageChB = new wxCheckBox(propertiesPanel, ID_CHECK_INCLUDE_PACKAGE, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); + pPackageChB->SetName(crea::std2wx(packages[i]->GetName())); + std::string tt = "if this box is checked the the " + packages[i]->GetName() + " package is included in the project compilation."; + pPackageChB->SetToolTip(crea::std2wx(tt)); + pPackageChB->SetValue(this->project->IsPackageIncluded(packages[i]->GetName())); + propertiesGridSizer -> Add(pPackageChB, 0, wxEXPAND | wxALIGN_CENTER); + + //link to package with description + wxHyperlinkCtrl* pPackagelk = new wxHyperlinkCtrl(propertiesPanel, ID_LINK_SELECT_PACKAGE, crea::std2wx(packages[i]->GetName().c_str()), crea::std2wx(packages[i]->GetName().c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE); + pPackagelk->SetWindowStyle(wxALIGN_LEFT | wxNO_BORDER); + tt = "Name: " + packages[i]->GetName() + "\n"; + tt += "Location: " + packages[i]->GetPath(); pPackagelk->SetToolTip(crea::std2wx(tt)); - propertiesPanelSizer -> Add(pPackagelk, 0, wxEXPAND | wxALL, 5); pPackagelk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerPanel::OnMouseEnter,NULL,this); pPackagelk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerPanel::OnMouseExit,NULL,this); + propertiesGridSizer -> Add(pPackagelk, 0, wxEXPAND); + + //help icon + wxButton* pPackageHlp = new wxButton(propertiesPanel, wxID_ANY, wxT("?"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); + pPackageHlp->Enable(false); + tt = "When this package is included in the CMakeLists file, the\nfollowing line is included in the CMakeList.txt file in the\nproject folder:\n" + "ADD_SUBDIRECTORY(" + packages[i]->GetName() + ")"; + pPackageHlp->SetToolTip(crea::std2wx(tt)); + + propertiesGridSizer -> Add(pPackageHlp, 0, wxEXPAND | wxALIGN_CENTER); } - propertiesPanel->SetSizer(propertiesPanelSizer); - propertiesPanelSizer->Fit(propertiesPanel); + propertiesGridSizer->AddGrowableCol(1,1); + + propertiesPanel->SetSizer(propertiesGridSizer); + propertiesGridSizer->Fit(propertiesPanel); + + propertiesBox->Add(propertiesPanel, 1, wxALL | wxEXPAND, 5); sizer -> Add(propertiesBox, 0, wxEXPAND | wxALL, 10); @@ -141,7 +178,7 @@ void wxCDMPackageManagerPanel::CreateControls() wxButton* createPkgbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_PACKAGE, _T("A. Create Package")); createPkgbt->SetToolTip(wxT("Create a new package for this project.")); actionsGridSizer->Add(createPkgbt, 1, wxALL | wxEXPAND, 5); - wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("B. Edit CMakeLists File")); + wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")); editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file of this project.")); editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerPanel::OnCMakeMouseEnter,NULL,this); editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerPanel::OnCMakeMouseExit,NULL,this); @@ -175,31 +212,39 @@ modelCDMProject* wxCDMPackageManagerPanel::GetProject() const void wxCDMPackageManagerPanel::OnBtnReturn(wxHyperlinkEvent& event) { wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED); - newEvent->SetInt(project->GetId()); + newEvent->SetClientData(project); newEvent->SetId(0); wxPostEvent(this->GetParent(), *newEvent); } +void wxCDMPackageManagerPanel::OnChBPackageChange(wxCommandEvent& event) +{ + this->project->SetPackageInclude( + crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()), + ((wxCheckBox*)event.GetEventObject())->GetValue() + ); +} + void wxCDMPackageManagerPanel::OnLnkPackageSelect(wxHyperlinkEvent& event) { - int packageId = 0; + modelCDMPackage* thePackage = NULL; std::vector packages = this->project->GetPackages(); - for (int i = 0; i < packages.size(); i++) + for (int i = 0; i < (int)(packages.size()); i++) { if(packages[i]->GetName() == crea::wx2std(event.GetURL())) { - packageId = packages[i]->GetId(); + thePackage = packages[i]; break; } } wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED); - newEvent->SetInt(packageId); + newEvent->SetClientData(thePackage); newEvent->SetId(0); wxPostEvent(this->GetParent(), *newEvent); - wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); - newEvent1->SetInt(packageId); + wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED); + newEvent1->SetClientData(thePackage); newEvent1->SetId(0); wxPostEvent(this->GetParent(), *newEvent1); @@ -237,7 +282,7 @@ void wxCDMPackageManagerPanel::OnBtnCreatePackage(wxCommandEvent& event) ((wxCDMMainFrame*)this->GetParent())->RefreshProject(); wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED); - newEvent->SetInt(package->GetId()); + newEvent->SetClientData(package); newEvent->SetId(0); wxPostEvent(this->GetParent(), *newEvent); event.Skip(); @@ -252,12 +297,11 @@ void wxCDMPackageManagerPanel::OnBtnEditCMakeLists(wxCommandEvent& event) if(!this->project->OpenCMakeListsFile(result)) wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); - wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED); if(this->project->GetCMakeLists() != NULL) { - int CMId = this->project->GetCMakeLists()->GetId(); - newEvent->SetInt(CMId); + newEvent->SetClientData(this->project->GetCMakeLists()); newEvent->SetId(0); wxPostEvent(this->GetParent(), *newEvent); } @@ -265,19 +309,19 @@ void wxCDMPackageManagerPanel::OnBtnEditCMakeLists(wxCommandEvent& event) void wxCDMPackageManagerPanel::OnMouseEnter(wxMouseEvent& event) { - wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED); std::string PkgName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL()); - int pkgId = 0; + modelCDMPackage* thePackage = NULL; std::vector packages = this->project->GetPackages(); - for (int i = 0; i < packages.size(); i++) + for (int i = 0; i < (int)(packages.size()); i++) { if(packages[i]->GetName() == PkgName) { - pkgId = packages[i]->GetId(); + thePackage = packages[i]; break; } } - newEvent->SetInt(pkgId); + newEvent->SetClientData(thePackage); newEvent->SetId(0); wxPostEvent(this->GetParent(), *newEvent); event.Skip(); @@ -285,20 +329,20 @@ void wxCDMPackageManagerPanel::OnMouseEnter(wxMouseEvent& event) void wxCDMPackageManagerPanel::OnMouseExit(wxMouseEvent& event) { - wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED); std::string PkgName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL()); - int pkgId = 0; + modelCDMPackage* thePackage = NULL; std::vector packages = this->project->GetPackages(); project->GetPackages(); - for (int i = 0; i < packages.size(); i++) + for (int i = 0; i < (int)(packages.size()); i++) { if(packages[i]->GetName() == PkgName) { - pkgId = packages[i]->GetId(); + thePackage = packages[i]; break; } } - newEvent->SetInt(pkgId); + newEvent->SetClientData(thePackage); newEvent->SetId(0); wxPostEvent(this->GetParent(), *newEvent); event.Skip(); @@ -306,12 +350,11 @@ void wxCDMPackageManagerPanel::OnMouseExit(wxMouseEvent& event) void wxCDMPackageManagerPanel::OnCMakeMouseEnter(wxMouseEvent& event) { - wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED); if(this->project->GetCMakeLists() != NULL) { - int CMId = this->project->GetCMakeLists()->GetId(); - newEvent->SetInt(CMId); + newEvent->SetClientData(this->project->GetCMakeLists()); newEvent->SetId(0); wxPostEvent(this->GetParent(), *newEvent); } @@ -320,12 +363,11 @@ void wxCDMPackageManagerPanel::OnCMakeMouseEnter(wxMouseEvent& event) void wxCDMPackageManagerPanel::OnCMakeMouseExit(wxMouseEvent& event) { - wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED); if(this->project->GetCMakeLists() != NULL) { - int CMId = this->project->GetCMakeLists()->GetId(); - newEvent->SetInt(CMId); + newEvent->SetClientData(this->project->GetCMakeLists()); newEvent->SetId(0); wxPostEvent(this->GetParent(), *newEvent); }