+++ /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 "bbwtSlider.h"
-#include "bbwtPackage.h"
-#include "bbtkUtilities.h"
-namespace bbwt
-{
-
- class SliderWidget : public Wt::WContainerWidget
- {
- public:
- SliderWidget(Slider* box, Wt::WContainerWidget *parent,
- int orientation,
- bool changeresolution,
- Wt::WString title,
- int vmin,
- int vmax,
- int value,
- bool reactiveontrack);
-
- ~SliderWidget();
-
- /// Events callbacks
- /// Called when the slider is moved
- void OnSliderTrack();
- void OnSliderMove();
- /// Called when the little slider which controls the resolution
- /// of the main slider is moved (if activated)
- void OnResolutionOfSlider();
-
- // Accessors
- void SetValue(int v) { mwtSlider->setValue(v); }
- int GetValue() { return mwtSlider->value(); }
- int GetMin() {return min;}
- int GetMax() {return max;}
- void SetRange(int min, int max);
- void SetReactiveOnTrack(bool ok);
-
-
- private:
- Slider* mBox;
- Wt::WSlider *mwtSlider;
- Wt::WSlider *mResolutionOfSlider;
- Wt::WText *textTitle;
- Wt::WString tTitle;
- int min;
- int max;
- bool reactiveOnTrack;
-
-
- };
-
- //------------------------------------------------------------------------
- //------------------------------------------------------------------------
- //------------------------------------------------------------------------
-
-
-
- //-------------------------------------------------------------------------
- SliderWidget::SliderWidget(Slider* box, Wt::WContainerWidget *parent,
- int orientation,
- bool changeresolution,
- Wt::WString title,
- int vmin,
- int vmax,
- int value,
- bool reactiveontrack)
- :
- Wt::WContainerWidget(parent),
- mBox(box),
- tTitle(title),
- min(vmin),
- max(vmax),
- reactiveOnTrack(reactiveontrack)
-
- {
- std::cout<<"Creando SLIDER -- 0 "<<std::endl;
- Wt::WContainerWidget * panel = this;
- Wt::WBorderLayout* layout = new Wt::WBorderLayout();
-
-
-
- mResolutionOfSlider = NULL;
-
- int sizeX,sizeY;
- Wt::Orientation wtorientation;
- std::cout<<"Creando SLIDER -- 1 "<<std::endl;
- if (orientation==0)
- {
- sizeX = 2;
- sizeY = 40;
- wtorientation = Wt::Horizontal;
-
- }
- else
- {
- sizeX = 20;
- sizeY = 2;
- wtorientation = Wt::Vertical;
- }
-
- //---------------------------------------------------------------------
- // 1) Creation of the components of the widget
- // Any top level sub-widget must have the panel returned by panel
- // for parent
-
- std::cout<<"Creando SLIDER -- 2 "<<std::endl;
- mwtSlider = new Wt::WSlider(wtorientation);
- mwtSlider->resize(sizeX,sizeY);
- mwtSlider->setMinimum(min);
- mwtSlider->setMaximum(max);
- mwtSlider->setValue(value);
- mwtSlider->setTickPosition(Wt::WSlider::TicksBothSides);
- //mwtSlider->setValueText(title);
- mwtSlider->valueChanged().connect(this,&SliderWidget::OnSliderTrack);
- mwtSlider->sliderMoved().connect(this,&SliderWidget::OnSliderMove);
- // mwtSlider->resize(Wt::WLength::Auto, 50);
-
-
- // If asked : creation of the other little slider which allows to change
- // the resolution of the main slider
- std::cout<<"Creando SLIDER -- 3 "<<std::endl;
- if (changeresolution==true)
- {
- // has panel for parent too
- mResolutionOfSlider = new Wt::WSlider(Wt::Vertical);
- mResolutionOfSlider->setMinimum(1);
- mResolutionOfSlider->setMaximum(8);
- mResolutionOfSlider->setValue(5);
- mResolutionOfSlider->valueChanged().connect(this,&SliderWidget::OnResolutionOfSlider);
- mResolutionOfSlider->resize(5,10);
- if (orientation==0)
- {
- // HORIZONTAL
- layout->addWidget(mResolutionOfSlider,Wt::WBorderLayout::West);
-
- }
- else
- {
- // VERTICAL
- layout->addWidget(mResolutionOfSlider,Wt::WBorderLayout::South);
-
- }
-
- }
-
- //---------------------------------------------------------------------
-
- //---------------------------------------------------------------------
- // 2) Insertion of the components in the window
- std::cout<<"Creando SLIDER -- 4 "<<std::endl;
- textTitle = new Wt::WText(tTitle + bbtk::std2wt(" : ")+ mwtSlider->valueText());
- layout->addWidget(textTitle,Wt::WBorderLayout::North);
- layout->addWidget(mwtSlider,Wt::WBorderLayout::Center);
- std::cout<<"Creando SLIDER -- 5 "<<std::endl;
- // Insert the sizer in the main panel and refresh the layout
- panel->setLayout(layout);
- std::cout<<"Creando SLIDER -- 6 "<<std::endl;
- }
- //-------------------------------------------------------------------------
-
-
-
- //-------------------------------------------------------------------------
- SliderWidget::~SliderWidget()
- {
- }
- //-------------------------------------------------------------------------
-
-
- //-------------------------------------------------------------------------
- void SliderWidget::OnResolutionOfSlider()
- {
- int value = mwtSlider->value();
- int delta = (int) (pow((double) 4 ,(double) mResolutionOfSlider->value() ));
- int minTmp = value - delta/2;
- int maxTmp = value + delta/2;
- if (minTmp<min)
- {
- minTmp = min;
- // maxTmp = delta;
- }
- if (maxTmp>max)
- {
- maxTmp = max;
- }
- mwtSlider->setMinimum(minTmp);
- mwtSlider->setMaximum(maxTmp);
-
- }
- //-------------------------------------------------------------------------
-
-
-
- //-------------------------------------------------------------------------
- void SliderWidget::OnSliderTrack()
- {
-
-printf("EED SliderWidget::OnSliderTrack value=%d\n", mwtSlider->value() );
-
- // When user releases the slider
- // we update the output of the box
- mBox->bbSetOutputOut( mwtSlider->value() );
- mBox->bbSetInputIn( mwtSlider->value() );
- mBox->bbSignalOutputModification(std::string("Out"));
- textTitle->setText(tTitle + bbtk::std2wt(" : ") + mwtSlider->valueText());
- }
-
-
- //-------------------------------------------------------------------------
- void SliderWidget::OnSliderMove()
- {
-printf("EED SliderWidget::OnSliderMove value %d\n",mwtSlider->value() );
-
- // When user releases the slider
- // we update the output of the box
- if(reactiveOnTrack==true)
- {
- mBox->bbSetOutputOut( mwtSlider->value() );
- mBox->bbSetInputIn( mwtSlider->value() );
- mBox->bbSignalOutputModification(std::string("Out"));
- }
- textTitle->setText(tTitle + bbtk::std2wt(" :: ") + mwtSlider->valueText());
- }
-
- //-------------------------------------------------------------------------
-
-
- //-------------------------------------------------------------------------
- void SliderWidget::SetRange(int min, int max)
- {
- this->min = min;
- this->max = max;
- mwtSlider->setMinimum(min);
- mwtSlider->setMaximum(max);
- }
-
-
- //-------------------------------------------------------------------------
- void SliderWidget::SetReactiveOnTrack(bool ok)
- {
- reactiveOnTrack = ok;
- }
-
-
-
-
- BBTK_ADD_BLACK_BOX_TO_PACKAGE(wt,Slider);
- BBTK_BLACK_BOX_IMPLEMENTATION(Slider,bbtk::WtBlackBox);
- //=====
- // 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 Slider::Process()
- {
-
- bbtkDebugMessage("process",3,
- "Slider "<<bbGetName()<<" input="
- <<bbGetInputIn()<<std::endl);
-
-
- // desperate try // JPR
- if ( bbGetInputMin() != ((SliderWidget*)bbGetOutputWidget())->GetMin() || bbGetInputMax() != ((SliderWidget*)bbGetOutputWidget())->GetMax() )
- {
- ((SliderWidget*)bbGetOutputWidget())->SetRange(bbGetInputMin(),bbGetInputMax()) ;
- }
-
- ((SliderWidget*)bbGetOutputWidget())->SetReactiveOnTrack( bbGetInputReactiveOnTrack() ) ;
-
- bbSetOutputOut( bbGetInputIn() );
- if (bbGetOutputWidget()!=0)
- {
- ((SliderWidget*)bbGetOutputWidget())->SetValue(bbGetInputIn());
- }
-
- }
-//=====
-// Before editing this file, make sure it'sWt::WSlider a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
-//=====
- void Slider::CreateWidget(Wt::WContainerWidget* parent)
- {
-
- int orientation=0;
- if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"1|V|VERTICAL")==true) { orientation=1; }
-
-
- // std::cout << "bbGetWxParent = "<<bbGetWxParent()<<std::endl;
- SliderWidget *w = new SliderWidget(this,
- parent, //bbGetWxParent(),
- orientation ,
- bbGetInputChangeResolution(),
- bbtk::std2wt( bbGetInputTitle() ),
- bbGetInputMin(),
- bbGetInputMax(),
- bbGetInputIn(),
- bbGetInputReactiveOnTrack()
- );
- // std::cout << "w = "<<w<<std::endl;
- // w->SetName( bbtk::std2wx( bbGetInputWinTitle() ) );
- w->setMinimumSize(Wt::WLength::Auto, 120);
- w->setMaximumSize(Wt::WLength::Auto, 180);
- bbSetOutputWidget( w );
- }
-
-
-
-//=====
-// 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 Slider::bbUserSetDefaultValues()
-{
- bbSetInputIn(0);
- bbSetInputMin(0);
- bbSetInputMax(500);
- bbSetOutputOut(0);
- bbSetInputOrientation("HORIZONTAL");
- bbSetInputChangeResolution(false);
- bbSetInputReactiveOnTrack(false);
-
-
-}
-//=====
-// 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 Slider::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 Slider::bbUserFinalizeProcessing()
-{
-
-}
-}
-// EO namespace bbwt
-
-