]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMAppliHelpDialog.cpp
446c65159651c615c91b01b6555b496043acaee1
[crea.git] / lib / creaDevManagerLib / wxCDMAppliHelpDialog.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 /*
30  * wxCDMAppliHelpDialog.cpp
31  *
32  *  Created on: 11/1/2013
33  *      Author: Daniel Felipe Gonzalez Obando
34  */
35
36 #include "wxCDMAppliHelpDialog.h"
37
38 #include "creaDevManagerIds.h"
39
40
41 BEGIN_EVENT_TABLE(wxCDMAppliHelpDialog, wxDialog)
42 EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMAppliHelpDialog::OnFinish)
43 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMAppliHelpDialog::OnEditCMake)
44 EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMAppliHelpDialog::OnDisableHelp)
45 END_EVENT_TABLE()
46
47 wxCDMAppliHelpDialog::wxCDMAppliHelpDialog(
48     wxWindow* parent,
49     modelCDMAppli* appli,
50     wxWindowID id,
51     const wxString& caption,
52     const wxPoint& position,
53     const wxSize& size,
54     long style
55 )
56 {
57   wxCDMAppliHelpDialog::Create(parent, id, caption, position, size, style);
58   this->appli = appli;
59 }
60
61 wxCDMAppliHelpDialog::~wxCDMAppliHelpDialog()
62 {
63 }
64
65 bool wxCDMAppliHelpDialog::Create(
66     wxWindow* parent,
67     wxWindowID id,
68     const wxString& caption,
69     const wxPoint& position,
70     const wxSize& size,
71     long int style
72 )
73 {
74   wxDialog::Create(parent, id, caption, position, size, style);
75
76   this->CreateControls();
77
78   return TRUE;
79 }
80
81 void wxCDMAppliHelpDialog::CreateControls()
82 {
83   wxBoxSizer* v_sizer1 = new wxBoxSizer(wxVERTICAL);
84
85
86   wxStaticText* title = new wxStaticText(this, wxID_ANY, wxT("Managing your applications"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);//new wxRichTextCtrl(this,wxID_ANY, wxString("Create a new project"), wxDefaultPosition, wxDefaultSize, wxRE_READONLY);
87   v_sizer1->Add(title, 0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL, 5);
88
89   wxStaticText* instruction = new wxStaticText(
90       this,
91       wxID_ANY,
92       crea::std2wx(
93           "Applications are stand alone programs that use the projects' core functionality (libraries' functions). These "
94           "applications are useful when showing the projects' \"out of the box\" functionalities.\n"
95           "\n"
96           "In the application manager you can view a list of the available applications in the current project, as well as create "
97           "new applications. Remember that any application you make must be included in the appli's folder CMakeLists file. You can do that "
98           "by clicking on the \"Edit Appli's CMakeLists File\" button bellow or in the Application Manager the \"Edit CMakeLists file\" "
99           "button and include the desired applications at the end of the file.\n"
100           "For a better understanding of how to use the applications please check the \"myFierceAppli\" application (which is shipped by "
101           "default in every new project) and take a look at how it's included in the project."),
102           wxDefaultPosition,
103           wxDefaultSize,
104           wxALIGN_LEFT
105   );
106   v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5);
107
108   wxButton* editCMakeAppliBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Edit Appli's CMakeLists File"));
109   editCMakeAppliBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliHelpDialog::OnCMakeListsEnter,NULL,this);
110   editCMakeAppliBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliHelpDialog::OnCMakeListsExit,NULL,this);
111   v_sizer1->Add(editCMakeAppliBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15);
112
113   v_sizer1->Add(new wxCheckBox(this, ID_CHECKBOX_DISABLE_HELP, wxT("&Disable help")), 0, wxALIGN_RIGHT | wxRIGHT, 10);
114
115   v_sizer1->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Close")), 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 30);
116
117   SetSizer(v_sizer1);
118
119 }
120
121 void wxCDMAppliHelpDialog::OnFinish(wxCommandEvent& event)
122 {
123   this->EndDialog(wxID_CANCEL);
124 }
125
126 void wxCDMAppliHelpDialog::OnEditCMake(wxCommandEvent& event)
127 {
128   std::string* result;
129   if(!this->appli->OpenCMakeListsFile(result))
130     wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
131
132   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
133
134   if(this->appli->GetCMakeLists() != NULL)
135     {
136       int CMId = this->appli->GetCMakeLists()->GetId();
137       newEvent->SetInt(CMId);
138       newEvent->SetId(0);
139       wxPostEvent(this->GetParent(), *newEvent);
140     }
141 }
142
143
144 void wxCDMAppliHelpDialog::OnCMakeListsEnter(wxMouseEvent& event)
145 {
146   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
147
148   if(this->appli->GetCMakeLists() != NULL)
149     {
150       int CMId = this->appli->GetCMakeLists()->GetId();
151       newEvent->SetInt(CMId);
152       newEvent->SetId(0);
153       wxPostEvent(this->GetParent(), *newEvent);
154     }
155   event.Skip();
156 }
157
158 void wxCDMAppliHelpDialog::OnCMakeListsExit(wxMouseEvent& event)
159 {
160   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
161
162   if(this->appli->GetCMakeLists() != NULL)
163     {
164       int CMId = this->appli->GetCMakeLists()->GetId();
165       newEvent->SetInt(CMId);
166       newEvent->SetId(0);
167       wxPostEvent(this->GetParent(), *newEvent);
168     }
169   event.Skip();
170 }
171
172
173 void wxCDMAppliHelpDialog::OnDisableHelp(wxCommandEvent& event)
174 {
175   wxPostEvent(this->GetParent(), event);
176 }