]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMProjectHelpDialog.cpp
7ced2c2c62daff1a08565d02ad71ee694c81e74b
[crea.git] / lib / creaDevManagerLib / wxCDMProjectHelpDialog.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  * wxCDMProjectReadyDialog.cpp
31  *
32  *  Created on: 3/1/2013
33  *      Author: Daniel Felipe Gonzalez Obando
34  */
35
36 #include "wxCDMProjectHelpDialog.h"
37
38 #include "wxCDMProjectDescriptionPanel.h"
39
40 #include "creaDevManagerIds.h"
41
42 BEGIN_EVENT_TABLE(wxCDMProjectHelpDialog, wxDialog)
43 EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMProjectHelpDialog::OnFinish)
44 EVT_BUTTON(ID_BUTTON_GOTO_PACKAGE_MANAGER, wxCDMProjectHelpDialog::OnManagePackages)
45 EVT_BUTTON(ID_BUTTON_GOTO_LIB_MANAGER, wxCDMProjectHelpDialog::OnManageLibraries)
46 EVT_BUTTON(ID_BUTTON_GOTO_APPLI_MANAGER, wxCDMProjectHelpDialog::OnManageApplications)
47 EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMProjectHelpDialog::OnDisableHelp)
48 END_EVENT_TABLE()
49
50 wxCDMProjectHelpDialog::wxCDMProjectHelpDialog(
51     wxWindow* parent,
52     wxCDMProjectDescriptionPanel* projectDescription,
53     wxWindowID id,
54     const wxString& caption,
55     const wxPoint& position,
56     const wxSize& size,
57     long style
58 )
59 {
60   wxCDMProjectHelpDialog::Create(parent, id, caption, position, size, style);
61   this->projectDescription = projectDescription;
62 }
63
64 wxCDMProjectHelpDialog::~wxCDMProjectHelpDialog()
65 {
66 }
67
68 bool wxCDMProjectHelpDialog::Create(
69     wxWindow* parent,
70     wxWindowID id,
71     const wxString& caption,
72     const wxPoint& position,
73     const wxSize& size,
74     long int style
75 )
76 {
77   wxDialog::Create(parent, id, caption, position, size, style);
78
79   this->CreateControls();
80
81   return TRUE;
82 }
83
84 void wxCDMProjectHelpDialog::CreateControls()
85 {
86
87   wxBoxSizer* v_sizer1 = new wxBoxSizer(wxVERTICAL);
88
89
90   wxStaticText* title = new wxStaticText(this, wxID_ANY, wxT("Your project is ready!"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);//new wxRichTextCtrl(this,wxID_ANY, wxString("Create a new project"), wxDefaultPosition, wxDefaultSize, wxRE_READONLY);
91   v_sizer1->Add(title, 0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL, 5);
92
93   wxStaticText* instruction = new wxStaticText(
94       this,
95       wxID_ANY,
96       crea::std2wx(
97           "A project has four main elements:\n"
98           "- Packages: Host the black boxes you make.\n"
99           "- Libraries: Contain the core functions of your programs, they are called by the black boxes and applications you make.\n"
100           "- Applications: Stand alone programs that use the functions available on your libraries.\n"
101           "- Configuration file: Contains the information of what should or shouldn't be compiled from this project.\n"
102           "\n"
103           "To the right of the project you will find a tree with the project structure and it's actual content.\n"
104           "When you create a project it comes with a default package. If you need to work on it or if you want to create more "
105           "packages you can do it by clicking the \"Package Manager\" button bellow. You can also work with Libraries and "
106           "Applications. Just click in the \"Library Manager\" button or \"Application manager\" button to start working "
107           "with them.\n"),
108           wxDefaultPosition,
109           wxDefaultSize,
110           wxALIGN_LEFT
111   );
112   v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5);
113
114   v_sizer1->Add(new wxCheckBox(this, ID_CHECKBOX_DISABLE_HELP, wxT("&Disable help")), 0, wxALIGN_RIGHT | wxRIGHT, 10);
115
116   v_sizer1->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Close")), 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 30);
117
118   SetSizer(v_sizer1);
119   //v_sizer1->RecalcSizes();
120 }
121
122 void wxCDMProjectHelpDialog::OnFinish(wxCommandEvent& event)
123 {
124   this->EndDialog(wxID_CANCEL);
125 }
126
127 void wxCDMProjectHelpDialog::OnManagePackages(wxCommandEvent& event)
128 {
129   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
130   newEvent->SetId(1);
131   newEvent->SetString(wxT("manage_packages"));
132   newEvent->SetInt(this->projectDescription->GetProject()->GetId());
133   wxPostEvent(this->GetParent(), *newEvent);
134   event.Skip();
135
136   this->EndDialog(wxID_OK);
137 }
138
139 void wxCDMProjectHelpDialog::OnManageLibraries(wxCommandEvent& event)
140 {
141   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
142   newEvent->SetId(1);
143   newEvent->SetString(wxT("manage_libraries"));
144   wxPostEvent(this->GetParent(), *newEvent);
145
146   wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
147
148   if(this->projectDescription->GetProject()->GetLib() != NULL)
149     {
150       int CMId = this->projectDescription->GetProject()->GetLib()->GetId();
151       newEvent1->SetInt(CMId);
152       newEvent1->SetId(0);
153       wxPostEvent(this->GetParent(), *newEvent1);
154     }
155
156   event.Skip();
157
158   this->EndDialog(wxID_OK);
159 }
160
161 void wxCDMProjectHelpDialog::OnManageApplications(wxCommandEvent& event)
162 {
163   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
164   newEvent->SetId(1);
165   newEvent->SetString(wxT("manage_applications"));
166   wxPostEvent(this->GetParent(), *newEvent);
167
168   wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
169
170   if(this->projectDescription->GetProject()->GetAppli() != NULL)
171     {
172       int CMId = this->projectDescription->GetProject()->GetAppli()->GetId();
173       newEvent1->SetInt(CMId);
174       newEvent1->SetId(0);
175       wxPostEvent(this->GetParent(), *newEvent1);
176     }
177
178   event.Skip();
179
180   this->EndDialog(wxID_OK);
181 }
182
183 void wxCDMProjectHelpDialog::OnAppliMouseEnter(wxMouseEvent& event)
184 {
185   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
186
187   if(this->projectDescription->GetProject()->GetAppli() != NULL)
188     {
189       int AppId = this->projectDescription->GetProject()->GetAppli()->GetId();
190       newEvent->SetInt(AppId);
191       newEvent->SetId(0);
192       wxPostEvent(this->GetParent(), *newEvent);
193     }
194   event.Skip();
195 }
196
197 void wxCDMProjectHelpDialog::OnAppliMouseExit(wxMouseEvent& event)
198 {
199   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
200
201   if(this->projectDescription->GetProject()->GetAppli() != NULL)
202     {
203       int AppId = this->projectDescription->GetProject()->GetAppli()->GetId();
204       newEvent->SetInt(AppId);
205       newEvent->SetId(0);
206       wxPostEvent(this->GetParent(), *newEvent);
207     }
208   event.Skip();
209 }
210
211 void wxCDMProjectHelpDialog::OnLibMouseEnter(wxMouseEvent& event)
212 {
213   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
214
215   if(this->projectDescription->GetProject()->GetLib() != NULL)
216     {
217       int LbId = this->projectDescription->GetProject()->GetLib()->GetId();
218       newEvent->SetInt(LbId);
219       newEvent->SetId(0);
220       wxPostEvent(this->GetParent(), *newEvent);
221     }
222   event.Skip();
223 }
224
225 void wxCDMProjectHelpDialog::OnLibMouseExit(wxMouseEvent& event)
226 {
227   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
228
229   if(this->projectDescription->GetProject()->GetLib() != NULL)
230     {
231       int LbId = this->projectDescription->GetProject()->GetLib()->GetId();
232       newEvent->SetInt(LbId);
233       newEvent->SetId(0);
234       wxPostEvent(this->GetParent(), *newEvent);
235     }
236   event.Skip();
237 }
238
239 void wxCDMProjectHelpDialog::OnDisableHelp(wxCommandEvent& event)
240 {
241   wxPostEvent(this->GetParent(), event);
242 }