]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Reve/RGValuators.h
Added class RGTriVecValuator, a composite widget for editing three-vectors.
[u/mrichter/AliRoot.git] / EVE / Reve / RGValuators.h
1 // $Header$
2
3 #ifndef REVE_RGValuators_H
4 #define REVE_RGValuators_H
5
6 #include <TGNumberEntry.h>
7
8 class TGLabel;
9 class TGHSlider;
10 class TGDoubleHSlider;
11
12
13 namespace Reve {
14
15 class RGValuatorBase: public TGCompositeFrame
16 {
17   RGValuatorBase(const RGValuatorBase&);            // Not implemented
18   RGValuatorBase& operator=(const RGValuatorBase&); // Not implemented
19
20 protected:
21   UInt_t      fLabelWidth;
22   Bool_t      fAlignRight;
23   Bool_t      fShowSlider;
24
25   Int_t       fNELength; // Number-entry length (in characters)
26   Int_t       fNEHeight; // Number-entry height (in pixels)
27
28   TGLabel*    fLabel;
29
30 public:
31   RGValuatorBase(const TGWindow *p, const char* title, UInt_t w, UInt_t h);
32   virtual ~RGValuatorBase() {}
33
34   virtual void Build(Bool_t connect=kTRUE) = 0;
35
36   void SetLabelWidth(Int_t w)        { fLabelWidth = w; }
37   void SetAlignRight(Bool_t a)       { fAlignRight = a; }
38   void SetShowSlider(Bool_t s=kTRUE) { fShowSlider = s; }
39
40   void SetNELength(Int_t l)          { fNELength = l; }
41   void SetNEHeight(Int_t h)          { fNEHeight = h; }
42
43   ClassDef(RGValuatorBase, 0);
44 }; // endclass RGValuatorBase
45
46 /**************************************************************************/
47
48 class RGValuator: public RGValuatorBase
49 {
50   RGValuator(const RGValuator&);            // Not implemented
51   RGValuator& operator=(const RGValuator&); // Not implemented
52
53 protected:
54   Float_t        fValue;
55   Float_t        fMin;
56   Float_t        fMax;
57
58   Bool_t         fSliderNewLine;
59   Int_t          fSliderDivs;
60   TGNumberEntry* fEntry;
61   TGHSlider*     fSlider;
62
63   Int_t CalcSliderPos(Float_t v);
64   
65 public:
66   RGValuator(const TGWindow *p, const char* title, UInt_t w, UInt_t h);
67   virtual ~RGValuator() {}
68
69   virtual void Build(Bool_t connect=kTRUE);
70   
71   Float_t GetValue() const { return fValue; }
72   virtual void SetValue(Float_t v, Bool_t emit=kFALSE);
73
74   void SliderCallback();
75   void EntryCallback();
76   void ValueSet(Double_t); //*SIGNAL* 
77
78   TGHSlider*     GetSlider() { return fSlider; }
79   TGNumberEntry* GetEntry()  { return fEntry; }
80
81   void SetSliderNewLine(Bool_t nl) { fSliderNewLine = nl; }
82
83   void SetLimits(Int_t min, Int_t max);
84   void SetLimits(Float_t min, Float_t max, Int_t npos,
85                  TGNumberFormat::EStyle nef=TGNumberFormat::kNESRealTwo);
86
87   void SetToolTip(const Text_t* tip);
88   void SetEnabled(Bool_t state);
89
90   ClassDef(RGValuator, 0);
91 }; // endclass RGValuator
92
93 /**************************************************************************/
94
95 class RGDoubleValuator: public RGValuatorBase
96 {
97   RGDoubleValuator(const RGDoubleValuator&);            // Not implemented
98   RGDoubleValuator& operator=(const RGDoubleValuator&); // Not implemented
99
100 protected:
101   TGNumberEntry*    fMinEntry;
102   TGNumberEntry*    fMaxEntry;
103   TGDoubleHSlider*  fSlider;
104   
105 public:
106   RGDoubleValuator(const TGWindow *p, const char* title, UInt_t w, UInt_t h);
107   virtual ~RGDoubleValuator() {}
108
109   virtual void Build(Bool_t connect=kTRUE);
110  
111   void MinEntryCallback();
112   void MaxEntryCallback();
113   void SliderCallback();
114   void ValueSet(); //*SIGNAL* 
115
116   TGDoubleHSlider* GetSlider()   { return fSlider; }
117   TGNumberEntry*   GetMinEntry() { return fMinEntry; }
118   TGNumberEntry*   GetMaxEntry() { return fMaxEntry; }
119
120   void SetLimits(Float_t min, Float_t max, TGNumberFormat::EStyle nef=TGNumberFormat::kNESRealTwo);
121   void SetValues(Float_t min, Float_t max, Bool_t emit=kFALSE);
122
123   void GetValues(Float_t& min, Float_t& max) const
124   { min = fMinEntry->GetNumber(); max = fMaxEntry->GetNumber(); }
125   Float_t GetMin() const { return fMinEntry->GetNumber(); }
126   Float_t GetMax() const { return fMaxEntry->GetNumber(); }
127
128   ClassDef(RGDoubleValuator, 0);
129 }; // endclass RGDoubleValuator
130
131 /**************************************************************************/
132
133 class RGTriVecValuator : public TGCompositeFrame
134 {
135 protected:
136   RGValuator* fVal[3];
137
138   // Weed-size vars from RGValuator; copied.
139   UInt_t      fLabelWidth;
140   Int_t       fNELength; // Number-entry length (in characters)
141   Int_t       fNEHeight; // Number-entry height (in pixels)
142
143 public:
144   RGTriVecValuator(const TGWindow *p, const char* name, UInt_t w, UInt_t h);
145   virtual ~RGTriVecValuator();
146
147   void Build(Bool_t vertical, const char* lab0, const char* lab1, const char* lab2);
148
149   RGValuator* GetValuator(Int_t i) const { return fVal[i]; }
150
151   Float_t GetValue(Int_t i) const   { return fVal[i]->GetValue(); }
152   void SetValue(Int_t i, Float_t v) { fVal[i]->SetValue(v); }
153
154   void GetValues(Float_t& v0, Float_t& v1, Float_t& v2) const
155   { v0 = GetValue(0); v1 = GetValue(1); v2 = GetValue(2); }
156   void GetValues(Float_t v[3]) const
157   { v[0] = GetValue(0); v[1] = GetValue(1); v[2] = GetValue(2); }
158   void GetValues(Double_t v[3]) const
159   { v[0] = GetValue(0); v[1] = GetValue(1); v[2] = GetValue(2); }
160
161   void SetValues(Float_t v0, Float_t v1, Float_t v2)
162   { SetValue(0, v0); SetValue(1, v1); SetValue(2, v2); }
163   void SetValues(Float_t v[3])
164   { SetValue(0, v[0]); SetValue(1, v[1]); SetValue(2, v[2]); }
165   void SetValues(Double_t v[3])
166   { SetValue(0, v[0]); SetValue(1, v[1]); SetValue(2, v[2]); }
167
168   void ValueSet(); //*SIGNAL*
169   
170   // Weed-size vars from RGValuator; copied.
171   void SetLabelWidth(Int_t w) { fLabelWidth = w; }
172   void SetNELength(Int_t l)   { fNELength   = l; }
173   void SetNEHeight(Int_t h)   { fNEHeight   = h; }
174
175   void SetLimits(Int_t min, Int_t max);
176   void SetLimits(Float_t min, Float_t max,
177                  TGNumberFormat::EStyle nef=TGNumberFormat::kNESRealTwo);
178
179   ClassDef(RGTriVecValuator, 0)
180 };
181
182 }
183
184 #endif