]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp
Feature #1711 CreaDevManager application implementation
[crea.git] / lib / creaDevManagerLib / wxCDMPackageManagerPanel.cpp
index 3176c561b57561280a9a610b53527208e755b2eb..c7d0d778821b4749822ea380943725594c4981ad 100644 (file)
@@ -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,49 @@ 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<modelCDMPackage*> packages = this->project->GetPackages();
+  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);
+      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 +173,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);
@@ -180,6 +212,14 @@ void wxCDMPackageManagerPanel::OnBtnReturn(wxHyperlinkEvent& event)
   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)
 {
   modelCDMPackage* thePackage = NULL;