1 /*=========================================================================
4 Module: $RCSfile: bbwxInputText.cxx,v $
6 Date: $Date: 2008/02/15 12:47:18 $
7 Version: $Revision: 1.1 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
24 #ifdef _USE_WXWIDGETS_
27 #include "bbwxInputText.h"
28 #include "bbwxPackage.h"
29 //#include <wx/dialog.h>
37 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,InputText);
40 InputTextWidget::InputTextWidget(InputText* box,
44 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
47 wxPanel *panel = this;
49 mwxTextCtrl = new wxTextCtrl( panel, -1, In,
50 wxDefaultPosition, wxSize(800,20));
51 Connect( mwxTextCtrl->GetId(), wxEVT_COMMAND_TEXT_UPDATED,
52 (wxObjectEventFunction)
54 (wxCommandEventFunction)
55 (void (wxPanel::*)(wxCommandEvent&))
56 &InputTextWidget::OnTextUpdate );
59 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
64 mwxTitle = new wxStaticText(panel,-1, title );
65 sizer -> Add( mwxTitle );
67 sizer -> Add( mwxTextCtrl,1,wxGROW );
68 sizer -> AddGrowableCol(0);
70 panel -> SetSizer(sizer);
71 panel -> SetAutoLayout(true);
75 //-------------------------------------------------------------------------
77 InputTextWidget::~InputTextWidget()
81 //-------------------------------------------------------------------------
84 void InputTextWidget::SetTitle(wxString s)
86 mwxTitle->SetLabel(s);
89 //-------------------------------------------------------------------------
90 std::string InputTextWidget::GetValue()
92 return bbtk::wx2std ( mwxTextCtrl->GetValue() );
95 //--------------------------------------------------------------------------
96 void InputTextWidget::OnTextUpdate(wxCommandEvent& event)
98 mBox->bbSetOutputOut( GetValue() );
99 mBox->bbSetInputIn( GetValue() );
100 mBox->bbSignalOutputModification("Out");
103 //--------------------------------------------------------------------------
104 //-------------------------------------------------------------------------
105 //--------------------------------------------------------------------------
106 //--------------------------------------------------------------------------
109 BBTK_USER_BLACK_BOX_IMPLEMENTATION(InputText,bbtk::WxBlackBox);
113 void InputText::bbUserConstructor()
120 void InputText::Process()
122 InputTextWidget *w=(InputTextWidget *)bbGetOutputWidget();
123 bbSetInputIn( w->GetValue() );
124 bbSetOutputOut( w->GetValue() );
125 w->SetTitle( bbtk::std2wx ( bbGetInputTitle() ) );
130 void InputText::CreateWidget()
133 ( (wxWindow*) new InputTextWidget(this, bbGetWxParent(),
134 bbtk::std2wx ( bbGetInputIn() ) ,
135 bbtk::std2wx ( bbGetInputTitle() ) ) );
144 #endif // _USE_WXWIDGETS_