]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMProjectConfigurationDialog.cpp
Feature #1711 CreaDevManager application implementation
[crea.git] / lib / creaDevManagerLib / wxCDMProjectConfigurationDialog.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  * wxCDMProjectConfigurationDialog.cpp
31  *
32  *  Created on: 6/4/2013
33  *      Author: Daniel Felipe Gonzalez Obando
34  */
35
36 #include "wxCDMProjectConfigurationDialog.h"
37
38 #include "creaDevManagerIds.h"
39
40 BEGIN_EVENT_TABLE(wxCDMProjectConfigurationDialog, wxDialog)
41 EVT_BUTTON(wxID_OK, wxCDMProjectConfigurationDialog::OnFinish)
42 EVT_CHECKBOX(ID_CHECK_INCLUDE_3RDLIBRARY, wxCDMProjectConfigurationDialog::On3rdLibraryIncludeChange)
43 END_EVENT_TABLE()
44
45 wxCDMProjectConfigurationDialog::wxCDMProjectConfigurationDialog(
46     wxWindow* parent,
47     modelCDMProject* project,
48     wxWindowID id,
49     const wxString& caption,
50     const wxPoint& position,
51     const wxSize& size,
52     long style
53 )
54 {
55   this->project = project;
56   wxCDMProjectConfigurationDialog::Create(parent, id, caption, position, size, style);
57 }
58
59 wxCDMProjectConfigurationDialog::~wxCDMProjectConfigurationDialog()
60 {
61 }
62
63 bool wxCDMProjectConfigurationDialog::Create(
64     wxWindow* parent,
65     wxWindowID id,
66     const wxString& caption,
67     const wxPoint& position,
68     const wxSize& size,
69     long int style
70 )
71 {
72   wxDialog::Create(parent, id, caption, position, size, style);
73
74   this->CreateControls();
75
76   return TRUE;
77 }
78
79 void wxCDMProjectConfigurationDialog::CreateControls()
80 {
81
82   wxBoxSizer* v_sizer1 = new wxBoxSizer(wxVERTICAL);
83
84
85   wxStaticText* title = new wxStaticText(this, wxID_ANY, wxT("Please select the libraries that are used in this project."), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);//new wxRichTextCtrl(this,wxID_ANY, wxString("Create a new project"), wxDefaultPosition, wxDefaultSize, wxRE_READONLY);
86   v_sizer1->Add(title, 0, wxEXPAND | wxALIGN_LEFT | wxALL, 5);
87
88   wxScrolledWindow* includesPanel = new wxScrolledWindow(this);
89   includesPanel->FitInside();
90   includesPanel->SetScrollRate(5,5);
91
92   wxBoxSizer* includesPanelSizer = new wxBoxSizer(wxVERTICAL);
93
94   //Third Party Libraries
95   wxStaticText* Title1 = new wxStaticText(includesPanel, wxID_ANY, wxT("Third Party Libraries:"));
96   wxFont font = Title1->GetFont();
97   font.SetWeight(wxFONTWEIGHT_BOLD);
98   Title1->SetFont(font);
99   includesPanelSizer->Add(Title1, 0, wxEXPAND);
100
101   //inclusion data
102   std::map<std::string, bool> inclusions = this->project->Get3rdPartyLibraries();
103   //includesGrid Sizer
104   wxFlexGridSizer* includesGridSizer = new wxFlexGridSizer(inclusions.size()+1, 2, 0, 5);
105
106   wxStaticText* ChBTitle = new wxStaticText(
107       includesPanel,
108       wxID_ANY,
109       wxT("Included"),
110       wxDefaultPosition,
111       wxDefaultSize,
112       wxALIGN_CENTER
113     );
114   wxStaticText* LNmTitle = new wxStaticText(
115       includesPanel,
116       wxID_ANY,
117       wxT("Library Name"),
118       wxDefaultPosition,
119       wxDefaultSize,
120       wxALIGN_LEFT
121     );
122
123   includesGridSizer->Add(ChBTitle, 1, wxEXPAND);
124   includesGridSizer->Add(LNmTitle, 1, wxEXPAND);
125
126   for (std::map<std::string, bool>::iterator it = inclusions.begin(); it != inclusions.end(); ++it) {
127     wxCheckBox* ChBIncl = new wxCheckBox(
128         includesPanel, ID_CHECK_INCLUDE_3RDLIBRARY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT
129       );
130     ChBIncl->SetToolTip(crea::std2wx(
131         "When this box is checked the " + it->first + " library\n"
132         "is included in the project configuration for\n"
133         "this package including the following instruction\n"
134         "in the package's folder CMakeLists.txt file:\n"
135         "SET(${BBTK_PACKAGE_NAME}_USE_" + it->first+ "  ON)\n"
136         ));
137     ChBIncl->SetName(crea::std2wx(it->first));
138     ChBIncl->SetValue(it->second);
139     includesGridSizer->Add(ChBIncl, 0, wxEXPAND);
140
141     wxStaticText* LNmIncl = new wxStaticText(includesPanel, wxID_ANY, crea::std2wx(it->first));
142     includesGridSizer->Add(LNmIncl, 1, wxEXPAND);
143   }
144
145   includesGridSizer->AddGrowableCol(1,1);
146
147   includesPanelSizer->Add(includesGridSizer, 1, wxEXPAND | wxLEFT, 5);
148
149   includesPanel->SetSizer(includesPanelSizer);
150
151   v_sizer1->Add(includesPanel, 1, wxEXPAND | wxALL, 10);
152
153   v_sizer1->Add(new wxButton(this, wxID_OK, wxT("Close")), 0, wxALIGN_CENTER | wxRIGHT | wxBOTTOM, 30);
154
155   SetSizer(v_sizer1);
156 }
157
158 void wxCDMProjectConfigurationDialog::OnFinish(wxCommandEvent& event)
159 {
160   this->EndModal(wxID_OK);
161 }
162
163 void wxCDMProjectConfigurationDialog::On3rdLibraryIncludeChange(
164     wxCommandEvent& event)
165 {
166   if(this->project->Set3rdPartyLibrary(crea::wx2std(((wxCheckBox*)event.GetEventObject())->GetName()), ((wxCheckBox*)event.GetEventObject())->GetValue()))
167     ((wxCheckBox*)event.GetEventObject())->SetValue(((wxCheckBox*)event.GetEventObject())->GetValue());
168   else
169     ((wxCheckBox*)event.GetEventObject())->SetValue(!((wxCheckBox*)event.GetEventObject())->GetValue());
170 }