1 /*=========================================================================
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux, Ricardo A Corredor
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.
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
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 * ------------------------------------------------------------------------ */
33 * \brief Class bbtk::wxDiagramPropertiesEditionDialog .
36 #include "wxDiagramPropertiesEditionDialog.h"
41 //=========================================================================
43 wxDiagramPropertiesEditionDialog::wxDiagramPropertiesEditionDialog(wxGUIEditorGraphicBBS *parent):wxDialog(parent,wxID_ANY,_T("Diagram Properties"), wxDefaultPosition, wxSize(320, 280),wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
46 constructDiagramPropertiesEditionDialog();
49 //=========================================================================
52 wxDiagramPropertiesEditionDialog::~wxDiagramPropertiesEditionDialog()
57 //=========================================================================
59 void wxDiagramPropertiesEditionDialog::constructDiagramPropertiesEditionDialog()
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);
67 // SELECTION CONSTANTS
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);
76 Connect(ID_COMBO, wxEVT_COMMAND_COMBOBOX_SELECTED,
77 wxCommandEventHandler(wxDiagramPropertiesEditionDialog::OnComboBoxSelected));
79 int currentType = (_parent->isCurrentDiagramComplexBox()==false)? 0 : 1;
80 _diagramType->Select(currentType);
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"));
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));
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));
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()));
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);
114 fgsizer->AddGrowableRow(3, 1);
115 fgsizer->AddGrowableCol(1, 1);
117 hbox->Add(fgsizer, 1, wxALL | wxEXPAND, 15);
118 panel->SetSizerAndFit(hbox);
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()));
130 //=========================================================================
132 void wxDiagramPropertiesEditionDialog::onClickOk(wxCommandEvent& event)
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);
142 // SELECTION CONSTANTS
145 int selection = _diagramType->GetSelection();
147 _parent->disableComplexBox();
148 else if (selection == 1)
149 _parent->enableComplexBox();
154 //=========================================================================
156 void wxDiagramPropertiesEditionDialog::onClickClose(wxCommandEvent& event)
158 printf("RaC wxDiagramPropertiesEditionDialog::onClickClose\n");
162 //=========================================================================
164 void wxDiagramPropertiesEditionDialog::OnComboBoxSelected(wxCommandEvent& event)
166 // TODO Show info to edit complex boxes
169 //=========================================================================
174 } // EO namespace bbtk