]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / wxCDMBlackBoxDescriptionPanel.cpp
index f04d5afe33c5ad2df4b4914efcf9e19a27308cbe..1303e9538ba0160a2ae4c4b44717e7c4b7245eef 100644 (file)
 
 #include "wxCDMBlackBoxDescriptionPanel.h"
 
+#include "wxCDMMainFrame.h"
+
 #include "creaDevManagerIds.h"
 #include "images/BBIcon64.xpm"
 
 BEGIN_EVENT_TABLE(wxCDMBlackBoxDescriptionPanel, wxPanel)
+EVT_BUTTON(ID_BUTTON_PREV, wxCDMBlackBoxDescriptionPanel::OnBtnReturn)
 EVT_MENU(ID_BUTTON_OPEN_CXX, wxCDMBlackBoxDescriptionPanel::OnBtnOpenCxx)
 EVT_MENU(ID_BUTTON_OPEN_HXX, wxCDMBlackBoxDescriptionPanel::OnBtnOpenHxx)
+EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMBlackBoxDescriptionPanel::OnBtnOpenFolder)
 END_EVENT_TABLE()
 
 wxCDMBlackBoxDescriptionPanel::wxCDMBlackBoxDescriptionPanel(
@@ -79,6 +83,11 @@ void wxCDMBlackBoxDescriptionPanel::CreateControls()
 {
   wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
 
+  //Link to return
+  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);
+
   //Welcome
   sizer->Add(new wxStaticText(this, -1, _("Black Box")),0, wxALIGN_CENTER, 0);
 
@@ -89,49 +98,100 @@ void wxCDMBlackBoxDescriptionPanel::CreateControls()
   sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->blackBox->GetNameBlackBox())),0, wxALIGN_CENTER, 0);
 
   //BlackBox Properties
-    wxStaticBox* propertiesBox = new wxStaticBox(this, -1, _T("&Properties"));
-    wxStaticBoxSizer* propertiesBoxInnerSizer = new wxStaticBoxSizer(propertiesBox, wxVERTICAL);
-
-    wxFlexGridSizer* flexGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
-
-    wxStaticText *pAuthor = new wxStaticText(this, -1, wxT("Author"));
-    wxStaticText *pAuthorEmail = new wxStaticText(this, -1, wxT("Author E-mail"));
-    wxStaticText *pCategories = new wxStaticText(this, -1, wxT("Categories"));
-    wxStaticText *pDescription = new wxStaticText(this, -1, wxT("Description"));
-
-    wxTextCtrl *pAuthortc = new wxTextCtrl(this, -1, crea::std2wx(this->blackBox->GetAuthors()));
-    wxTextCtrl *pAuthorEmailtc = new wxTextCtrl(this, -1, crea::std2wx(this->blackBox->GetAuthorsEmail()));
-    wxTextCtrl *pCategoriestc = new wxTextCtrl(this, -1, crea::std2wx(this->blackBox->GetCategories()));
-    wxTextCtrl *pDescriptiontc = new wxTextCtrl(this, -1, crea::std2wx(this->blackBox->GetDescription()));
-
-    flexGridSizer->Add(pAuthor, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
-    flexGridSizer->Add(pAuthortc, 1, wxEXPAND);
-    flexGridSizer->Add(pAuthorEmail, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
-    flexGridSizer->Add(pAuthorEmailtc, 1, wxEXPAND);
-    flexGridSizer->Add(pCategories, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
-    flexGridSizer->Add(pCategoriestc, 1, wxEXPAND);
-    flexGridSizer->Add(pDescription, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
-    flexGridSizer->Add(pDescriptiontc, 1, wxEXPAND);
-
-    propertiesBoxInnerSizer -> Add(flexGridSizer, 0, wxEXPAND);
-    sizer -> Add(propertiesBoxInnerSizer, 1, wxEXPAND | wxALL, 20);
+  wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("&Properties"));
+  wxPanel* propertiesPanel = new wxPanel(this);
+  wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
+  wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
+
+  wxStaticText *pAuthor = new wxStaticText(propertiesPanel, -1, wxT("Author"));
+  wxStaticText *pVersion = new wxStaticText(propertiesPanel, -1, wxT("Version"));
+  wxStaticText *pDescription = new wxStaticText(propertiesPanel, -1, wxT("Description"));
+  wxStaticText *pCategories = new wxStaticText(propertiesPanel, -1, wxT("Categories"));
+
+  // author
+  wxBoxSizer* pAuthorsz = new wxBoxSizer(wxHORIZONTAL);
+  wxStaticText* pAuthortc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetAuthors()));
+  wxButton* pAuthorbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Change"));
+  pAuthorbt->SetToolTip(wxT("Update the author/s of the package."));
+  pAuthorsz->Add(pAuthortc, 0, wxALIGN_CENTER_VERTICAL, 0);
+  pAuthorsz->Add(pAuthorbt, 0, wxALIGN_CENTER | wxLEFT, 10);
+
+  // version
+  wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL);
+  wxStaticText* pVersiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetVersion()));
+  wxButton* pVersionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set"));
+  pVersionbt->SetToolTip(wxT("Update the version of the package."));
+  pVersionsz->Add(pVersiontc, 0, wxALIGN_CENTER_VERTICAL, 0);
+  pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER | wxLEFT, 10);
+
+  // description
+  wxBoxSizer* pDescriptionsz = new wxBoxSizer(wxHORIZONTAL);
+  wxStaticText* pDescriptiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetDescription()));
+  wxButton* pDescriptionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Change"));
+  pDescriptionbt->SetToolTip(wxT("Update the description of the project."));
+  pDescriptionsz->Add(pDescriptiontc, 0, wxALIGN_CENTER_VERTICAL, 0);
+  pDescriptionsz->Add(pDescriptionbt, 0, wxALIGN_CENTER | wxLEFT, 10);
+
+  // categories
+  wxBoxSizer* pCategoriessz = new wxBoxSizer(wxHORIZONTAL);
+  wxStaticText* pCategoriestc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetCategories()));
+  wxButton* pCategoriesbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Change"));
+  pCategoriesbt->SetToolTip(wxT("Update the categories of the project."));
+  pCategoriessz->Add(pCategoriestc, 0, wxALIGN_CENTER_VERTICAL, 0);
+  pCategoriessz->Add(pCategoriesbt, 0, wxALIGN_CENTER | wxLEFT, 10);
+
+  propertiesGridSizer->Add(pAuthor, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  propertiesGridSizer->Add(pAuthorsz, 1, wxEXPAND);
+  propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND);
+  propertiesGridSizer->Add(pDescription, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  propertiesGridSizer->Add(pDescriptionsz, 1, wxEXPAND);
+  propertiesGridSizer->Add(pCategories, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  propertiesGridSizer->Add(pCategoriessz, 1, wxEXPAND);
+
+  propertiesGridSizer->AddGrowableCol(1,1);
+
+  propertiesPanelSizer -> Add(propertiesGridSizer, 1, wxEXPAND);
+  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);
-
-  actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_OPEN_CXX, _T("Open Cxx")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20);
-  actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_OPEN_HXX, _T("Open Hxx")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20);
+  wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Actions"));
+  wxPanel* actionsPanel = new wxPanel(this);
+  wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
+
+  wxButton* openCxxbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_CXX, _T("Open Cxx"));
+  openCxxbt->SetToolTip(wxT("Open the .cxx file in the default text editor."));
+  actionsPanelSizer->Add(openCxxbt, 0, wxALL, 5);
+  wxButton* openHxxbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_CXX, _T("Open Hxx"));
+  openHxxbt->SetToolTip(wxT("Open the .hxx file in the default text editor."));
+  actionsPanelSizer->Add(openHxxbt, 0, wxALL, 5);
+  wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Package Folder"));
+  openFolderbt->SetToolTip(wxT("Open the package folder in the file explorer."));
+  actionsPanelSizer->Add(openFolderbt, 0, wxALL, 5);
+
+  actionsPanel->SetSizer(actionsPanelSizer);
+  actionsPanelSizer->Fit(actionsPanel);
+  actionsBox->Add(actionsPanel, 0, wxEXPAND);
+  sizer -> Add(actionsBox, 0, wxEXPAND | wxALL, 10);
 
   //Assign sizer
-  actionsBoxInnerSizer->SetSizeHints(this);
-
   SetSizer(sizer);
   sizer->SetSizeHints(this);
 }
 
+void wxCDMBlackBoxDescriptionPanel::OnBtnReturn(wxCommandEvent& event)
+{
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
+  newEvent->SetInt(((wxCDMMainFrame*)this->GetParent())->GetModel()->GetProject()->GetId());
+  newEvent->SetId(0);
+  wxPostEvent(this->GetParent(), *newEvent);
+}
+
 void wxCDMBlackBoxDescriptionPanel::OnBtnOpenCxx(wxCommandEvent& event)
 {
   //TODO: implement method
@@ -145,3 +205,10 @@ void wxCDMBlackBoxDescriptionPanel::OnBtnOpenHxx(wxCommandEvent& event)
   std::cerr << "Event OnBtnOpenHxx not implemented" << std::endl;
   event.Skip();
 }
+
+void wxCDMBlackBoxDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
+{
+  //TODO: implement method
+  std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl;
+  event.Skip();
+}