/*========================================================================= Program: bbtk Module: $RCSfile: bbwxInputText.cxx,v $ Language: C++ Date: $Date: 2008/04/18 12:59:52 $ Version: $Revision: 1.2 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ /** * \file * \brief */ #ifdef _USE_WXWIDGETS_ #include "bbwxInputText.h" #include "bbwxPackage.h" //#include namespace bbwx { BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,InputText); InputTextWidget::InputTextWidget(InputText* box, wxWindow *parent, wxString In, wxString title) : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL), mBox(box) { wxPanel *panel = this; mwxTextCtrl = new wxTextCtrl( panel, -1, In, wxDefaultPosition, wxSize(800,20)); Connect( mwxTextCtrl->GetId(), wxEVT_COMMAND_TEXT_UPDATED, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (void (wxPanel::*)(wxCommandEvent&)) &InputTextWidget::OnTextUpdate ); wxFlexGridSizer *sizer = new wxFlexGridSizer(1); /* if (title!=_T("")) { */ mwxTitle = new wxStaticText(panel,-1, title ); sizer -> Add( mwxTitle ); // } sizer -> Add( mwxTextCtrl,1,wxGROW ); sizer -> AddGrowableCol(0); panel -> SetSizer(sizer); panel -> SetAutoLayout(true); panel -> Layout(); } //------------------------------------------------------------------------- InputTextWidget::~InputTextWidget() { } //------------------------------------------------------------------------- void InputTextWidget::SetTitle(wxString s) { mwxTitle->SetLabel(s); } //------------------------------------------------------------------------- std::string InputTextWidget::GetValue() { return bbtk::wx2std ( mwxTextCtrl->GetValue() ); } //-------------------------------------------------------------------------- void InputTextWidget::OnTextUpdate(wxCommandEvent& event) { mBox->bbSetOutputOut( GetValue() ); mBox->bbSetInputIn( GetValue() ); mBox->bbSignalOutputModification("Out"); } //-------------------------------------------------------------------------- //------------------------------------------------------------------------- //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- BBTK_BLACK_BOX_IMPLEMENTATION(InputText,bbtk::WxBlackBox); void InputText::bbUserConstructor() { bbSetInputTitle(""); bbSetInputIn(""); } void InputText::Process() { InputTextWidget *w=(InputTextWidget *)bbGetOutputWidget(); bbSetInputIn( w->GetValue() ); bbSetOutputOut( w->GetValue() ); w->SetTitle( bbtk::std2wx ( bbGetInputTitle() ) ); } void InputText::CreateWidget() { bbSetOutputWidget ( (wxWindow*) new InputTextWidget(this, bbGetWxParent(), bbtk::std2wx ( bbGetInputIn() ) , bbtk::std2wx ( bbGetInputTitle() ) ) ); } }//namespace bbtk #endif // _USE_WXWIDGETS_