2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
29 * wxCDMBBGFileDescriptionPanel.cpp
31 * Created on: Jun 27, 2013
32 * Author: Daniel Felipe Gonzalez Obando
35 #include "wxCDMBBGFileDescriptionPanel.h"
37 #include "wxCDMMainFrame.h"
39 #include "creaDevManagerIds.h"
40 #include "images/BBGIcon64.xpm"
42 BEGIN_EVENT_TABLE(wxCDMBBGFileDescriptionPanel, wxPanel)
43 EVT_HYPERLINK(ID_BUTTON_PREV, wxCDMBBGFileDescriptionPanel::OnBtnReturn)
44 EVT_BUTTON(ID_BUTTON_OPEN_FILE, wxCDMBBGFileDescriptionPanel::OnBtnOpenInEditor)
45 EVT_BUTTON(ID_BUTTON_OPEN_COMMAND, wxCDMBBGFileDescriptionPanel::OnBtnOpenInBBEditor)
46 EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMBBGFileDescriptionPanel::OnBtnOpenFolder)
49 wxCDMBBGFileDescriptionPanel::wxCDMBBGFileDescriptionPanel(
51 modelCDMBBGFile* bbgfile,
53 const wxString& caption,
59 wxCDMBBGFileDescriptionPanel::Create(parent, bbgfile, id, caption, pos, size, style);
62 wxCDMBBGFileDescriptionPanel::~wxCDMBBGFileDescriptionPanel()
66 bool wxCDMBBGFileDescriptionPanel::Create(
68 modelCDMBBGFile* bbgfile,
70 const wxString& caption,
76 wxPanel::Create(parent, id, pos, size, style);
77 this->bbgFile = bbgfile;
79 // this part makes the scrollbars show up
80 this->FitInside(); // ask the sizer about the needed size
81 this->SetScrollRate(5, 5);
85 void wxCDMBBGFileDescriptionPanel::CreateControls()
87 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
90 wxBoxSizer *linksSizer = new wxBoxSizer(wxHORIZONTAL);
91 std::vector<modelCDMIProjectTreeNode*> parents = this->bbgFile->GetParents();
92 for (int i = 0; i < (int)(parents.size()); i++)
94 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);
95 returnLnk->SetWindowStyle(wxNO_BORDER);
96 returnLnk->SetToolTip(crea::std2wx("Return to " + parents[parents.size()-1-i]->GetName() + "."));
97 linksSizer->Add(returnLnk, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5);
98 linksSizer->Add(new wxStaticText(this,wxID_ANY, wxT("/")), 0, wxALIGN_CENTER, 0);
101 linksSizer->Add(new wxStaticText(this, wxID_ANY, crea::std2wx(this->bbgFile->GetName())), 0, wxALIGN_CENTER, 0);
103 sizer->Add(linksSizer, 0, wxALIGN_CENTER | wxALL, 5);
106 wxBoxSizer* headerSizer = new wxBoxSizer(wxHORIZONTAL);
109 headerSizer->Add(new wxStaticBitmap(this, -1, wxBitmap(BBGIcon64)),0, wxALIGN_CENTER, 0);
110 wxBoxSizer* textSizer = new wxBoxSizer(wxVERTICAL);
112 textSizer->Add(new wxStaticText(this, -1, _("BBG Script File")),0, wxALIGN_LEFT, 0);
114 textSizer->Add(new wxStaticText(this, -1, crea::std2wx(this->bbgFile->GetName())),0, wxALIGN_LEFT, 0);
115 headerSizer->Add(textSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
117 sizer->Add(headerSizer, 0, wxALIGN_CENTER);
120 wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Actions"));
121 wxPanel* actionsPanel = new wxPanel(this);
122 wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
124 wxFlexGridSizer* actionsGridSizer = new wxFlexGridSizer(2, 2, 9, 15);
126 wxButton* executeScriptbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_COMMAND, _T("Open in BBEditor"));
127 executeScriptbt->SetToolTip(wxT("Edit the BBG file using bbEditor."));
128 actionsGridSizer->Add(executeScriptbt, 1, wxALL | wxEXPAND, 5);
129 wxButton* editScriptbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FILE, _T("Edit File"));
130 editScriptbt->SetToolTip(wxT("Edit the BBG file in the default text editor."));
131 actionsGridSizer->Add(editScriptbt, 1, wxALL | wxEXPAND, 5);
132 wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Containing Folder"));
133 openFolderbt->SetToolTip(wxT("Open the folder where the BBG file is located in the file explorer."));
134 actionsGridSizer->Add(openFolderbt, 1, wxALL | wxEXPAND, 5);
136 actionsGridSizer->AddGrowableCol(0,1);
137 actionsGridSizer->AddGrowableCol(1,1);
139 actionsPanelSizer->Add(actionsGridSizer, 1, wxEXPAND, 0);
140 actionsPanel->SetSizer(actionsPanelSizer);
141 actionsPanelSizer->Fit(actionsPanel);
142 actionsBox->Add(actionsPanel, 1, wxEXPAND);
143 sizer -> Add(actionsBox, 0, wxEXPAND | wxALL, 10);
147 sizer->SetSizeHints(this);
150 void wxCDMBBGFileDescriptionPanel::OnBtnReturn(wxHyperlinkEvent& event)
152 std::vector<modelCDMIProjectTreeNode*> parents = this->bbgFile->GetParents();
153 std::string parentURL = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
154 //std::cout << parentURL << std::endl;
155 for (int i = 0; i < (int)(parents.size()); i++)
157 if (parents[i]->GetPath() == parentURL)
159 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
160 newEvent->SetClientData(parents[i]);
162 wxPostEvent(this->GetParent(), *newEvent);
167 void wxCDMBBGFileDescriptionPanel::OnBtnOpenInEditor(wxCommandEvent& event)
170 if(!this->bbgFile->OpenFile(result))
171 wxMessageBox(crea::std2wx(*result),_T("Open BBG File - Error!"),wxOK | wxICON_ERROR);
175 wxCDMBBGFileDescriptionPanel::OnBtnOpenInBBEditor(wxCommandEvent& event)
178 std::string params = "";
179 if(!this->bbgFile->EditFile(result, params))
181 wxMessageBox(crea::std2wx(*result),_T("Edit BBG File - Error!"),wxOK | wxICON_ERROR);
185 void wxCDMBBGFileDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
188 if(!this->bbgFile->OpenInFileExplorer(result))
189 wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);