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 "creaDevManagerIds.h"
40 #include "images/BBIcon64.xpm"
42 BEGIN_EVENT_TABLE(wxCDMBlackBoxDescriptionPanel, wxPanel)
43 EVT_BUTTON(ID_BUTTON_PREV, wxCDMBlackBoxDescriptionPanel::OnBtnReturn)
44 EVT_BUTTON(ID_BUTTON_SET_AUTHOR, wxCDMBlackBoxDescriptionPanel::OnBtnSetAuthor)
45 EVT_BUTTON(ID_BUTTON_SET_DESCRIPTION, wxCDMBlackBoxDescriptionPanel::OnBtnSetDescription)
46 EVT_BUTTON(ID_BUTTON_SET_CATEGORY, wxCDMBlackBoxDescriptionPanel::OnBtnSetCategories)
47 EVT_BUTTON(ID_BUTTON_OPEN_CXX, wxCDMBlackBoxDescriptionPanel::OnBtnOpenCxx)
48 EVT_BUTTON(ID_BUTTON_OPEN_HXX, wxCDMBlackBoxDescriptionPanel::OnBtnOpenHxx)
49 EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMBlackBoxDescriptionPanel::OnBtnOpenFolder)
52 wxCDMBlackBoxDescriptionPanel::wxCDMBlackBoxDescriptionPanel(
54 modelCDMBlackBox* blackBox,
56 const wxString& caption,
62 wxCDMBlackBoxDescriptionPanel::Create(parent, blackBox, id, caption, pos, size, style);
65 wxCDMBlackBoxDescriptionPanel::~wxCDMBlackBoxDescriptionPanel()
69 bool wxCDMBlackBoxDescriptionPanel::Create(
71 modelCDMBlackBox* blackBox,
73 const wxString& caption,
79 wxPanel::Create(parent, id, pos, size, style);
80 this->blackBox = blackBox;
85 void wxCDMBlackBoxDescriptionPanel::CreateControls()
87 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
90 wxButton* returnbt = new wxButton(this, ID_BUTTON_PREV, wxT("Return to project"));
91 returnbt->SetToolTip(wxT("Return to the active project description."));
92 sizer->Add(returnbt, 0, wxALIGN_CENTER | wxALL, 5);
95 sizer->Add(new wxStaticText(this, -1, _("Black Box")),0, wxALIGN_CENTER, 0);
98 sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(BBIcon64)),0, wxALIGN_CENTER, 0);
101 sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->blackBox->GetNameBlackBox())),0, wxALIGN_CENTER, 0);
103 //BlackBox Properties
104 wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("&Properties"));
105 wxPanel* propertiesPanel = new wxPanel(this);
106 wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
107 wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
109 wxStaticText *pAuthor = new wxStaticText(propertiesPanel, -1, wxT("Author"));
110 wxStaticText *pDescription = new wxStaticText(propertiesPanel, -1, wxT("Description"));
111 wxStaticText *pCategories = new wxStaticText(propertiesPanel, -1, wxT("Categories"));
114 wxBoxSizer* pAuthorsz = new wxBoxSizer(wxHORIZONTAL);
115 this->authortc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetAuthors()));
116 wxButton* pAuthorbt = new wxButton(propertiesPanel, ID_BUTTON_SET_AUTHOR, wxT("Change"));
117 pAuthorbt->SetToolTip(wxT("Update the author/s of the package."));
118 pAuthorsz->Add(this->authortc, 0, wxALIGN_CENTER_VERTICAL, 0);
119 pAuthorsz->Add(pAuthorbt, 0, wxALIGN_CENTER | wxLEFT, 10);
122 wxBoxSizer* pDescriptionsz = new wxBoxSizer(wxHORIZONTAL);
123 this->descriptiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetDescription()));
124 wxButton* pDescriptionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_DESCRIPTION, wxT("Change"));
125 pDescriptionbt->SetToolTip(wxT("Update the description of the project."));
126 pDescriptionsz->Add(this->descriptiontc, 0, wxALIGN_CENTER_VERTICAL, 0);
127 pDescriptionsz->Add(pDescriptionbt, 0, wxALIGN_CENTER | wxLEFT, 10);
130 wxBoxSizer* pCategoriessz = new wxBoxSizer(wxHORIZONTAL);
131 this->categoriestc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetCategories()));
132 wxButton* pCategoriesbt = new wxButton(propertiesPanel, ID_BUTTON_SET_CATEGORY, wxT("Change"));
133 pCategoriesbt->SetToolTip(wxT("Update the categories of the project."));
134 pCategoriessz->Add(this->categoriestc, 0, wxALIGN_CENTER_VERTICAL, 0);
135 pCategoriessz->Add(pCategoriesbt, 0, wxALIGN_CENTER | wxLEFT, 10);
137 propertiesGridSizer->Add(pAuthor, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
138 propertiesGridSizer->Add(pAuthorsz, 1, wxEXPAND);
139 propertiesGridSizer->Add(pDescription, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
140 propertiesGridSizer->Add(pDescriptionsz, 1, wxEXPAND);
141 propertiesGridSizer->Add(pCategories, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
142 propertiesGridSizer->Add(pCategoriessz, 1, wxEXPAND);
144 propertiesGridSizer->AddGrowableCol(1,1);
146 propertiesPanelSizer -> Add(propertiesGridSizer, 1, wxEXPAND);
147 propertiesPanel->SetSizer(propertiesPanelSizer);
148 propertiesPanelSizer->Fit(propertiesPanel);
149 propertiesBox->Add(propertiesPanel, 0, wxALL, 5);
151 sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
155 wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Actions"));
156 wxPanel* actionsPanel = new wxPanel(this);
157 wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
159 wxButton* openCxxbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_CXX, _T("Open .cxx"));
160 openCxxbt->SetToolTip(wxT("Open the .cxx file in the default text editor."));
161 actionsPanelSizer->Add(openCxxbt, 0, wxALL, 5);
162 wxButton* openHxxbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_HXX, _T("Open .h"));
163 openHxxbt->SetToolTip(wxT("Open the .h file in the default text editor."));
164 actionsPanelSizer->Add(openHxxbt, 0, wxALL, 5);
165 wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Source Folder"));
166 openFolderbt->SetToolTip(wxT("Open the source folder in the file explorer."));
167 actionsPanelSizer->Add(openFolderbt, 0, wxALL, 5);
169 actionsPanel->SetSizer(actionsPanelSizer);
170 actionsPanelSizer->Fit(actionsPanel);
171 actionsBox->Add(actionsPanel, 0, wxEXPAND);
172 sizer -> Add(actionsBox, 0, wxEXPAND | wxALL, 10);
176 sizer->SetSizeHints(this);
179 void wxCDMBlackBoxDescriptionPanel::OnBtnReturn(wxCommandEvent& event)
181 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
182 newEvent->SetInt(((wxCDMMainFrame*)this->GetParent())->GetModel()->GetProject()->GetId());
184 wxPostEvent(this->GetParent(), *newEvent);
187 void wxCDMBlackBoxDescriptionPanel::OnBtnSetAuthor(wxCommandEvent& event)
189 //get author from user
190 wxTextEntryDialog* authDlg = new wxTextEntryDialog(
192 wxT("Enter the new authors name. Separate each author with a '/'."),
193 wxT("Change Black Box Author - creaDevManager"),
194 crea::std2wx(this->blackBox->GetAuthors()),
198 if (authDlg->ShowModal() == wxID_OK)
200 std::string authorsStr = crea::wx2std(authDlg->GetValue());
202 if(authorsStr.size() > 0)
205 if(!this->blackBox->SetAuthors(authorsStr, result))
206 wxMessageBox(crea::std2wx(*result),_T("Change Black Box Author - Error!"),wxOK | wxICON_ERROR);
210 this->authortc->SetLabel(crea::std2wx(this->blackBox->GetAuthors()));
211 this->authortc->GetParent()->GetSizer()->RecalcSizes();
216 void wxCDMBlackBoxDescriptionPanel::OnBtnSetDescription(wxCommandEvent& event)
218 //get author from user
219 wxTextEntryDialog* descDlg = new wxTextEntryDialog(
221 wxT("Edit the black box description."),
222 wxT("Change Black Box Description - creaDevManager"),
223 crea::std2wx(this->blackBox->GetDescription()),
224 wxTE_MULTILINE | wxOK | wxCANCEL
227 if (descDlg->ShowModal() == wxID_OK)
229 std::string descriptionStr = crea::wx2std(descDlg->GetValue());
231 if(descriptionStr.size() > 0)
234 if(!this->blackBox->SetDescription(descriptionStr, result))
235 wxMessageBox(crea::std2wx(*result),_T("Change Black Box Description - Error!"),wxOK | wxICON_ERROR);
237 this->descriptiontc->SetLabel(crea::std2wx(this->blackBox->GetDescription()));
238 this->descriptiontc->GetParent()->GetSizer()->RecalcSizes();
242 void wxCDMBlackBoxDescriptionPanel::OnBtnSetCategories(wxCommandEvent& event)
244 //get author from user
245 wxTextEntryDialog* catsDlg = new wxTextEntryDialog(
247 wxT("Edit the black box categories separated by '/'."),
248 wxT("Change Black Box Categories - creaDevManager"),
249 crea::std2wx(this->blackBox->GetCategories()),
250 wxTE_MULTILINE | wxOK | wxCANCEL
253 if (catsDlg->ShowModal() == wxID_OK)
255 std::string categoriesStr = crea::wx2std(catsDlg->GetValue());
257 if(categoriesStr.size() > 0)
260 if(!this->blackBox->SetCategories(categoriesStr, result))
261 wxMessageBox(crea::std2wx(*result),_T("Change Black Box Categories - Error!"),wxOK | wxICON_ERROR);
263 this->categoriestc->SetLabel(crea::std2wx(this->blackBox->GetCategories()));
264 this->categoriestc->GetParent()->GetSizer()->RecalcSizes();
268 void wxCDMBlackBoxDescriptionPanel::OnBtnOpenCxx(wxCommandEvent& event)
271 if(!this->blackBox->OpenCxx(result))
272 wxMessageBox(crea::std2wx(*result),_T("Open Source File - Error!"),wxOK | wxICON_ERROR);
275 void wxCDMBlackBoxDescriptionPanel::OnBtnOpenHxx(wxCommandEvent& event)
278 if(!this->blackBox->OpenHxx(result))
279 wxMessageBox(crea::std2wx(*result),_T("Open Header File - Error!"),wxOK | wxICON_ERROR);
282 void wxCDMBlackBoxDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
285 if(!this->blackBox->OpenInFileExplorer(result))
286 wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);