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