1 /*=========================================================================
3 Module: $RCSfile: bbwxInputText.cxx,v $
5 Date: $Date: 2009/05/15 14:58:03 $
6 Version: $Revision: 1.6 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
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 * ------------------------------------------------------------------------ */
37 #ifdef _USE_WXWIDGETS_
40 #include "bbwxInputText.h"
41 #include "bbwxPackage.h"
42 //#include <wx/dialog.h>
55 //--------------------------------------------------------------------------
56 class InputTextWidget : wxPanel
59 InputTextWidget(InputText* box, wxWindow *parent,
60 wxString In, wxString title);
63 std::string GetValue();
64 void OnTextUpdate(wxCommandEvent& event);
66 void SetTitle(wxString);
70 wxTextCtrl *mwxTextCtrl;
71 wxStaticText *mwxTitle;
74 //------------------------------------------------------------------------
75 //------------------------------------------------------------------------
76 //------------------------------------------------------------------------
81 InputTextWidget::InputTextWidget(InputText* box,
85 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
88 wxPanel *panel = this;
90 mwxTextCtrl = new wxTextCtrl( panel, -1, In,
91 wxDefaultPosition, wxSize(800,20));
92 Connect( mwxTextCtrl->GetId(), wxEVT_COMMAND_TEXT_UPDATED,
93 (wxObjectEventFunction)
95 (wxCommandEventFunction)
96 (void (wxPanel::*)(wxCommandEvent&))
97 &InputTextWidget::OnTextUpdate );
100 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
105 mwxTitle = new wxStaticText(panel,-1, title );
106 sizer -> Add( mwxTitle );
108 sizer -> Add( mwxTextCtrl,1,wxGROW );
109 sizer -> AddGrowableCol(0);
111 panel -> SetSizer(sizer);
112 panel -> SetAutoLayout(true);
116 //-------------------------------------------------------------------------
118 InputTextWidget::~InputTextWidget()
122 //-------------------------------------------------------------------------
125 void InputTextWidget::SetTitle(wxString s)
127 mwxTitle->SetLabel(s);
130 //-------------------------------------------------------------------------
131 std::string InputTextWidget::GetValue()
133 return bbtk::wx2std ( mwxTextCtrl->GetValue() );
136 //--------------------------------------------------------------------------
137 void InputTextWidget::OnTextUpdate(wxCommandEvent& event)
139 mBox->bbSetOutputOut( GetValue() );
140 mBox->bbSetInputIn( GetValue() );
141 mBox->bbSignalOutputModification("Out");
144 //--------------------------------------------------------------------------
145 //-------------------------------------------------------------------------
146 //--------------------------------------------------------------------------
147 //--------------------------------------------------------------------------
149 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,InputText);
150 BBTK_BLACK_BOX_IMPLEMENTATION(InputText,bbtk::WxBlackBox);
153 //-----------------------------------------------------------------
154 void InputText::bbUserSetDefaultValues()
158 bbSetOutputWidget(0);
161 //-----------------------------------------------------------------
162 void InputText::bbUserInitializeProcessing()
166 //-----------------------------------------------------------------
167 void InputText::bbUserFinalizeProcessing()
172 //-----------------------------------------------------------------
173 void InputText::Process()
175 InputTextWidget *w=(InputTextWidget *)bbGetOutputWidget();
178 bbSetInputIn( w->GetValue() );
179 w->SetTitle( bbtk::std2wx ( bbGetInputTitle() ) );
181 bbSetOutputOut( bbGetInputIn() );
186 void InputText::CreateWidget(wxWindow* parent)
189 ( (wxWindow*) new InputTextWidget(this, //bbGetWxParent(),
191 bbtk::std2wx ( bbGetInputIn() ) ,
192 bbtk::std2wx ( bbGetInputTitle() ) ) );
201 #endif // _USE_WXWIDGETS_