]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMLibHelpDialog.cpp
Fixes:
[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 create must be included in the lib's folder CMakeLists file by using the "
99           "\"ADD_SUBDIRECTORY([libraryName])\" command. You can open this file by clicking on the \"Edit Lib's CMakeLists File\" "
100           "button below or in the Library Manager the \"Edit CMakeLists file\" button and include the desired libraries at the end "
101           "of the file."),
102           wxDefaultPosition,
103           wxDefaultSize,
104           wxALIGN_LEFT
105   );
106   v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5);
107
108   wxButton* editCMakeLibBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Edit Lib's CMakeLists File"));
109   editCMakeLibBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibHelpDialog::OnEditCMakeMouseEnter,NULL,this);
110   editCMakeLibBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibHelpDialog::OnEditCMakeMouseExit,NULL,this);
111   v_sizer1->Add(editCMakeLibBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15);
112
113   v_sizer1->Add(new wxCheckBox(this, ID_CHECKBOX_DISABLE_HELP, wxT("&Disable help")), 0, wxALIGN_RIGHT | wxRIGHT, 10);
114
115   v_sizer1->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Close")), 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 30);
116
117   SetSizer(v_sizer1);
118
119 }
120
121 void wxCDMLibHelpDialog::OnFinish(wxCommandEvent& event)
122 {
123   this->EndDialog(wxID_CANCEL);
124 }
125
126 void wxCDMLibHelpDialog::OnEditCMake(wxCommandEvent& event)
127 {
128   std::string* result;
129   if(!this->lib->OpenCMakeListsFile(result))
130     wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
131
132   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
133
134   if(this->lib->GetCMakeLists() != NULL)
135     {
136       newEvent->SetClientData(this->lib->GetCMakeLists());
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       newEvent->SetClientData(this->lib->GetCMakeLists());
150       newEvent->SetId(0);
151       wxPostEvent(this->GetParent(), *newEvent);
152     }
153   event.Skip();
154 }
155
156 void wxCDMLibHelpDialog::OnEditCMakeMouseExit(wxMouseEvent& event)
157 {
158   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
159
160   if(this->lib->GetCMakeLists() != NULL)
161     {
162       newEvent->SetClientData(this->lib->GetCMakeLists());
163       newEvent->SetId(0);
164       wxPostEvent(this->GetParent(), *newEvent);
165     }
166   event.Skip();
167 }
168
169
170 void wxCDMLibHelpDialog::OnDisableHelp(wxCommandEvent& event)
171 {
172   wxPostEvent(this->GetParent(), event);
173 }