TGTripleSlider.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGTripleSlider.h 26446 2008-11-25 11:00:24Z brun $
00002 // Author: Bertrand Bellenot   20/01/06
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGTripleSlider
00013 #define ROOT_TGTripleSlider
00014 
00015 //////////////////////////////////////////////////////////////////////////
00016 //                                                                      //
00017 // TGTripleVSlider and TGTripleHSlider                                  //
00018 //                                                                      //
00019 // TripleSlider inherit from DoubleSlider widgets and allow easy        //
00020 // selection of a min, max and pointer value out of a range.            //
00021 // The pointer position can be constrained to edges of slider and / or  //
00022 // can be relative to the slider position.                              //
00023 //                                                                      //
00024 // To change the min value press the mouse near to the left / bottom    //
00025 // edge of the slider.                                                  //
00026 // To change the max value press the mouse near to the right / top      //
00027 // edge of the slider.                                                  //
00028 // To change both values simultaneously press the mouse near to the     //
00029 // center of the slider.                                                //
00030 // To change pointer value press the mouse on the pointer and drag it   //
00031 // to the desired position                                              //
00032 //                                                                      //
00033 // Dragging the slider will generate the event:                         //
00034 // kC_VSLIDER, kSL_POS, slider id, 0  (for vertical slider)             //
00035 // kC_HSLIDER, kSL_POS, slider id, 0  (for horizontal slider)           //
00036 //                                                                      //
00037 // Pressing the mouse will generate the event:                          //
00038 // kC_VSLIDER, kSL_PRESS, slider id, 0  (for vertical slider)           //
00039 // kC_HSLIDER, kSL_PRESS, slider id, 0  (for horizontal slider)         //
00040 //                                                                      //
00041 // Releasing the mouse will generate the event:                         //
00042 // kC_VSLIDER, kSL_RELEASE, slider id, 0  (for vertical slider)         //
00043 // kC_HSLIDER, kSL_RELEASE, slider id, 0  (for horizontal slider)       //
00044 //                                                                      //
00045 // Moving the pointer will generate the event:                          //
00046 // kC_VSLIDER, kSL_POINTER, slider id, 0  (for vertical slider)         //
00047 // kC_HSLIDER, kSL_POINTER, slider id, 0  (for horizontal slider)       //
00048 //                                                                      //
00049 // Use the functions GetMinPosition(), GetMaxPosition() and             //
00050 // GetPosition() to retrieve the position of the slider.                //
00051 // Use the function GetPointerPosition() to retrieve the position of    //
00052 // the pointer                                                          //
00053 //                                                                      //
00054 //////////////////////////////////////////////////////////////////////////
00055 
00056 #ifndef ROOT_TGFrame
00057 #include "TGFrame.h"
00058 #endif
00059 #ifndef ROOT_TGWidget
00060 #include "TGWidget.h"
00061 #endif
00062 #ifndef ROOT_TGDoubleSlider
00063 #include "TGDoubleSlider.h"
00064 #endif
00065 
00066 class TGTripleVSlider : public TGDoubleVSlider {
00067 
00068 protected:
00069    Int_t            fCz;           // vertical pointer position in pixel coordinates
00070    Float_t          fSCz;          // vertical pointer position
00071    Bool_t           fConstrained;  // kTRUE if pointer is constrained to slider edges
00072    Bool_t           fRelative;     // kTRUE if pointer position is relative to slider
00073    const TGPicture *fPointerPic;   // picture to draw pointer
00074 
00075    virtual void     DoRedraw();
00076    virtual void     SetPointerPos(Int_t z, Int_t opt = 0);
00077 
00078 public:
00079    TGTripleVSlider(const TGWindow *p = 0, UInt_t h = 1, UInt_t type = 1, Int_t id = -1,
00080                    UInt_t options = kVerticalFrame,
00081                    Pixel_t back = GetDefaultFrameBackground(),
00082                    Bool_t reversed = kFALSE,
00083                    Bool_t mark_ends = kFALSE,
00084                    Bool_t constrained = kTRUE,
00085                    Bool_t relative = kFALSE);
00086 
00087    virtual ~TGTripleVSlider();
00088 
00089    virtual void      PointerPositionChanged() { Emit("PointerPositionChanged()"); } //*SIGNAL*
00090    virtual void      DrawPointer();
00091    virtual Float_t   GetPointerPosition() const {
00092       if (fReversedScale) return fVmin + fVmax - fSCz;
00093       else return fSCz;
00094    }
00095    virtual Bool_t    HandleButton(Event_t *event);
00096    virtual Bool_t    HandleConfigureNotify(Event_t* event);
00097    virtual Bool_t    HandleMotion(Event_t *event);
00098    virtual void      SetConstrained(Bool_t on = kTRUE);
00099    virtual void      SetPointerPosition(Float_t pos);
00100    virtual void      SetRelative(Bool_t rel = kTRUE) { fRelative = rel; }
00101    virtual void      SavePrimitive(ostream &out, Option_t *option = "");
00102 
00103    ClassDef(TGTripleVSlider,0)  // Vertical triple slider widget
00104 };
00105 
00106 
00107 class TGTripleHSlider : public TGDoubleHSlider {
00108 
00109 protected:
00110    Int_t            fCz;           // horizontal pointer position in pixel coordinates
00111    Float_t          fSCz;          // vertical pointer position
00112    Bool_t           fConstrained;  // kTRUE if pointer is constrained to slider edges
00113    Bool_t           fRelative;     // kTRUE if pointer position is relative to slider
00114    const TGPicture *fPointerPic;   // picture to draw pointer
00115 
00116    virtual void     DoRedraw();
00117    virtual void     SetPointerPos(Int_t z, Int_t opt = 0);
00118 
00119 public:
00120    TGTripleHSlider(const TGWindow *p = 0, UInt_t w = 1, UInt_t type = 1, Int_t id = -1,
00121                    UInt_t options = kHorizontalFrame,
00122                    Pixel_t back = GetDefaultFrameBackground(),
00123                    Bool_t reversed = kFALSE,
00124                    Bool_t mark_ends = kFALSE,
00125                    Bool_t constrained = kTRUE,
00126                    Bool_t relative = kFALSE);
00127 
00128    virtual ~TGTripleHSlider();
00129 
00130    virtual void      PointerPositionChanged() { Emit("PointerPositionChanged()"); } //*SIGNAL*
00131    virtual void      DrawPointer();
00132    virtual Float_t   GetPointerPosition() const {
00133       if (fReversedScale) return fVmin + fVmax - fSCz;
00134       else return fSCz;
00135    }
00136    virtual Bool_t    HandleButton(Event_t *event);
00137    virtual Bool_t    HandleConfigureNotify(Event_t* event);
00138    virtual Bool_t    HandleMotion(Event_t *event);
00139    virtual void      SetConstrained(Bool_t on = kTRUE);
00140    virtual void      SetPointerPosition(Float_t pos);
00141    virtual void      SetRelative(Bool_t rel = kTRUE) { fRelative = rel; }
00142    virtual void      SavePrimitive(ostream &out, Option_t *option = "");
00143 
00144    ClassDef(TGTripleHSlider,0)  // Horizontal triple slider widget
00145 };
00146 
00147 #endif

Generated on Tue Jul 5 14:20:10 2011 for ROOT_528-00b_version by  doxygen 1.5.1