Logo ROOT   6.08/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 #ifndef ROOT_TGFrame
57 #include "TGFrame.h"
58 #endif
59 #ifndef ROOT_TGWidget
60 #include "TGWidget.h"
61 #endif
62 #ifndef ROOT_TGDoubleSlider
63 #include "TGDoubleSlider.h"
64 #endif
65 
67 
68 protected:
69  Int_t fCz; // vertical pointer position in pixel coordinates
70  Float_t fSCz; // vertical pointer position
71  Bool_t fConstrained; // kTRUE if pointer is constrained to slider edges
72  Bool_t fRelative; // kTRUE if pointer position is relative to slider
73  const TGPicture *fPointerPic; // picture to draw pointer
74 
75  virtual void DoRedraw();
76  virtual void SetPointerPos(Int_t z, Int_t opt = 0);
77 
78 public:
79  TGTripleVSlider(const TGWindow *p = 0, UInt_t h = 1, UInt_t type = 1, Int_t id = -1,
80  UInt_t options = kVerticalFrame,
82  Bool_t reversed = kFALSE,
83  Bool_t mark_ends = kFALSE,
84  Bool_t constrained = kTRUE,
85  Bool_t relative = kFALSE);
86 
87  virtual ~TGTripleVSlider();
88 
89  virtual void PointerPositionChanged() { Emit("PointerPositionChanged()"); } //*SIGNAL*
90  virtual void DrawPointer();
91  virtual Float_t GetPointerPosition() const {
92  if (fReversedScale) return fVmin + fVmax - fSCz;
93  else return fSCz;
94  }
95  virtual Bool_t HandleButton(Event_t *event);
96  virtual Bool_t HandleConfigureNotify(Event_t* event);
97  virtual Bool_t HandleMotion(Event_t *event);
98  virtual void SetConstrained(Bool_t on = kTRUE);
99  virtual void SetPointerPosition(Float_t pos);
100  virtual void SetRelative(Bool_t rel = kTRUE) { fRelative = rel; }
101  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
102 
103  ClassDef(TGTripleVSlider,0) // Vertical triple slider widget
104 };
105 
106 
108 
109 protected:
110  Int_t fCz; // horizontal pointer position in pixel coordinates
111  Float_t fSCz; // vertical pointer position
112  Bool_t fConstrained; // kTRUE if pointer is constrained to slider edges
113  Bool_t fRelative; // kTRUE if pointer position is relative to slider
114  const TGPicture *fPointerPic; // picture to draw pointer
115 
116  virtual void DoRedraw();
117  virtual void SetPointerPos(Int_t z, Int_t opt = 0);
118 
119 public:
120  TGTripleHSlider(const TGWindow *p = 0, UInt_t w = 1, UInt_t type = 1, Int_t id = -1,
121  UInt_t options = kHorizontalFrame,
123  Bool_t reversed = kFALSE,
124  Bool_t mark_ends = kFALSE,
125  Bool_t constrained = kTRUE,
126  Bool_t relative = kFALSE);
127 
128  virtual ~TGTripleHSlider();
129 
130  virtual void PointerPositionChanged() { Emit("PointerPositionChanged()"); } //*SIGNAL*
131  virtual void DrawPointer();
132  virtual Float_t GetPointerPosition() const {
133  if (fReversedScale) return fVmin + fVmax - fSCz;
134  else return fSCz;
135  }
136  virtual Bool_t HandleButton(Event_t *event);
137  virtual Bool_t HandleConfigureNotify(Event_t* event);
138  virtual Bool_t HandleMotion(Event_t *event);
139  virtual void SetConstrained(Bool_t on = kTRUE);
140  virtual void SetPointerPosition(Float_t pos);
141  virtual void SetRelative(Bool_t rel = kTRUE) { fRelative = rel; }
142  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
143 
144  ClassDef(TGTripleHSlider,0) // Horizontal triple slider widget
145 };
146 
147 #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
const Bool_t kFALSE
Definition: Rtypes.h:92
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:254
ULong_t Pixel_t
Definition: GuiTypes.h:41
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:665
virtual Float_t GetPointerPosition() const
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:561
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 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()
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: Rtypes.h:91
virtual void SetConstrained(Bool_t on=kTRUE)
Set pointer position constrained in the slider range.