]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / wxCDMBlackBoxDescriptionPanel.cpp
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 #                        pour la Sant�)
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
9 #
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.
16 #
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
21 #  liability.
22 #
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 # ------------------------------------------------------------------------
26  */
27
28 /*
29  * wxCDMBlackBoxDescriptionPanel.cpp
30  *
31  *  Created on: Nov 27, 2012
32  *      Author: Daniel Felipe Gonzalez Obando
33  */
34
35 #include "wxCDMBlackBoxDescriptionPanel.h"
36
37 #include "wxCDMMainFrame.h"
38
39 #include "creaDevManagerIds.h"
40 #include "images/BBIcon64.xpm"
41
42 BEGIN_EVENT_TABLE(wxCDMBlackBoxDescriptionPanel, wxPanel)
43 EVT_BUTTON(ID_BUTTON_PREV, wxCDMBlackBoxDescriptionPanel::OnBtnReturn)
44 EVT_MENU(ID_BUTTON_OPEN_CXX, wxCDMBlackBoxDescriptionPanel::OnBtnOpenCxx)
45 EVT_MENU(ID_BUTTON_OPEN_HXX, wxCDMBlackBoxDescriptionPanel::OnBtnOpenHxx)
46 EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMBlackBoxDescriptionPanel::OnBtnOpenFolder)
47 END_EVENT_TABLE()
48
49 wxCDMBlackBoxDescriptionPanel::wxCDMBlackBoxDescriptionPanel(
50     wxWindow* parent,
51     modelCDMBlackBox* blackBox,
52     wxWindowID id,
53     const wxString& caption,
54     const wxPoint& pos,
55     const wxSize& size,
56     long style
57 )
58 {
59   wxCDMBlackBoxDescriptionPanel::Create(parent, blackBox, id, caption, pos, size, style);
60 }
61
62 wxCDMBlackBoxDescriptionPanel::~wxCDMBlackBoxDescriptionPanel()
63 {
64 }
65
66 bool wxCDMBlackBoxDescriptionPanel::Create(
67     wxWindow* parent,
68     modelCDMBlackBox* blackBox,
69     wxWindowID id,
70     const wxString& caption,
71     const wxPoint& pos,
72     const wxSize& size,
73     long style
74 )
75 {
76   wxPanel::Create(parent, id, pos, size, style);
77   this->blackBox = blackBox;
78   CreateControls();
79   return TRUE;
80 }
81
82 void wxCDMBlackBoxDescriptionPanel::CreateControls()
83 {
84   wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
85
86   //Link to return
87   wxButton* returnbt = new wxButton(this, ID_BUTTON_PREV, wxT("Return to project"));
88   returnbt->SetToolTip(wxT("Return to the active project description."));
89   sizer->Add(returnbt, 0, wxALIGN_CENTER | wxALL, 5);
90
91   //Welcome
92   sizer->Add(new wxStaticText(this, -1, _("Black Box")),0, wxALIGN_CENTER, 0);
93
94   //Image
95   sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(BBIcon64)),0, wxALIGN_CENTER, 0);
96
97   //BlackBox Name
98   sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->blackBox->GetNameBlackBox())),0, wxALIGN_CENTER, 0);
99
100   //BlackBox Properties
101   wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("&Properties"));
102   wxPanel* propertiesPanel = new wxPanel(this);
103   wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
104   wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
105
106   wxStaticText *pAuthor = new wxStaticText(propertiesPanel, -1, wxT("Author"));
107   wxStaticText *pVersion = new wxStaticText(propertiesPanel, -1, wxT("Version"));
108   wxStaticText *pDescription = new wxStaticText(propertiesPanel, -1, wxT("Description"));
109   wxStaticText *pCategories = new wxStaticText(propertiesPanel, -1, wxT("Categories"));
110
111   // author
112   wxBoxSizer* pAuthorsz = new wxBoxSizer(wxHORIZONTAL);
113   wxStaticText* pAuthortc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetAuthors()));
114   wxButton* pAuthorbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Change"));
115   pAuthorbt->SetToolTip(wxT("Update the author/s of the package."));
116   pAuthorsz->Add(pAuthortc, 0, wxALIGN_CENTER_VERTICAL, 0);
117   pAuthorsz->Add(pAuthorbt, 0, wxALIGN_CENTER | wxLEFT, 10);
118
119   // version
120   wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL);
121   wxStaticText* pVersiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetVersion()));
122   wxButton* pVersionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set"));
123   pVersionbt->SetToolTip(wxT("Update the version of the package."));
124   pVersionsz->Add(pVersiontc, 0, wxALIGN_CENTER_VERTICAL, 0);
125   pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER | wxLEFT, 10);
126
127   // description
128   wxBoxSizer* pDescriptionsz = new wxBoxSizer(wxHORIZONTAL);
129   wxStaticText* pDescriptiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetDescription()));
130   wxButton* pDescriptionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Change"));
131   pDescriptionbt->SetToolTip(wxT("Update the description of the project."));
132   pDescriptionsz->Add(pDescriptiontc, 0, wxALIGN_CENTER_VERTICAL, 0);
133   pDescriptionsz->Add(pDescriptionbt, 0, wxALIGN_CENTER | wxLEFT, 10);
134
135   // categories
136   wxBoxSizer* pCategoriessz = new wxBoxSizer(wxHORIZONTAL);
137   wxStaticText* pCategoriestc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetCategories()));
138   wxButton* pCategoriesbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Change"));
139   pCategoriesbt->SetToolTip(wxT("Update the categories of the project."));
140   pCategoriessz->Add(pCategoriestc, 0, wxALIGN_CENTER_VERTICAL, 0);
141   pCategoriessz->Add(pCategoriesbt, 0, wxALIGN_CENTER | wxLEFT, 10);
142
143   propertiesGridSizer->Add(pAuthor, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
144   propertiesGridSizer->Add(pAuthorsz, 1, wxEXPAND);
145   propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
146   propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND);
147   propertiesGridSizer->Add(pDescription, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
148   propertiesGridSizer->Add(pDescriptionsz, 1, wxEXPAND);
149   propertiesGridSizer->Add(pCategories, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
150   propertiesGridSizer->Add(pCategoriessz, 1, wxEXPAND);
151
152   propertiesGridSizer->AddGrowableCol(1,1);
153
154   propertiesPanelSizer -> Add(propertiesGridSizer, 1, wxEXPAND);
155   propertiesPanel->SetSizer(propertiesPanelSizer);
156   propertiesPanelSizer->Fit(propertiesPanel);
157   propertiesBox->Add(propertiesPanel, 0, wxALL, 5);
158
159   sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
160
161
162   //Actions
163   wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Actions"));
164   wxPanel* actionsPanel = new wxPanel(this);
165   wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
166
167   wxButton* openCxxbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_CXX, _T("Open Cxx"));
168   openCxxbt->SetToolTip(wxT("Open the .cxx file in the default text editor."));
169   actionsPanelSizer->Add(openCxxbt, 0, wxALL, 5);
170   wxButton* openHxxbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_CXX, _T("Open Hxx"));
171   openHxxbt->SetToolTip(wxT("Open the .hxx file in the default text editor."));
172   actionsPanelSizer->Add(openHxxbt, 0, wxALL, 5);
173   wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Package Folder"));
174   openFolderbt->SetToolTip(wxT("Open the package folder in the file explorer."));
175   actionsPanelSizer->Add(openFolderbt, 0, wxALL, 5);
176
177   actionsPanel->SetSizer(actionsPanelSizer);
178   actionsPanelSizer->Fit(actionsPanel);
179   actionsBox->Add(actionsPanel, 0, wxEXPAND);
180   sizer -> Add(actionsBox, 0, wxEXPAND | wxALL, 10);
181
182   //Assign sizer
183   SetSizer(sizer);
184   sizer->SetSizeHints(this);
185 }
186
187 void wxCDMBlackBoxDescriptionPanel::OnBtnReturn(wxCommandEvent& event)
188 {
189   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
190   newEvent->SetInt(((wxCDMMainFrame*)this->GetParent())->GetModel()->GetProject()->GetId());
191   newEvent->SetId(0);
192   wxPostEvent(this->GetParent(), *newEvent);
193 }
194
195 void wxCDMBlackBoxDescriptionPanel::OnBtnOpenCxx(wxCommandEvent& event)
196 {
197   //TODO: implement method
198   std::cerr << "Event OnBtnOpenCxx not implemented" << std::endl;
199   event.Skip();
200 }
201
202 void wxCDMBlackBoxDescriptionPanel::OnBtnOpenHxx(wxCommandEvent& event)
203 {
204   //TODO: implement method
205   std::cerr << "Event OnBtnOpenHxx not implemented" << std::endl;
206   event.Skip();
207 }
208
209 void wxCDMBlackBoxDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
210 {
211   //TODO: implement method
212   std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl;
213   event.Skip();
214 }