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 * wxCDMApplicationDescriptionPanel.cpp
31 * Created on: Nov 27, 2012
32 * Author: Daniel Felipe Gonzalez Obando
35 #include "wxCDMApplicationDescriptionPanel.h"
37 #include "wxCDMMainFrame.h"
39 #include "creaDevManagerIds.h"
40 #include "images/AIcon64.xpm"
42 BEGIN_EVENT_TABLE(wxCDMApplicationDescriptionPanel, wxPanel)
43 EVT_BUTTON(ID_BUTTON_PREV, wxCDMApplicationDescriptionPanel::OnBtnReturn)
44 EVT_BUTTON(ID_BUTTON_CREATE_CLASS, wxCDMApplicationDescriptionPanel::OnBtnCreateClass)
45 EVT_BUTTON(ID_BUTTON_CREATE_FOLDER, wxCDMApplicationDescriptionPanel::OnBtnCreateFolder)
46 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMApplicationDescriptionPanel::OnBtnEditCMakeLists)
47 EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMApplicationDescriptionPanel::OnBtnOpenFolder)
50 wxCDMApplicationDescriptionPanel::wxCDMApplicationDescriptionPanel(
52 modelCDMApplication* application,
54 const wxString& caption,
60 wxCDMApplicationDescriptionPanel::Create(parent, application, id, caption, pos, size, style);
63 wxCDMApplicationDescriptionPanel::~wxCDMApplicationDescriptionPanel()
67 bool wxCDMApplicationDescriptionPanel::Create(
69 modelCDMApplication* application,
71 const wxString& caption,
77 wxPanel::Create(parent, id, pos, size, style);
78 this->application = application;
83 void wxCDMApplicationDescriptionPanel::CreateControls()
85 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
88 wxButton* returnbt = new wxButton(this, ID_BUTTON_PREV, wxT("Return to project"));
89 returnbt->SetToolTip(wxT("Return to the active project description."));
90 sizer->Add(returnbt, 0, wxALIGN_CENTER | wxALL, 5);
93 sizer->Add(new wxStaticText(this, -1, _("Application")),0, wxALIGN_CENTER, 0);
96 sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(AIcon64)),0, wxALIGN_CENTER, 0);
99 sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->application->GetNameApplication())),0, wxALIGN_CENTER, 0);
102 wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("&Properties"));
103 wxPanel* propertiesPanel = new wxPanel(this);
104 wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
106 wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
108 wxStaticText *pMainFile = new wxStaticText(propertiesPanel, -1, wxT("Executable Name"));
109 wxBoxSizer* pMainFilesz = new wxBoxSizer(wxHORIZONTAL);
110 wxStaticText* pMainFiletc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->application->GetExecutableName()));
111 wxButton* pMainFilebt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set"));
112 pMainFilebt->SetToolTip(wxT("Set the name of the executable file for the application."));
113 pMainFilesz->Add(pMainFiletc, 0, wxALIGN_CENTER_VERTICAL, 0);
114 pMainFilesz->Add(pMainFilebt, 0, wxALIGN_CENTER | wxLEFT, 10);
116 propertiesGridSizer->Add(pMainFile, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
117 propertiesGridSizer->Add(pMainFilesz, 1, wxEXPAND);
119 propertiesGridSizer->AddGrowableCol(1,1);
121 propertiesPanelSizer->Add(propertiesGridSizer, 0, wxEXPAND);
122 propertiesPanel->SetSizer(propertiesPanelSizer);
123 propertiesPanelSizer->Fit(propertiesPanel);
124 propertiesBox->Add(propertiesPanel, 0, wxEXPAND);
125 sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
128 //actions StaticBoxSizer
129 wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("&Actions"));
130 actionsBox->GetStaticBox()->SetToolTip(wxT("Create classes or edit them for this application, as well as editing the application's CMakeLists.txt file by selecting the desired action."));
132 wxPanel* actionsPanel = new wxPanel(this);
134 wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
136 wxButton* createClassbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_CLASS, _T("Create Class"));
137 createClassbt->SetToolTip(wxT("Create a new Class (.h and .cxx files)."));
138 wxButton* createFolderbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_FOLDER, _T("Create Folder"));
139 createFolderbt->SetToolTip(wxT("Create a new Folder inside the application folder."));
140 wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
141 editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file inside this application."));
142 editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationDescriptionPanel::OnCMakeMouseEnter,NULL,this);
143 editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationDescriptionPanel::OnCMakeMouseExit,NULL,this);
144 wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Application Folder"));
145 openFolderbt->SetToolTip(wxT("Open the application folder in the file explorer."));
148 actionsPanelSizer->Add(createClassbt, 0, wxALL, 5);
149 actionsPanelSizer->Add(createFolderbt, 0, wxALL, 5);
150 actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5);
151 actionsPanelSizer->Add(openFolderbt, 0, wxALL, 5);
153 //SetPanel sizer and box
154 actionsPanel->SetSizer(actionsPanelSizer);
155 actionsPanelSizer->Fit(actionsPanel);
156 actionsBox->Add(actionsPanel, 0, wxALL, 5);
157 sizer->Add(actionsBox, 0, wxEXPAND | wxALL, 10);
161 sizer->SetSizeHints(this);
164 void wxCDMApplicationDescriptionPanel::OnBtnReturn(wxCommandEvent& event)
166 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
167 newEvent->SetInt(((wxCDMMainFrame*)this->GetParent())->GetModel()->GetProject()->GetId());
169 wxPostEvent(this->GetParent(), *newEvent);
172 void wxCDMApplicationDescriptionPanel::OnBtnCreateClass(wxCommandEvent& event)
174 //TODO: implement method
175 std::cerr << "Event OnBtnCreateClass not implemented" << std::endl;
179 void wxCDMApplicationDescriptionPanel::OnBtnCreateFolder(wxCommandEvent& event)
181 //TODO: implement method
182 std::cerr << "Event OnBtnCreateFolder not implemented" << std::endl;
186 void wxCDMApplicationDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
189 if(!this->application->OpenCMakeListsFile(result))
190 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
192 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
194 if(this->application->GetCMakeLists() != NULL)
196 int CMId = this->application->GetCMakeLists()->GetId();
197 newEvent->SetInt(CMId);
199 wxPostEvent(this->GetParent(), *newEvent);
205 void wxCDMApplicationDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
208 if(!this->application->OpenInFileExplorer(result))
209 wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);
212 void wxCDMApplicationDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event)
214 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
216 if(this->application->GetCMakeLists() != NULL)
218 int CMId = this->application->GetCMakeLists()->GetId();
219 newEvent->SetInt(CMId);
221 wxPostEvent(this->GetParent(), *newEvent);
226 void wxCDMApplicationDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event)
228 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
230 if(this->application->GetCMakeLists() != NULL)
232 int CMId = this->application->GetCMakeLists()->GetId();
233 newEvent->SetInt(CMId);
235 wxPostEvent(this->GetParent(), *newEvent);