]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxDiagramPropertiesEditionDialog.cxx
02b8a583b429ba7daf3e08d010b7724fe852bd62
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / wxDiagramPropertiesEditionDialog.cxx
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 #
8 #  This software is governed by the CeCILL-B license under French law and 
9 #  abiding by the rules of distribution of free software. You can  use, 
10 #  modify and/ or redistribute the software under the terms of the CeCILL-B 
11 #  license as circulated by CEA, CNRS and INRIA at the following URL 
12 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
13 #  or in the file LICENSE.txt.
14 #
15 #  As a counterpart to the access to the source code and  rights to copy,
16 #  modify and redistribute granted by the license, users are provided only
17 #  with a limited warranty  and the software's author,  the holder of the
18 #  economic rights,  and the successive licensors  have only  limited
19 #  liability. 
20 #
21 #  The fact that you are presently reading this means that you have had
22 #  knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------  
24 */
25
26 /*=========================================================================
27 Program:   bbtkGEditor
28 Module:    $RCSfile$
29 Language:  C++
30 Date:      $Date$
31 Version:   $Revision$
32 =========================================================================*/
33
34 /* ---------------------------------------------------------------------
35
36 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
37 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux, Ricardo A Corredor
38 *
39 *  This software is governed by the CeCILL-B license under French law and
40 *  abiding by the rules of distribution of free software. You can  use,
41 *  modify and/ or redistribute the software under the terms of the CeCILL-B
42 *  license as circulated by CEA, CNRS and INRIA at the following URL
43 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
44 *  or in the file LICENSE.txt.
45 *
46 *  As a counterpart to the access to the source code and  rights to copy,
47 *  modify and redistribute granted by the license, users are provided only
48 *  with a limited warranty  and the software's author,  the holder of the
49 *  economic rights,  and the successive licensors  have only  limited
50 *  liability.
51 *
52 *  The fact that you are presently reading this means that you have had
53 *  knowledge of the CeCILL-B license and that you accept its terms.
54 * ------------------------------------------------------------------------ */
55
56 /**
57 *  \file
58 *  \brief Class bbtk::wxDiagramPropertiesEditionDialog .
59 */
60
61 #include "wxDiagramPropertiesEditionDialog.h"
62 #include "creaWx.h"
63
64 namespace bbtk
65 {
66         //=========================================================================
67
68         wxDiagramPropertiesEditionDialog::wxDiagramPropertiesEditionDialog(wxGUIEditorGraphicBBS *parent):wxDialog(parent,wxID_ANY,_T("Diagram Properties"), wxDefaultPosition, wxSize(320, 280),wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
69         {
70                 _parent = parent;
71                 constructDiagramPropertiesEditionDialog();
72         }
73
74         //=========================================================================
75
76
77         wxDiagramPropertiesEditionDialog::~wxDiagramPropertiesEditionDialog()
78         {
79
80         }
81
82         //=========================================================================
83
84         void wxDiagramPropertiesEditionDialog::constructDiagramPropertiesEditionDialog()
85         {
86                 const int ID_COMBO = 1;
87                 wxPanel *panel = new wxPanel(this, -1);
88                 wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
89                 wxFlexGridSizer *fgsizer = new wxFlexGridSizer(5, 2, 9, 25);
90
91
92                 // SELECTION CONSTANTS
93                 // 0 - Application
94                 // 1 - Complex box
95                 _diagramType = new wxComboBox(panel, -1, wxEmptyString, wxDefaultPosition, wxSize(100,-1) );
96                 _diagramType->Append (wxT("Application"));
97                 _diagramType->Append (wxT("Complex box"));
98                 _diagramType->SetEditable(false);
99                 //_diagramType->Enable(false);
100
101                 Connect(ID_COMBO, wxEVT_COMMAND_COMBOBOX_SELECTED,
102                                         wxCommandEventHandler(wxDiagramPropertiesEditionDialog::OnComboBoxSelected));
103
104                 int currentType = (_parent->isCurrentDiagramComplexBox()==false)? 0 : 1;
105                 _diagramType->Select(currentType);
106
107                 wxStaticText *type = new wxStaticText(panel, -1, wxT("Type"));
108                 wxStaticText *author = new wxStaticText(panel, -1, wxT("Author"));
109                 wxStaticText *category = new wxStaticText(panel, -1, wxT("Categories"));
110                 wxStaticText *description = new wxStaticText(panel, -1, wxT("Description"));
111
112                 _txtAuthor = new wxTextCtrl(panel, -1);
113                 _txtCategory = new wxTextCtrl(panel, -1);
114                 _txtDescription = new wxTextCtrl(panel, -1, wxT(""), wxPoint(-1, -1), wxSize(-1, -1), wxTE_MULTILINE);
115                 wxButton *okButton      = new wxButton(panel, -1, _T("Ok"),wxDefaultPosition, wxSize(-1, -1));
116                 wxButton *closeButton   = new wxButton(panel, -1, _T("Close"), wxDefaultPosition, wxSize(-1, -1));
117
118                 // connect command event handlers
119                 Connect(okButton->GetId(),wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxDiagramPropertiesEditionDialog::onClickOk));
120                 Connect(closeButton->GetId(),wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxDiagramPropertiesEditionDialog::onClickClose));
121
122                 // Assign loaded values
123                 _txtAuthor->SetValue(crea::std2wx(_parent->getCurrentDiagramAuthor()));
124                 _txtCategory->SetValue(crea::std2wx(_parent->getCurrentDiagramCategory()));
125                 _txtDescription->SetValue(crea::std2wx(_parent->getCurrentDiagramDescription()));
126
127
128                 fgsizer->Add(type);
129                 fgsizer->Add(_diagramType, 1, wxEXPAND);
130                 fgsizer->Add(author);
131                 fgsizer->Add(_txtAuthor, 1, wxEXPAND);
132                 fgsizer->Add(category);
133                 fgsizer->Add(_txtCategory, 1, wxEXPAND);
134                 fgsizer->Add(description, 1, wxEXPAND);
135                 fgsizer->Add(_txtDescription, 1, wxEXPAND);
136                 fgsizer->Add(okButton, 1, wxEXPAND);
137                 fgsizer->Add(closeButton, 1, wxEXPAND);
138
139                 fgsizer->AddGrowableRow(3, 1);
140                 fgsizer->AddGrowableCol(1, 1);
141
142                 hbox->Add(fgsizer, 1, wxALL | wxEXPAND, 15);
143                 panel->SetSizerAndFit(hbox);
144                 Centre();
145
146                 ShowModal();
147                 Destroy();
148
149                 // Assign loaded values
150                 _txtAuthor->SetValue(crea::std2wx(_parent->getCurrentDiagramAuthor()));
151                 _txtCategory->SetValue(crea::std2wx(_parent->getCurrentDiagramCategory()));
152                 _txtDescription->SetValue(crea::std2wx(_parent->getCurrentDiagramDescription()));
153         }
154
155         //=========================================================================
156
157         void wxDiagramPropertiesEditionDialog::onClickOk(wxCommandEvent& event)
158         {
159
160                 std::string txtAuthor = wx2std(_txtAuthor->GetValue());
161                 std::string txtCategory = wx2std(_txtCategory->GetValue());
162                 std::string txtDescription = wx2std(_txtDescription->GetValue());
163                 _parent->setCurrentDiagramAuthor(txtAuthor);
164                 _parent->setCurrentDiagramCategory(txtCategory);
165                 _parent->setCurrentDiagramDescription(txtDescription);
166
167                 // SELECTION CONSTANTS
168                 // 0 - Application
169                 // 1 - Complex box
170                 int selection = _diagramType->GetSelection();
171                 if(selection == 0)
172                         _parent->disableComplexBox();
173                 else if (selection == 1)
174                         _parent->enableComplexBox();
175
176                 Close(true);
177         }
178
179         //=========================================================================
180
181         void wxDiagramPropertiesEditionDialog::onClickClose(wxCommandEvent& event)
182         {
183                 printf("RaC wxDiagramPropertiesEditionDialog::onClickClose\n");
184                 Close(true);
185         }
186
187         //=========================================================================
188
189         void wxDiagramPropertiesEditionDialog::OnComboBoxSelected(wxCommandEvent& event)
190         {
191                 // TODO Show info to edit complex boxes
192         }
193
194         //=========================================================================
195         
196
197         
198         
199 }  // EO namespace bbtk
200
201