]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMPackageManagerHelpDialog.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / wxCDMPackageManagerHelpDialog.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  * wxCDMPackageManagerHelpDialog.cpp
31  *
32  *  Created on: 7/1/2013
33  *      Author: Daniel Felipe Gonzalez Obando
34  */
35
36 #include "wxCDMPackageManagerHelpDialog.h"
37
38 #include "creaDevManagerIds.h"
39
40 BEGIN_EVENT_TABLE(wxCDMPackageManagerHelpDialog, wxDialog)
41 EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMPackageManagerHelpDialog::OnFinish)
42 EVT_BUTTON(ID_BUTTON_CREATE_PACKAGE, wxCDMPackageManagerHelpDialog::OnCreatePackage)
43 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMPackageManagerHelpDialog::OnEditCMake)
44 EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMPackageManagerHelpDialog::OnDisableHelp)
45 END_EVENT_TABLE()
46
47 wxCDMPackageManagerHelpDialog::wxCDMPackageManagerHelpDialog(
48     wxWindow* parent,
49     wxCDMPackageManagerPanel* packageManager,
50     wxWindowID id,
51     const wxString& caption,
52     const wxPoint& position,
53     const wxSize& size,
54     long style
55 )
56 {
57   wxCDMPackageManagerHelpDialog::Create(parent, id, caption, position, size, style);
58   this->packageManager = packageManager;
59 }
60
61 wxCDMPackageManagerHelpDialog::~wxCDMPackageManagerHelpDialog()
62 {
63 }
64
65 bool wxCDMPackageManagerHelpDialog::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 wxCDMPackageManagerHelpDialog::CreateControls()
82 {
83   wxBoxSizer* v_sizer1 = new wxBoxSizer(wxVERTICAL);
84
85
86   wxStaticText* title = new wxStaticText(this, wxID_ANY, wxT("Managing your packages"), 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           "Packages contain black boxes, which allow to work modularly with other boxes. This boxes can use the functions "
94           "present in your libraries and expose them to work in a BBTK-fashion.\n"
95           "\n"
96           "In the package manager you can view a list of the available packages in the current project, as well as create "
97           "new packages. Remember that any package you make must be included in the CMakeLists file. You can do that by "
98           "clicking on the \"Edit CMakeLists File\" button in the package manager section and include the desired packages "
99           "at the end of the file. You should also include in this file those libraries your black boxes located in this "
100           "package use."),
101           wxDefaultPosition,
102           wxDefaultSize,
103           wxALIGN_LEFT
104   );
105   v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5);
106
107 //  wxFlexGridSizer* formItems = new wxFlexGridSizer(1,2,9,15);
108 //
109 //  wxButton* createPackageBtn = new wxButton(this, ID_BUTTON_CREATE_PACKAGE, wxT("Create a Package"));
110 //  wxButton* editCMakeBtn= new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Edit the CMakeLists File"));
111 //  editCMakeBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerHelpDialog::OnEditCMakeMouseEnter,NULL,this);
112 //  editCMakeBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerHelpDialog::OnEditCMakeMouseExit,NULL,this);
113 //
114 //  formItems->Add(createPackageBtn, 1, wxALIGN_CENTER);
115 //  formItems->Add(editCMakeBtn, 1, wxALIGN_CENTER);
116 //
117 //  formItems->AddGrowableCol(0,1);
118 //  formItems->AddGrowableCol(1,1);
119 //
120 //  v_sizer1->Add(formItems, 1, wxEXPAND | wxALL, 15);
121
122   v_sizer1->Add(new wxCheckBox(this, ID_CHECKBOX_DISABLE_HELP, wxT("&Disable help")), 0, wxALIGN_RIGHT | wxRIGHT, 10);
123
124   v_sizer1->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Close")), 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 30);
125
126   SetSizer(v_sizer1);
127   //v_sizer1->RecalcSizes();
128 }
129
130 void wxCDMPackageManagerHelpDialog::OnFinish(wxCommandEvent& event)
131 {
132   this->EndDialog(wxID_CANCEL);
133 }
134
135 void wxCDMPackageManagerHelpDialog::OnCreatePackage(wxCommandEvent& event)
136 {
137   if(this->packageManager != NULL)
138     {
139       wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_TOOL_CLICKED);
140       wxPostEvent(this->packageManager, *newEvent);
141     }
142   event.Skip();
143
144   this->EndDialog(wxID_OK);
145 }
146
147 void wxCDMPackageManagerHelpDialog::OnEditCMake(wxCommandEvent& event)
148 {
149   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_TOOL_ENTER);
150   if(this->packageManager != NULL)
151     wxPostEvent(this->packageManager, *newEvent);
152   event.Skip();
153
154   this->EndDialog(wxID_OK);
155 }
156
157
158 void wxCDMPackageManagerHelpDialog::OnEditCMakeMouseEnter(wxMouseEvent& event)
159 {
160   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
161
162   if(packageManager->GetProject()->GetCMakeLists() != NULL)
163     {
164       newEvent->SetClientData(packageManager->GetProject()->GetCMakeLists());
165       newEvent->SetId(0);
166       wxPostEvent(this->GetParent(), *newEvent);
167     }
168   event.Skip();
169 }
170
171 void wxCDMPackageManagerHelpDialog::OnEditCMakeMouseExit(wxMouseEvent& event)
172 {
173   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
174
175   if(packageManager->GetProject()->GetCMakeLists() != NULL)
176     {
177       newEvent->SetClientData(packageManager->GetProject()->GetCMakeLists());
178       newEvent->SetId(0);
179       wxPostEvent(this->GetParent(), *newEvent);
180     }
181   event.Skip();
182 }
183
184
185 void wxCDMPackageManagerHelpDialog::OnDisableHelp(wxCommandEvent& event)
186 {
187   wxPostEvent(this->GetParent(), event);
188 }