]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMAppliHelpDialog.cpp
Fixes:
[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 by using the "
98           "\"ADD_SUBDIRECTORY([applicationName])\" command. You can do that by clicking on the \"Edit Appli's CMakeLists File\" button "
99           "below or in the Application Manager the \"Edit CMakeLists file\" button and include the desired applications at the end of "
100           "the file.\n"
101           "For a better understanding of how to use the applications please check the \"myFierceAppli\" application (which is shipped by "
102           "default in every new project) and take a look at how it's included in the project."),
103           wxDefaultPosition,
104           wxDefaultSize,
105           wxALIGN_LEFT
106   );
107   v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5);
108
109   wxButton* editCMakeAppliBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Edit Appli's CMakeLists File"));
110   editCMakeAppliBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliHelpDialog::OnCMakeListsEnter,NULL,this);
111   editCMakeAppliBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliHelpDialog::OnCMakeListsExit,NULL,this);
112   v_sizer1->Add(editCMakeAppliBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15);
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
120 }
121
122 void wxCDMAppliHelpDialog::OnFinish(wxCommandEvent& event)
123 {
124   this->EndDialog(wxID_CANCEL);
125 }
126
127 void wxCDMAppliHelpDialog::OnEditCMake(wxCommandEvent& event)
128 {
129   std::string* result;
130   if(!this->appli->OpenCMakeListsFile(result))
131     wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
132
133   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
134
135   if(this->appli->GetCMakeLists() != NULL)
136     {
137       newEvent->SetClientData(this->appli->GetCMakeLists());
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       newEvent->SetClientData(this->appli->GetCMakeLists());
151       newEvent->SetId(0);
152       wxPostEvent(this->GetParent(), *newEvent);
153     }
154   event.Skip();
155 }
156
157 void wxCDMAppliHelpDialog::OnCMakeListsExit(wxMouseEvent& event)
158 {
159   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
160
161   if(this->appli->GetCMakeLists() != NULL)
162     {
163       newEvent->SetClientData(this->appli->GetCMakeLists());
164       newEvent->SetId(0);
165       wxPostEvent(this->GetParent(), *newEvent);
166     }
167   event.Skip();
168 }
169
170
171 void wxCDMAppliHelpDialog::OnDisableHelp(wxCommandEvent& event)
172 {
173   wxPostEvent(this->GetParent(), event);
174 }