00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00037 #ifdef _USE_WXWIDGETS_
00038
00039
00040 #include "bbwxInputText.h"
00041 #include "bbwxPackage.h"
00042
00043
00044
00045
00046
00047
00048 namespace bbwx
00049 {
00050
00051
00052
00053
00054
00055
00056 class InputTextWidget : wxPanel
00057 {
00058 public:
00059 InputTextWidget(InputText* box, wxWindow *parent,
00060 wxString In, wxString title);
00061 ~InputTextWidget();
00062
00063 std::string GetValue();
00064 void OnTextUpdate(wxCommandEvent& event);
00065
00066 void SetTitle(wxString);
00067
00068 private:
00069 InputText *mBox;
00070 wxTextCtrl *mwxTextCtrl;
00071 wxStaticText *mwxTitle;
00072 };
00073
00074
00075
00076
00077
00078
00079
00080
00081 InputTextWidget::InputTextWidget(InputText* box,
00082 wxWindow *parent,
00083 wxString In,
00084 wxString title)
00085 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
00086 mBox(box)
00087 {
00088 wxPanel *panel = this;
00089
00090 mwxTextCtrl = new wxTextCtrl( panel, -1, In,
00091 wxDefaultPosition, wxSize(800,20));
00092 Connect( mwxTextCtrl->GetId(), wxEVT_COMMAND_TEXT_UPDATED,
00093 (wxObjectEventFunction)
00094 (wxEventFunction)
00095 (wxCommandEventFunction)
00096 (void (wxPanel::*)(wxCommandEvent&))
00097 &InputTextWidget::OnTextUpdate );
00098
00099
00100 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
00101
00102
00103
00104
00105 mwxTitle = new wxStaticText(panel,-1, title );
00106 sizer -> Add( mwxTitle );
00107
00108 sizer -> Add( mwxTextCtrl,1,wxGROW );
00109 sizer -> AddGrowableCol(0);
00110
00111 panel -> SetSizer(sizer);
00112 panel -> SetAutoLayout(true);
00113 panel -> Layout();
00114
00115 }
00116
00117
00118 InputTextWidget::~InputTextWidget()
00119 {
00120 }
00121
00122
00123
00124
00125 void InputTextWidget::SetTitle(wxString s)
00126 {
00127 mwxTitle->SetLabel(s);
00128 }
00129
00130
00131 std::string InputTextWidget::GetValue()
00132 {
00133 return bbtk::wx2std ( mwxTextCtrl->GetValue() );
00134 }
00135
00136
00137 void InputTextWidget::OnTextUpdate(wxCommandEvent& event)
00138 {
00139 mBox->bbSetOutputOut( GetValue() );
00140 mBox->bbSetInputIn( GetValue() );
00141 mBox->bbSignalOutputModification("Out");
00142 }
00143
00144
00145
00146
00147
00148
00149 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,InputText);
00150 BBTK_BLACK_BOX_IMPLEMENTATION(InputText,bbtk::WxBlackBox);
00151
00152
00153
00154 void InputText::bbUserConstructor()
00155 {
00156 bbSetInputTitle("");
00157 bbSetInputIn("");
00158 bbSetOutputWidget(0);
00159 }
00160
00161
00162 void InputText::Process()
00163 {
00164 InputTextWidget *w=(InputTextWidget *)bbGetOutputWidget();
00165 if (w)
00166 {
00167 bbSetInputIn( w->GetValue() );
00168 w->SetTitle( bbtk::std2wx ( bbGetInputTitle() ) );
00169 }
00170 bbSetOutputOut( bbGetInputIn() );
00171 }
00172
00173
00174
00175 void InputText::CreateWidget(wxWindow* parent)
00176 {
00177 bbSetOutputWidget
00178 ( (wxWindow*) new InputTextWidget(this,
00179 parent,
00180 bbtk::std2wx ( bbGetInputIn() ) ,
00181 bbtk::std2wx ( bbGetInputTitle() ) ) );
00182
00183 }
00184
00185
00186
00187
00188 }
00189
00190 #endif // _USE_WXWIDGETS_
00191