From: guigues Date: Fri, 15 Feb 2008 12:47:16 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: r0.6.1~193 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=888f2592d143847b6598d947cd037162c4fb90c6;p=bbtk.git *** empty log message *** --- diff --git a/kernel/cmake/BBTKConfigurePackage.cmake b/kernel/cmake/BBTKConfigurePackage.cmake index b4d4869..3776cc0 100644 --- a/kernel/cmake/BBTKConfigurePackage.cmake +++ b/kernel/cmake/BBTKConfigurePackage.cmake @@ -22,7 +22,9 @@ SET(${BBTK_PACKAGE_NAME}_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) # DOES THE USER WANT TO BUILD THE PACKAGE ? OPTION(BUILD_BBTK_PACKAGE_${BBTK_PACKAGE_NAME} "Build the bbtk package ${BBTK_PACKAGE_NAME} ?" OFF) -SWITCH_ON_IF_BUILD_ALL(BUILD_BBTK_PACKAGE_${BBTK_PACKAGE_NAME}) +IF(NOT ${BBTK_PACKAGE_NAME}_EXCLUDE_FROM_BUILD_ALL) + SWITCH_ON_IF_BUILD_ALL(BUILD_BBTK_PACKAGE_${BBTK_PACKAGE_NAME}) +ENDIF(NOT ${BBTK_PACKAGE_NAME}_EXCLUDE_FROM_BUILD_ALL) #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- diff --git a/packages/CMakeLists.txt b/packages/CMakeLists.txt index 0bef0e2..7945af1 100644 --- a/packages/CMakeLists.txt +++ b/packages/CMakeLists.txt @@ -5,5 +5,6 @@ SUBDIRS(std) SUBDIRS(wx) SUBDIRS(itk) SUBDIRS(vtk) -SUBDIRS(util) +SUBDIRS(bbtkTools) +SUBDIRS(test) #----------------------------------------------------------------------------- diff --git a/packages/std/bbs/appli/exampleLoadHola.bbs b/packages/vtk/bbs/appli/exampleLoadHola.bbs similarity index 90% rename from packages/std/bbs/appli/exampleLoadHola.bbs rename to packages/vtk/bbs/appli/exampleLoadHola.bbs index f74cdd3..cca198f 100644 --- a/packages/std/bbs/appli/exampleLoadHola.bbs +++ b/packages/vtk/bbs/appli/exampleLoadHola.bbs @@ -3,7 +3,7 @@ description "LoadHola box example" author "laurent.guigues at creatis.insa-lyon.fr" category "example" -include util +include vtk/boxes/bbLoadHola new LoadHola loader print "Path to the 'hola' image = '$loader.FileName$'" print "Image loaded = $loader.Out$" diff --git a/packages/wx/src/bbwxCommandButton.cxx b/packages/wx/src/bbwxCommandButton.cxx new file mode 100644 index 0000000..b13d242 --- /dev/null +++ b/packages/wx/src/bbwxCommandButton.cxx @@ -0,0 +1,190 @@ +/*========================================================================= + + Program: bbtk + Module: $RCSfile: bbwxCommandButton.cxx,v $ + Language: C++ + Date: $Date: 2008/02/15 12:47:17 $ + Version: $Revision: 1.1 $ + + 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 "bbwxCommandButton.h" +#include "bbwxPackage.h" +#include "bbtkInterpreter.h" + + + +namespace bbwx +{ + BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,CommandButton); + + CommandButtonWidget::CommandButtonWidget(CommandButton* box, + wxWindow *parent, + wxString title ) + : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL), + mBox(box) + { + + wxPanel *panel = this; + + mwxCommandButton = new wxButton( panel, -1, title); + Connect( mwxCommandButton->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , + (wxObjectEventFunction) + (void (wxPanel::*)(wxEvent&)) + &CommandButtonWidget::OnCommandButton ); + + wxFlexGridSizer *sizer = new wxFlexGridSizer(1); + sizer -> Add( mwxCommandButton,1,wxGROW ); + sizer -> AddGrowableCol(0); + + panel -> SetSizer(sizer); + panel -> SetAutoLayout(true); + panel -> Layout(); + + } + + CommandButtonWidget::~CommandButtonWidget() + { + } + + + void CommandButtonWidget::OnCommandButton( wxEvent& ) + { + std::string commandstr(mBox->bbGetInputIn()); + + // bbtk::Interpreter::mGlobalInterpreter->InterpretLine( commandstr ); + int i; + bool ok=true; + int pos1=0,pos2; + pos2 = commandstr.find(";",pos1); + std::string ccommand; + while (ok==true) + { + if (pos2==-1) + { + ok=false; + ccommand=commandstr.substr(pos1,commandstr.length()-pos1 ); + } + else + { + ccommand=commandstr.substr(pos1,pos2-pos1); + } + for ( i=0 ; i < ccommand.length() ; i++) + { + if (ccommand[i]==39) + { + ccommand[i]=34; + } + } + bool insideComment = false; // for multiline comment + bbtk::Interpreter::mGlobalInterpreter->InterpretLine( ccommand, insideComment ); + pos1=pos2+1; + pos2 = commandstr.find(";",pos2+1); + + } + + mBox->UpdateLabel(); + mBox->UpdateColour(); + mBox->bbSignalOutputModification(); + } + + + //-------------------------------------------------------------------------- + + void CommandButtonWidget::SetLabel(wxString title) + { + mwxCommandButton->SetLabel(title); + } + //-------------------------------------------------------------------------- + + void CommandButtonWidget::SetColour(wxColour color) + { + mwxCommandButton->SetBackgroundColour(color); + } + + + + //-------------------------------------------------------------------------- + //------------------------------------------------------------------------- + //-------------------------------------------------------------------------- + //-------------------------------------------------------------------------- + + + BBTK_USER_BLACK_BOX_IMPLEMENTATION(CommandButton,bbtk::WxBlackBox); + + void CommandButton::bbUserConstructor() + { + bbSetInputIn(""); + bbSetInputLabel(""); + std::vector lstColour; + lstColour.push_back(-1); + lstColour.push_back(-1); + lstColour.push_back(-1); + bbSetInputColour(lstColour); + } + + + void CommandButton::Process() + { + UpdateColour(); + UpdateLabel(); + } + + void CommandButton::UpdateColour() + { + CommandButtonWidget* wxwidget = (CommandButtonWidget*)bbGetOutputWidget(); + if ( (bbGetInputColour()[0]==-1) && + (bbGetInputColour()[1]==-1) && + (bbGetInputColour()[2]==-1) ) + { + wxwidget->SetColour( wxwidget->GetParent()->GetBackgroundColour() ); + } + else + { + int r=(int) (255*bbGetInputColour()[0]); + int g=(int) (255*bbGetInputColour()[1]); + int b=(int) (255*bbGetInputColour()[2]); + wxwidget->SetColour( wxColour(r,g,b) ); + } + + } + void CommandButton::UpdateLabel() + { + CommandButtonWidget* wxwidget = (CommandButtonWidget*)bbGetOutputWidget(); + wxwidget->SetLabel( bbtk::std2wx( bbGetInputLabel() ) ); + } + + /** + * \brief Create wxWidget . + * + * + */ + void CommandButton::CreateWidget() + { + bbSetOutputWidget + ( new CommandButtonWidget ( this, bbGetWxParent(), + bbtk::std2wx(bbGetInputLabel()) ) ); + UpdateColour(); + } + + +} //namespace bbwx + +#endif // _USE_WXWIDGETS_ + diff --git a/packages/wx/src/bbwxCommandButton.h b/packages/wx/src/bbwxCommandButton.h new file mode 100644 index 0000000..1c4374d --- /dev/null +++ b/packages/wx/src/bbwxCommandButton.h @@ -0,0 +1,109 @@ +/*========================================================================= + + Program: bbtk + Module: $RCSfile: bbwxCommandButton.h,v $ + Language: C++ + Date: $Date: 2008/02/15 12:47:18 $ + Version: $Revision: 1.1 $ + + 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. + +=========================================================================*//** + * \brief Short description in one line + * + * Long description which + * can span multiple lines + */ +/** + * \file + * \brief Pattern for the definition of a new type of Node (header) + */ +/** + * \class bbtk::NodePatern + * \brief Pattern for the definition of a new type of Node + */ + + +#ifdef _USE_WXWIDGETS_ + +#ifndef __bbwxCommandButton_h_INCLUDED_H__ +#define __bbwxCommandButton_h_INCLUDED_H__ + + +#include "bbtkWxBlackBox.h" + + + +namespace bbwx +{ + class CommandButton; + + //-------------------------------------------------------------------------- + class CommandButtonWidget : public wxPanel + { + public: + CommandButtonWidget(CommandButton* box, wxWindow *parent, + wxString title); + ~CommandButtonWidget(); + void OnCommandButton( wxEvent& ); + void SetLabel(wxString title); + void SetColour(wxColour color); + + private: + CommandButton* mBox; + wxButton *mwxCommandButton; + }; + + //-------------------------------------------------------------------------- + //-------------------------------------------------------------------------- + //-------------------------------------------------------------------------- + + class /*BBTK_EXPORT*/ CommandButton : public bbtk::WxBlackBox + { + friend class CommandButtonWidget; + BBTK_USER_BLACK_BOX_INTERFACE(CommandButton,bbtk::WxBlackBox); + BBTK_DECLARE_INPUT(In, std::string ); + BBTK_DECLARE_INPUT(Label, std::string ); + BBTK_DECLARE_INPUT(Colour, std::vector ); + // BBTK_DECLARE_OUTPUT(Out,int); + BBTK_PROCESS(Process); + void Process(); + BBTK_CREATE_WIDGET(CreateWidget); + void CreateWidget(); + protected: + virtual void bbUserConstructor(); + + + private: + void UpdateColour(); + void UpdateLabel(); + }; + + //================================================================= + // UserBlackBox description + BBTK_BEGIN_DESCRIBE_BLACK_BOX(CommandButton,bbtk::WxBlackBox); + BBTK_NAME("CommandButton"); + BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr"); + BBTK_DESCRIPTION("Button which executes bbi commands"); + + typedef std::vector vectorcolour; + + BBTK_INPUT(CommandButton,In,"Commands to be executed separated by commas (;). Each single quote (') is replaced by a double quote (\").",std::string); + BBTK_INPUT(CommandButton,Label,"Label of the button",std::string); + BBTK_INPUT(CommandButton,Colour,"Colour of the button (-1 -1 -1 Background)",vectorcolour); + // BBTK_OUTPUT(CommandButton,Out,"..Out..",int); + BBTK_END_DESCRIBE_BLACK_BOX(CommandButton); + //================================================================= + + +}//namespace bbwx + +#endif // __bbwxCommandButton_h_INCLUDED_H__ + +#endif //_USE_WXWIDGETS_ diff --git a/packages/wx/src/bbwxDirectorySelector.cxx b/packages/wx/src/bbwxDirectorySelector.cxx new file mode 100644 index 0000000..813a911 --- /dev/null +++ b/packages/wx/src/bbwxDirectorySelector.cxx @@ -0,0 +1,73 @@ +/*========================================================================= + + Program: bbtk + Module: $RCSfile: bbwxDirectorySelector.cxx,v $ + Language: C++ + Date: $Date: 2008/02/15 12:47:18 $ + Version: $Revision: 1.1 $ + + 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 "bbwxDirectorySelector.h" +#include "bbwxPackage.h" + +#include + + +namespace bbwx +{ + + BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,DirectorySelector); + + + BBTK_USER_BLACK_BOX_IMPLEMENTATION(DirectorySelector,bbtk::AtomicBlackBox); + + + void DirectorySelector::Process() + { + bbtkDebugMessageInc("Core",9,"DirectorySelector::Process() [" + <ShowModal(); + + if (FD->GetReturnCode()==wxID_OK) + { + bbSetOutputOut( bbtk::wx2std (FD->GetPath()) ); + bbSetInputDefaultDir( bbtk::wx2std (FD->GetPath()) ); + } + else + { + bbSetOutputOut(""); + bbSetInputDefaultDir(""); + } + + bbtkDebugDecTab("Core",9); + } + + + +}//namespace bbtk + +#endif // _USE_WXWIDGETS_ + diff --git a/packages/wx/src/bbwxDirectorySelector.h b/packages/wx/src/bbwxDirectorySelector.h new file mode 100644 index 0000000..f30f63d --- /dev/null +++ b/packages/wx/src/bbwxDirectorySelector.h @@ -0,0 +1,89 @@ +/*========================================================================= + + Program: bbtk + Module: $RCSfile: bbwxDirectorySelector.h,v $ + Language: C++ + Date: $Date: 2008/02/15 12:47:18 $ + Version: $Revision: 1.1 $ + + 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. + +=========================================================================*//** + * \brief Short description in one line + * + * Long description which + * can span multiple lines + */ +/** + * \file + * \brief Pattern for the definition of a new type of Node (header) + */ +/** + * \class bbtk::NodePatern + * \brief Pattern for the definition of a new type of Node + */ + + +#ifdef _USE_WXWIDGETS_ + + +#ifndef __bbWxDirectorySelector_h__ +#define __bbWxDirectorySelector_h__ + +#include "bbtkAtomicBlackBox.h" + + + +namespace bbwx +{ + + + + + //================================================================= + class /*BBTK_EXPORT*/ DirectorySelector : public bbtk::AtomicBlackBox + { + BBTK_USER_BLACK_BOX_INTERFACE(DirectorySelector,bbtk::AtomicBlackBox); + BBTK_DECLARE_INPUT(Title,std::string); + BBTK_DECLARE_INPUT(Message,std::string); + BBTK_DECLARE_INPUT(DefaultDir,std::string); + BBTK_DECLARE_INPUT(DefaultDirectory,std::string); + BBTK_DECLARE_INPUT(Wildcard,std::string); + BBTK_DECLARE_INPUT(OpenSave,std::string); + BBTK_DECLARE_OUTPUT(Out,std::string); + BBTK_PROCESS(Process); + void Process(); + }; + //================================================================= + + + //================================================================= + // AtomicBlackBox description + BBTK_BEGIN_DESCRIBE_BLACK_BOX(DirectorySelector,bbtk::AtomicBlackBox); + BBTK_NAME("DirectorySelector"); + BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr"); + BBTK_CATEGORY("widget"); + BBTK_DESCRIPTION("Pops up a directory selection dialog (wxDirDialog)"); + BBTK_INPUT(DirectorySelector,Title,"Title of the dialog",std::string); + BBTK_INPUT(DirectorySelector,Message,"Message to show on the dialog",std::string); + BBTK_INPUT(DirectorySelector,DefaultDir,"The default directory",std::string); + BBTK_OUTPUT(DirectorySelector,Out,"The directory selected by the user",std::string); + BBTK_END_DESCRIBE_BLACK_BOX(DirectorySelector); + //================================================================= + + + +} + + + +//namespace bbtk +#endif //__bbtkWxDirectorySelector_h__ + +#endif //_USE_WXWIDGETS_ diff --git a/packages/wx/src/bbwxFileSelector.cxx b/packages/wx/src/bbwxFileSelector.cxx new file mode 100644 index 0000000..53e3ee3 --- /dev/null +++ b/packages/wx/src/bbwxFileSelector.cxx @@ -0,0 +1,91 @@ +/*========================================================================= + + Program: bbtk + Module: $RCSfile: bbwxFileSelector.cxx,v $ + Language: C++ + Date: $Date: 2008/02/15 12:47:18 $ + Version: $Revision: 1.1 $ + + 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 "bbwxFileSelector.h" +#include "bbwxPackage.h" + +#include + + +namespace bbwx +{ + + BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,FileSelector); + + + BBTK_USER_BLACK_BOX_IMPLEMENTATION(FileSelector,bbtk::AtomicBlackBox); + + + void FileSelector::Process() + { + bbtkDebugMessageInc("Core",9,"FileSelector::Process() [" + <ShowModal(); + + if (FD->GetReturnCode()==wxID_OK) + { + bbSetOutputOut( bbtk::wx2std (FD->GetPath()) ); + } + else + { + bbSetOutputOut(""); + } + + bbtkDebugDecTab("Core",9); + } + + + +}//namespace bbtk + +#endif // _USE_WXWIDGETS_ + diff --git a/packages/wx/src/bbwxFileSelector.h b/packages/wx/src/bbwxFileSelector.h new file mode 100644 index 0000000..b0a9037 --- /dev/null +++ b/packages/wx/src/bbwxFileSelector.h @@ -0,0 +1,92 @@ +/*========================================================================= + + Program: bbtk + Module: $RCSfile: bbwxFileSelector.h,v $ + Language: C++ + Date: $Date: 2008/02/15 12:47:18 $ + Version: $Revision: 1.1 $ + + 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. + +=========================================================================*//** + * \brief Short description in one line + * + * Long description which + * can span multiple lines + */ +/** + * \file + * \brief Pattern for the definition of a new type of Node (header) + */ +/** + * \class bbtk::NodePatern + * \brief Pattern for the definition of a new type of Node + */ + + +#ifdef _USE_WXWIDGETS_ + + +#ifndef __bbWxFileSelector_h__ +#define __bbWxFileSelector_h__ + +#include "bbtkAtomicBlackBox.h" + + + +namespace bbwx +{ + + + + + //================================================================= + class /*BBTK_EXPORT*/ FileSelector : public bbtk::AtomicBlackBox + { + BBTK_USER_BLACK_BOX_INTERFACE(FileSelector,bbtk::AtomicBlackBox); + BBTK_DECLARE_INPUT(Title,std::string); + BBTK_DECLARE_INPUT(Message,std::string); + BBTK_DECLARE_INPUT(DefaultDir,std::string); + BBTK_DECLARE_INPUT(DefaultFile,std::string); + BBTK_DECLARE_INPUT(Wildcard,std::string); + BBTK_DECLARE_INPUT(OpenSave,std::string); + BBTK_DECLARE_OUTPUT(Out,std::string); + BBTK_PROCESS(Process); + void Process(); + }; + //================================================================= + + + //================================================================= + // AtomicBlackBox description + BBTK_BEGIN_DESCRIBE_BLACK_BOX(FileSelector,bbtk::AtomicBlackBox); + BBTK_NAME("FileSelector"); + BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr"); + BBTK_CATEGORY("widget"); + BBTK_DESCRIPTION("Pops up a file selection dialog for reading or saving (wxFileDialog)"); + BBTK_INPUT(FileSelector,Title,"Title of the dialog",std::string); + BBTK_INPUT(FileSelector,Message,"Message to show on the dialog",std::string); + BBTK_INPUT(FileSelector,DefaultDir,"The default directory",std::string); + BBTK_INPUT(FileSelector,DefaultFile,"The default filename",std::string); + BBTK_INPUT(FileSelector,Wildcard,"A wildcard, such as \"*.*\" or \"BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif\"",std::string); + BBTK_INPUT(FileSelector,OpenSave,"Open for an open dialog (default) / Save for a save dialog",std::string); + BBTK_OUTPUT(FileSelector,Out,"The file selected by the user",std::string); + BBTK_END_DESCRIBE_BLACK_BOX(FileSelector); + //================================================================= + + + +} + + + +//namespace bbtk +#endif //__bbtkWxFileSelector_h__ + +#endif //_USE_WXWIDGETS_ diff --git a/packages/wx/src/bbwxInputText.cxx b/packages/wx/src/bbwxInputText.cxx new file mode 100644 index 0000000..5b3dd20 --- /dev/null +++ b/packages/wx/src/bbwxInputText.cxx @@ -0,0 +1,145 @@ +/*========================================================================= + + Program: bbtk + Module: $RCSfile: bbwxInputText.cxx,v $ + Language: C++ + Date: $Date: 2008/02/15 12:47:18 $ + Version: $Revision: 1.1 $ + + 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_USER_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_ + diff --git a/packages/wx/src/bbwxInputText.h b/packages/wx/src/bbwxInputText.h new file mode 100644 index 0000000..6cdb27e --- /dev/null +++ b/packages/wx/src/bbwxInputText.h @@ -0,0 +1,118 @@ +/*========================================================================= + + Program: bbtk + Module: $RCSfile: bbwxInputText.h,v $ + Language: C++ + Date: $Date: 2008/02/15 12:47:18 $ + Version: $Revision: 1.1 $ + + 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. + +=========================================================================*//** + * \brief Short description in one line + * + * Long description which + * can span multiple lines + */ +/** + * \file + * \brief Pattern for the definition of a new type of Node (header) + */ +/** + * \class bbtk::NodePatern + * \brief Pattern for the definition of a new type of Node + */ + + +#ifdef _USE_WXWIDGETS_ + + +#ifndef __bbWxInputText_h__ +#define __bbWxInputText_h__ + +#include "bbtkWxBlackBox.h" + + + +namespace bbwx +{ + + + + + class InputText; + + //-------------------------------------------------------------------------- + class InputTextWidget : wxPanel + { + public: + InputTextWidget(InputText* box, wxWindow *parent, + wxString In, wxString title); + ~InputTextWidget(); + + std::string GetValue(); + void OnTextUpdate(wxCommandEvent& event); + + void SetTitle(wxString); + + private: + InputText *mBox; + wxTextCtrl *mwxTextCtrl; + wxStaticText *mwxTitle; + }; + + //------------------------------------------------------------------------ + //------------------------------------------------------------------------ + //------------------------------------------------------------------------ + + + + + + class /*BBTK_EXPORT*/ InputText : public bbtk::WxBlackBox + { + + BBTK_USER_BLACK_BOX_INTERFACE(InputText,bbtk::WxBlackBox); + BBTK_DECLARE_INPUT(In,std::string); + BBTK_DECLARE_INPUT(Title,std::string); + BBTK_DECLARE_OUTPUT(Out,std::string); + BBTK_PROCESS(Process); + void Process(); + BBTK_CREATE_WIDGET(CreateWidget); + void CreateWidget(); + + protected: + virtual void bbUserConstructor(); + }; + + + //================================================================= + // UserBlackBox description + BBTK_BEGIN_DESCRIBE_BLACK_BOX(InputText,bbtk::WxBlackBox); + BBTK_NAME("InputText"); + BBTK_AUTHOR("laurent guigues at creatis.insa-lyon.fr"); + BBTK_DESCRIPTION("A zone in which the user can enter a text (wxTextCtrl)"); + BBTK_INPUT(InputText,In,"Initial text (default '')",std::string); + + BBTK_INPUT(InputText,Title,"Title of the input zone (default '') ",std::string); + + BBTK_OUTPUT(InputText,Out,"Current text",std::string); + BBTK_END_DESCRIBE_BLACK_BOX(InputText); + //================================================================= + + + +} + + + +//namespace bbtk +#endif //__bbWxInputText_h__ + +#endif //_USE_WXWIDGETS_ diff --git a/packages/wx/src/bbwxOutputText.xml b/packages/wx/src/bbwxOutputText.xml new file mode 100644 index 0000000..7b8af12 --- /dev/null +++ b/packages/wx/src/bbwxOutputText.xml @@ -0,0 +1,37 @@ + + + + + laurent.guigues at creatis.insa-lyon.fr + Text zone to be inserted into a window (wxStaticText) + + + + + +
+   bbSetOutputWidget( new wxStaticText ( bbGetWxParent() , -1 , _T("") ) );
+   Process();
+  
+ +
+   std::string msg;
+    if (bbGetInputTitle()!="")
+      {
+	msg = bbGetInputTitle()+": " + bbGetInputIn();
+      }  
+    else 
+      {
+	msg = bbGetInputIn();
+      }
+   ((wxStaticText*)bbGetOutputWidget())->SetLabel( bbtk::std2wx( msg ) ); 
+  
+ +
 
+    bbSetInputIn("");
+    bbSetInputTitle("");
+  
+ + +
+