Logo ROOT   6.12/07
Reference Guide
TGTripleSlider.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Bertrand Bellenot 20/01/06
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGTripleSlider
13 #define ROOT_TGTripleSlider
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TGTripleVSlider and TGTripleHSlider //
18 // //
19 // TripleSlider inherit from DoubleSlider widgets and allow easy //
20 // selection of a min, max and pointer value out of a range. //
21 // The pointer position can be constrained to edges of slider and / or //
22 // can be relative to the slider position. //
23 // //
24 // To change the min value press the mouse near to the left / bottom //
25 // edge of the slider. //
26 // To change the max value press the mouse near to the right / top //
27 // edge of the slider. //
28 // To change both values simultaneously press the mouse near to the //
29 // center of the slider. //
30 // To change pointer value press the mouse on the pointer and drag it //
31 // to the desired position //
32 // //
33 // Dragging the slider will generate the event: //
34 // kC_VSLIDER, kSL_POS, slider id, 0 (for vertical slider) //
35 // kC_HSLIDER, kSL_POS, slider id, 0 (for horizontal slider) //
36 // //
37 // Pressing the mouse will generate the event: //
38 // kC_VSLIDER, kSL_PRESS, slider id, 0 (for vertical slider) //
39 // kC_HSLIDER, kSL_PRESS, slider id, 0 (for horizontal slider) //
40 // //
41 // Releasing the mouse will generate the event: //
42 // kC_VSLIDER, kSL_RELEASE, slider id, 0 (for vertical slider) //
43 // kC_HSLIDER, kSL_RELEASE, slider id, 0 (for horizontal slider) //
44 // //
45 // Moving the pointer will generate the event: //
46 // kC_VSLIDER, kSL_POINTER, slider id, 0 (for vertical slider) //
47 // kC_HSLIDER, kSL_POINTER, slider id, 0 (for horizontal slider) //
48 // //
49 // Use the functions GetMinPosition(), GetMaxPosition() and //
50 // GetPosition() to retrieve the position of the slider. //
51 // Use the function GetPointerPosition() to retrieve the position of //
52 // the pointer //
53 // //
54 //////////////////////////////////////////////////////////////////////////
55 
56 #include "TGFrame.h"
57 #include "TGWidget.h"
58 #include "TGDoubleSlider.h"
59 
61 
62 protected:
63  Int_t fCz; // vertical pointer position in pixel coordinates
64  Float_t fSCz; // vertical pointer position
65  Bool_t fConstrained; // kTRUE if pointer is constrained to slider edges
66  Bool_t fRelative; // kTRUE if pointer position is relative to slider
67  const TGPicture *fPointerPic; // picture to draw pointer
68 
69  virtual void DoRedraw();
70  virtual void SetPointerPos(Int_t z, Int_t opt = 0);
71 
72 public:
73  TGTripleVSlider(const TGWindow *p = 0, UInt_t h = 1, UInt_t type = 1, Int_t id = -1,
74  UInt_t options = kVerticalFrame,
76  Bool_t reversed = kFALSE,
77  Bool_t mark_ends = kFALSE,
78  Bool_t constrained = kTRUE,
79  Bool_t relative = kFALSE);
80 
81  virtual ~TGTripleVSlider();
82 
83  virtual void PointerPositionChanged() { Emit("PointerPositionChanged()"); } //*SIGNAL*
84  virtual void DrawPointer();
85  virtual Float_t GetPointerPosition() const {
86  if (fReversedScale) return fVmin + fVmax - fSCz;
87  else return fSCz;
88  }
89  virtual Bool_t HandleButton(Event_t *event);
90  virtual Bool_t HandleConfigureNotify(Event_t* event);
91  virtual Bool_t HandleMotion(Event_t *event);
92  virtual void SetConstrained(Bool_t on = kTRUE);
93  virtual void SetPointerPosition(Float_t pos);
94  virtual void SetRelative(Bool_t rel = kTRUE) { fRelative = rel; }
95  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
96 
97  ClassDef(TGTripleVSlider,0) // Vertical triple slider widget
98 };
99 
100 
102 
103 protected:
104  Int_t fCz; // horizontal pointer position in pixel coordinates
105  Float_t fSCz; // vertical pointer position
106  Bool_t fConstrained; // kTRUE if pointer is constrained to slider edges
107  Bool_t fRelative; // kTRUE if pointer position is relative to slider
108  const TGPicture *fPointerPic; // picture to draw pointer
109 
110  virtual void DoRedraw();
111  virtual void SetPointerPos(Int_t z, Int_t opt = 0);
112 
113 public:
114  TGTripleHSlider(const TGWindow *p = 0, UInt_t w = 1, UInt_t type = 1, Int_t id = -1,
115  UInt_t options = kHorizontalFrame,
117  Bool_t reversed = kFALSE,
118  Bool_t mark_ends = kFALSE,
119  Bool_t constrained = kTRUE,
120  Bool_t relative = kFALSE);
121 
122  virtual ~TGTripleHSlider();
123 
124  virtual void PointerPositionChanged() { Emit("PointerPositionChanged()"); } //*SIGNAL*
125  virtual void DrawPointer();
126  virtual Float_t GetPointerPosition() const {
127  if (fReversedScale) return fVmin + fVmax - fSCz;
128  else return fSCz;
129  }
130  virtual Bool_t HandleButton(Event_t *event);
131  virtual Bool_t HandleConfigureNotify(Event_t* event);
132  virtual Bool_t HandleMotion(Event_t *event);
133  virtual void SetConstrained(Bool_t on = kTRUE);
134  virtual void SetPointerPosition(Float_t pos);
135  virtual void SetRelative(Bool_t rel = kTRUE) { fRelative = rel; }
136  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
137 
138  ClassDef(TGTripleHSlider,0) // Horizontal triple slider widget
139 };
140 
141 #endif
virtual void SetPointerPos(Int_t z, Int_t opt=0)
Set slider pointer position in pixel value.
virtual void PointerPositionChanged()
float Float_t
Definition: RtypesCore.h:53
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an horizontal slider as a C++ statement(s) on output stream out.
const char Option_t
Definition: RtypesCore.h:62
TH1 * h
Definition: legend2.C:5
virtual void SetRelative(Bool_t rel=kTRUE)
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in vertical slider.
virtual ~TGTripleVSlider()
Delete vertical slider widget.
const TGPicture * fPointerPic
virtual Float_t GetPointerPosition() const
#define ClassDef(name, id)
Definition: Rtypes.h:320
ULong_t Pixel_t
Definition: GuiTypes.h:39
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:665
virtual Float_t GetPointerPosition() const
virtual void SetRelative(Bool_t rel=kTRUE)
virtual void SetPointerPosition(Float_t pos)
Set pointer position in scaled (real) value.
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
const TGPicture * fPointerPic
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in vertical slider.
int type
Definition: TGX11.cxx:120
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
Bool_t fReversedScale
virtual void DrawPointer()
Draw slider pointer.
virtual void DoRedraw()
Redraw vertical slider widget.
virtual void PointerPositionChanged()
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:165
TGTripleVSlider(const TGWindow *p=0, UInt_t h=1, UInt_t type=1, Int_t id=-1, UInt_t options=kVerticalFrame, Pixel_t back=GetDefaultFrameBackground(), Bool_t reversed=kFALSE, Bool_t mark_ends=kFALSE, Bool_t constrained=kTRUE, Bool_t relative=kFALSE)
Create a vertical slider widget.
virtual Bool_t HandleConfigureNotify(Event_t *event)
Handles resize events for this widget.
const Bool_t kTRUE
Definition: RtypesCore.h:87
virtual void SetConstrained(Bool_t on=kTRUE)
Set pointer position constrained in the slider range.