]> Creatis software - crea.git/blob - lib/creaDevManagerLib/wxCDMNewPackageDialog.cpp
Feature #1711 CreaDevManager application implementation
[crea.git] / lib / creaDevManagerLib / wxCDMNewPackageDialog.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  * wxCDMNewPackageDialog.cpp
31  *
32  *  Created on: 05/12/2012
33  *      Author: Daniel Felipe Gonzalez Obando
34  */
35
36 #include "wxCDMNewPackageDialog.h"
37
38 #include "creaDevManagerIds.h"
39
40 BEGIN_EVENT_TABLE(wxCDMNewPackageDialog, wxDialog)
41   EVT_BUTTON(ID_BUTTON_NEXT, wxCDMNewPackageDialog::OnCreatePackage)
42   EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMNewPackageDialog::OnCancel)
43 END_EVENT_TABLE()
44
45 wxCDMNewPackageDialog::wxCDMNewPackageDialog(
46     wxWindow* parent,
47     wxWindowID id,
48     const wxString& caption,
49     const wxPoint& position,
50     const wxSize& size,
51     long style
52 )
53 {
54   wxCDMNewPackageDialog::Create(parent, id, caption, position, size, style);
55 }
56
57 wxCDMNewPackageDialog::~wxCDMNewPackageDialog()
58 {
59 }
60
61 bool wxCDMNewPackageDialog::Create(
62     wxWindow* parent,
63     wxWindowID id,
64     const wxString& caption,
65     const wxPoint& position,
66     const wxSize& size,
67     long int style
68 )
69 {
70   wxDialog::Create(parent, id, caption, position, size, style);
71
72   this->CreateControls();
73
74   return TRUE;
75 }
76
77 const wxString wxCDMNewPackageDialog::GetPackageName()
78 {
79   return this->packageName->GetValue();
80 }
81 const wxString wxCDMNewPackageDialog::GetPackageAuthor()
82 {
83   return this->packageAuthor->GetValue();
84 }
85 const wxString wxCDMNewPackageDialog::GetPackageAuthorEmail()
86 {
87   return this->packageAuthorEmail->GetValue();
88 }
89 const wxString wxCDMNewPackageDialog::GetPackageDescription()
90 {
91   return this->packageDescription->GetValue();
92 }
93
94 void wxCDMNewPackageDialog::CreateControls()
95 {
96   wxBoxSizer* v_sizer1 = new wxBoxSizer(wxVERTICAL);
97
98
99   wxStaticText* title = new wxStaticText(this, wxID_ANY, wxT("Create a new package"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
100   v_sizer1->Add(title, 0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL, 5);
101
102   wxStaticText* instruction = new wxStaticText(this, wxID_ANY, wxT("Please fill the following details."), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
103   v_sizer1->Add(instruction, 0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL, 5);
104
105   wxFlexGridSizer* formItems = new wxFlexGridSizer(4,2,9,15);
106
107   wxStaticText *stxtPrjName = new wxStaticText(this, -1, wxT("Package Name"));
108   wxStaticText *stxtPrjAuth = new wxStaticText(this, -1, wxT("Package's Author (1 word)"));
109   wxStaticText *stxtPrjAuthEmail = new wxStaticText(this, -1, wxT("Package's Author Email"));
110   wxStaticText *stxtPrjPkg = new wxStaticText(this, -1, wxT("Package's Description (HTML)"));
111
112   this->packageName = new wxTextCtrl(this, -1);
113   this->packageAuthor = new wxTextCtrl(this, -1);
114   this->packageAuthorEmail = new wxTextCtrl(this, -1);
115   this->packageDescription = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
116
117   formItems->Add(stxtPrjName, 0, wxALIGN_CENTER_VERTICAL);
118   formItems->Add(this->packageName, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
119   formItems->Add(stxtPrjAuth, 0, wxALIGN_CENTER_VERTICAL);
120   formItems->Add(this->packageAuthor, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
121   formItems->Add(stxtPrjAuthEmail, 0, wxALIGN_CENTER_VERTICAL);
122   formItems->Add(this->packageAuthorEmail, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
123   formItems->Add(stxtPrjPkg);
124   formItems->Add(this->packageDescription, 1, wxEXPAND);
125
126   formItems->AddGrowableCol(1,1);
127   formItems->AddGrowableRow(3,1);
128
129   v_sizer1->Add(formItems, 1, wxEXPAND | wxALL, 15);
130
131   wxBoxSizer* h_sizer2 = new wxBoxSizer(wxHORIZONTAL);
132   h_sizer2->Add(new wxButton(this, ID_BUTTON_NEXT, wxT("Create Package")), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
133   h_sizer2->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Cancel")), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
134
135   v_sizer1->Add(h_sizer2, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 30);
136
137   SetSizer(v_sizer1);
138 }
139
140 void wxCDMNewPackageDialog::OnCreatePackage(wxCommandEvent& event)
141 {
142   bool ready = true;
143
144   if(ready && this->packageName->GetValue() == wxT(""))
145     {
146       wxMessageBox(wxT("The package name cannot be empty"),_T("Error"),wxOK | wxICON_ERROR);
147       ready = false;
148     }
149   if(ready && this->packageAuthor->GetValue() == wxT(""))
150     {
151       wxMessageBox(wxT("The package's author cannot be empty"),_T("Error"),wxOK | wxICON_ERROR);
152       ready = false;
153     }
154
155   if(ready)
156     {
157       this->EndModal(wxID_FORWARD);
158     }
159
160   event.Skip();
161 }
162
163 void wxCDMNewPackageDialog::OnCancel(wxCommandEvent& event)
164 {
165   this->EndModal(wxID_CANCEL);
166   event.Skip();
167 }