]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxDiagramPropertiesEditionDialog.cxx
Feature #1665 . RaC - Create dialog box to edit diagram properties. By now, it doesn...
[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(520, 640),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
62                 wxPanel *panel = new wxPanel(this, -1);
63                 wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
64                 wxFlexGridSizer *fgsizer = new wxFlexGridSizer(4, 2, 9, 25);
65
66                 wxStaticText *author = new wxStaticText(panel, -1, wxT("Author"));
67                 wxStaticText *category = new wxStaticText(panel, -1, wxT("Category"));
68                 wxStaticText *description = new wxStaticText(panel, -1, wxT("Description"));
69
70                 _txtAuthor = new wxTextCtrl(panel, -1);
71                 _txtCategory = new wxTextCtrl(panel, -1);
72                 _txtDescription = new wxTextCtrl(panel, -1, wxT(""), wxPoint(-1, -1), wxSize(-1, -1), wxTE_MULTILINE);
73                 wxButton *okButton      = new wxButton(panel, -1, _T("Ok"),wxDefaultPosition, wxSize(-1, -1));
74                 wxButton *closeButton   = new wxButton(panel, -1, _T("Close"), wxDefaultPosition, wxSize(-1, -1));
75
76                 // connect command event handlers
77                 Connect(okButton->GetId(),wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxDiagramPropertiesEditionDialog::onClickOk));
78                 Connect(closeButton->GetId(),wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxDiagramPropertiesEditionDialog::onClickClose));
79
80
81                 fgsizer->Add(author);
82                 fgsizer->Add(_txtAuthor, 1, wxEXPAND);
83                 fgsizer->Add(category);
84                 fgsizer->Add(_txtCategory, 1, wxEXPAND);
85                 fgsizer->Add(description, 1, wxEXPAND);
86                 fgsizer->Add(_txtDescription, 1, wxEXPAND);
87                 fgsizer->Add(okButton, 1, wxEXPAND);
88                 fgsizer->Add(closeButton, 1, wxEXPAND);
89
90                 fgsizer->AddGrowableRow(2, 1);
91                 fgsizer->AddGrowableCol(1, 1);
92
93                 hbox->Add(fgsizer, 1, wxALL | wxEXPAND, 15);
94                 panel->SetSizer(hbox);
95                 Centre();
96
97                 ShowModal();
98                 Destroy();
99
100                 // Assign loaded values
101
102                 _txtAuthor->SetValue(crea::std2wx(_parent->getCurrentDiagramAuthor()));
103                 _txtCategory->SetValue(crea::std2wx(_parent->getCurrentDiagramCategory()));
104                 _txtDescription->SetValue(crea::std2wx(_parent->getCurrentDiagramDescription()));
105         }
106
107         //=========================================================================
108
109         void wxDiagramPropertiesEditionDialog::onClickOk(wxCommandEvent& event)
110         {
111
112                 std::string txtAuthor = wx2std(_txtAuthor->GetValue());
113                 std::string txtCategory = wx2std(_txtCategory->GetValue());
114                 std::string txtDescription = wx2std(_txtDescription->GetValue());
115                 _parent->setCurrentDiagramAuthor(txtAuthor);
116                 _parent->setCurrentDiagramCategory(txtCategory);
117                 _parent->setCurrentDiagramDescription(txtDescription);
118                 Close(true);
119         }
120
121         //=========================================================================
122
123         void wxDiagramPropertiesEditionDialog::onClickClose(wxCommandEvent& event)
124         {
125                 printf("RaC wxDiagramPropertiesEditionDialog::onClickClose\n");
126                 Close(true);
127         }
128
129         //=========================================================================
130
131         //=========================================================================
132         
133
134         
135         
136 }  // EO namespace bbtk
137
138