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 * wxCDMPackageHelpDialog.cpp
32 * Created on: 9/1/2013
33 * Author: Daniel Felipe Gonzalez Obando
36 #include "wxCDMPackageHelpDialog.h"
38 #include "creaDevManagerIds.h"
40 #include "modelCDMProject.h"
42 BEGIN_EVENT_TABLE(wxCDMPackageHelpDialog, wxDialog)
43 EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMPackageHelpDialog::OnCMakeLists)
44 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMPackageHelpDialog::OnCMakeLists)
45 EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMPackageHelpDialog::OnFinish)
46 EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMPackageHelpDialog::OnDisableHelp)
49 wxCDMPackageHelpDialog::wxCDMPackageHelpDialog(
51 modelCDMPackage* package,
53 const wxString& caption,
54 const wxPoint& position,
59 wxCDMPackageHelpDialog::Create(parent, id, caption, position, size, style);
60 this->package = package;
63 wxCDMPackageHelpDialog::~wxCDMPackageHelpDialog()
67 bool wxCDMPackageHelpDialog::Create(
70 const wxString& caption,
71 const wxPoint& position,
76 wxDialog::Create(parent, id, caption, position, size, style);
78 this->CreateControls();
83 void wxCDMPackageHelpDialog::CreateControls()
86 wxBoxSizer* v_sizer1 = new wxBoxSizer(wxVERTICAL);
89 wxStaticText* title = new wxStaticText(this, wxID_ANY, wxT("Working with Packages"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);//new wxRichTextCtrl(this,wxID_ANY, wxString("Create a new project"), wxDefaultPosition, wxDefaultSize, wxRE_READONLY);
90 v_sizer1->Add(title, 0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL, 5);
92 wxStaticText* instruction = new wxStaticText(
96 "Packages contain black boxes, which allow to work modularly with other boxes. This boxes can use the functions "
97 "present in your libraries and expose them to work in a BBTK-fashion.\n"
99 "To create a black box click on the \"Create Black Box\" button.\n"
100 "If you want to check the files in the file explorer click the \"Open Package Folder\" "
103 "Don't forget to include the libraries your black boxes use in the Package directory CMakeLists.txt file\n"
104 "Also, make sure you include this package in the Project directory CMakeLists.txt file\n"
105 "You can open these files with the following buttons."),
110 v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5);
112 wxButton* editCMakePkgBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Open Package's directory CMakeLists file"));
113 editCMakePkgBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageHelpDialog::OnCMakeListsEnter,NULL,this);
114 editCMakePkgBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageHelpDialog::OnCMakeListsExit,NULL,this);
115 wxButton* editCMakePrjBtn= new wxButton(this, ID_BUTTON_OPENPROJECT, wxT("Open Project's directory CMakeLists file"));
116 editCMakePrjBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageHelpDialog::OnCMakeListsEnter,NULL,this);
117 editCMakePrjBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageHelpDialog::OnCMakeListsExit,NULL,this);
119 v_sizer1->Add(editCMakePkgBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15);
120 v_sizer1->Add(editCMakePrjBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15);
122 v_sizer1->Add(new wxCheckBox(this, ID_CHECKBOX_DISABLE_HELP, wxT("&Disable help")), 0, wxALIGN_RIGHT | wxRIGHT, 10);
124 v_sizer1->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Close")), 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 30);
127 //v_sizer1->RecalcSizes();
130 void wxCDMPackageHelpDialog::OnCMakeLists(wxCommandEvent& event)
134 if((int)((wxButton*)event.GetEventObject())->GetId() == (int)ID_BUTTON_EDIT_CMAKELISTSFILE)
137 if(!this->package->OpenCMakeListsFile(result))
138 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
140 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
142 if(this->package->GetCMakeLists() != NULL)
144 int CMId = this->package->GetCMakeLists()->GetId();
145 newEvent->SetInt(CMId);
147 wxPostEvent(this->GetParent(), *newEvent);
150 else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT)
152 modelCDMIProjectTreeNode* node = this->package;
153 while (node != NULL && dynamic_cast<modelCDMProject*>(node) == NULL)
155 node = node->GetParent();
159 if(!((modelCDMProject*)node)->OpenCMakeListsFile(result))
160 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
162 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
164 if(((modelCDMProject*)node)->GetCMakeLists() != NULL)
166 int CMId = ((modelCDMProject*)node)->GetCMakeLists()->GetId();
167 newEvent->SetInt(CMId);
169 wxPostEvent(this->GetParent(), *newEvent);
174 wxMessageBox(crea::std2wx("No project CMakeLists file was found."),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
179 void wxCDMPackageHelpDialog::OnCMakeListsEnter(wxMouseEvent& event)
181 if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_EDIT_CMAKELISTSFILE)
183 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
185 if(this->package->GetCMakeLists() != NULL)
187 int CMId = this->package->GetCMakeLists()->GetId();
188 newEvent->SetInt(CMId);
190 wxPostEvent(this->GetParent(), *newEvent);
193 else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT)
195 modelCDMIProjectTreeNode* node = this->package;
196 while (node != NULL && dynamic_cast<modelCDMProject*>(node) == NULL)
198 node = node->GetParent();
202 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
204 if(((modelCDMProject*)node)->GetCMakeLists() != NULL)
206 int CMId = ((modelCDMProject*)node)->GetCMakeLists()->GetId();
207 newEvent->SetInt(CMId);
209 wxPostEvent(this->GetParent(), *newEvent);
216 void wxCDMPackageHelpDialog::OnCMakeListsExit(wxMouseEvent& event)
218 if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_EDIT_CMAKELISTSFILE)
220 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
222 if(this->package->GetCMakeLists() != NULL)
224 int CMId = this->package->GetCMakeLists()->GetId();
225 newEvent->SetInt(CMId);
227 wxPostEvent(this->GetParent(), *newEvent);
230 else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT)
232 modelCDMIProjectTreeNode* node = this->package;
233 while (node != NULL && dynamic_cast<modelCDMProject*>(node) == NULL)
235 node = node->GetParent();
239 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
241 if(((modelCDMProject*)node)->GetCMakeLists() != NULL)
243 int CMId = ((modelCDMProject*)node)->GetCMakeLists()->GetId();
244 newEvent->SetInt(CMId);
246 wxPostEvent(this->GetParent(), *newEvent);
253 void wxCDMPackageHelpDialog::OnFinish(wxCommandEvent& event)
255 this->EndDialog(wxID_CANCEL);
258 void wxCDMPackageHelpDialog::OnDisableHelp(wxCommandEvent& event)
260 wxPostEvent(this->GetParent(), event);