Logo ROOT  
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
TGWindow
Definition: TGWindow.h:31
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TGDoubleSlider.h
TGPicture
Definition: TGPicture.h:36
TGDoubleSlider::fVmax
Float_t fVmax
Definition: TGDoubleSlider.h:84
Pixel_t
ULong_t Pixel_t
Definition: GuiTypes.h:39
TGTripleVSlider::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in vertical slider.
Definition: TGTripleSlider.cxx:124
TGTripleHSlider::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in horizontal slide widget.
Definition: TGTripleSlider.cxx:457
kVerticalFrame
@ kVerticalFrame
Definition: GuiTypes.h:381
TGTripleVSlider::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an horizontal slider as a C++ statement(s) on output stream out.
Definition: TGTripleSlider.cxx:675
TGTripleVSlider::DrawPointer
virtual void DrawPointer()
Draw slider pointer.
Definition: TGTripleSlider.cxx:116
TGTripleVSlider::SetPointerPosition
virtual void SetPointerPosition(Float_t pos)
Set pointer position in scaled (real) value.
Definition: TGTripleSlider.cxx:336
Float_t
float Float_t
Definition: RtypesCore.h:57
TGFrame::GetDefaultFrameBackground
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:668
TGTripleVSlider::fRelative
Bool_t fRelative
Definition: TGTripleSlider.h:72
TGTripleHSlider::fRelative
Bool_t fRelative
Definition: TGTripleSlider.h:107
TGTripleHSlider::HandleConfigureNotify
virtual Bool_t HandleConfigureNotify(Event_t *event)
Handles resize events for this widget.
Definition: TGTripleSlider.cxx:447
TGTripleVSlider::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in vertical slider.
Definition: TGTripleSlider.cxx:184
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TGTripleVSlider::SetPointerPos
virtual void SetPointerPos(Int_t z, Int_t opt=0)
Set slider pointer position in pixel value.
Definition: TGTripleSlider.cxx:277
bool
TGTripleHSlider::fPointerPic
const TGPicture * fPointerPic
Definition: TGTripleSlider.h:108
TGTripleHSlider::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an horizontal slider as a C++ statement(s) on output stream out.
Definition: TGTripleSlider.cxx:624
TGTripleHSlider::PointerPositionChanged
virtual void PointerPositionChanged()
Definition: TGTripleSlider.h:124
TGDoubleHSlider
Definition: TGDoubleSlider.h:180
TGTripleVSlider::GetPointerPosition
virtual Float_t GetPointerPosition() const
Definition: TGTripleSlider.h:91
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TGTripleVSlider
Definition: TGTripleSlider.h:60
h
#define h(i)
Definition: RSha256.hxx:124
TGTripleVSlider::fCz
Int_t fCz
Definition: TGTripleSlider.h:69
TGTripleVSlider::~TGTripleVSlider
virtual ~TGTripleVSlider()
Delete vertical slider widget.
Definition: TGTripleSlider.cxx:98
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TGFrame.h
TGTripleVSlider::DoRedraw
virtual void DoRedraw()
Redraw vertical slider widget.
Definition: TGTripleSlider.cxx:106
TGTripleHSlider
Definition: TGTripleSlider.h:101
TGTripleVSlider::SetRelative
virtual void SetRelative(Bool_t rel=kTRUE)
Definition: TGTripleSlider.h:100
TGTripleVSlider::fSCz
Float_t fSCz
Definition: TGTripleSlider.h:70
TGDoubleSlider::fVmin
Float_t fVmin
Definition: TGDoubleSlider.h:83
TGTripleHSlider::~TGTripleHSlider
virtual ~TGTripleHSlider()
Delete a horizontal slider widget.
Definition: TGTripleSlider.cxx:371
TGTripleHSlider::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in horizontal slider widget.
Definition: TGTripleSlider.cxx:397
TGWidget.h
unsigned int
TGDoubleVSlider
Definition: TGDoubleSlider.h:154
kHorizontalFrame
@ kHorizontalFrame
Definition: GuiTypes.h:382
TGTripleHSlider::fSCz
Float_t fSCz
Definition: TGTripleSlider.h:105
TGTripleHSlider::SetConstrained
virtual void SetConstrained(Bool_t on=kTRUE)
Set pointer position constrained in the slider range.
Definition: TGTripleSlider.cxx:535
TGTripleVSlider::fConstrained
Bool_t fConstrained
Definition: TGTripleSlider.h:71
TGTripleVSlider::fPointerPic
const TGPicture * fPointerPic
Definition: TGTripleSlider.h:73
TGTripleHSlider::fConstrained
Bool_t fConstrained
Definition: TGTripleSlider.h:106
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGTripleHSlider::DoRedraw
virtual void DoRedraw()
Redraw horizontal slider widget.
Definition: TGTripleSlider.cxx:379
Event_t
Definition: GuiTypes.h:173
TGDoubleSlider::fReversedScale
Bool_t fReversedScale
Definition: TGDoubleSlider.h:94
TGTripleVSlider::TGTripleVSlider
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.
Definition: TGTripleSlider.cxx:78
TGTripleVSlider::HandleConfigureNotify
virtual Bool_t HandleConfigureNotify(Event_t *event)
Handles resize events for this widget.
Definition: TGTripleSlider.cxx:174
TGTripleHSlider::DrawPointer
virtual void DrawPointer()
Draw slider pointer.
Definition: TGTripleSlider.cxx:389
TGTripleHSlider::GetPointerPosition
virtual Float_t GetPointerPosition() const
Definition: TGTripleSlider.h:126
TGTripleHSlider::SetPointerPosition
virtual void SetPointerPosition(Float_t pos)
Set pointer position in scaled (real) value.
Definition: TGTripleSlider.cxx:609
type
int type
Definition: TGX11.cxx:121
TGTripleHSlider::SetPointerPos
virtual void SetPointerPos(Int_t z, Int_t opt=0)
Set slider pointer position in pixel value.
Definition: TGTripleSlider.cxx:550
TGTripleVSlider::SetConstrained
virtual void SetConstrained(Bool_t on=kTRUE)
Set pointer position constrained in the slider range.
Definition: TGTripleSlider.cxx:262
TGTripleVSlider::PointerPositionChanged
virtual void PointerPositionChanged()
Definition: TGTripleSlider.h:89
TQObject::Emit
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
TGTripleHSlider::fCz
Int_t fCz
Definition: TGTripleSlider.h:104
TGTripleHSlider::SetRelative
virtual void SetRelative(Bool_t rel=kTRUE)
Definition: TGTripleSlider.h:135
int
TGTripleHSlider::TGTripleHSlider
TGTripleHSlider(const TGWindow *p=0, UInt_t w=1, UInt_t type=1, Int_t id=-1, UInt_t options=kHorizontalFrame, Pixel_t back=GetDefaultFrameBackground(), Bool_t reversed=kFALSE, Bool_t mark_ends=kFALSE, Bool_t constrained=kTRUE, Bool_t relative=kFALSE)
Create horizontal slider widget.
Definition: TGTripleSlider.cxx:351