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 * wxCDMBlackBoxDescriptionPanel.cpp
31 * Created on: Nov 27, 2012
32 * Author: Daniel Felipe Gonzalez Obando
35 #include "wxCDMBlackBoxDescriptionPanel.h"
37 #include "wxCDMMainFrame.h"
39 #include "wxCDMBlackBoxHelpDialog.h"
41 #include "creaDevManagerIds.h"
42 #include "images/BBIcon64.xpm"
44 BEGIN_EVENT_TABLE(wxCDMBlackBoxDescriptionPanel, wxPanel)
45 EVT_BUTTON(ID_BUTTON_PREV, wxCDMBlackBoxDescriptionPanel::OnBtnReturn)
46 EVT_BUTTON(ID_BUTTON_SET_AUTHOR, wxCDMBlackBoxDescriptionPanel::OnBtnSetAuthor)
47 EVT_BUTTON(ID_BUTTON_SET_DESCRIPTION, wxCDMBlackBoxDescriptionPanel::OnBtnSetDescription)
48 EVT_BUTTON(ID_BUTTON_SET_CATEGORY, wxCDMBlackBoxDescriptionPanel::OnBtnSetCategories)
49 EVT_BUTTON(ID_BUTTON_OPEN_CXX, wxCDMBlackBoxDescriptionPanel::OnBtnOpenCxx)
50 EVT_BUTTON(ID_BUTTON_OPEN_HXX, wxCDMBlackBoxDescriptionPanel::OnBtnOpenHxx)
51 EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMBlackBoxDescriptionPanel::OnBtnOpenFolder)
54 wxCDMBlackBoxDescriptionPanel::wxCDMBlackBoxDescriptionPanel(
56 modelCDMBlackBox* blackBox,
58 const wxString& caption,
64 wxCDMBlackBoxDescriptionPanel::Create(parent, blackBox, id, caption, pos, size, style);
67 wxCDMBlackBoxDescriptionPanel::~wxCDMBlackBoxDescriptionPanel()
71 bool wxCDMBlackBoxDescriptionPanel::Create(
73 modelCDMBlackBox* blackBox,
75 const wxString& caption,
81 wxPanel::Create(parent, id, pos, size, style);
82 this->blackBox = blackBox;
87 void wxCDMBlackBoxDescriptionPanel::CreateControls()
89 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
92 wxButton* returnbt = new wxButton(this, ID_BUTTON_PREV, wxT("Return to project"));
93 returnbt->SetToolTip(wxT("Return to the active project description."));
94 sizer->Add(returnbt, 0, wxALIGN_CENTER | wxALL, 5);
97 sizer->Add(new wxStaticText(this, -1, _("Black Box")),0, wxALIGN_CENTER, 0);
100 sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(BBIcon64)),0, wxALIGN_CENTER, 0);
103 sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->blackBox->GetNameBlackBox())),0, wxALIGN_CENTER, 0);
105 //BlackBox Properties
106 wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("&Properties"));
107 wxPanel* propertiesPanel = new wxPanel(this);
108 wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
109 wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
111 wxStaticText *pAuthor = new wxStaticText(propertiesPanel, -1, wxT("Author"));
112 wxStaticText *pDescription = new wxStaticText(propertiesPanel, -1, wxT("Description"));
113 wxStaticText *pCategories = new wxStaticText(propertiesPanel, -1, wxT("Categories"));
116 wxBoxSizer* pAuthorsz = new wxBoxSizer(wxHORIZONTAL);
117 this->authortc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetAuthors()));
118 wxButton* pAuthorbt = new wxButton(propertiesPanel, ID_BUTTON_SET_AUTHOR, wxT("Change"));
119 pAuthorbt->SetToolTip(wxT("Update the author/s of the package."));
120 pAuthorsz->Add(this->authortc, 0, wxALIGN_CENTER_VERTICAL, 0);
121 pAuthorsz->Add(pAuthorbt, 0, wxALIGN_CENTER | wxLEFT, 10);
124 wxBoxSizer* pDescriptionsz = new wxBoxSizer(wxHORIZONTAL);
125 this->descriptiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetDescription()));
126 wxButton* pDescriptionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_DESCRIPTION, wxT("Change"));
127 pDescriptionbt->SetToolTip(wxT("Update the description of the project."));
128 pDescriptionsz->Add(this->descriptiontc, 0, wxALIGN_CENTER_VERTICAL, 0);
129 pDescriptionsz->Add(pDescriptionbt, 0, wxALIGN_CENTER | wxLEFT, 10);
132 wxBoxSizer* pCategoriessz = new wxBoxSizer(wxHORIZONTAL);
133 this->categoriestc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetCategories()));
134 wxButton* pCategoriesbt = new wxButton(propertiesPanel, ID_BUTTON_SET_CATEGORY, wxT("Change"));
135 pCategoriesbt->SetToolTip(wxT("Update the categories of the project."));
136 pCategoriessz->Add(this->categoriestc, 0, wxALIGN_CENTER_VERTICAL, 0);
137 pCategoriessz->Add(pCategoriesbt, 0, wxALIGN_CENTER | wxLEFT, 10);
139 propertiesGridSizer->Add(pAuthor, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
140 propertiesGridSizer->Add(pAuthorsz, 1, wxEXPAND);
141 propertiesGridSizer->Add(pDescription, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
142 propertiesGridSizer->Add(pDescriptionsz, 1, wxEXPAND);
143 propertiesGridSizer->Add(pCategories, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
144 propertiesGridSizer->Add(pCategoriessz, 1, wxEXPAND);
146 propertiesGridSizer->AddGrowableCol(1,1);
148 propertiesPanelSizer -> Add(propertiesGridSizer, 1, wxEXPAND);
149 propertiesPanel->SetSizer(propertiesPanelSizer);
150 propertiesPanelSizer->Fit(propertiesPanel);
151 propertiesBox->Add(propertiesPanel, 0, wxALL, 5);
153 sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
157 wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Actions"));
158 wxPanel* actionsPanel = new wxPanel(this);
159 wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
161 wxButton* openCxxbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_CXX, _T("Open .cxx"));
162 openCxxbt->SetToolTip(wxT("Open the .cxx file in the default text editor."));
163 actionsPanelSizer->Add(openCxxbt, 0, wxALL, 5);
164 wxButton* openHxxbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_HXX, _T("Open .h"));
165 openHxxbt->SetToolTip(wxT("Open the .h file in the default text editor."));
166 actionsPanelSizer->Add(openHxxbt, 0, wxALL, 5);
167 wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Source Folder"));
168 openFolderbt->SetToolTip(wxT("Open the source folder in the file explorer."));
169 actionsPanelSizer->Add(openFolderbt, 0, wxALL, 5);
171 actionsPanel->SetSizer(actionsPanelSizer);
172 actionsPanelSizer->Fit(actionsPanel);
173 actionsBox->Add(actionsPanel, 0, wxEXPAND);
174 sizer -> Add(actionsBox, 0, wxEXPAND | wxALL, 10);
178 sizer->SetSizeHints(this);
180 if (((wxCDMMainFrame*)this->GetParent())->isHelp())
182 wxCDMBlackBoxHelpDialog* helpDialog = new wxCDMBlackBoxHelpDialog(this->GetParent(), this->blackBox, wxID_ANY);
183 helpDialog->Show(true);
187 void wxCDMBlackBoxDescriptionPanel::OnBtnReturn(wxCommandEvent& event)
189 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
190 newEvent->SetInt(((wxCDMMainFrame*)this->GetParent())->GetModel()->GetProject()->GetId());
192 wxPostEvent(this->GetParent(), *newEvent);
195 void wxCDMBlackBoxDescriptionPanel::OnBtnSetAuthor(wxCommandEvent& event)
197 //get author from user
198 wxTextEntryDialog* authDlg = new wxTextEntryDialog(
200 wxT("Enter the new authors name. Separate each author with a '/'."),
201 wxT("Change Black Box Author - creaDevManager"),
202 crea::std2wx(this->blackBox->GetAuthors()),
206 if (authDlg->ShowModal() == wxID_OK)
208 std::string authorsStr = crea::wx2std(authDlg->GetValue());
210 if(authorsStr.size() > 0)
213 if(!this->blackBox->SetAuthors(authorsStr, result))
214 wxMessageBox(crea::std2wx(*result),_T("Change Black Box Author - Error!"),wxOK | wxICON_ERROR);
218 this->authortc->SetLabel(crea::std2wx(this->blackBox->GetAuthors()));
219 this->authortc->GetParent()->GetSizer()->RecalcSizes();
224 void wxCDMBlackBoxDescriptionPanel::OnBtnSetDescription(wxCommandEvent& event)
226 //get author from user
227 wxTextEntryDialog* descDlg = new wxTextEntryDialog(
229 wxT("Edit the black box description."),
230 wxT("Change Black Box Description - creaDevManager"),
231 crea::std2wx(this->blackBox->GetDescription()),
232 wxTE_MULTILINE | wxOK | wxCANCEL
235 if (descDlg->ShowModal() == wxID_OK)
237 std::string descriptionStr = crea::wx2std(descDlg->GetValue());
239 if(descriptionStr.size() > 0)
242 if(!this->blackBox->SetDescription(descriptionStr, result))
243 wxMessageBox(crea::std2wx(*result),_T("Change Black Box Description - Error!"),wxOK | wxICON_ERROR);
245 this->descriptiontc->SetLabel(crea::std2wx(this->blackBox->GetDescription()));
246 this->descriptiontc->GetParent()->GetSizer()->RecalcSizes();
250 void wxCDMBlackBoxDescriptionPanel::OnBtnSetCategories(wxCommandEvent& event)
252 //get author from user
253 wxTextEntryDialog* catsDlg = new wxTextEntryDialog(
255 wxT("Edit the black box categories separated by '/'."),
256 wxT("Change Black Box Categories - creaDevManager"),
257 crea::std2wx(this->blackBox->GetCategories()),
258 wxTE_MULTILINE | wxOK | wxCANCEL
261 if (catsDlg->ShowModal() == wxID_OK)
263 std::string categoriesStr = crea::wx2std(catsDlg->GetValue());
265 if(categoriesStr.size() > 0)
268 if(!this->blackBox->SetCategories(categoriesStr, result))
269 wxMessageBox(crea::std2wx(*result),_T("Change Black Box Categories - Error!"),wxOK | wxICON_ERROR);
271 this->categoriestc->SetLabel(crea::std2wx(this->blackBox->GetCategories()));
272 this->categoriestc->GetParent()->GetSizer()->RecalcSizes();
276 void wxCDMBlackBoxDescriptionPanel::OnBtnOpenCxx(wxCommandEvent& event)
279 if(!this->blackBox->OpenCxx(result))
280 wxMessageBox(crea::std2wx(*result),_T("Open Source File - Error!"),wxOK | wxICON_ERROR);
283 void wxCDMBlackBoxDescriptionPanel::OnBtnOpenHxx(wxCommandEvent& event)
286 if(!this->blackBox->OpenHxx(result))
287 wxMessageBox(crea::std2wx(*result),_T("Open Header File - Error!"),wxOK | wxICON_ERROR);
290 void wxCDMBlackBoxDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
293 if(!this->blackBox->OpenInFileExplorer(result))
294 wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);