]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMPackageManagerHelpDialog.cpp
Fixes:
[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 using \"ADD_SUBDIRECTORY([packageName])\"."),
100           wxDefaultPosition,
101           wxDefaultSize,
102           wxALIGN_LEFT
103   );
104   v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5);
105
106 //  wxFlexGridSizer* formItems = new wxFlexGridSizer(1,2,9,15);
107 //
108 //  wxButton* createPackageBtn = new wxButton(this, ID_BUTTON_CREATE_PACKAGE, wxT("Create a Package"));
109 //  wxButton* editCMakeBtn= new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Edit the CMakeLists File"));
110 //  editCMakeBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerHelpDialog::OnEditCMakeMouseEnter,NULL,this);
111 //  editCMakeBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerHelpDialog::OnEditCMakeMouseExit,NULL,this);
112 //
113 //  formItems->Add(createPackageBtn, 1, wxALIGN_CENTER);
114 //  formItems->Add(editCMakeBtn, 1, wxALIGN_CENTER);
115 //
116 //  formItems->AddGrowableCol(0,1);
117 //  formItems->AddGrowableCol(1,1);
118 //
119 //  v_sizer1->Add(formItems, 1, wxEXPAND | wxALL, 15);
120
121   v_sizer1->Add(new wxCheckBox(this, ID_CHECKBOX_DISABLE_HELP, wxT("&Disable help")), 0, wxALIGN_RIGHT | wxRIGHT, 10);
122
123   v_sizer1->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Close")), 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 30);
124
125   SetSizer(v_sizer1);
126   //v_sizer1->RecalcSizes();
127 }
128
129 void wxCDMPackageManagerHelpDialog::OnFinish(wxCommandEvent& event)
130 {
131   this->EndDialog(wxID_CANCEL);
132 }
133
134 void wxCDMPackageManagerHelpDialog::OnCreatePackage(wxCommandEvent& event)
135 {
136   if(this->packageManager != NULL)
137     {
138       wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_TOOL_CLICKED);
139       wxPostEvent(this->packageManager, *newEvent);
140     }
141   event.Skip();
142
143   this->EndDialog(wxID_OK);
144 }
145
146 void wxCDMPackageManagerHelpDialog::OnEditCMake(wxCommandEvent& event)
147 {
148   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_TOOL_ENTER);
149   if(this->packageManager != NULL)
150     wxPostEvent(this->packageManager, *newEvent);
151   event.Skip();
152
153   this->EndDialog(wxID_OK);
154 }
155
156
157 void wxCDMPackageManagerHelpDialog::OnEditCMakeMouseEnter(wxMouseEvent& event)
158 {
159   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
160
161   if(packageManager->GetProject()->GetCMakeLists() != NULL)
162     {
163       newEvent->SetClientData(packageManager->GetProject()->GetCMakeLists());
164       newEvent->SetId(0);
165       wxPostEvent(this->GetParent(), *newEvent);
166     }
167   event.Skip();
168 }
169
170 void wxCDMPackageManagerHelpDialog::OnEditCMakeMouseExit(wxMouseEvent& event)
171 {
172   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
173
174   if(packageManager->GetProject()->GetCMakeLists() != NULL)
175     {
176       newEvent->SetClientData(packageManager->GetProject()->GetCMakeLists());
177       newEvent->SetId(0);
178       wxPostEvent(this->GetParent(), *newEvent);
179     }
180   event.Skip();
181 }
182
183
184 void wxCDMPackageManagerHelpDialog::OnDisableHelp(wxCommandEvent& event)
185 {
186   wxPostEvent(this->GetParent(), event);
187 }