library: libGpad #include "TSlider.h"

# TSlider

class description - source file - inheritance tree (.pdf)

## class TSlider : public TPad

| Inheritance Chart:
`TObject`
`TAttLine`
`TAttFill`
`TAttPad`
`TQObject`
| <- | `TVirtualPad`
| <- | `TPad`
| <- | `TSlider` |

        private:

                   TSlider(const TSlider& org)
          TSlider& operator=(const TSlider& rhs)

        public:

                              TSlider()
                              TSlider(const char* name, const char* title, Double_t x1, Double_t y1, Double_t x2, Double_t y2, Color_t color = 16, Short_t bordersize = 2, Short_t bordermode = -1)
                      virtual ~TSlider()
               static TClass* Class()
                     Double_t GetMaximum() const
          virtual const char* GetMethod() const
                     Double_t GetMinimum() const
                     TObject* GetObject() const
              virtual TClass* IsA() const
                 virtual void Paint(Option_t* option = "")
                 virtual void SavePrimitive(ofstream& out, Option_t* option)
                 virtual void SetMaximum(Double_t max = 1)
                 virtual void SetMethod(const char* method)
                 virtual void SetMinimum(Double_t min = 0)
                         void SetObject(TObject* obj = 0)
                 virtual void SetRange(Double_t xmin = 0, Double_t xmax = 1)
                 virtual void ShowMembers(TMemberInspector& insp, char* parent)
                 virtual void Streamer(TBuffer& b)
                         void StreamerNVirtual(TBuffer& b)

### Data Members

        protected:

          Double_t fMinimum  Slider minimum value in [0,1]
          Double_t fMaximum  Slider maximum value in [0,1]
          TObject* fObject   !Pointer to associated object
           TString fMethod   command to be executed when slider is changed

## Class Description

     TSlider

      A TSlider object is a specialized TPad including a TSliderBox object
      The TSliderBox can be moved in the pad.
      Slider drawing options include the possibility to change the slider
      starting and ending positions or only one of them.

      The current slider position can be retrieved via the functions
         TSlider::GetMinimum and TSlider::GetMaximum
      These two functions return numbers in the range [0,1].

      if a method has been set (via SetMethod), the expression  is
      executed via the interpreter when the button 1 is released.

      if no method has been set, and an object is referenced (SetObject
      has been called), while the slider is being moved/resized,
      the object ExecuteEvent function is called.                         //

      Example 1 using SetMethod    macro xyslider.C
      =========================
    {
       //Example of macro featuring two sliders
       TFile *f = new TFile("hsimple.root");
       TH2F *hpxpy = (TH2F*)f->Get("hpxpy");
       TCanvas *c1 = new TCanvas("c1");
       TPad *pad = new TPad("pad","lego pad",0.1,0.1,0.98,0.98);
       pad->SetFillColor(33);
       pad->Draw();
       pad->cd();
       gStyle->SetFrameFillColor(42);
       hpxpy->SetFillColor(46);
       hpxpy->Draw("lego1");
       c1->cd();

       //Create two sliders in main canvas. When button1
       //of the mouse will be released, action.C will be called
       TSlider *xslider = new TSlider("xslider","x",0.1,0.02,0.98,0.08);
       xslider->SetMethod(".x action.C");
       TSlider *yslider = new TSlider("yslider","y",0.02,0.1,0.06,0.98);
       yslider->SetMethod(".x action.C");
    }

                macro action.C
    {
       Int_t nx = hpxpy->GetXaxis()->GetNbins();
       Int_t ny = hpxpy->GetYaxis()->GetNbins();
       Int_t binxmin = nx*xslider->GetMinimum();
       Int_t binxmax = nx*xslider->GetMaximum();
       hpxpy->GetXaxis()->SetRange(binxmin,binxmax);
       Int_t binymin = ny*yslider->GetMinimum();
       Int_t binymax = ny*yslider->GetMaximum();
       hpxpy->GetYaxis()->SetRange(binymin,binymax);
       pad->cd();
       hpxpy->Draw("lego1");
       c1->Update();
    }
        The canvas and the sliders created in the above macro are shown
        in the picture below.

/* */

      Example 2 using SetObject    macro xyslider.C
      =========================

      Same example as above. Instead of SetMethod:
        Myclass *obj = new Myclass(); // Myclass derived from TObject
        xslider->SetObject(obj);
        yslider->SetObject(obj);

        When the slider will be changed, MyClass::ExecuteEvent will be
        called with px=0 and py = 0

TSlider(): TPad()

    *-*-*-*-*-*-*-*-*-*-*slider default constructor*-*-*-*-*-*-*-*-*-*-*-*-*
    *-*                  ==========================

TSlider(const char *name, const char *title, Double_t x1, Double_t y1,Double_t x2, Double_t y2, Color_t color, Short_t bordersize, Short_t bordermode) :TPad(name,title,0.1,0.1,0.9,0.9,color,bordersize,bordermode)

    *-*-*-*-*-*-*-*-*-*-*Slider normal constructor*-*-*-*-*-*-*-*-*-*-*-*-*-*
    *-*                  =========================

       x1,y1,x2,y2 are in pad user coordinates

~TSlider()

    *-*-*-*-*-*-*-*-*-*-*slider default destructor*-*-*-*-*-*-*-*-*-*-*-*-*-*
    *-*                  =========================

void Paint(Option_t *option)

    *-*-*-*-*-*-*-*-*-*-*Paint this slider with its current attributes*-*-*-*
    *-*                  =============================================

void SavePrimitive(ofstream &out, Option_t *)

     Save primitive as a C++ statement(s) on output stream out

void SetRange(Double_t xmin, Double_t xmax)

    *-*-*-*-*-*-*-*-*-*-*Set Slider range in [0,1]*-*-*-*-*
    *-*                  =========================

### Inline Functions

               TSlider& operator=(const TSlider& rhs)
                TSlider TSlider(const char* name, const char* title, Double_t x1, Double_t y1, Double_t x2, Double_t y2, Color_t color = 16, Short_t bordersize = 2, Short_t bordermode = -1)
               TObject* GetObject() const
               Double_t GetMinimum() const
               Double_t GetMaximum() const
            const char* GetMethod() const
                   void SetMethod(const char* method)
                   void SetObject(TObject* obj = 0)
                   void SetMinimum(Double_t min = 0)
                   void SetMaximum(Double_t max = 1)
                TClass* Class()
                TClass* IsA() const
                   void ShowMembers(TMemberInspector& insp, char* parent)
                   void Streamer(TBuffer& b)
                   void StreamerNVirtual(TBuffer& b)

Author: Rene Brun 23/11/96
Last update: root/gpad:$Name: $:$Id: TSlider.cxx,v 1.4 2002/01/24 11:39:28 rdm Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *