--- /dev/null
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+#include "bbwxSpinCtrl.h"
+#include "bbwxPackage.h"
+
+#include <wx/spinbutt.h>
+#include <wx/spinctrl.h>
+
+namespace bbwx
+{
+
+
+
+ //--------------------------------------------------------------------------
+ // The widget created by the box
+ class SpinCtrlWidget : public wxPanel
+ {
+ public:
+ /// Ctor with the two first params the parent window and the creator box
+ /// which must be passed to the WxBlackBoxWidget constructor.
+ /// The other params initialize the widget
+ SpinCtrlWidget(SpinCtrl* box, wxWindow *parent,
+ wxString title, int reactiveOnKeyStroke );
+ /// Dtor
+ ~SpinCtrlWidget();
+ /// Events callbacks
+ /// Called when the box is clicked
+ void OnSpinCtrlClick(wxCommandEvent& event);
+
+ // Accessors
+ bool GetValue() { return mwxSpinCtrl->GetValue(); }
+ void SetValue(int min, int max, int selected);
+ // Update the texts which display the min/max/current values of the slider
+
+ private:
+ SpinCtrl* mBox;
+ wxSpinCtrl *mwxSpinCtrl;
+ wxSpinButton *mwxSpinButton;
+ int _reactiveOnKeyStroke;
+ int selected;
+ };
+ //------------------------------------------------------------------------
+ //------------------------------------------------------------------------
+ //------------------------------------------------------------------------
+
+
+
+ //-------------------------------------------------------------------------
+ SpinCtrlWidget::SpinCtrlWidget(SpinCtrl* box, wxWindow *parent,
+ wxString title,
+ int reactiveOnKeyStroke)
+ :
+ wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
+ mBox(box),
+ _reactiveOnKeyStroke(reactiveOnKeyStroke)
+ {
+ wxPanel * panel = this;
+ //---------------------------------------------------------------------
+ // 1) Creation of the components of the widget
+ // Any top level sub-widget must have the panel returned by panel
+ // for parent
+
+
+ wxFlexGridSizer *sizer;
+ sizer = new wxFlexGridSizer(1);
+
+
+ mwxSpinCtrl = NULL;
+ mwxSpinButton = NULL;
+ if (mBox->bbGetInputType()==0)
+ {
+ mwxSpinCtrl = new wxSpinCtrl( panel, -1 );
+ // Connecting events to callbacks
+ Connect( mwxSpinCtrl->GetId(),
+ wxEVT_COMMAND_SPINCTRL_UPDATED,
+ (wxObjectEventFunction)
+ (void (wxPanel::*)(wxScrollEvent&))
+ &SpinCtrlWidget::OnSpinCtrlClick);
+ sizer->Add( mwxSpinCtrl );
+ } else {
+ mwxSpinButton = new wxSpinButton( panel, -1 );
+ // Connecting events to callbacks
+ Connect( mwxSpinButton->GetId(),
+ wxEVT_SPIN,
+ (wxObjectEventFunction)
+ (void (wxPanel::*)(wxScrollEvent&))
+ &SpinCtrlWidget::OnSpinCtrlClick);
+ sizer->Add( mwxSpinButton );
+ }// if Type
+
+ //---------------------------------------------------------------------
+
+ //---------------------------------------------------------------------
+ // 2) Insertion of the components in the window
+
+ // We use a FlexGridSizer
+ panel->SetSizer(sizer);
+ }
+ //-------------------------------------------------------------------------
+
+
+ //-------------------------------------------------------------------------
+ SpinCtrlWidget::~SpinCtrlWidget()
+ {
+ }
+ //-------------------------------------------------------------------------
+
+
+ //-------------------------------------------------------------------------
+
+
+
+ //-------------------------------------------------------------------------
+ void SpinCtrlWidget::OnSpinCtrlClick(wxCommandEvent& event)
+ {
+ // When user clicks the box
+ // we update the output of the box
+
+ if (mBox->bbGetInputType()==0)
+ {
+ mBox->bbSetOutputOut( mwxSpinCtrl->GetValue() );
+ } else {
+ mBox->bbSetOutputOut( mwxSpinButton->GetValue() );
+ }// if Type
+
+ // and signal that the output has changed
+ //if(_reactiveOnKeyStroke==1){
+ mBox->bbSignalOutputModification(std::string("Out"));
+ //}
+ }
+ //-------------------------------------------------------------------------
+
+ //-------------------------------------------------------------------------
+
+
+ //-------------------------------------------------------------------------
+ void SpinCtrlWidget::SetValue(int min, int max, int selected)
+ {
+ if (mBox->bbGetInputType()==0)
+ {
+ mwxSpinCtrl->SetRange( min,max );
+ mwxSpinCtrl->SetValue( selected );
+ } else {
+ mwxSpinButton->SetRange( min,max );
+ mwxSpinButton->SetValue( selected );
+ }// if Type
+ }
+ //-------------------------------------------------------------------------
+
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,SpinCtrl)
+BBTK_BLACK_BOX_IMPLEMENTATION(SpinCtrl,bbtk::WxBlackBox);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void SpinCtrl::Process()
+{
+ // if with label
+ ((SpinCtrlWidget*)bbGetOutputWidget())->SetValue( bbGetInputMin() , bbGetInputMax(), bbGetInputSelected() );
+ bbSetOutputOut( bbGetInputSelected() );
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void SpinCtrl::CreateWidget(wxWindow* parent)
+{
+
+ SpinCtrlWidget *spinctrlwidget=new SpinCtrlWidget( this , parent, bbGetInputTitle() ,1);
+ bbSetOutputWidget( spinctrlwidget );
+ spinctrlwidget->SetValue( bbGetInputMin() , bbGetInputMax(), bbGetInputSelected() );
+
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void SpinCtrl::bbUserSetDefaultValues()
+{
+ bbSetInputMin(0);
+ bbSetInputMax(100);
+ bbSetInputSelected(0);
+ bbSetInputType(0);
+ bbSetInputTitle("");
+
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void SpinCtrl::bbUserInitializeProcessing()
+{
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void SpinCtrl::bbUserFinalizeProcessing()
+{
+}
+
+} // EO namespace bbwx
+
+
--- /dev/null
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+#ifdef _USE_WXWIDGETS_
+#ifndef __bbwxSpinCtrl_h_INCLUDED__
+#define __bbwxSpinCtrl_h_INCLUDED__
+
+#include "bbwx_EXPORT.h"
+#include "bbtkWxBlackBox.h"
+
+namespace bbwx
+{
+
+class bbwx_EXPORT SpinCtrl
+ :
+ public bbtk::WxBlackBox
+{
+ BBTK_BLACK_BOX_INTERFACE(SpinCtrl,bbtk::WxBlackBox);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+ BBTK_DECLARE_INPUT(Title,std::string);
+ BBTK_DECLARE_INPUT(Min,int);
+ BBTK_DECLARE_INPUT(Max,int);
+ BBTK_DECLARE_INPUT(Selected,int);
+ BBTK_DECLARE_INPUT(Type,int);
+ BBTK_DECLARE_OUTPUT(Out,int);
+ BBTK_PROCESS(Process);
+ void Process();
+ BBTK_CREATE_WIDGET(CreateWidget);
+ void CreateWidget(wxWindow*);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(SpinCtrl,bbtk::WxBlackBox);
+ BBTK_NAME("SpinCtrl");
+ BBTK_AUTHOR("InfoDev");
+ BBTK_DESCRIPTION("No Description.");
+ BBTK_CATEGORY("__CategoryBlackBox__");
+
+ BBTK_INPUT(SpinCtrl,Title,"Title",std::string,"");
+ BBTK_INPUT(SpinCtrl,Min,"(default 0) Min",int,"");
+ BBTK_INPUT(SpinCtrl,Max,"default 100) Max",int,"");
+ BBTK_INPUT(SpinCtrl,Selected,"default 0) Selected",int,"");
+ BBTK_INPUT(SpinCtrl,Type,"(default 0) 0:with Label 1:not Label",int,"");
+
+ BBTK_OUTPUT(SpinCtrl,Out,"Output value",int,"");
+
+BBTK_END_DESCRIBE_BLACK_BOX(SpinCtrl);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+}
+// EO namespace bbwx
+
+#endif // __bbwxSpinCtrl_h_INCLUDED__
+#endif // _USE_WXWIDGETS_
+