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