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 # ------------------------------------------------------------------------
29 * wxCDMProjectDescriptionPanel.cpp
31 * Created on: Nov 27, 2012
32 * Author: Daniel Felipe Gonzalez Obando
35 #include "wxCDMProjectDescriptionPanel.h"
37 #include "wxCDMMainFrame.h"
39 #include "creaDevManagerIds.h"
40 #include "images/PrIcon64.xpm"
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)
51 wxCDMProjectDescriptionPanel::wxCDMProjectDescriptionPanel(
53 modelCDMProject* project,
55 const wxString& caption,
61 wxCDMProjectDescriptionPanel::Create(parent, project, id, caption, pos, size, style);
64 wxCDMProjectDescriptionPanel::~wxCDMProjectDescriptionPanel()
68 bool wxCDMProjectDescriptionPanel::Create(
70 modelCDMProject* project,
72 const wxString& caption,
78 wxPanel::Create(parent, id, pos, size, style);
79 this->project = project;
84 void wxCDMProjectDescriptionPanel::CreateControls()
86 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
89 sizer->Add(new wxStaticText(this, -1, _("Project")),0, wxALIGN_CENTER, 0);
92 sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(PrIcon64)),0, wxALIGN_CENTER, 0);
95 sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->project->GetName())),0, wxALIGN_CENTER, 0);
98 wxStaticBox* propertiesBox = new wxStaticBox(this, -1, _T("&Properties"));
99 wxStaticBoxSizer* propertiesBoxInnerSizer = new wxStaticBoxSizer(propertiesBox, wxVERTICAL);
101 wxFlexGridSizer* flexGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
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"));
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()));
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);
122 propertiesBoxInnerSizer -> Add(flexGridSizer, 0, wxEXPAND);
123 sizer -> Add(propertiesBoxInnerSizer, 1, wxEXPAND | wxALL, 20);
126 wxStaticBox* actionsBox = new wxStaticBox(this, -1, _T("&Actions"));
127 wxStaticBoxSizer* actionsBoxInnerSizer = new wxStaticBoxSizer(actionsBox, wxVERTICAL);
128 sizer -> Add(actionsBoxInnerSizer, 1, wxEXPAND | wxALL, 20);
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);
135 actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20);
138 actionsBoxInnerSizer->SetSizeHints(this);
141 sizer->SetSizeHints(this);
144 void wxCDMProjectDescriptionPanel::OnBtnCreatePackage(wxCommandEvent& event)
146 //TODO: implement method
147 //TODO: call project to create package : use bbCreatePackage <path> <name> [author] [description]
148 std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
152 void wxCDMProjectDescriptionPanel::OnBtnCreateBlackBox(wxCommandEvent& event)
154 //TODO: implement method
155 std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
159 void wxCDMProjectDescriptionPanel::OnBtnCreateLibrary(wxCommandEvent& event)
162 wxString libraryName = wxGetTextFromUser(
163 _T("Enter the new library name"),
164 _T("New Library - creaDevManager"),
168 if(libraryName.Len() > 0)
172 modelCDMIProjectTreeNode* library = this->project->CreateLibrary(crea::wx2std(libraryName),result);
173 //check library created
176 wxMessageBox(crea::std2wx(*result),_T("New Library - Error!"),wxOK | wxICON_ERROR);
180 wxMessageBox(crea::std2wx("Library successfully created."),_T("New Library - Success!"),wxOK | wxICON_INFORMATION);
182 //refreshing tree and description
183 //send event instead of calling parent to avoid crashing
185 ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
187 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
188 newEvent->SetInt(library->GetId());
189 wxPostEvent(this->GetParent(), *newEvent);
194 void wxCDMProjectDescriptionPanel::OnBtnCreateApplication(wxCommandEvent& event)
196 //TODO: implement method
197 std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
201 void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
203 //TODO: implement method
204 std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
208 void wxCDMProjectDescriptionPanel::OnCreationComplete(wxCommandEvent& event)
210 std::cout << "catched" << std::endl;