1 /*=========================================================================
3 Module: $RCSfile: bbwxInputText.cxx,v $
5 Date: $Date: 2008/11/24 15:45:51 $
6 Version: $Revision: 1.4 $
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>
50 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,InputText);
53 InputTextWidget::InputTextWidget(InputText* box,
57 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
60 wxPanel *panel = this;
62 mwxTextCtrl = new wxTextCtrl( panel, -1, In,
63 wxDefaultPosition, wxSize(800,20));
64 Connect( mwxTextCtrl->GetId(), wxEVT_COMMAND_TEXT_UPDATED,
65 (wxObjectEventFunction)
67 (wxCommandEventFunction)
68 (void (wxPanel::*)(wxCommandEvent&))
69 &InputTextWidget::OnTextUpdate );
72 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
77 mwxTitle = new wxStaticText(panel,-1, title );
78 sizer -> Add( mwxTitle );
80 sizer -> Add( mwxTextCtrl,1,wxGROW );
81 sizer -> AddGrowableCol(0);
83 panel -> SetSizer(sizer);
84 panel -> SetAutoLayout(true);
88 //-------------------------------------------------------------------------
90 InputTextWidget::~InputTextWidget()
94 //-------------------------------------------------------------------------
97 void InputTextWidget::SetTitle(wxString s)
99 mwxTitle->SetLabel(s);
102 //-------------------------------------------------------------------------
103 std::string InputTextWidget::GetValue()
105 return bbtk::wx2std ( mwxTextCtrl->GetValue() );
108 //--------------------------------------------------------------------------
109 void InputTextWidget::OnTextUpdate(wxCommandEvent& event)
111 mBox->bbSetOutputOut( GetValue() );
112 mBox->bbSetInputIn( GetValue() );
113 mBox->bbSignalOutputModification("Out");
116 //--------------------------------------------------------------------------
117 //-------------------------------------------------------------------------
118 //--------------------------------------------------------------------------
119 //--------------------------------------------------------------------------
122 BBTK_BLACK_BOX_IMPLEMENTATION(InputText,bbtk::WxBlackBox);
126 void InputText::bbUserConstructor()
130 bbSetOutputWidget(0);
134 void InputText::Process()
136 InputTextWidget *w=(InputTextWidget *)bbGetOutputWidget();
139 bbSetInputIn( w->GetValue() );
140 w->SetTitle( bbtk::std2wx ( bbGetInputTitle() ) );
142 bbSetOutputOut( bbGetInputIn() );
147 void InputText::CreateWidget(wxWindow* parent)
150 ( (wxWindow*) new InputTextWidget(this, //bbGetWxParent(),
152 bbtk::std2wx ( bbGetInputIn() ) ,
153 bbtk::std2wx ( bbGetInputTitle() ) ) );
162 #endif // _USE_WXWIDGETS_