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