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 * wxCDMApplicationHelpDialog.cpp
32 * Created on: 11/1/2013
33 * Author: Daniel Felipe Gonzalez Obando
36 #include "wxCDMApplicationHelpDialog.h"
38 #include "creaDevManagerIds.h"
40 #include "modelCDMAppli.h"
42 BEGIN_EVENT_TABLE(wxCDMApplicationHelpDialog, wxDialog)
43 EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMApplicationHelpDialog::OnFinish)
44 EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMApplicationHelpDialog::OnCMakeLists)
45 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMApplicationHelpDialog::OnCMakeLists)
46 EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMApplicationHelpDialog::OnDisableHelp)
49 wxCDMApplicationHelpDialog::wxCDMApplicationHelpDialog(
51 modelCDMApplication* application,
53 const wxString& caption,
54 const wxPoint& position,
59 wxCDMApplicationHelpDialog::Create(parent, id, caption, position, size, style);
60 this->application = application;
63 wxCDMApplicationHelpDialog::~wxCDMApplicationHelpDialog()
67 bool wxCDMApplicationHelpDialog::Create(
70 const wxString& caption,
71 const wxPoint& position,
76 wxDialog::Create(parent, id, caption, position, size, style);
78 this->CreateControls();
83 void wxCDMApplicationHelpDialog::CreateControls()
86 wxBoxSizer* v_sizer1 = new wxBoxSizer(wxVERTICAL);
89 wxStaticText* title = new wxStaticText(this, wxID_ANY, wxT("Working with Applications"), 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 "Applications are stand alone programs that use the projects' core functionality (libraries' functions). These "
97 "applications are useful when showing the projects' \"out of the box\" functionalities.\n"
98 "Applications are stored in the project's appli folder and each application has its own dedicated folder. Inside "
99 "these folders each application has its main file.\n"
101 "To start developing an application, go ahead and open the application main file with the button \"Open Main File\" "
102 "and implement the application's functionality.\n"
103 "If you need to create separate classes in the application folder, or inside an specific folders you can do it by "
104 "creating a new class with the \"Create Class\" button or by creating a folder with the \"Create Folder\" button.\n"
105 "Then, in order to include your applications in the project correctly you must include them in the appli's folder "
106 "\"CMakeLists.txt\" file using the command \"ADD_SUBDIRECTORY([applicationName])\". Also, if you create additional "
107 "folders in your application you should include them in the application's \"CMakeLists.txt\" file using the command "
108 "\"ADD_SUBDIRECTORY([folderName])\". If you use a third party library in your application you must include it by "
109 "uncommenting its inclusion in the application's \"CMakeLists.txt\" file. If you use a custom library in your "
110 "application you must include it by including the library path inside the \"INCLUDE_DIRECTORIES\" command, and its "
111 "name inside the \"SET ( ${EXE_NAME}_LINK_LIBRARIES...\"command.\n"
113 "You can easily edit the CMakeLists files previously mentioned by clicking on the following buttons."),
118 v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5);
120 wxButton* editCMakeApplicationBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Open Application's directory CMakeLists file"));
121 editCMakeApplicationBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationHelpDialog::OnCMakeListsEnter,NULL,this);
122 editCMakeApplicationBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationHelpDialog::OnCMakeListsExit,NULL,this);
123 wxButton* editCMakeAppliBtn= new wxButton(this, ID_BUTTON_OPENPROJECT, wxT("Open Appli's directory CMakeLists file"));
124 editCMakeAppliBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationHelpDialog::OnCMakeListsEnter,NULL,this);
125 editCMakeAppliBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationHelpDialog::OnCMakeListsExit,NULL,this);
127 v_sizer1->Add(editCMakeApplicationBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15);
128 v_sizer1->Add(editCMakeAppliBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15);
130 v_sizer1->Add(new wxCheckBox(this, ID_CHECKBOX_DISABLE_HELP, wxT("&Disable help")), 0, wxALIGN_RIGHT | wxRIGHT, 10);
132 v_sizer1->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Close")), 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 30);
135 //v_sizer1->RecalcSizes();
138 void wxCDMApplicationHelpDialog::OnFinish(wxCommandEvent& event)
140 this->EndDialog(wxID_CANCEL);
143 void wxCDMApplicationHelpDialog::OnCMakeLists(wxCommandEvent& event)
147 if((int)((wxButton*)event.GetEventObject())->GetId() == (int)ID_BUTTON_EDIT_CMAKELISTSFILE)
150 if(!this->application->OpenCMakeListsFile(result))
151 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
153 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
155 if(this->application->GetCMakeLists() != NULL)
157 newEvent->SetClientData(this->application->GetCMakeLists());
159 wxPostEvent(this->GetParent(), *newEvent);
162 else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT)
164 modelCDMIProjectTreeNode* node = this->application;
165 while (node != NULL && dynamic_cast<modelCDMAppli*>(node) == NULL)
167 node = node->GetParent();
171 if(!((modelCDMAppli*)node)->OpenCMakeListsFile(result))
172 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
174 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
176 if(((modelCDMAppli*)node)->GetCMakeLists() != NULL)
178 newEvent->SetClientData(((modelCDMAppli*)node)->GetCMakeLists());
180 wxPostEvent(this->GetParent(), *newEvent);
185 wxMessageBox(crea::std2wx("No project CMakeLists file was found."),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
190 void wxCDMApplicationHelpDialog::OnCMakeListsEnter(wxMouseEvent& event)
192 if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_EDIT_CMAKELISTSFILE)
194 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
196 if(this->application->GetCMakeLists() != NULL)
198 newEvent->SetClientData(this->application->GetCMakeLists());
200 wxPostEvent(this->GetParent(), *newEvent);
203 else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT)
205 modelCDMIProjectTreeNode* node = this->application;
206 while (node != NULL && dynamic_cast<modelCDMAppli*>(node) == NULL)
208 node = node->GetParent();
212 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
214 if(((modelCDMAppli*)node)->GetCMakeLists() != NULL)
216 newEvent->SetClientData(((modelCDMAppli*)node)->GetCMakeLists());
218 wxPostEvent(this->GetParent(), *newEvent);
225 void wxCDMApplicationHelpDialog::OnCMakeListsExit(wxMouseEvent& event)
227 if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_EDIT_CMAKELISTSFILE)
229 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
231 if(this->application->GetCMakeLists() != NULL)
233 newEvent->SetClientData(this->application->GetCMakeLists());
235 wxPostEvent(this->GetParent(), *newEvent);
238 else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT)
240 modelCDMIProjectTreeNode* node = this->application;
241 while (node != NULL && dynamic_cast<modelCDMAppli*>(node) == NULL)
243 node = node->GetParent();
247 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
249 if(((modelCDMAppli*)node)->GetCMakeLists() != NULL)
251 newEvent->SetClientData(((modelCDMAppli*)node)->GetCMakeLists());
253 wxPostEvent(this->GetParent(), *newEvent);
260 void wxCDMApplicationHelpDialog::OnDisableHelp(wxCommandEvent& event)
262 wxPostEvent(this->GetParent(), event);