]> 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           "In the package manager you can view a list of the available packages in the current project, as well as create "
94           "new packages. Remember that any package you make must be included in the CMakeLists file. You can do that by "
95           "clicking on the \"Edit CMakeLists File\" button and include the desired packages at the end of the file. You "
96           "should also include the libraries you are using on your black boxes in this file.\n"
97           "\n"
98           "Select an action or click Close to continue working on the project."),
99           wxDefaultPosition,
100           wxDefaultSize,
101           wxALIGN_LEFT
102   );
103   v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5);
104
105   wxFlexGridSizer* formItems = new wxFlexGridSizer(1,2,9,15);
106
107   wxButton* createPackageBtn = new wxButton(this, ID_BUTTON_CREATE_PACKAGE, wxT("Create a Package"));
108   wxButton* editCMakeBtn= new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Edit the CMakeLists File"));
109   editCMakeBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerHelpDialog::OnEditCMakeMouseEnter,NULL,this);
110   editCMakeBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerHelpDialog::OnEditCMakeMouseExit,NULL,this);
111
112   formItems->Add(createPackageBtn, 1, wxALIGN_CENTER);
113   formItems->Add(editCMakeBtn, 1, wxALIGN_CENTER);
114
115   formItems->AddGrowableCol(0,1);
116   formItems->AddGrowableCol(1,1);
117
118   v_sizer1->Add(formItems, 1, wxEXPAND | wxALL, 15);
119
120   v_sizer1->Add(new wxCheckBox(this, ID_CHECKBOX_DISABLE_HELP, wxT("&Disable help")), 0, wxALIGN_RIGHT | wxRIGHT, 10);
121
122   v_sizer1->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Close")), 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 30);
123
124   SetSizer(v_sizer1);
125   //v_sizer1->RecalcSizes();
126 }
127
128 void wxCDMPackageManagerHelpDialog::OnFinish(wxCommandEvent& event)
129 {
130   this->EndDialog(wxID_CANCEL);
131 }
132
133 void wxCDMPackageManagerHelpDialog::OnCreatePackage(wxCommandEvent& event)
134 {
135   if(this->packageManager != NULL)
136     {
137       wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_TOOL_CLICKED);
138       wxPostEvent(this->packageManager, *newEvent);
139     }
140   event.Skip();
141
142   this->EndDialog(wxID_OK);
143 }
144
145 void wxCDMPackageManagerHelpDialog::OnEditCMake(wxCommandEvent& event)
146 {
147   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_TOOL_ENTER);
148   if(this->packageManager != NULL)
149     wxPostEvent(this->packageManager, *newEvent);
150   event.Skip();
151
152   this->EndDialog(wxID_OK);
153 }
154
155
156 void wxCDMPackageManagerHelpDialog::OnEditCMakeMouseEnter(wxMouseEvent& event)
157 {
158   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
159
160   if(packageManager->GetProject()->GetCMakeLists() != NULL)
161     {
162       int CMId = packageManager->GetProject()->GetCMakeLists()->GetId();
163       newEvent->SetInt(CMId);
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_LIST_ITEM_DESELECTED);
173
174   if(packageManager->GetProject()->GetCMakeLists() != NULL)
175     {
176       int CMId = packageManager->GetProject()->GetCMakeLists()->GetId();
177       newEvent->SetInt(CMId);
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 }