]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMPackageConfigurationDialog.cpp
af407bff3f371c00d61c5b3feaab8aa5a5c24e3d
[crea.git] / lib / creaDevManagerLib / wxCDMPackageConfigurationDialog.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 /*
30  * wxCDMPackageConfigurationDialog.cpp
31  *
32  *  Created on: 6/4/2013
33  *      Author: Daniel Felipe Gonzalez Obando
34  */
35
36 #include "wxCDMPackageConfigurationDialog.h"
37
38 #include "creaDevManagerIds.h"
39
40 BEGIN_EVENT_TABLE(wxCDMPackageConfigurationDialog, wxDialog)
41 EVT_BUTTON(wxID_OK, wxCDMPackageConfigurationDialog::OnFinish)
42 EVT_CHECKBOX(ID_CHECK_INCLUDE_3RDLIBRARY, wxCDMPackageConfigurationDialog::On3rdLibraryIncludeChange)
43 EVT_CHECKBOX(ID_CHECK_INCLUDE_LIBRARY, wxCDMPackageConfigurationDialog::OnCustomLibraryIncludeChange)
44 END_EVENT_TABLE()
45
46 wxCDMPackageConfigurationDialog::wxCDMPackageConfigurationDialog(
47     wxWindow* parent,
48     modelCDMPackage* package,
49     wxWindowID id,
50     const wxString& caption,
51     const wxPoint& position,
52     const wxSize& size,
53     long style
54 )
55 {
56   wxCDMPackageConfigurationDialog::Create(parent, id, caption, position, size, style);
57   this->package = package;
58 }
59
60 wxCDMPackageConfigurationDialog::~wxCDMPackageConfigurationDialog()
61 {
62 }
63
64 bool wxCDMPackageConfigurationDialog::Create(
65     wxWindow* parent,
66     wxWindowID id,
67     const wxString& caption,
68     const wxPoint& position,
69     const wxSize& size,
70     long int style
71 )
72 {
73   wxDialog::Create(parent, id, caption, position, size, style);
74
75   this->CreateControls();
76
77   return TRUE;
78 }
79
80 void wxCDMPackageConfigurationDialog::CreateControls()
81 {
82
83   wxBoxSizer* v_sizer1 = new wxBoxSizer(wxVERTICAL);
84
85
86   wxStaticText* title = new wxStaticText(this, wxID_ANY, wxT("Please select the libraries that are used in this package."), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);//new wxRichTextCtrl(this,wxID_ANY, wxString("Create a new project"), wxDefaultPosition, wxDefaultSize, wxRE_READONLY);
87   v_sizer1->Add(title, 0, wxALIGN_LEFT | wxALL, 5);
88
89   wxBoxSizer* includesPanelSizer = new wxBoxSizer(wxVERTICAL);
90
91     //Third Party Libraries
92     wxStaticText* Title1 = new wxStaticText(this, wxID_ANY, wxT("Third Party Libraries:"));
93     wxFont font = Title1->GetFont();
94     font.SetWeight(wxFONTWEIGHT_BOLD);
95     Title1->SetFont(font);
96     includesPanelSizer->Add(Title1, 0, wxEXPAND | wxALL, 5);
97
98     //inclusion data
99     std::map<std::string, bool> inclusions = this->package->Get3rdPartyLibraries();
100     //includesGrid Sizer
101     wxFlexGridSizer* includesGridSizer = new wxFlexGridSizer(inclusions.size()+1, 2, 0, 5);
102
103     wxStaticText* ChBTitle = new wxStaticText(
104         this,
105         wxID_ANY,
106         wxT("Included"),
107         wxDefaultPosition,
108         wxDefaultSize,
109         wxALIGN_CENTER
110       );
111     wxStaticText* LNmTitle = new wxStaticText(
112         this,
113         wxID_ANY,
114         wxT("Library Name"),
115         wxDefaultPosition,
116         wxDefaultSize,
117         wxALIGN_LEFT
118       );
119
120     includesGridSizer->Add(ChBTitle, 1, wxEXPAND);
121     includesGridSizer->Add(LNmTitle, 1, wxEXPAND);
122
123     for (std::map<std::string, bool>::iterator it = inclusions.begin(); it != inclusions.end(); ++it) {
124       wxCheckBox* ChBIncl = new wxCheckBox(
125           this, ID_CHECK_INCLUDE_3RDLIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT
126         );
127       ChBIncl->SetToolTip(crea::std2wx("When this box is checked the " + it->first + " library is included in the project configuration for this library."));
128       ChBIncl->SetName(crea::std2wx(it->first));
129       ChBIncl->SetValue(it->second);
130       includesGridSizer->Add(ChBIncl, 1, wxEXPAND);
131
132       wxStaticText* LNmIncl = new wxStaticText(this, wxID_ANY, crea::std2wx(it->first));
133       includesGridSizer->Add(LNmIncl, 1, wxEXPAND);
134     }
135
136     includesGridSizer->AddGrowableCol(1,1);
137
138     includesPanelSizer->Add(includesGridSizer, 1, wxEXPAND, 0);
139
140     //Custom Libraries
141     wxStaticText* Title2 = new wxStaticText(this, wxID_ANY, wxT("Custom Libraries:"));
142     font = Title2->GetFont();
143     font.SetWeight(wxFONTWEIGHT_BOLD);
144     Title2->SetFont(font);
145     includesPanelSizer->Add(Title2, 0, wxEXPAND | wxALL, 5);
146
147     //inclusion data
148     std::map<std::string, bool> inclusionsLibs = this->package->GetCustomLibraries();
149     //includesGrid Sizer
150     wxFlexGridSizer* includesLibGridSizer = new wxFlexGridSizer(inclusionsLibs.size()+1, 2, 0, 5);
151
152     wxStaticText* ChBTitle1 = new wxStaticText(
153         this,
154         wxID_ANY,
155         wxT("Included"),
156         wxDefaultPosition,
157         wxDefaultSize,
158         wxALIGN_CENTER
159       );
160     wxStaticText* LNmTitle1 = new wxStaticText(
161         this,
162         wxID_ANY,
163         wxT("Library Name"),
164         wxDefaultPosition,
165         wxDefaultSize,
166         wxALIGN_LEFT
167       );
168
169     includesLibGridSizer->Add(ChBTitle1, 1, wxEXPAND);
170     includesLibGridSizer->Add(LNmTitle1, 1, wxEXPAND);
171
172     for (std::map<std::string, bool>::iterator it = inclusionsLibs.begin(); it != inclusionsLibs.end(); ++it) {
173       wxCheckBox* ChBIncl = new wxCheckBox(
174           this, ID_CHECK_INCLUDE_LIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT
175         );
176       ChBIncl->SetToolTip(crea::std2wx("When this box is checked the " + it->first + " custom library is included in the project configuration for this library."));
177       ChBIncl->SetName(crea::std2wx(it->first));
178       ChBIncl->SetValue(it->second);
179       includesLibGridSizer->Add(ChBIncl, 1, wxEXPAND);
180
181       wxStaticText* LNmIncl = new wxStaticText(this, wxID_ANY, crea::std2wx(it->first));
182       includesLibGridSizer->Add(LNmIncl, 1, wxEXPAND);
183     }
184
185     includesLibGridSizer->AddGrowableCol(1,1);
186
187     includesPanelSizer->Add(includesLibGridSizer, 1, wxEXPAND, 0);
188
189     v_sizer1->Add(includesPanelSizer, 1, wxEXPAND);
190
191   v_sizer1->Add(new wxButton(this, wxID_OK, wxT("Close")), 0, wxALIGN_CENTER | wxRIGHT | wxBOTTOM, 30);
192
193   SetSizer(v_sizer1);
194 }
195
196 void wxCDMPackageConfigurationDialog::OnFinish(wxCommandEvent& event)
197 {
198   this->EndModal(wxID_OK);
199 }
200
201 void wxCDMPackageConfigurationDialog::On3rdLibraryIncludeChange(
202     wxCommandEvent& event)
203 {
204   this->package->Set3rdPartyLibrary(
205     crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()),
206     ((wxCheckBox*)event.GetEventObject())->GetValue()
207   );
208 }
209
210 void wxCDMPackageConfigurationDialog::OnCustomLibraryIncludeChange(
211     wxCommandEvent& event)
212 {
213   this->package->SetCustomLibrary(
214     crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()),
215     ((wxCheckBox*)event.GetEventObject())->GetValue()
216   );
217 }