Logo ROOT  
Reference Guide
TGDoubleSlider.cxx
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Reiner Rohlfs 30/09/98
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 
13  This source is based on Xclass95, a Win95-looking GUI toolkit.
14  Copyright (C) 1996, 1997 David Barth, Ricky Ralston, Hector Peraza.
15 
16  Xclass95 is free software; you can redistribute it and/or
17  modify it under the terms of the GNU Library General Public
18  License as published by the Free Software Foundation; either
19  version 2 of the License, or (at your option) any later version.
20 
21 **************************************************************************/
22 
23 //////////////////////////////////////////////////////////////////////////
24 // //
25 // TGDoubleSlider, TGDoubleVSlider and TGDoubleHSlider //
26 // //
27 // DoubleSlider widgets allow easy selection of a min and a max value //
28 // out of a range. //
29 // DoubleSliders can be either horizontal or vertical oriented and //
30 // there is a choice of three different types of tick marks. //
31 // //
32 // To change the min value press the mouse near to the left / bottom //
33 // edge of the slider. //
34 // To change the max value press the mouse near to the right / top //
35 // edge of the slider. //
36 // To change both values simultaneously press the mouse near to the //
37 // center of the slider. //
38 // //
39 // TGDoubleSlider is an abstract base class. Use the concrete //
40 // TGDoubleVSlider and TGDoubleHSlider. //
41 // //
42 // Dragging the slider will generate the event: //
43 // kC_VSLIDER, kSL_POS, slider id, 0 (for vertical slider) //
44 // kC_HSLIDER, kSL_POS, slider id, 0 (for horizontal slider) //
45 // //
46 // Pressing the mouse will generate the event: //
47 // kC_VSLIDER, kSL_PRESS, slider id, 0 (for vertical slider) //
48 // kC_HSLIDER, kSL_PRESS, slider id, 0 (for horizontal slider) //
49 // //
50 // Releasing the mouse will generate the event: //
51 // kC_VSLIDER, kSL_RELEASE, slider id, 0 (for vertical slider) //
52 // kC_HSLIDER, kSL_RELEASE, slider id, 0 (for horizontal slider) //
53 // //
54 // Use the functions GetMinPosition(), GetMaxPosition() and //
55 // GetPosition() to retrieve the position of the slider. //
56 // //
57 //////////////////////////////////////////////////////////////////////////
58 
59 #include "TGDoubleSlider.h"
60 #include "TGPicture.h"
61 #include "TSystem.h"
62 #include "TVirtualX.h"
63 
64 #include <iostream>
65 
66 
70 
71 ////////////////////////////////////////////////////////////////////////////////
72 /// Slider constructor.
73 
75  UInt_t options, ULong_t back,
76  Bool_t reversed, Bool_t mark_ends)
77  : TGFrame(p, w, h, options, back)
78 {
79  fSliderPic = 0;
80 
81  fWidgetId = id;
83  fMsgWindow = p;
84 
85  fScaleType = type;
86  fScale = 10;
87  fMove = 0;
88 
89  fPos = fSmin = fSmax = 0.0;
90  fRelPos = 0;
91  fVmin = fVmax = 0.0;
92  fPressPoint = 0;
93  fPressSmin = fPressSmax = 0.0;
94 
95  fReversedScale = reversed;
96  fMarkEnds = mark_ends;
97 
98  gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
102  SetWindowName();
103 }
104 
105 ////////////////////////////////////////////////////////////////////////////////
106 /// Avoid boundaries to be equal.
107 
109 {
110  if (min > max) min = max;
111 
112  Float_t eps = 1e-6;
113  if (max - min < eps) {
114  if (max == 0)
115  max += eps;
116  else
117  max += max*eps;
118  if (min == 0)
119  min -= eps;
120  else
121  min -= min*eps;
122  }
123 }
124 
125 ////////////////////////////////////////////////////////////////////////////////
126 /// Returns the slider type as a string - used in SavePrimitive()
127 
129 {
130  TString stype;
131 
132  if (fScaleType) {
133  if (fScaleType & kDoubleScaleNo) {
134  if (stype.Length() == 0)
135  stype = "kDoubleScaleNo";
136  else
137  stype += " | kDoubleScaleNo";
138  }
140  if (stype.Length() == 0)
141  stype = "kDoubleScaleDownRight";
142  else
143  stype += " | kDoubleScaleDownRight";
144  }
146  if (stype.Length() == 0)
147  stype = "kDoubleScaleBoth";
148  else
149  stype += " | kDoubleScaleBoth";
150  }
151  }
152  return stype;
153 }
154 
155 ////////////////////////////////////////////////////////////////////////////////
156 /// Change the cursor shape depending on the slider area.
157 
159 {
160  static Cursor_t topCur = kNone, leftCur = kNone;
161  static Cursor_t botCur = kNone, rightCur = kNone;
162  Int_t hw = 0, wh = 0, xy = 0, yx = 0;
163  Cursor_t minCur = kNone, maxCur = kNone;
164 
165  if (topCur == kNone)
166  topCur = gVirtualX->CreateCursor(kTopSide);
167  if (leftCur == kNone)
168  leftCur = gVirtualX->CreateCursor(kLeftSide);
169  if (botCur == kNone)
170  botCur = gVirtualX->CreateCursor(kBottomSide);
171  if (rightCur == kNone)
172  rightCur = gVirtualX->CreateCursor(kRightSide);
173  if (GetOptions() & kVerticalFrame) {
174  hw = (Int_t)fWidth;
175  wh = (Int_t)fHeight;
176  xy = (Int_t)event->fX;
177  yx = (Int_t)event->fY;
178  minCur = topCur;
179  maxCur = botCur;
180  }
181  else if (GetOptions() & kHorizontalFrame) {
182  hw = (Int_t)fHeight;
183  wh = (Int_t)fWidth;
184  xy = (Int_t)event->fY;
185  yx = (Int_t)event->fX;
186  minCur = leftCur;
187  maxCur = rightCur;
188  }
189  else return;
190 
191  Int_t relMin = (Int_t)((wh-16) * (fSmin - fVmin) / (fVmax - fVmin)) + 1;
192  Int_t relMax = (Int_t)((wh-16) * (fSmax - fVmin) / (fVmax - fVmin) + 15);
193  // constrain to the slider width
194  if (xy > hw/2-7 && xy < hw/2+7 && fMove != 3) {
195  // if the mouse pointer is in the top resizing zone,
196  // and we are not already moving the the bottom side,
197  // set the cursor shape as TopSide
198  if ((yx <= (relMax - relMin) / 4 + relMin) &&
199  (yx >= relMin) && (fMove != 2))
200  gVirtualX->SetCursor(fId, minCur);
201  // if the mouse pointer is in the bottom resizing zone,
202  // and we are not already moving the the top side,
203  // set the cursor shape as BottomSide
204  else if ((yx >= (relMax - relMin) / 4 * 3 + relMin) &&
205  (yx <= relMax) && (fMove != 1))
206  gVirtualX->SetCursor(fId, maxCur);
207  // if we are not moving any side, restore the cursor
208  else if ((fMove < 1) || (fMove > 2))
209  gVirtualX->SetCursor(fId, kNone);
210  }
211  // if we are not inside the slider, and not moving any side,
212  // restore the cursor
213  else if ((fMove < 1) || (fMove > 2))
214  gVirtualX->SetCursor(fId, kNone);
215 }
216 
217 ////////////////////////////////////////////////////////////////////////////////
218 /// Create a vertical slider widget.
219 
221  UInt_t options, ULong_t back,
222  Bool_t reversed, Bool_t mark_ends)
223  : TGDoubleSlider(p, kDoubleSliderWidth, h, type, id, options, back,
224  reversed, mark_ends)
225 {
226  fYp = 0;
227  fSliderPic = fClient->GetPicture("sliderv.xpm");
228 
229  if (!fSliderPic)
230  Error("TGDoubleVSlider", "sliderv.xpm not found");
231  // set initial values
232  fSmin = h/8*3; fSmax = h/8*5; fVmin = 0; fVmax = h;
234  SetWindowName();
235 }
236 
237 ////////////////////////////////////////////////////////////////////////////////
238 /// Delete vertical slider widget.
239 
241 {
243 }
244 
245 ////////////////////////////////////////////////////////////////////////////////
246 /// Redraw vertical slider widget.
247 
249 {
251 
252  // cleanup the drawable
253  gVirtualX->ClearWindow(fId);
254 
255  if (fSmin < fVmin) fSmin = fVmin;
256  if (fSmax < fVmin) fSmax = fVmin;
257  if (fSmin > fVmax) fSmin = fVmax;
258  if (fSmax > fVmax) fSmax = fVmax;
259  if (fSmin > fSmax) fSmin = fSmax = (fSmin + fSmax) / 2;
260 
261  int relMin = (int)((fHeight-16) * (fSmin - fVmin) / (fVmax - fVmin)) + 1;
262  int relMax = (int)((fHeight-16) * (fSmax - fVmin) / (fVmax - fVmin) + 15);
263 
264  gVirtualX->DrawLine(fId, GetHilightGC()(), fWidth/2-6, relMin, fWidth/2+5, relMin);
265  gVirtualX->DrawLine(fId, GetHilightGC()(), fWidth/2-6, relMin, fWidth/2-6, relMax);
266  gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth/2+5, relMax, fWidth/2-6, relMax);
267  gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth/2+5, relMax, fWidth/2+5, relMin);
268 
269  if (relMin-1 > 8) {
270  gVirtualX->DrawLine(fId, GetShadowGC()(), fWidth/2-1, 8, fWidth/2-1, relMin-1);
271  gVirtualX->DrawLine(fId, GetHilightGC()(), fWidth/2+1, 8, fWidth/2+1, relMin-1);
272  gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth/2, 8, fWidth/2, relMin-1);
273  }
274  if (relMax+1 < (int)fHeight-8) {
275  gVirtualX->DrawLine(fId, GetShadowGC()(), fWidth/2-1, relMax+1, fWidth/2-1, fHeight-8);
276  gVirtualX->DrawLine(fId, GetHilightGC()(), fWidth/2+1, relMax+1, fWidth/2+1, fHeight-8);
277  gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth/2, relMax+1, fWidth/2, fHeight-8);
278  }
279 
280  // check scale
281  if (fScale == 1) fScale++;
282  if (fScale * 2 > (int)fHeight) fScale = 0;
283  if (fScale > 0 && !(fScaleType & kDoubleScaleNo)) {
284  int lines = ((int)fHeight-16) / fScale;
285  int remain = ((int)fHeight-16) % fScale;
286  if (lines < 1) lines = 1;
287  for (int i = 0; i <= lines; i++) {
288  int y = i * fScale + (i * remain) / lines;
289  gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth/2+8, y+7, fWidth/2+10, y+7);
291  gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth/2-9, y+7, fWidth/2-11, y+7);
292  }
293  }
294 
295  if (fSliderPic) {
296  Int_t xpos = (fWidth/2) - (fSliderPic->GetWidth()/2);
297  Int_t ypos = relMin + 2;
298  fSliderPic->Draw(fId, GetBckgndGC()(), xpos, ypos);
299  ypos = relMax - fSliderPic->GetHeight() - 2;
300  fSliderPic->Draw(fId, GetBckgndGC()(), xpos, ypos);
301  }
302  if (fMarkEnds) {
303  // Draw scaling zones.
304  int y1 = (relMax - relMin) / 4 + relMin;
305  int y2 = (relMax - relMin) / 4 * 3 + relMin;
306  gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth/2-6, y1, fWidth/2+5, y1);
307  gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth/2-6, y2, fWidth/2+5, y2);
308  }
309 }
310 
311 ////////////////////////////////////////////////////////////////////////////////
312 /// Handle mouse button event in vertical slider.
313 
315 {
316  if (event->fType == kButtonPress && event->fCode == kButton1) {
317  // constrain to the slider width
318  if (event->fX < (Int_t)fWidth/2-7 || event->fX > (Int_t)fWidth/2+7) {
319  return kTRUE;
320  }
321  fPressPoint = event->fY;
322  fPressSmin = fSmin;
323  fPressSmax = fSmax;
324 
325  int relMin = (int)((fHeight-16) * (fSmin - fVmin) / (fVmax - fVmin)) + 1;
326  int relMax = (int)((fHeight-16) * (fSmax - fVmin) / (fVmax - fVmin) + 15);
327  if (fPressPoint < (relMax - relMin) / 4 + relMin)
328  // move only min value
329  fMove = 1;
330  else if (fPressPoint > (relMax - relMin) / 4 * 3 + relMin)
331  // move only max value
332  fMove = 2;
333  else
334  // move min and max value
335  fMove = 3;
336 
339  Pressed();
340 
341  // last argument kFALSE forces all specified events to this window
344  kTRUE, kFALSE);
345  } else if (event->fType == kButtonRelease && event->fCode == kButton1) {
348  Released();
349  fMove = 0;
350 
351  gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
352  } else
353  fMove = 0;
354 
355  return kTRUE;
356 }
357 
358 ////////////////////////////////////////////////////////////////////////////////
359 /// Handle mouse motion event in vertical slider.
360 
362 {
363  ChangeCursor(event);
364  if (fMove == 0) return kTRUE;
365 
366  static Long64_t was = gSystem->Now();
367  Long64_t now = gSystem->Now();
368 
369  if ((now-was) < 50) return kTRUE;
370  was = now;
371 
372  int diff;
373  Float_t oldMin, oldMax;
374 
375  diff = event->fY - fPressPoint;
376  oldMin = fSmin;
377  oldMax = fSmax;
378 
379  if (fMove == 1) {
380  // change of min value
381  fSmin = fPressSmin + diff * (fVmax - fVmin) / (fHeight-16);
382  if (fSmin < fVmin) fSmin = fVmin;
383  if (fSmin > fSmax) fSmin = fSmax;
384  } else if (fMove == 2) {
385  // change of max value
386  fSmax = fPressSmax + diff * (fVmax - fVmin) / (fHeight-16);
387  if (fSmax > fVmax) fSmax = fVmax;
388  if (fSmax < fSmin) fSmax = fSmin;
389  } else if (fMove == 3) {
390  // change of min and of max value
391  Float_t logicalDiff;
392  logicalDiff = diff * (fVmax - fVmin) / (fHeight-16);
393  if (fPressSmax + logicalDiff > fVmax)
394  logicalDiff = fVmax - fPressSmax;
395  if (fPressSmin + logicalDiff < fVmin)
396  logicalDiff = fVmin - fPressSmin;
397  fSmax = fPressSmax + logicalDiff;
398  fSmin = fPressSmin + logicalDiff;
399  }
400 
401  // check if position has changed
402  if (fMove != 0 && (fSmax != oldMax || fSmin != oldMin)) {
403  fClient->NeedRedraw(this);
406  PositionChanged();
407  }
408  return kTRUE;
409 }
410 
411 ////////////////////////////////////////////////////////////////////////////////
412 /// Create horizontal slider widget.
413 
415  UInt_t options, ULong_t back,
416  Bool_t reversed, Bool_t mark_ends)
417  : TGDoubleSlider(p, w, kDoubleSliderHeight, type, id, options, back,
418  reversed, mark_ends)
419 {
420  fXp = 0;
421  fSliderPic = fClient->GetPicture("sliderh.xpm");
422 
423  if (!fSliderPic)
424  Error("TGDoubleHSlider", "sliderh.xpm not found");
425  // set initial values
426  fSmin = w/8*3; fSmax = w/8*5; fVmin = 0; fVmax = w;
428  SetWindowName();
429 }
430 
431 ////////////////////////////////////////////////////////////////////////////////
432 /// Delete a horizontal slider widget.
433 
435 {
437 }
438 
439 ////////////////////////////////////////////////////////////////////////////////
440 /// Redraw horizontal slider widget.
441 
443 {
445 
446  // cleanup drawable
447  gVirtualX->ClearWindow(fId);
448 
449  if (fSmin < fVmin) fSmin = fVmin;
450  if (fSmax > fVmax) fSmax = fVmax;
451  if (fSmin > fSmax) fSmin = fSmax = (fSmin + fSmax) / 2;
452 
453  int relMin = (int)((fWidth-16) * (fSmin - fVmin) / (fVmax - fVmin)) + 1;
454  int relMax = (int)((fWidth-16) * (fSmax - fVmin) / (fVmax - fVmin) + 15);
455 
456  gVirtualX->DrawLine(fId, GetHilightGC()(), relMin, fHeight/2-6, relMin, fHeight/2+5);
457  gVirtualX->DrawLine(fId, GetHilightGC()(), relMax, fHeight/2-6, relMin, fHeight/2-6);
458  gVirtualX->DrawLine(fId, GetBlackGC()(), relMax, fHeight/2+5, relMax, fHeight/2-6);
459  gVirtualX->DrawLine(fId, GetBlackGC()(), relMin, fHeight/2+5, relMax, fHeight/2+5);
460 
461  if (relMin-1 > 8) {
462  gVirtualX->DrawLine(fId, GetShadowGC()(), 8, fHeight/2-1, relMin-1, fHeight/2-1);
463  gVirtualX->DrawLine(fId, GetHilightGC()(), 8, fHeight/2+1, relMin-1, fHeight/2+1);
464  gVirtualX->DrawLine(fId, GetBlackGC()(), 8, fHeight/2, relMin-1, fHeight/2);
465  }
466  if (relMax+1 < (int)fWidth-8) {
467  gVirtualX->DrawLine(fId, GetShadowGC()(), relMax+1, fHeight/2-1, fWidth-8, fHeight/2-1);
468  gVirtualX->DrawLine(fId, GetHilightGC()(), relMax+1, fHeight/2+1, fWidth-8, fHeight/2+1);
469  gVirtualX->DrawLine(fId, GetBlackGC()(), relMax+1, fHeight/2, fWidth-8, fHeight/2);
470  }
471 
472  if (fScale == 1) fScale++;
473  if (fScale * 2 > (int)fWidth) fScale = 0;
474  if (fScale > 0 && !(fScaleType & kDoubleScaleNo)) {
475  int lines = ((int)fWidth-16) / fScale;
476  int remain = ((int)fWidth-16) % fScale;
477  if (lines < 1) lines = 1;
478  for (int i = 0; i <= lines; i++) {
479  int x = i * fScale + (i * remain) / lines;
480  gVirtualX->DrawLine(fId, GetBlackGC()(), x+7, fHeight/2+8, x+7, fHeight/2+10);
482  gVirtualX->DrawLine(fId, GetBlackGC()(), x+7, fHeight/2-9, x+7, fHeight/2-11);
483  }
484  }
485 
486  if (fSliderPic) {
487  Int_t ypos = (fHeight/2) - (fSliderPic->GetHeight()/2);
488  Int_t xpos = relMin + 2;
489  fSliderPic->Draw(fId, GetBckgndGC()(), xpos, ypos);
490  xpos = relMax - fSliderPic->GetWidth() - 2;
491  fSliderPic->Draw(fId, GetBckgndGC()(), xpos, ypos);
492  }
493  if (fMarkEnds) {
494  // Draw scaling zones.
495  int x1 = (relMax - relMin) / 4 + relMin;
496  int x2 = (relMax - relMin) / 4 * 3 + relMin;
497  gVirtualX->DrawLine(fId, GetBlackGC()(), x1, fHeight/2-6, x1, fHeight/2+5);
498  gVirtualX->DrawLine(fId, GetBlackGC()(), x2, fHeight/2-6, x2, fHeight/2+5);
499  }
500 }
501 
502 ////////////////////////////////////////////////////////////////////////////////
503 /// Handle mouse button event in horizontal slider widget.
504 
506 {
507  if (event->fType == kButtonPress && event->fCode == kButton1) {
508  // constrain to the slider height
509  if (event->fY < (Int_t)fHeight/2-7 || event->fY > (Int_t)fHeight/2+7) {
510  return kTRUE;
511  }
512  fPressPoint = event->fX;
513  fPressSmin = fSmin;
514  fPressSmax = fSmax;
515 
516  int relMin = (int)((fWidth-16) * (fSmin - fVmin) / (fVmax - fVmin)) + 1;
517  int relMax = (int)((fWidth-16) * (fSmax - fVmin) / (fVmax - fVmin) + 15);
518  if (fPressPoint < (relMax - relMin) / 4 + relMin)
519  // move only min value
520  fMove = 1;
521  else if (fPressPoint > (relMax - relMin) / 4 * 3 + relMin)
522  // move only max value
523  fMove = 2;
524  else
525  // move min and max value
526  fMove = 3;
527 
530  Pressed();
531 
532  // last argument kFALSE forces all specified events to this window
535  kTRUE, kFALSE);
536  } else if (event->fType == kButtonRelease && event->fCode == kButton1) {
539  Released();
540  fMove = 0;
541 
542  gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
543  } else
544  fMove = 0;
545 
546  return kTRUE;
547 }
548 
549 ////////////////////////////////////////////////////////////////////////////////
550 /// Handle mouse motion event in horizontal slide widget.
551 
553 {
554  ChangeCursor(event);
555  if (fMove == 0) return kTRUE;
556 
557  static Long64_t was = gSystem->Now();
558  Long64_t now = gSystem->Now();
559 
560  if ((now-was) < 50) return kTRUE;
561  was = now;
562 
563  int diff;
564  Float_t oldMin, oldMax;
565 
566  diff = event->fX - fPressPoint;
567  oldMin = fSmin;
568  oldMax = fSmax;
569 
570  if (fMove == 1) {
571  // change of min value
572  fSmin = fPressSmin + diff * (fVmax - fVmin) / (fWidth-16);
573  if (fSmin < fVmin) fSmin = fVmin;
574  if (fSmin > fSmax) fSmin = fSmax;
575  } else if (fMove == 2) {
576  // change of max value
577  fSmax = fPressSmax + diff * (fVmax - fVmin) / (fWidth-16);
578  if (fSmax > fVmax) fSmax = fVmax;
579  if (fSmax < fSmin) fSmax = fSmin;
580  } else if (fMove == 3) {
581  // change of min and of max value
582  Float_t logicalDiff;
583  logicalDiff = diff * (fVmax - fVmin) / (fWidth-16);
584  if (fPressSmax + logicalDiff > fVmax)
585  logicalDiff = fVmax - fPressSmax;
586  if (fPressSmin + logicalDiff < fVmin)
587  logicalDiff = fVmin - fPressSmin;
588  fSmax = fPressSmax + logicalDiff;
589  fSmin = fPressSmin + logicalDiff;
590  }
591 
592  // check if position has changed
593  if (fMove != 0 && (fSmax != oldMax || fSmin != oldMin)) {
594  fClient->NeedRedraw(this);
597  PositionChanged();
598  }
599  return kTRUE;
600 }
601 
602 ////////////////////////////////////////////////////////////////////////////////
603 /// Save an horizontal slider as a C++ statement(s) on output stream out.
604 
605 void TGDoubleHSlider::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
606 {
607  SaveUserColor(out, option);
608 
609  out <<" TGDoubleHSlider *";
610  out << GetName() << " = new TGDoubleHSlider(" << fParent->GetName()
611  << "," << GetWidth() << ",";
612  out << GetSString() << "," << WidgetId() << ",";
613  out << GetOptionString() << ",ucolor";
614  if (fMarkEnds) {
615  if (fReversedScale)
616  out << ",kTRUE,kTRUE);" << std::endl;
617  else
618  out << ",kFALSE,kTRUE);" << std::endl;
619  } else if (fReversedScale) {
620  out << ",kTRUE);" << std::endl;
621  } else {
622  out << ");" << std::endl;
623  }
624  if (option && strstr(option, "keep_names"))
625  out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
626 
627  if (fVmin != 0 || fVmax != (Int_t)fWidth)
628  out << " " << GetName() << "->SetRange(" << fVmin << "," << fVmax
629  << ");" << std::endl;
630 
631  if (fSmin != fWidth/8*3 || fSmax != fWidth/8*5)
632  out << " " << GetName() << "->SetPosition(" << GetMinPosition()
633  << "," << GetMaxPosition() << ");" << std::endl;
634 
635  if (fScale != 10)
636  out << " " << GetName() << "->SetScale(" << fScale << ");" << std::endl;
637 
638 }
639 
640 ////////////////////////////////////////////////////////////////////////////////
641 /// Save an horizontal slider as a C++ statement(s) on output stream out.
642 
643 void TGDoubleVSlider::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
644 {
645  SaveUserColor(out, option);
646 
647  out<<" TGDoubleVSlider *";
648  out << GetName() << " = new TGDoubleVSlider("<< fParent->GetName()
649  << "," << GetHeight() << ",";
650  out << GetSString() << "," << WidgetId() << ",";
651  out << GetOptionString() << ",ucolor";
652  if (fMarkEnds) {
653  if (fReversedScale)
654  out << ",kTRUE,kTRUE);" << std::endl;
655  else
656  out << ",kFALSE,kTRUE);" << std::endl;
657  } else if (fReversedScale) {
658  out << ",kTRUE);" << std::endl;
659  } else {
660  out << ");" << std::endl;
661  }
662  if (option && strstr(option, "keep_names"))
663  out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
664 
665  if (fVmin != 0 || fVmax != (Int_t)fHeight)
666  out << " " << GetName() <<"->SetRange(" << fVmin << "," << fVmax
667  << ");" << std::endl;
668 
669 
670  if (fSmin != fHeight/8*3 || fSmax != fHeight/8*5)
671  out << " " << GetName() << "->SetPosition(" << GetMinPosition()
672  << "," << GetMaxPosition() << ");" << std::endl;
673 
674 
675  if (fScale != 10)
676  out << " " << GetName() << "->SetScale(" << fScale << ");" << std::endl;
677 
678 }
TGWindow::SetWindowName
virtual void SetWindowName(const char *name=0)
Set window name.
Definition: TGWindow.cxx:118
Event_t::fType
EGEventType fType
Definition: GuiTypes.h:174
TGDoubleSlider::GetSString
TString GetSString() const
Returns the slider type as a string - used in SavePrimitive()
Definition: TGDoubleSlider.cxx:128
TGFrame::GetHeight
UInt_t GetHeight() const
Definition: TGFrame.h:250
kLeftSide
@ kLeftSide
Definition: GuiTypes.h:372
Event_t::fY
Int_t fY
Definition: GuiTypes.h:177
Event_t::fX
Int_t fX
Definition: GuiTypes.h:177
TGWindow
Definition: TGWindow.h:31
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TGDoubleHSlider::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in horizontal slide widget.
Definition: TGDoubleSlider.cxx:552
e
#define e(i)
Definition: RSha256.hxx:121
TGDoubleSlider.h
kTopSide
@ kTopSide
Definition: GuiTypes.h:372
TGDoubleSlider::PositionChanged
virtual void PositionChanged()
Definition: TGDoubleSlider.h:146
kAnyModifier
const Mask_t kAnyModifier
Definition: GuiTypes.h:209
kRightSide
@ kRightSide
Definition: GuiTypes.h:372
TGDoubleVSlider::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in vertical slider.
Definition: TGDoubleSlider.cxx:314
TGClient::ProcessLine
void ProcessLine(TString cmd, Long_t msg, Long_t parm1, Long_t parm2)
Execute string "cmd" via the interpreter.
Definition: TGClient.cxx:914
TGPicture::GetWidth
UInt_t GetWidth() const
Definition: TGPicture.h:63
kPointerMotionMask
const Mask_t kPointerMotionMask
Definition: GuiTypes.h:162
TGDoubleSlider::fVmax
Float_t fVmax
Definition: TGDoubleSlider.h:84
gVirtualX
#define gVirtualX
Definition: TVirtualX.h:338
kAnyButton
@ kAnyButton
Definition: GuiTypes.h:213
TGDoubleVSlider::TGDoubleVSlider
TGDoubleVSlider(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)
Create a vertical slider widget.
Definition: TGDoubleSlider.cxx:220
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TGPicture.h
TGFrame::fWidth
UInt_t fWidth
Definition: TGFrame.h:112
kVerticalFrame
@ kVerticalFrame
Definition: GuiTypes.h:381
TGDoubleHSlider::DoRedraw
virtual void DoRedraw()
Redraw horizontal slider widget.
Definition: TGDoubleSlider.cxx:442
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TObject::Error
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:890
Float_t
float Float_t
Definition: RtypesCore.h:57
Int_t
int Int_t
Definition: RtypesCore.h:45
TGDoubleSlider::fRelPos
Int_t fRelPos
Definition: TGDoubleSlider.h:82
kDoubleScaleDownRight
@ kDoubleScaleDownRight
Definition: TGDoubleSlider.h:67
TGDoubleVSlider::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in vertical slider.
Definition: TGDoubleSlider.cxx:361
TGPicture::Draw
void Draw(Option_t *="")
Default Draw method for all objects.
Definition: TGPicture.h:57
x
Double_t x[n]
Definition: legend1.C:17
TString::Length
Ssiz_t Length() const
Definition: TString.h:410
kSL_RELEASE
@ kSL_RELEASE
Definition: WidgetMessageTypes.h:71
TGDoubleSlider::fPressSmax
Float_t fPressSmax
Definition: TGDoubleSlider.h:89
kButton1
@ kButton1
Definition: GuiTypes.h:213
TGDoubleSlider::fPressSmin
Float_t fPressSmin
Definition: TGDoubleSlider.h:88
TVirtualX.h
TGClient::FreePicture
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition: TGClient.cxx:309
kBottomSide
@ kBottomSide
Definition: GuiTypes.h:372
TGDoubleSlider::fPos
Float_t fPos
Definition: TGDoubleSlider.h:79
TGDoubleSlider
Definition: TGDoubleSlider.h:72
TGFrame::GetBlackGC
static const TGGC & GetBlackGC()
Get black graphics context.
Definition: TGFrame.cxx:720
TString
Definition: TString.h:136
TGDoubleSlider::fMove
Int_t fMove
Definition: TGDoubleSlider.h:90
TGFrame
Definition: TGFrame.h:105
kButtonPressMask
const Mask_t kButtonPressMask
Definition: GuiTypes.h:160
TGDoubleSlider::Pressed
virtual void Pressed()
Definition: TGDoubleSlider.h:147
bool
TGFrame::GetWidth
UInt_t GetWidth() const
Definition: TGFrame.h:249
Cursor_t
Handle_t Cursor_t
Definition: GuiTypes.h:33
id
XFontStruct * id
Definition: TGX11.cxx:109
x1
static const double x1[5]
Definition: RooGaussKronrodIntegrator1D.cxx:346
TGFrame::GetOptionString
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition: TGFrame.cxx:2465
TGFrame::GetOptions
virtual UInt_t GetOptions() const
Definition: TGFrame.h:222
xy
XPoint xy[kMAXMK]
Definition: TGX11.cxx:123
TGWidget::fCommand
TString fCommand
Definition: TGWidget.h:61
TGDoubleSlider::TGDoubleSlider
TGDoubleSlider(const TGDoubleSlider &)
TGFrame::AddInput
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition: TGFrame.cxx:324
kNone
const Handle_t kNone
Definition: GuiTypes.h:87
TGFrame::GetHilightGC
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition: TGFrame.cxx:740
kC_HSLIDER
@ kC_HSLIDER
Definition: WidgetMessageTypes.h:66
TGDoubleHSlider
Definition: TGDoubleSlider.h:180
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TGDoubleVSlider::fYp
Int_t fYp
Definition: TGDoubleSlider.h:157
TGDoubleSlider::fSliderPic
const TGPicture * fSliderPic
Definition: TGDoubleSlider.h:96
TSystem.h
kDoubleSliderHeight
@ kDoubleSliderHeight
Definition: TGDoubleSlider.h:60
h
#define h(i)
Definition: RSha256.hxx:124
TGWidget::WidgetId
Int_t WidgetId() const
Definition: TGWidget.h:80
TGWidget::fMsgWindow
const TGWindow * fMsgWindow
Definition: TGWidget.h:60
TGWindow::GetName
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:317
TGObject::fId
Handle_t fId
Definition: TGObject.h:36
TGDoubleSlider::fMarkEnds
Bool_t fMarkEnds
Definition: TGDoubleSlider.h:95
Event_t::fCode
UInt_t fCode
Definition: GuiTypes.h:179
TGFrame::SendMessage
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
Definition: TGFrame.cxx:630
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TGDoubleHSlider::~TGDoubleHSlider
virtual ~TGDoubleHSlider()
Delete a horizontal slider widget.
Definition: TGDoubleSlider.cxx:434
TGWidget::fWidgetFlags
Int_t fWidgetFlags
Definition: TGWidget.h:59
kButtonPress
@ kButtonPress
Definition: GuiTypes.h:59
kButtonReleaseMask
const Mask_t kButtonReleaseMask
Definition: GuiTypes.h:161
kButtonRelease
@ kButtonRelease
Definition: GuiTypes.h:59
kDoubleScaleNo
@ kDoubleScaleNo
Definition: TGDoubleSlider.h:66
TGDoubleHSlider::fXp
Int_t fXp
Definition: TGDoubleSlider.h:183
TGFrame::SaveUserColor
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition: TGFrame.cxx:2438
TGDoubleSlider::fVmin
Float_t fVmin
Definition: TGDoubleSlider.h:83
TGClient::GetPicture
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition: TGClient.cxx:290
TGDoubleVSlider::~TGDoubleVSlider
virtual ~TGDoubleVSlider()
Delete vertical slider widget.
Definition: TGDoubleSlider.cxx:240
TSystem::Now
virtual TTime Now()
Get current time in milliseconds since 0:00 Jan 1 1995.
Definition: TSystem.cxx:464
y
Double_t y[n]
Definition: legend1.C:17
ULong_t
unsigned long ULong_t
Definition: RtypesCore.h:55
TGDoubleSlider::Released
virtual void Released()
Definition: TGDoubleSlider.h:148
TGDoubleSlider::fSmin
Float_t fSmin
Definition: TGDoubleSlider.h:80
TGFrame::GetBckgndGC
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition: TGFrame.cxx:760
kSL_POS
@ kSL_POS
Definition: WidgetMessageTypes.h:68
unsigned int
TGDoubleSlider::fPressPoint
Int_t fPressPoint
Definition: TGDoubleSlider.h:87
TGDoubleVSlider
Definition: TGDoubleSlider.h:154
kHorizontalFrame
@ kHorizontalFrame
Definition: GuiTypes.h:382
gSystem
R__EXTERN TSystem * gSystem
Definition: TSystem.h:559
TGWidget::fWidgetId
Int_t fWidgetId
Definition: TGWidget.h:58
TGClient::NeedRedraw
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:373
TGDoubleVSlider::DoRedraw
virtual void DoRedraw()
Redraw vertical slider widget.
Definition: TGDoubleSlider.cxx:248
TGDoubleVSlider::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an horizontal slider as a C++ statement(s) on output stream out.
Definition: TGDoubleSlider.cxx:643
TGObject::fClient
TGClient * fClient
Definition: TGObject.h:37
kSL_PRESS
@ kSL_PRESS
Definition: WidgetMessageTypes.h:70
TGDoubleSlider::ChangeCursor
void ChangeCursor(Event_t *event)
Change the cursor shape depending on the slider area.
Definition: TGDoubleSlider.cxx:158
TGDoubleSlider::FixBounds
static void FixBounds(Float_t &min, Float_t &max)
Avoid boundaries to be equal.
Definition: TGDoubleSlider.cxx:108
Event_t
Definition: GuiTypes.h:173
kDoubleSliderWidth
@ kDoubleSliderWidth
Definition: TGDoubleSlider.h:59
TGDoubleSlider::fReversedScale
Bool_t fReversedScale
Definition: TGDoubleSlider.h:94
TGFrame::GetShadowGC
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition: TGFrame.cxx:750
x2
static const double x2[5]
Definition: RooGaussKronrodIntegrator1D.cxx:364
TGDoubleHSlider::TGDoubleHSlider
TGDoubleHSlider(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)
Create horizontal slider widget.
Definition: TGDoubleSlider.cxx:414
kC_VSLIDER
@ kC_VSLIDER
Definition: WidgetMessageTypes.h:67
TGDoubleSlider::GetMinPosition
virtual Float_t GetMinPosition() const
Definition: TGDoubleSlider.h:127
TGFrame::fHeight
UInt_t fHeight
Definition: TGFrame.h:113
kDoubleScaleBoth
@ kDoubleScaleBoth
Definition: TGDoubleSlider.h:68
TGDoubleSlider::fSmax
Float_t fSmax
Definition: TGDoubleSlider.h:81
TGDoubleSlider::fScale
Int_t fScale
Definition: TGDoubleSlider.h:85
type
int type
Definition: TGX11.cxx:121
TGDoubleHSlider::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in horizontal slider widget.
Definition: TGDoubleSlider.cxx:505
TGPicture::GetHeight
UInt_t GetHeight() const
Definition: TGPicture.h:64
TGDoubleSlider::fScaleType
Int_t fScaleType
Definition: TGDoubleSlider.h:86
kWidgetWantFocus
@ kWidgetWantFocus
Definition: TGWidget.h:46
MK_MSG
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
Definition: WidgetMessageTypes.h:110
TGWindow::fParent
const TGWindow * fParent
Definition: TGWindow.h:36
TGDoubleHSlider::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an horizontal slider as a C++ statement(s) on output stream out.
Definition: TGDoubleSlider.cxx:605
int
TGDoubleSlider::GetMaxPosition
virtual Float_t GetMaxPosition() const
Definition: TGDoubleSlider.h:131