]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxDiagramPropertiesEditionDialog.cxx
Display of the tree obtained in the information dialog window in BBEditor. 12/05...
[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
65 namespace bbtk
66 {
67         //=========================================================================
68
69         wxDiagramPropertiesEditionDialog::wxDiagramPropertiesEditionDialog(wxGUIEditorGraphicBBS *parent, NodeTreeC tree):wxDialog(parent,wxID_ANY,_T("Diagram Properties"), wxDefaultPosition, wxSize(450, 580),wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
70         {
71                 _parent = parent;
72                 _tree = tree;
73                 constructDiagramPropertiesEditionDialog();
74         }
75
76         //=========================================================================
77
78
79         wxDiagramPropertiesEditionDialog::~wxDiagramPropertiesEditionDialog()
80         {
81
82         }
83
84         //=========================================================================
85         
86         void wxDiagramPropertiesEditionDialog::constructBoxTree(NodeTreeC nodeTree, wxTreeItemId itemId)
87         {
88                 
89                 for(int i = 0 ; i < nodeTree.childs.size() ; i++)
90                 {
91                         string spc = nodeTree.childs[i].data;
92                         const char* ccc = spc.c_str();
93                         wxString pc = wxString::FromUTF8 (ccc);
94                         wxTreeItemId iId = _treeBox->AppendItem(itemId, pc, -1, -1, NULL);
95                         constructBoxTree(nodeTree.childs[i], iId );
96                 }
97         }
98
99   //==================================================================================
100
101         void wxDiagramPropertiesEditionDialog::constructDiagramPropertiesEditionDialog()
102         {
103                 const int ID_COMBO = 1;
104                 wxPanel *panel = new wxPanel(this, -1);
105                 wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
106                 wxFlexGridSizer *fgsizer = new wxFlexGridSizer(5, 2, 9, 25);
107
108
109                 //CFT           
110
111                 wxStaticText *tree = new wxStaticText(panel, -1, wxT("Tree of Box"));
112                 
113                 string sp = _tree.data;
114                 const char* cc = sp.c_str();
115                 wxString p = wxString::FromUTF8 (cc);
116
117                 _treeBox = new wxTreeCtrl (this, wxID_ANY, wxPoint(0,0), wxSize(320,300), wxTR_HAS_BUTTONS | wxTR_SINGLE );
118                 wxTreeItemId itemId = _treeBox->AddRoot(p, -1,-1,NULL);
119                 
120                 constructBoxTree(_tree, itemId);
121                 _treeBox->ExpandAll();          
122                 _tree.treeTour();
123                 //CFT end
124
125
126                 // SELECTION CONSTANTS
127                 // 0 - Application
128                 // 1 - Complex box
129                 _diagramType = new wxComboBox(panel, -1, wxEmptyString, wxDefaultPosition, wxSize(100,-1) );
130                 _diagramType->Append (wxT("Application"));
131                 _diagramType->Append (wxT("Complex box"));
132                 _diagramType->SetEditable(false);
133                 //_diagramType->Enable(false);
134
135                 Connect(ID_COMBO, wxEVT_COMMAND_COMBOBOX_SELECTED,
136                                         wxCommandEventHandler(wxDiagramPropertiesEditionDialog::OnComboBoxSelected));
137
138                 int currentType = (_parent->isCurrentDiagramComplexBox()==false)? 0 : 1;
139                 _diagramType->Select(currentType);
140
141                 wxStaticText *type = new wxStaticText(panel, -1, wxT("Type"));
142                 wxStaticText *author = new wxStaticText(panel, -1, wxT("Author"));
143                 wxStaticText *category = new wxStaticText(panel, -1, wxT("Categories"));
144                 wxStaticText *description = new wxStaticText(panel, -1, wxT("Description"));
145
146                 _txtAuthor = new wxTextCtrl(panel, -1);
147                 _txtCategory = new wxTextCtrl(panel, -1);
148                 _txtDescription = new wxTextCtrl(panel, -1, wxT(""), wxPoint(-1, -1), wxSize(-1, -1), wxTE_MULTILINE);
149                 wxButton *okButton      = new wxButton(panel, -1, _T("Ok"),wxDefaultPosition, wxSize(-1, -1));
150                 wxButton *closeButton   = new wxButton(panel, -1, _T("Close"), wxDefaultPosition, wxSize(-1, -1));
151
152                 // connect command event handlers
153                 Connect(okButton->GetId(),wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxDiagramPropertiesEditionDialog::onClickOk));
154                 Connect(closeButton->GetId(),wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxDiagramPropertiesEditionDialog::onClickClose));
155
156                 // Assign loaded values
157                 _txtAuthor->SetValue(crea::std2wx(_parent->getCurrentDiagramAuthor()));
158                 _txtCategory->SetValue(crea::std2wx(_parent->getCurrentDiagramCategory()));
159                 _txtDescription->SetValue(crea::std2wx(_parent->getCurrentDiagramDescription()));
160
161
162                 fgsizer->Add(type);
163                 fgsizer->Add(_diagramType, 1, wxEXPAND);
164                 fgsizer->Add(author);
165                 fgsizer->Add(_txtAuthor, 1, wxEXPAND);
166                 fgsizer->Add(category);
167                 fgsizer->Add(_txtCategory, 1, wxEXPAND);
168                 fgsizer->Add(description, 1, wxEXPAND);
169                 fgsizer->Add(_txtDescription, 1, wxEXPAND);
170 //cft
171                 fgsizer->Add(tree);
172                 fgsizer->Add(_treeBox, 1, wxEXPAND);
173 //cft end               
174         fgsizer->Add(okButton, 1, wxEXPAND);
175                 fgsizer->Add(closeButton, 1, wxEXPAND);
176
177                 fgsizer->AddGrowableRow(3, 1);
178                 fgsizer->AddGrowableCol(1, 1);
179
180                 hbox->Add(fgsizer, 1, wxALL | wxEXPAND, 15);
181                 panel->SetSizerAndFit(hbox);
182                 Centre();
183
184                 ShowModal();
185                 Destroy();
186
187                 // Assign loaded values
188                 _txtAuthor->SetValue(crea::std2wx(_parent->getCurrentDiagramAuthor()));
189                 _txtCategory->SetValue(crea::std2wx(_parent->getCurrentDiagramCategory()));
190                 _txtDescription->SetValue(crea::std2wx(_parent->getCurrentDiagramDescription()));
191         }
192
193         //=========================================================================
194
195         void wxDiagramPropertiesEditionDialog::onClickOk(wxCommandEvent& event)
196         {
197
198                 std::string txtAuthor = wx2std(_txtAuthor->GetValue());
199                 std::string txtCategory = wx2std(_txtCategory->GetValue());
200                 std::string txtDescription = wx2std(_txtDescription->GetValue());
201                 _parent->setCurrentDiagramAuthor(txtAuthor);
202                 _parent->setCurrentDiagramCategory(txtCategory);
203                 _parent->setCurrentDiagramDescription(txtDescription);
204
205                 // SELECTION CONSTANTS
206                 // 0 - Application
207                 // 1 - Complex box
208                 int selection = _diagramType->GetSelection();
209                 if(selection == 0)
210                         _parent->disableComplexBox();
211                 else if (selection == 1)
212                         _parent->enableComplexBox();
213
214                 Close(true);
215         }
216
217         //=========================================================================
218
219         void wxDiagramPropertiesEditionDialog::onClickClose(wxCommandEvent& event)
220         {
221                 printf("RaC wxDiagramPropertiesEditionDialog::onClickClose\n");
222                 Close(true);
223         }
224
225         //=========================================================================
226
227         void wxDiagramPropertiesEditionDialog::OnComboBoxSelected(wxCommandEvent& event)
228         {
229                 // TODO Show info to edit complex boxes
230         }
231
232         //=========================================================================
233         
234
235         
236         
237 }  // EO namespace bbtk
238
239