]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / wxCDMProjectDescriptionPanel.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  * wxCDMProjectDescriptionPanel.cpp
30  *
31  *  Created on: Nov 27, 2012
32  *      Author: Daniel Felipe Gonzalez Obando
33  */
34
35 #include "wxCDMProjectDescriptionPanel.h"
36
37 #include "wxCDMMainFrame.h"
38
39 #include "creaDevManagerIds.h"
40 #include "images/PrIcon.xpm"
41
42 BEGIN_EVENT_TABLE(wxCDMProjectDescriptionPanel, wxPanel)
43 EVT_BUTTON(ID_BUTTON_CREATE_PACKAGE, wxCDMProjectDescriptionPanel::OnBtnCreatePackage)
44 EVT_BUTTON(ID_BUTTON_CREATE_BLACKBOX, wxCDMProjectDescriptionPanel::OnBtnCreateBlackBox)
45 EVT_BUTTON(ID_BUTTON_CREATE_LIBRARY, wxCDMProjectDescriptionPanel::OnBtnCreateLibrary)
46 EVT_BUTTON(ID_BUTTON_CREATE_APPLICATION, wxCDMProjectDescriptionPanel::OnBtnCreateApplication)
47 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists)
48 EVT_COMMAND(wxID_ANY, wxEVT_DISPLAY_CHANGED, wxCDMProjectDescriptionPanel::OnCreationComplete)
49 END_EVENT_TABLE()
50
51 wxCDMProjectDescriptionPanel::wxCDMProjectDescriptionPanel(
52     wxWindow* parent,
53     modelCDMProject* project,
54     wxWindowID id,
55     const wxString& caption,
56     const wxPoint& pos,
57     const wxSize& size,
58     long style
59 )
60 {
61   wxCDMProjectDescriptionPanel::Create(parent, project, id, caption, pos, size, style);
62 }
63
64 wxCDMProjectDescriptionPanel::~wxCDMProjectDescriptionPanel()
65 {
66 }
67
68 bool wxCDMProjectDescriptionPanel::Create(
69     wxWindow* parent,
70     modelCDMProject* project,
71     wxWindowID id,
72     const wxString& caption,
73     const wxPoint& pos,
74     const wxSize& size,
75     long style
76 )
77 {
78   wxPanel::Create(parent, id, pos, size, style);
79   this->project = project;
80   CreateControls();
81   return TRUE;
82 }
83
84 void wxCDMProjectDescriptionPanel::CreateControls()
85 {
86   wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
87
88   //Welcome
89   sizer->Add(new wxStaticText(this, -1, _("Project")),0, wxALIGN_CENTER, 0);
90
91   //Image
92   sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(PrIcon)),0, wxALIGN_CENTER, 0);
93
94   //Project Name
95   sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->project->GetName())),0, wxALIGN_CENTER, 0);
96
97   //Project Properties
98   wxStaticBox* propertiesBox = new wxStaticBox(this, -1, _T("&Properties"));
99   wxStaticBoxSizer* propertiesBoxInnerSizer = new wxStaticBoxSizer(propertiesBox, wxVERTICAL);
100
101   wxFlexGridSizer* flexGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
102
103   wxStaticText *pVersion = new wxStaticText(this, -1, wxT("Version"));
104   wxStaticText *pVersionDate = new wxStaticText(this, -1, wxT("Version Date"));
105   wxStaticText *pSourceLocation = new wxStaticText(this, -1, wxT("Source Location"));
106   wxStaticText *pBuildLocation = new wxStaticText(this, -1, wxT("Build Location"));
107
108   wxTextCtrl *pVersiontc = new wxTextCtrl(this, -1, crea::std2wx(this->project->GetVersion()));
109   wxTextCtrl *pVersionDatetc = new wxTextCtrl(this, -1, crea::std2wx(this->project->GetVersionDate()));
110   wxTextCtrl *pSourceLocationtc = new wxTextCtrl(this, -1, crea::std2wx(this->project->GetPath()));
111   wxTextCtrl *pBuildLocationtc = new wxTextCtrl(this, -1, crea::std2wx(this->project->GetBuildPath()));
112
113   flexGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
114   flexGridSizer->Add(pVersiontc, 1, wxEXPAND);
115   flexGridSizer->Add(pVersionDate, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
116   flexGridSizer->Add(pVersionDatetc, 1, wxEXPAND);
117   flexGridSizer->Add(pSourceLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
118   flexGridSizer->Add(pSourceLocationtc, 1, wxEXPAND);
119   flexGridSizer->Add(pBuildLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
120   flexGridSizer->Add(pBuildLocationtc, 1, wxEXPAND);
121
122   propertiesBoxInnerSizer -> Add(flexGridSizer, 0, wxEXPAND);
123   sizer -> Add(propertiesBoxInnerSizer, 1, wxEXPAND | wxALL, 20);
124
125   //Actions
126   wxStaticBox* actionsBox = new wxStaticBox(this, -1, _T("&Actions"));
127   wxStaticBoxSizer* actionsBoxInnerSizer = new wxStaticBoxSizer(actionsBox, wxVERTICAL);
128   sizer -> Add(actionsBoxInnerSizer, 1, wxEXPAND | wxALL, 20);
129
130   actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_CREATE_PACKAGE, _T("Create Package")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20);
131   actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_CREATE_BLACKBOX, _T("Create Black Box")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20);
132   actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_CREATE_LIBRARY, _T("Create Library")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20);
133   actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_CREATE_APPLICATION, _T("Create Application")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20);
134
135   actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20);
136
137   //Assign sizer
138   actionsBoxInnerSizer->SetSizeHints(this);
139
140   SetSizer(sizer);
141   sizer->SetSizeHints(this);
142 }
143
144 void wxCDMProjectDescriptionPanel::OnBtnCreatePackage(wxCommandEvent& event)
145 {
146   //TODO: implement method
147   std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
148   event.Skip();
149 }
150
151 void wxCDMProjectDescriptionPanel::OnBtnCreateBlackBox(wxCommandEvent& event)
152 {
153   //TODO: implement method
154   std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
155   event.Skip();
156 }
157
158 void wxCDMProjectDescriptionPanel::OnBtnCreateLibrary(wxCommandEvent& event)
159 {
160   //implement method
161   std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
162   wxString libraryName = wxGetTextFromUser(
163       _T("Enter the new library name"),
164       _T("New Library - creaDevManager"),
165       _T("")
166   );
167   std::string* result;
168   modelCDMIProjectTreeNode* library = this->project->CreateLibrary(crea::wx2std(libraryName),result);
169   if(library == NULL)
170     {
171       wxMessageBox(crea::std2wx(*result),_T("New Library - Error!"),wxOK | wxICON_ERROR);
172       event.Skip();
173       return;
174     }
175   wxMessageBox(crea::std2wx("Library successfully created."),_T("New Library - Success!"),wxOK | wxICON_INFORMATION);
176
177   //send event instead of calling parent to avoid crashing
178   ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
179
180   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
181   newEvent->SetInt(library->GetId());
182   wxPostEvent(this->GetParent(), *newEvent);
183   event.Skip();
184 }
185
186 void wxCDMProjectDescriptionPanel::OnBtnCreateApplication(wxCommandEvent& event)
187 {
188   //TODO: implement method
189   std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
190   event.Skip();
191 }
192
193 void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
194 {
195   //TODO: implement method
196   std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
197   event.Skip();
198 }
199
200 void wxCDMProjectDescriptionPanel::OnCreationComplete(wxCommandEvent& event)
201 {
202   std::cout << "catched" << std::endl;
203
204 }