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 # ------------------------------------------------------------------------
30 * wxCDMPackageConfigurationDialog.cpp
32 * Created on: 6/4/2013
33 * Author: Daniel Felipe Gonzalez Obando
36 #include "wxCDMPackageConfigurationDialog.h"
38 #include "creaDevManagerIds.h"
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)
46 wxCDMPackageConfigurationDialog::wxCDMPackageConfigurationDialog(
48 modelCDMPackage* package,
50 const wxString& caption,
51 const wxPoint& position,
56 this->package = package;
57 wxCDMPackageConfigurationDialog::Create(parent, id, caption, position, size, style);
60 wxCDMPackageConfigurationDialog::~wxCDMPackageConfigurationDialog()
64 bool wxCDMPackageConfigurationDialog::Create(
67 const wxString& caption,
68 const wxPoint& position,
73 wxDialog::Create(parent, id, caption, position, size, style);
75 this->CreateControls();
80 void wxCDMPackageConfigurationDialog::CreateControls()
83 wxBoxSizer* v_sizer1 = new wxBoxSizer(wxVERTICAL);
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, wxEXPAND | wxALIGN_LEFT | wxALL, 5);
89 wxScrolledWindow* includesPanel = new wxScrolledWindow(this);
90 includesPanel->FitInside();
91 includesPanel->SetScrollRate(5,5);
93 wxBoxSizer* includesPanelSizer = new wxBoxSizer(wxVERTICAL);
95 //Third Party Libraries
96 wxStaticText* Title1 = new wxStaticText(includesPanel, wxID_ANY, wxT("Third Party Libraries:"));
97 wxFont font = Title1->GetFont();
98 font.SetWeight(wxFONTWEIGHT_BOLD);
99 Title1->SetFont(font);
100 includesPanelSizer->Add(Title1, 0, wxEXPAND);
103 std::map<std::string, bool> inclusions = this->package->Get3rdPartyLibraries();
105 wxFlexGridSizer* includesGridSizer = new wxFlexGridSizer(inclusions.size()+1, 2, 0, 5);
107 wxStaticText* ChBTitle = new wxStaticText(
115 wxStaticText* LNmTitle = new wxStaticText(
124 includesGridSizer->Add(ChBTitle, 1, wxEXPAND);
125 includesGridSizer->Add(LNmTitle, 1, wxEXPAND);
127 for (std::map<std::string, bool>::iterator it = inclusions.begin(); it != inclusions.end(); ++it) {
128 wxCheckBox* ChBIncl = new wxCheckBox(
129 includesPanel, ID_CHECK_INCLUDE_3RDLIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT
131 ChBIncl->SetToolTip(crea::std2wx(
132 "When this box is checked the " + it->first + " library\n"
133 "is included in the project configuration for\n"
134 "this package including the following instruction\n"
135 "in the package's folder CMakeLists.txt file:\n"
136 "SET(${BBTK_PACKAGE_NAME}_USE_" + it->first+ " ON)\n"
138 ChBIncl->SetName(crea::std2wx(it->first));
139 ChBIncl->SetValue(it->second);
140 includesGridSizer->Add(ChBIncl, 0, wxEXPAND);
142 wxStaticText* LNmIncl = new wxStaticText(includesPanel, wxID_ANY, crea::std2wx(it->first));
143 includesGridSizer->Add(LNmIncl, 1, wxEXPAND);
146 includesGridSizer->AddGrowableCol(1,1);
148 includesPanelSizer->Add(includesGridSizer, 1, wxEXPAND | wxLEFT, 5);
151 wxStaticText* Title2 = new wxStaticText(includesPanel, wxID_ANY, wxT("Custom Libraries:"));
152 font = Title2->GetFont();
153 font.SetWeight(wxFONTWEIGHT_BOLD);
154 Title2->SetFont(font);
155 includesPanelSizer->Add(Title2, 0, wxEXPAND);
158 std::map<std::string, bool> inclusionsLibs = this->package->GetCustomLibraries();
160 wxFlexGridSizer* includesLibGridSizer = new wxFlexGridSizer(inclusionsLibs.size()+1, 2, 0, 5);
162 wxStaticText* ChBTitle1 = new wxStaticText(
170 wxStaticText* LNmTitle1 = new wxStaticText(
179 includesLibGridSizer->Add(ChBTitle1, 1, wxEXPAND);
180 includesLibGridSizer->Add(LNmTitle1, 1, wxEXPAND);
182 for (std::map<std::string, bool>::iterator it = inclusionsLibs.begin(); it != inclusionsLibs.end(); ++it) {
183 wxCheckBox* ChBIncl = new wxCheckBox(
184 includesPanel, ID_CHECK_INCLUDE_LIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT
186 ChBIncl->SetToolTip(crea::std2wx(
187 "When this box is checked the " + it->first + " custom\n"
188 "library is included in the project configuration for\n"
189 "this packages including the following code in the\n"
190 "package's folder CMakeLists.txt file:\n"
191 "SET(${BBTK_PACKAGE_NAME}_INCLUDE_DIRS\n"
192 " ../lib/"+ it->first + "\n"
194 "SET(${BBTK_PACKAGE_NAME}_LIBS\n"
195 " " + it->first+ "\n"
197 ChBIncl->SetName(crea::std2wx(it->first));
198 ChBIncl->SetValue(it->second);
199 includesLibGridSizer->Add(ChBIncl, 0, wxEXPAND);
201 wxStaticText* LNmIncl = new wxStaticText(includesPanel, wxID_ANY, crea::std2wx(it->first));
202 includesLibGridSizer->Add(LNmIncl, 1, wxEXPAND);
205 includesLibGridSizer->AddGrowableCol(1,1);
207 includesPanelSizer->Add(includesLibGridSizer, 0, wxEXPAND | wxLEFT, 5);
209 includesPanel->SetSizer(includesPanelSizer);
211 v_sizer1->Add(includesPanel, 1, wxEXPAND | wxALL, 10);
213 v_sizer1->Add(new wxButton(this, wxID_OK, wxT("Close")), 0, wxALIGN_CENTER | wxRIGHT | wxBOTTOM, 30);
218 void wxCDMPackageConfigurationDialog::OnFinish(wxCommandEvent& event)
220 this->EndModal(wxID_OK);
223 void wxCDMPackageConfigurationDialog::On3rdLibraryIncludeChange(
224 wxCommandEvent& event)
226 if(this->package->Set3rdPartyLibrary(crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()), ((wxCheckBox*)event.GetEventObject())->GetValue()))
227 ((wxCheckBox*)event.GetEventObject())->SetValue(((wxCheckBox*)event.GetEventObject())->GetValue());
229 ((wxCheckBox*)event.GetEventObject())->SetValue(!((wxCheckBox*)event.GetEventObject())->GetValue());
232 void wxCDMPackageConfigurationDialog::OnCustomLibraryIncludeChange(
233 wxCommandEvent& event)
235 if(this->package->SetCustomLibrary(crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()), ((wxCheckBox*)event.GetEventObject())->GetValue()))
236 ((wxCheckBox*)event.GetEventObject())->SetValue(((wxCheckBox*)event.GetEventObject())->GetValue());
238 ((wxCheckBox*)event.GetEventObject())->SetValue(!((wxCheckBox*)event.GetEventObject())->GetValue());