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