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