]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMProjectHelpDialog.cpp
97b925add2e9015077a50991f5fa89374a14afaf
[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   wxBoxSizer* v_sizer1 = new wxBoxSizer(wxVERTICAL);
87
88
89   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);
90   v_sizer1->Add(title, 0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL, 5);
91
92   wxStaticText* instruction = new wxStaticText(
93       this,
94       wxID_ANY,
95       crea::std2wx("When you create a project it comes with a default package. If you need to work in it or you want to create more "
96           "packages you can do it by clicking the \"Manage Packages\" button bellow. You can also work with Libraries and "
97           "Applications, just click in the \"Manage Libraries\" button or \"Manage Applications\" button to start working "
98           "with them.\n"
99           "\n"
100           "Select an action or click Close to continue working on the project."),
101           wxDefaultPosition,
102           wxDefaultSize,
103           wxALIGN_LEFT
104   );
105   v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5);
106
107   wxFlexGridSizer* formItems = new wxFlexGridSizer(2,2,9,15);
108
109   wxButton* managePackagesBtn = new wxButton(this, ID_BUTTON_GOTO_PACKAGE_MANAGER, wxT("Manage Packages"));
110   wxButton* manageLibrariesBtn = new wxButton(this, ID_BUTTON_GOTO_LIB_MANAGER, wxT("Manage Libraries"));
111   manageLibrariesBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectHelpDialog::OnLibMouseEnter,NULL,this);
112   manageLibrariesBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectHelpDialog::OnLibMouseExit,NULL,this);
113   wxButton* manageApplicationsBtn = new wxButton(this, ID_BUTTON_GOTO_APPLI_MANAGER, wxT("Manage Applications"));
114   manageApplicationsBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectHelpDialog::OnAppliMouseEnter,NULL,this);
115   manageApplicationsBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectHelpDialog::OnAppliMouseExit,NULL,this);
116
117   formItems->Add(managePackagesBtn, 1, wxALIGN_CENTER_VERTICAL);
118   formItems->Add(manageLibrariesBtn, 1, wxALIGN_CENTER_VERTICAL);
119   formItems->Add(manageApplicationsBtn, 1, wxALIGN_CENTER_VERTICAL);
120
121   formItems->AddGrowableCol(0,1);
122   formItems->AddGrowableCol(1,1);
123
124   v_sizer1->Add(formItems, 1, wxEXPAND | wxALL, 15);
125
126   v_sizer1->Add(new wxCheckBox(this, ID_CHECKBOX_DISABLE_HELP, wxT("&Disable help")), 0, wxALIGN_RIGHT | wxRIGHT, 10);
127
128   v_sizer1->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Close")), 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 30);
129
130   SetSizer(v_sizer1);
131   //v_sizer1->RecalcSizes();
132 }
133
134 void wxCDMProjectHelpDialog::OnFinish(wxCommandEvent& event)
135 {
136   this->EndDialog(wxID_CANCEL);
137 }
138
139 void wxCDMProjectHelpDialog::OnManagePackages(wxCommandEvent& event)
140 {
141   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
142   newEvent->SetId(1);
143   newEvent->SetString(wxT("manage_packages"));
144   newEvent->SetInt(this->projectDescription->GetProject()->GetId());
145   wxPostEvent(this->GetParent(), *newEvent);
146   event.Skip();
147
148   this->EndDialog(wxID_OK);
149 }
150
151 void wxCDMProjectHelpDialog::OnManageLibraries(wxCommandEvent& event)
152 {
153   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
154   newEvent->SetId(1);
155   newEvent->SetString(wxT("manage_libraries"));
156   wxPostEvent(this->GetParent(), *newEvent);
157
158   wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
159
160   if(this->projectDescription->GetProject()->GetLib() != NULL)
161     {
162       int CMId = this->projectDescription->GetProject()->GetLib()->GetId();
163       newEvent1->SetInt(CMId);
164       newEvent1->SetId(0);
165       wxPostEvent(this->GetParent(), *newEvent1);
166     }
167
168   event.Skip();
169
170   this->EndDialog(wxID_OK);
171 }
172
173 void wxCDMProjectHelpDialog::OnManageApplications(wxCommandEvent& event)
174 {
175   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
176   newEvent->SetId(1);
177   newEvent->SetString(wxT("manage_applications"));
178   wxPostEvent(this->GetParent(), *newEvent);
179
180   wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
181
182   if(this->projectDescription->GetProject()->GetAppli() != NULL)
183     {
184       int CMId = this->projectDescription->GetProject()->GetAppli()->GetId();
185       newEvent1->SetInt(CMId);
186       newEvent1->SetId(0);
187       wxPostEvent(this->GetParent(), *newEvent1);
188     }
189
190   event.Skip();
191
192   this->EndDialog(wxID_OK);
193 }
194
195 void wxCDMProjectHelpDialog::OnAppliMouseEnter(wxMouseEvent& event)
196 {
197   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
198
199   if(this->projectDescription->GetProject()->GetAppli() != NULL)
200     {
201       int AppId = this->projectDescription->GetProject()->GetAppli()->GetId();
202       newEvent->SetInt(AppId);
203       newEvent->SetId(0);
204       wxPostEvent(this->GetParent(), *newEvent);
205     }
206   event.Skip();
207 }
208
209 void wxCDMProjectHelpDialog::OnAppliMouseExit(wxMouseEvent& event)
210 {
211   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
212
213   if(this->projectDescription->GetProject()->GetAppli() != NULL)
214     {
215       int AppId = this->projectDescription->GetProject()->GetAppli()->GetId();
216       newEvent->SetInt(AppId);
217       newEvent->SetId(0);
218       wxPostEvent(this->GetParent(), *newEvent);
219     }
220   event.Skip();
221 }
222
223 void wxCDMProjectHelpDialog::OnLibMouseEnter(wxMouseEvent& event)
224 {
225   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
226
227   if(this->projectDescription->GetProject()->GetLib() != NULL)
228     {
229       int LbId = this->projectDescription->GetProject()->GetLib()->GetId();
230       newEvent->SetInt(LbId);
231       newEvent->SetId(0);
232       wxPostEvent(this->GetParent(), *newEvent);
233     }
234   event.Skip();
235 }
236
237 void wxCDMProjectHelpDialog::OnLibMouseExit(wxMouseEvent& event)
238 {
239   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
240
241   if(this->projectDescription->GetProject()->GetLib() != NULL)
242     {
243       int LbId = this->projectDescription->GetProject()->GetLib()->GetId();
244       newEvent->SetInt(LbId);
245       newEvent->SetId(0);
246       wxPostEvent(this->GetParent(), *newEvent);
247     }
248   event.Skip();
249 }
250
251 void wxCDMProjectHelpDialog::OnDisableHelp(wxCommandEvent& event)
252 {
253   wxPostEvent(this->GetParent(), event);
254 }