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
27DoubleSlider widgets allow easy selection of a min and a max value
28out of a range.
29DoubleSliders can be either horizontal or vertical oriented and
30there is a choice of three different types of tick marks.
31
32To change the min value press the mouse near to the left / bottom
33edge of the slider.
34To change the max value press the mouse near to the right / top
35edge of the slider.
36To change both values simultaneously press the mouse near to the
37center of the slider.
38
39TGDoubleSlider is an abstract base class. Use the concrete
40TGDoubleVSlider and TGDoubleHSlider.
41
42
43\class TGDoubleVSlider
44\ingroup guiwidgets
45
46Dragging the slider will generate the event:
47 - kC_VSLIDER, kSL_POS, slider id, 0
48
49Pressing the mouse will generate the event:
50 - kC_VSLIDER, kSL_PRESS, slider id, 0
51
52Releasing the mouse will generate the event:
53 - kC_VSLIDER, kSL_RELEASE, slider id, 0
54
55Use the functions GetMinPosition(), GetMaxPosition() and
56GetPosition() to retrieve the position of the slider.
57
58
59\class TGDoubleHSlider
60\ingroup guiwidgets
61
62Dragging the slider will generate the event:
63 - kC_HSLIDER, kSL_POS, slider id, 0
64
65Pressing the mouse will generate the event:
66 - kC_HSLIDER, kSL_PRESS, slider id, 0
67
68Releasing the mouse will generate the event:
69 - kC_HSLIDER, kSL_RELEASE, slider id, 0
70
71Use the functions GetMinPosition(), GetMaxPosition() and
72GetPosition() 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
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,
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) {
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;
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;
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{
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);
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;
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;
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{
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);
616 }
617 return kTRUE;
618}
619
620////////////////////////////////////////////////////////////////////////////////
621/// Save an horizontal slider as a C++ statement(s) on output stream out.
622
623void 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
661void 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}
@ kButtonRelease
Definition: GuiTypes.h:60
@ kButtonPress
Definition: GuiTypes.h:60
Handle_t Cursor_t
Cursor handle.
Definition: GuiTypes.h:34
const Mask_t kButtonPressMask
Definition: GuiTypes.h:161
const Mask_t kAnyModifier
Definition: GuiTypes.h:210
const Mask_t kPointerMotionMask
Definition: GuiTypes.h:163
@ kVerticalFrame
Definition: GuiTypes.h:381
@ kHorizontalFrame
Definition: GuiTypes.h:382
const Handle_t kNone
Definition: GuiTypes.h:88
const Mask_t kButtonReleaseMask
Definition: GuiTypes.h:162
@ kRightSide
Definition: GuiTypes.h:373
@ kBottomSide
Definition: GuiTypes.h:373
@ kTopSide
Definition: GuiTypes.h:373
@ kLeftSide
Definition: GuiTypes.h:373
@ kButton1
Definition: GuiTypes.h:214
@ kAnyButton
Definition: GuiTypes.h:214
#define h(i)
Definition: RSha256.hxx:106
#define e(i)
Definition: RSha256.hxx:103
static const double x2[5]
static const double x1[5]
int Int_t
Definition: RtypesCore.h:45
unsigned int UInt_t
Definition: RtypesCore.h:46
const Bool_t kFALSE
Definition: RtypesCore.h:101
unsigned long ULong_t
Definition: RtypesCore.h:55
bool Bool_t
Definition: RtypesCore.h:63
double Double_t
Definition: RtypesCore.h:59
long long Long64_t
Definition: RtypesCore.h:80
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassImp(name)
Definition: Rtypes.h:364
@ kDoubleScaleBoth
@ kDoubleScaleDownRight
@ kDoubleScaleNo
@ kDoubleSliderWidth
@ kDoubleSliderHeight
@ kWidgetWantFocus
Definition: TGWidget.h:35
XFontStruct * id
Definition: TGX11.cxx:109
int type
Definition: TGX11.cxx:121
XPoint xy[kMAXMK]
Definition: TGX11.cxx:123
R__EXTERN TSystem * gSystem
Definition: TSystem.h:559
#define gVirtualX
Definition: TVirtualX.h:338
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
@ kSL_RELEASE
@ kSL_POS
@ kC_HSLIDER
@ kSL_PRESS
@ kC_VSLIDER
void ProcessLine(TString cmd, Long_t msg, Long_t parm1, Long_t parm2)
Execute string "cmd" via the interpreter.
Definition: TGClient.cxx:914
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition: TGClient.cxx:289
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:372
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition: TGClient.cxx:308
Dragging the slider will generate the event:
Int_t fXp
horizontal slider x position in pixel coordinates
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.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an horizontal slider as a C++ statement(s) on output stream out.
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in horizontal slide widget.
virtual ~TGDoubleHSlider()
Delete a horizontal slider widget.
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in horizontal slider widget.
virtual void DoRedraw()
Redraw horizontal slider widget.
DoubleSlider widgets allow easy selection of a min and a max value out of a range.
void ChangeCursor(Event_t *event)
Change the cursor shape depending on the slider area.
virtual Float_t GetMaxPosition() const
Double_t fSmin
logical position of min value of Slider
Int_t fScaleType
tick mark scale type (no, downright, both)
Double_t fPressSmax
logical max position at button press event
virtual void PositionChanged()
TGDoubleSlider(const TGDoubleSlider &)=delete
Double_t fSmax
logical position of max value of Slider
static void FixBounds(Double_t &min, Double_t &max)
Avoid boundaries to be equal.
Double_t fVmax
logical upper limit of slider
Int_t fScale
tick mark scale
Double_t fVmin
logical lower limit of slider
Int_t fMove
1: move min value 2: move max value 3: move min and max value 0: don't move any value
Int_t fRelPos
slider position in pixel coordinates
Double_t fPos
logical position between fVmin and fVmax
virtual Float_t GetMinPosition() const
Bool_t fReversedScale
reverse which end is min and max
Double_t fPressSmin
logical min position at button press event
virtual void Released()
Bool_t fMarkEnds
lines marking where stretch zones begin
virtual void Pressed()
Int_t fPressPoint
mouse position at button press event
const TGPicture * fSliderPic
picture to draw slider ends
TString GetSString() const
returns scaling type as string
Dragging the slider will generate the event:
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.
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in vertical slider.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an horizontal slider as a C++ statement(s) on output stream out.
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in vertical slider.
Int_t fYp
vertical slider y position in pixel coordinates
virtual ~TGDoubleVSlider()
Delete vertical slider widget.
virtual void DoRedraw()
Redraw vertical slider widget.
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition: TGFrame.h:80
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition: TGFrame.cxx:339
static const TGGC & GetBlackGC()
Get black graphics context.
Definition: TGFrame.cxx:735
UInt_t fHeight
frame height
Definition: TGFrame.h:88
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition: TGFrame.cxx:755
virtual UInt_t GetOptions() const
Definition: TGFrame.h:197
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition: TGFrame.cxx:2504
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition: TGFrame.cxx:645
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition: TGFrame.cxx:765
UInt_t fWidth
frame width
Definition: TGFrame.h:87
UInt_t GetHeight() const
Definition: TGFrame.h:225
UInt_t GetWidth() const
Definition: TGFrame.h:224
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition: TGFrame.cxx:2477
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition: TGFrame.cxx:775
TGClient * fClient
Connection to display server.
Definition: TGObject.h:27
Handle_t fId
X11/Win32 Window identifier.
Definition: TGObject.h:26
UInt_t GetHeight() const
Definition: TGPicture.h:53
void Draw(Option_t *="")
Default Draw method for all objects.
Definition: TGPicture.h:46
UInt_t GetWidth() const
Definition: TGPicture.h:52
Int_t fWidgetId
the widget id (used for event processing)
Definition: TGWidget.h:46
TString fCommand
command to be executed
Definition: TGWidget.h:49
Int_t fWidgetFlags
widget status flags (OR of EWidgetStatus)
Definition: TGWidget.h:47
const TGWindow * fMsgWindow
window which handles widget events
Definition: TGWidget.h:48
Int_t WidgetId() const
Definition: TGWidget.h:68
ROOT GUI Window base class.
Definition: TGWindow.h:23
virtual void SetWindowName(const char *name=0)
Set window name.
Definition: TGWindow.cxx:129
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:336
const TGWindow * fParent
Parent window.
Definition: TGWindow.h:28
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:893
Basic string class.
Definition: TString.h:136
Ssiz_t Length() const
Definition: TString.h:410
virtual TTime Now()
Get current time in milliseconds since 0:00 Jan 1 1995.
Definition: TSystem.cxx:466
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
Event structure.
Definition: GuiTypes.h:174