]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/wxCDMFileDescriptionPanel.cpp
Feature #1711 CreaDevManager application implementation
[crea.git] / lib / creaDevManagerLib / wxCDMFileDescriptionPanel.cpp
index efbc396135cb1cabe1000ed549668f7d6aa4ab2d..81768a97aaaded19ee78ee99074362f539c84998 100644 (file)
@@ -42,7 +42,7 @@
 #include "images/FlIcon64.xpm"
 
 BEGIN_EVENT_TABLE(wxCDMFileDescriptionPanel, wxPanel)
-EVT_BUTTON(ID_BUTTON_PREV, wxCDMFileDescriptionPanel::OnBtnReturn)
+EVT_HYPERLINK(ID_BUTTON_PREV, wxCDMFileDescriptionPanel::OnBtnReturn)
 EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMFileDescriptionPanel::OnBtnOpenFolder)
 EVT_BUTTON(ID_BUTTON_OPEN_COMMAND, wxCDMFileDescriptionPanel::OnBtnOpenWithCommand)
 END_EVENT_TABLE()
@@ -75,6 +75,10 @@ bool wxCDMFileDescriptionPanel::Create(
 )
 {
   wxPanel::Create(parent, id, pos, size, style);
+  // this part makes the scrollbars show up
+  this->FitInside(); // ask the sizer about the needed size
+  this->SetScrollRate(5, 5);
+
   this->file = file;
   CreateControls();
   return TRUE;
@@ -84,10 +88,21 @@ void wxCDMFileDescriptionPanel::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);
+  //Links to return
+  wxBoxSizer *linksSizer = new wxBoxSizer(wxHORIZONTAL);
+  std::vector<modelCDMIProjectTreeNode*> parents = this->file->GetParents();
+  for (int i = 0; i < (int)(parents.size()); i++)
+    {
+      wxHyperlinkCtrl* returnLnk = new wxHyperlinkCtrl(this, ID_BUTTON_PREV, crea::std2wx(parents[parents.size()-1-i]->GetName()), crea::std2wx(parents[parents.size()-1-i]->GetPath()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
+      returnLnk->SetWindowStyle(wxNO_BORDER);
+      returnLnk->SetToolTip(crea::std2wx("Return to " + parents[parents.size()-1-i]->GetName() + "."));
+      linksSizer->Add(returnLnk, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5);
+      linksSizer->Add(new wxStaticText(this,wxID_ANY, wxT("/")), 0, wxALIGN_CENTER, 0);
+    }
+
+  linksSizer->Add(new wxStaticText(this, wxID_ANY, crea::std2wx(this->file->GetName())), 0, wxALIGN_CENTER, 0);
+
+  sizer->Add(linksSizer, 0, wxALIGN_CENTER | wxALL, 5);
 
   //Header
   wxBoxSizer* headerSizer = new wxBoxSizer(wxHORIZONTAL);
@@ -113,16 +128,16 @@ void wxCDMFileDescriptionPanel::CreateControls()
   wxStaticText *pLength = new wxStaticText(propertiesPanel, -1, wxT("File Size"));
 
   wxStaticText* pLocationtc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->file->GetPath()));
-  pLocationtc->SetMaxSize(wxSize(350,-1));
+  pLocationtc->SetMaxSize(wxSize(300,-1));
   int lgth = this->file->GetLength();
   std::stringstream ss;
   ss << lgth / 1024;
   std::string lgths = ss.str() + " KB";
   wxStaticText* pLengthtc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(lgths));
 
-  propertiesGridSizer->Add(pLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  propertiesGridSizer->Add(pLocation, 0, wxALIGN_RIGHT | wxALIGN_TOP);
   propertiesGridSizer->Add(pLocationtc, 1, wxEXPAND);
-  propertiesGridSizer->Add(pLength, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  propertiesGridSizer->Add(pLength, 0, wxALIGN_RIGHT | wxALIGN_TOP);
   propertiesGridSizer->Add(pLengthtc, 1, wxEXPAND);
 
   propertiesGridSizer->AddGrowableCol(1,1);
@@ -130,7 +145,7 @@ void wxCDMFileDescriptionPanel::CreateControls()
   propertiesPanelSizer -> Add(propertiesGridSizer, 1, wxEXPAND);
   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);
 
@@ -163,12 +178,21 @@ void wxCDMFileDescriptionPanel::CreateControls()
   sizer->SetSizeHints(this);
 }
 
-void wxCDMFileDescriptionPanel::OnBtnReturn(wxCommandEvent& event)
+void wxCDMFileDescriptionPanel::OnBtnReturn(wxHyperlinkEvent& event)
 {
-  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
-  newEvent->SetInt(((wxCDMMainFrame*)this->GetParent())->GetModel()->GetProject()->GetId());
-  newEvent->SetId(0);
-  wxPostEvent(this->GetParent(), *newEvent);
+  std::vector<modelCDMIProjectTreeNode*> parents = this->file->GetParents();
+  std::string parentURL = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
+  //std::cout << parentURL << std::endl;
+  for (int i = 0; i < (int)(parents.size()); i++)
+    {
+      if (parents[i]->GetPath() == parentURL)
+        {
+          wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
+          newEvent->SetClientData(parents[i]);
+          newEvent->SetId(0);
+          wxPostEvent(this->GetParent(), *newEvent);
+        }
+    }
 }
 
 void wxCDMFileDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)