Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGScrollBar.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 10/01/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 TGScrollBar
25 \ingroup guiwidgets
26
27The classes in this file implement scrollbars. Scrollbars can be
28either placed horizontal or vertical. A scrollbar contains three
29
30\class TGScrollBarElements
31\ingroup guiwidgets
32The "head", "tail" and "slider". The head and
33tail are fixed at either end and have the typical arrows in them.
34
35\class TGHScrollBar
36\ingroup guiwidgets
37The TGHScrollBar will generate the following event messages:
38kC_HSCROLL, kSB_SLIDERPOS, position, 0
39kC_HSCROLL, kSB_SLIDERTRACK, position, 0
40
41\class TGVScrollBar
42\ingroup guiwidgets
43The TGVScrollBar will generate the following event messages:
44kC_VSCROLL, kSB_SLIDERPOS, position, 0
45kC_VSCROLL, kSB_SLIDERTRACK, position, 0
46
47*/
48
49
50#include "TGScrollBar.h"
51#include "TGResourcePool.h"
52#include "TGPicture.h"
53#include "TImage.h"
54#include "TSystem.h"
55#include "TTimer.h"
56#include "TEnv.h"
57#include "TVirtualX.h"
58
59#include <iostream>
60
61
64
69
70
71////////////////////////////////////////////////////////////////////////////////
72
73class TSBRepeatTimer : public TTimer {
74private:
75 TGScrollBar *fScrollBar; // scroll bar
77public:
79 { fScrollBar = s; fSmallInc = inc; }
80
81 Bool_t Notify() override;
82 Int_t GetSmallInc() const { return fSmallInc; }
83};
84
85////////////////////////////////////////////////////////////////////////////////
86/// Notify when timer times out and reset the timer.
87
89{
91 Reset();
92 return kFALSE;
93}
94
95////////////////////////////////////////////////////////////////////////////////
96/// Constructor.
97
99 UInt_t w, UInt_t h, UInt_t options, Pixel_t back) :
100 TGFrame(p, w, h, options | kOwnBackground, back)
101{
102 fPic = fPicN = pic;
104 fPicD = 0;
105 fStyle = 0;
106 if ((gClient->GetStyle() > 1) || (p && p->InheritsFrom("TGScrollBar")))
107 fStyle = gClient->GetStyle();
108
110 fHighColor = gClient->GetResourcePool()->GetHighLightColor();
112}
113
114////////////////////////////////////////////////////////////////////////////////
115/// destructor
116
118{
119 if (fPicD) {
121 }
122}
123
124////////////////////////////////////////////////////////////////////////////////
125/// Change state of scrollbar element (either up or down).
126
128{
129 if (state != fState) {
130 switch (state) {
131 case kButtonDown:
132 fOptions &= ~kRaisedFrame;
134 break;
135 case kButtonUp:
136 case kButtonDisabled:
137 fOptions &= ~kSunkenFrame;
139 break;
140 }
141 fState = state;
142 fClient->NeedRedraw(this);
143 }
144}
145
146////////////////////////////////////////////////////////////////////////////////
147/// Enable/Disable scroll bar button chaging the state.
148
150{
151 if (on) {
152 if (fState == kButtonUp) {
153 return;
154 }
156 fPic = fPicN;
157 } else {
158 if (fState == kButtonDisabled) {
159 return;
160 }
162
163 if (!fPicD) {
164 TImage *img = TImage::Create();
165 if (!img) return;
166 TImage *img2 = TImage::Create();
167 if (!img2) {
168 if (img) delete img;
169 return;
170 }
171 TString back = gEnv->GetValue("Gui.BackgroundColor", "#c0c0c0");
172 img2->FillRectangle(back.Data(), 0, 0, fPic->GetWidth(), fPic->GetHeight());
174 Pixmap_t mask = img->GetMask();
175 img2->Merge(img, "overlay");
176
177 TString name = "disbl_";
178 name += fPic->GetName();
179 fPicD = fClient->GetPicturePool()->GetPicture(name.Data(), img2->GetPixmap(),
180 mask);
181 delete img;
182 delete img2;
183 }
184 fPic = fPicD;
185 }
186 fClient->NeedRedraw(this);
187}
188
189////////////////////////////////////////////////////////////////////////////////
190/// Draw border around scollbar element.
191
193{
194 switch (fOptions & (kSunkenFrame | kRaisedFrame)) {
195 case kSunkenFrame: // pressed
196 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, 0, fWidth-2, 0);
197 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, 0, 0, fHeight-2);
198 gVirtualX->DrawLine(fId, GetShadowGC()(), 1, 1, fWidth-3, 1);
199 gVirtualX->DrawLine(fId, GetShadowGC()(), 1, 1, 1, fHeight-3);
200
201 gVirtualX->DrawLine(fId, GetWhiteGC()(), 0, fHeight-1, fWidth-1, fHeight-1);
202 gVirtualX->DrawLine(fId, GetWhiteGC()(), fWidth-1, fHeight-1, fWidth-1, 1);
203 gVirtualX->DrawLine(fId, GetBckgndGC()(), 1, fHeight-2, fWidth-2, fHeight-2);
204 gVirtualX->DrawLine(fId, GetBckgndGC()(), fWidth-2, fHeight-2, fWidth-2, 2);
205
206 if (fPic) {
207 int x = (fWidth - fPic->GetWidth()) >> 1;
208 int y = (fHeight - fPic->GetHeight()) >> 1;
209 fPic->Draw(fId, GetBckgndGC()(), x+1, y+1); // 3, 3
210 }
211 break;
212
213 case kRaisedFrame: // normal
214 case kButtonDisabled:
215 if (fStyle > 0) {
216 // new modern (flat) version
217 if (fBackground == fHighColor) {
218 gVirtualX->DrawRectangle(fId, GetShadowGC()(), 0, 0, fWidth-1, fHeight-1);
219 }
220 else {
221 if (fPic == 0)
222 gVirtualX->DrawRectangle(fId, GetShadowGC()(), 0, 0, fWidth-1, fHeight-1);
223 else
224 gVirtualX->DrawRectangle(fId, GetBckgndGC()(), 0, 0, fWidth-1, fHeight-1);
225 }
226 if (fParent && fParent->InheritsFrom("TGHScrollBar")) {
227 if (fWidth > 20) {
228 gVirtualX->DrawLine(fId, GetShadowGC()(), (fWidth/2)-3, 4, (fWidth/2)-3, fHeight-5);
229 gVirtualX->DrawLine(fId, GetShadowGC()(), (fWidth/2), 4, (fWidth/2), fHeight-5);
230 gVirtualX->DrawLine(fId, GetShadowGC()(), (fWidth/2)+3, 4, (fWidth/2)+3, fHeight-5);
231 }
232 }
233 else if (fParent && fParent->InheritsFrom("TGVScrollBar")) {
234 if (fHeight > 20) {
235 gVirtualX->DrawLine(fId, GetShadowGC()(), 4, (fHeight/2)-3, fWidth-5, (fHeight/2)-3);
236 gVirtualX->DrawLine(fId, GetShadowGC()(), 4, (fHeight/2) , fWidth-5, (fHeight/2));
237 gVirtualX->DrawLine(fId, GetShadowGC()(), 4, (fHeight/2)+3, fWidth-5, (fHeight/2)+3);
238 }
239 }
240 else { // not used in a scroll bar (e.g. in a combo box)
241 gVirtualX->DrawRectangle(fId, GetShadowGC()(), 0, 0, fWidth-1, fHeight-1);
242 }
243 }
244 else {
245 gVirtualX->DrawLine(fId, GetBckgndGC()(), 0, 0, fWidth-2, 0);
246 gVirtualX->DrawLine(fId, GetBckgndGC()(), 0, 0, 0, fHeight-2);
247 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 1, fWidth-3, 1);
248 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 1, 1, fHeight-3);
249
250 gVirtualX->DrawLine(fId, GetShadowGC()(), 1, fHeight-2, fWidth-2, fHeight-2);
251 gVirtualX->DrawLine(fId, GetShadowGC()(), fWidth-2, fHeight-2, fWidth-2, 1);
252 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, fHeight-1, fWidth-1, fHeight-1);
253 gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth-1, fHeight-1, fWidth-1, 0);
254 }
255 if (fPic) {
256 int x = (fWidth - fPic->GetWidth()) >> 1;
257 int y = (fHeight - fPic->GetHeight()) >> 1;
258 fPic->Draw(fId, GetBckgndGC()(), x, y); // 2, 2
259 }
260 break;
261
262 default:
263 break;
264 }
265}
266
267////////////////////////////////////////////////////////////////////////////////
268/// Handle mouse crossing event.
269
271{
272 if (fStyle > 0) {
273 TGScrollBarElement *el = 0;
274 TGScrollBar *bar = 0;
275 if ((event->fType == kEnterNotify) && (fState != kButtonDisabled)) {
277 } else {
279 }
280 if (event->fType == kLeaveNotify) {
282 }
283 gVirtualX->SetWindowBackground(fId, fBgndColor);
285 DrawBorder();
286 if (fParent && fParent->InheritsFrom("TGScrollBar")) {
287 bar = (TGScrollBar *)fParent;
288 if ((el = bar->GetHead()) != this) {
290 el->DrawBorder();
291 }
292 if ((el = bar->GetTail()) != this) {
294 el->DrawBorder();
295 }
296 if ((el = bar->GetSlider()) != this) {
298 el->DrawBorder();
299 }
300 }
301 }
302 return kTRUE;
303}
304
305////////////////////////////////////////////////////////////////////////////////
306/// Constructor.
307
309 UInt_t options, Pixel_t back) :
310 TGFrame(p, w, h, options | kOwnBackground, back),
311 fX0(0), fY0(0), fXp(0), fYp(0), fDragging(kFALSE), fGrabPointer(kTRUE),
312 fRange(0), fPsize(0), fPos(0), fSliderSize(0), fSliderRange(0),
313 fSmallInc(1), fHead(0), fTail(0), fSlider(0), fHeadPic(0),
314 fTailPic(0), fRepeat(0), fSubw()
315{
317
319 fHighColor = gClient->GetResourcePool()->GetHighLightColor();
320
321 fMsgWindow = p;
322 if (gClient->GetStyle() == 0)
326}
327
328////////////////////////////////////////////////////////////////////////////////
329/// Delete a scrollbar (either horizontal or vertical).
330
332{
333 delete fHead;
334 delete fTail;
335 delete fSlider;
338 if (fRepeat) { delete fRepeat; fRepeat = 0; }
339}
340
341////////////////////////////////////////////////////////////////////////////////
342/// Handle mouse crossing event.
343
345{
346 if (gClient->GetStyle() > 0) {
347 if (event->fType == kEnterNotify) {
349 } else {
351 }
352 if (event->fType == kLeaveNotify) {
354 }
358 fHead->DrawBorder();
359 fTail->DrawBorder();
361 }
362 return kTRUE;
363}
364
365////////////////////////////////////////////////////////////////////////////////
366/// Handle repeat timer for horizontal or vertical scrollbar. Every time
367/// timer times out we move slider.
368
370{
371 // shorten time out time to 50 milli seconds
372 t->SetTime(50);
373
374 Window_t dum1, dum2;
375 Event_t ev;
376
377 ev.fCode = kButton1;
378 ev.fType = kButtonPress;
379 ev.fUser[0] = fSubw;
380
381 if (IsAccelerated()) {
382 ++fSmallInc;
383 if (fSmallInc > 100) fSmallInc = 100;
384 }
385
386 gVirtualX->QueryPointer(fId, dum1, dum2, ev.fXRoot, ev.fYRoot, ev.fX, ev.fY,
387 ev.fState);
388
389 HandleButton(&ev);
390
391 return kTRUE;
392}
393
394////////////////////////////////////////////////////////////////////////////////
395/// Static method returning scrollbar background pixmap.
396
398{
399 static Bool_t init = kFALSE;
400 if (!init) {
401 fgBckgndPixmap = gClient->GetResourcePool()->GetCheckeredPixmap();
402 init = kTRUE;
403 }
404 return fgBckgndPixmap;
405}
406
407////////////////////////////////////////////////////////////////////////////////
408/// Static method returning the scrollbar width.
409
411{
412 return fgScrollBarWidth;
413}
414
415////////////////////////////////////////////////////////////////////////////////
416/// Change background color
417
419{
421 fHead->ChangeBackground(back);
422 fTail->ChangeBackground(back);
424}
425
426////////////////////////////////////////////////////////////////////////////////
427/// Create a horizontal scrollbar widget.
428
430 UInt_t options, ULong_t back) :
431 TGScrollBar(p, w, h, options, back)
432{
433 fHeadPic = fClient->GetPicture("arrow_left.xpm");
434 fTailPic = fClient->GetPicture("arrow_right.xpm");
435
436 if (!fHeadPic || !fTailPic) {
437 Error("TGHScrollBar", "arrow_*.xpm not found");
438 return;
439 }
446
449
452 fPos = 0;
453
454 fRange = TMath::Max((Int_t) w - (fgScrollBarWidth << 1), 1);
455 fPsize = fRange >> 1;
456
457 fSliderSize = 50;
458 fSliderRange = 1;
459
464}
465
466////////////////////////////////////////////////////////////////////////////////
467/// Layout and move horizontal scrollbar components.
468
470{
471 // Should also recalculate the slider size and range, etc.
472 fHead->Move(0, 0);
476
477 if (fSlider->GetX() != fX0) {
478 fSlider->Move(fX0, 0);
481 }
482}
483
484////////////////////////////////////////////////////////////////////////////////
485/// Handle a mouse button event in a horizontal scrolbar.
486
488{
489 Int_t newpos;
490
491 if (event->fCode == kButton4) {
492 if (!fHead->IsEnabled()) {
493 return kFALSE;
494 }
495 //scroll left
496 newpos = fPos - fPsize;
497 if (newpos<0) newpos = 0;
498 SetPosition(newpos);
499 return kTRUE;
500 }
501 if (event->fCode == kButton5) {
502 if (!fTail->IsEnabled()) {
503 return kFALSE;
504 }
505 // scroll right
506 newpos = fPos + fPsize;
507 SetPosition(newpos);
508 return kTRUE;
509 }
510
511 if (event->fType == kButtonPress) {
512 if (event->fCode == kButton3) {
513 fX0 = event->fX - fSliderSize/2;
517 fPos = (Int_t)pos;
518
519 fPos = TMath::Max(fPos, 0);
521 fSlider->Move(fX0, 0);
522
525 return kTRUE;
526 }
527
528 // fUser[0] contains the subwindow (child) in which the event occured
529 // (see GX11Gui.cxx)
530 Window_t subw = (Window_t)event->fUser[0];
531
532 if (subw == fSlider->GetId()) {
533 fXp = event->fX - fX0;
534 fYp = event->fY - fY0;
536
537 } else {
538
539 if (!fRepeat)
540 fRepeat = new TSBRepeatTimer(this, 400, fSmallInc); // 500
541 fRepeat->Reset();
543 fSubw = subw;
544
545 if (subw == fHead->GetId()) {
546 //if (!fHead->IsEnabled()) {
547 // return kFALSE;
548 //}
550 fPos -= fSmallInc;
551 } else if (subw == fTail->GetId()) {
552 //if (!fTail->IsEnabled()) {
553 // return kFALSE;
554 // }
556 fPos += fSmallInc;
557 } else if (event->fX > fgScrollBarWidth && event->fX < fX0)
558 fPos -= fPsize;
559 else if (event->fX > fX0+fSliderSize && event->fX < (Int_t)fWidth-fgScrollBarWidth)
560 fPos += fPsize;
561
562 fPos = TMath::Max(fPos, 0);
564
566
569
570 fSlider->Move(fX0, 0);
571
574 }
575
576 // last argument kFALSE forces all specified events to this window
580 kTRUE, kFALSE);
581 } else {
584
585 if (fRepeat) {
586 fRepeat->Remove();
587 fRepeat->SetTime(400); // might have been shortened in HandleTimer()
588 fSmallInc = ((TSBRepeatTimer*)fRepeat)->GetSmallInc();
589 }
590
592
593 fPos = TMath::Max(fPos, 0);
595
598
599 if (fGrabPointer)
600 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
601 }
602 return kTRUE;
603}
604
605////////////////////////////////////////////////////////////////////////////////
606/// Handle mouse motion event in a horizontal scrollbar.
607
609{
610 if (fDragging) {
611 fX0 = event->fX - fXp;
612 fY0 = event->fY - fYp;
613
616 fSlider->Move(fX0, 0);
618 fPos = (Int_t)pos;
619
620 fPos = TMath::Max(fPos, 0);
622
625 }
626 return kTRUE;
627}
628
629////////////////////////////////////////////////////////////////////////////////
630/// Set range of horizontal scrollbar.
631
632void TGHScrollBar::SetRange(Int_t range, Int_t page_size)
633{
634 fRange = TMath::Max(range, 1);
635 fPsize = TMath::Max(page_size, 0);
636 fPos = TMath::Max(fPos, 0);
638
640 fRange, (UInt_t) 6);
642
644 (UInt_t) 1);
645
649
650 fSlider->Move(fX0, 0);
653
654 // fPos = (fX0 - fgScrollBarWidth) * (fRange-fPsize) / fSliderRange;
655
660}
661
662////////////////////////////////////////////////////////////////////////////////
663/// Set logical slider position of horizontal scrollbar.
664
666{
667 fPos = TMath::Max(pos, 0);
669
673
674 fSlider->Move(fX0, 0);
677
680}
681
682
683////////////////////////////////////////////////////////////////////////////////
684/// Create a vertical scrollbar.
685
687 UInt_t options, ULong_t back) :
688 TGScrollBar(p, w, h, options, back)
689{
690 fHeadPic = fClient->GetPicture("arrow_up.xpm");
691 fTailPic = fClient->GetPicture("arrow_down.xpm");
692
693 if (!fHeadPic || !fTailPic) {
694 Error("TGVScrollBar", "arrow_*.xpm not found");
695 return;
696 }
703
706
709 fPos = 0;
710
711 fRange = TMath::Max((Int_t) h - (fgScrollBarWidth << 1), 1);
712 fPsize = fRange >> 1;
713
714 fSliderSize = 50;
715 fSliderRange = 1;
716
721}
722
723////////////////////////////////////////////////////////////////////////////////
724/// Layout and move vertical scrollbar components.
725
727{
728 // Should recalculate fSliderSize, fSliderRange, fX0, fY0, etc. too...
729 fHead->Move(0, 0);
733
734 if (fSlider->GetY() != fY0) {
735 fSlider->Move(0, fY0);
738 }
739}
740
741////////////////////////////////////////////////////////////////////////////////
742/// Handle mouse button event in vertical scrollbar.
743
745{
746 Int_t newpos;
747
748 if (event->fCode == kButton4) {
749 if (!fHead->IsEnabled()) {
750 return kFALSE;
751 }
752 //scroll up
753 newpos = fPos - fPsize;
754 if (newpos<0) newpos = 0;
755 SetPosition(newpos);
756 return kTRUE;
757 }
758 if (event->fCode == kButton5) {
759 if (!fTail->IsEnabled()) {
760 return kFALSE;
761 }
762
763 // scroll down
764 newpos = fPos + fPsize;
765 SetPosition(newpos);
766 return kTRUE;
767 }
768
769 if (event->fType == kButtonPress) {
770 if (event->fCode == kButton3) {
771 fY0 = event->fY - fSliderSize/2;
775 fPos = (Int_t)pos;
776
777 fPos = TMath::Max(fPos, 0);
779 fSlider->Move(0, fY0);
780
783 return kTRUE;
784 }
785
786 // fUser[0] contains the subwindow (child) in which the event occured
787 // (see GX11Gui.cxx)
788 Window_t subw = (Window_t)event->fUser[0];
789
790 if (subw == fSlider->GetId()) {
791 fXp = event->fX - fX0;
792 fYp = event->fY - fY0;
794
795 } else {
796
797 if (!fRepeat)
798 fRepeat = new TSBRepeatTimer(this, 400, fSmallInc); // 500
799 fRepeat->Reset();
801 fSubw = subw;
802
803 if (subw == fHead->GetId()) {
804 //if (!fHead->IsEnabled()) {
805 // return kFALSE;
806 // }
808 fPos -= fSmallInc;
809 } else if (subw == fTail->GetId()) {
810 //if (!fTail->IsEnabled()) {
811 // return kFALSE;
812 //}
814 fPos += fSmallInc;
815 } else if (event->fY > fgScrollBarWidth && event->fY < fY0)
816 fPos -= fPsize;
817 else if (event->fY > fY0+fSliderSize && event->fY < (Int_t)fHeight-fgScrollBarWidth)
818 fPos += fPsize;
819
820 fPos = TMath::Max(fPos, 0);
822
824 fY0 = (Int_t)y0;
825
828
829 fSlider->Move(0, fY0);
830
833 }
834
835 // last argument kFALSE forces all specified events to this window
839 kTRUE, kFALSE);
840 } else {
843
844 if (fRepeat) {
845 fRepeat->Remove();
846 fRepeat->SetTime(400); // might have been shortened in HandleTimer()
847 fSmallInc = ((TSBRepeatTimer*)fRepeat)->GetSmallInc();
848 }
849
851
852 fPos = TMath::Max(fPos, 0);
854
857
858 if (fGrabPointer) {
859 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
860 }
861 }
862 return kTRUE;
863}
864
865////////////////////////////////////////////////////////////////////////////////
866/// Handle mouse motion in a vertical scrollbar.
867
869{
870 if (fDragging) {
871 fX0 = event->fX - fXp;
872 fY0 = event->fY - fYp;
873
876 fSlider->Move(0, fY0);
878 fPos = (Int_t)pos;
879
880 fPos = TMath::Max(fPos, 0);
882
885 }
886 return kTRUE;
887}
888
889////////////////////////////////////////////////////////////////////////////////
890/// Set range of vertical scrollbar.
891
892void TGVScrollBar::SetRange(Int_t range, Int_t page_size)
893{
894 fRange = TMath::Max(range, 1);
895 fPsize = TMath::Max(page_size, 0);
896 fPos = TMath::Max(fPos, 0);
898
900 fRange, (UInt_t) 6);
902
904 (UInt_t)1);
905
907 fY0 = (Int_t)y0;
910
911 fSlider->Move(0, fY0);
914
915 // fPos = (fY0 - fgScrollBarWidth) * (fRange-fPsize) / fSliderRange;
916
917
922}
923
924////////////////////////////////////////////////////////////////////////////////
925/// Set logical slider position of vertical scrollbar.
926
928{
929 fPos = TMath::Max(pos, 0);
931
933 fY0 = (Int_t)y0;
936
937 fSlider->Move(0, fY0);
940
943}
944
945////////////////////////////////////////////////////////////////////////////////
946/// Save an horizontal scrollbar as a C++ statement(s) on output stream out.
947
948void TGHScrollBar::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
949{
951
952 out <<" TGHScrollBar *";
953 out << GetName() << " = new TGHScrollBar(" << fParent->GetName()
954 << "," << GetWidth() << "," << GetHeight();
955
957 if (!GetOptions()) {
958 out <<");" << std::endl;
959 } else {
960 out << "," << GetOptionString() <<");" << std::endl;
961 }
962 } else {
963 out << "," << GetOptionString() << ",ucolor);" << std::endl;
964 }
965 if (option && strstr(option, "keep_names"))
966 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
967
968 out << " " << GetName() <<"->SetRange(" << GetRange() << "," << GetPageSize() << ");" << std::endl;
969 out << " " << GetName() <<"->SetPosition(" << GetPosition() << ");" << std::endl;
970}
971
972////////////////////////////////////////////////////////////////////////////////
973/// Save an vertical scrollbar as a C++ statement(s) on output stream out.
974
975void TGVScrollBar::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
976{
978
979 out<<" TGVScrollBar *";
980 out << GetName() <<" = new TGVScrollBar("<< fParent->GetName()
981 << "," << GetWidth() << "," << GetHeight();
982
984
985 if (!GetOptions()) {
986 out <<");" << std::endl;
987 } else {
988 out << "," << GetOptionString() <<");" << std::endl;
989 }
990 } else {
991 out << "," << GetOptionString() << ",ucolor);" << std::endl;
992 }
993 if (option && strstr(option, "keep_names"))
994 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
995
996 out << " " << GetName() <<"->SetRange(" << GetRange() << "," << GetPageSize() << ");" << std::endl;
997 out << " " << GetName() <<"->SetPosition(" << GetPosition() << ");" << std::endl;
998}
@ kButtonPress
Definition GuiTypes.h:60
@ kEnterNotify
Definition GuiTypes.h:61
@ kLeaveNotify
Definition GuiTypes.h:61
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:30
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
const Mask_t kAnyModifier
Definition GuiTypes.h:210
const Mask_t kPointerMotionMask
Definition GuiTypes.h:163
@ kRaisedFrame
Definition GuiTypes.h:384
@ kSunkenFrame
Definition GuiTypes.h:383
@ kOwnBackground
Definition GuiTypes.h:391
const Handle_t kNone
Definition GuiTypes.h:88
@ kDefaultScrollBarWidth
Definition GuiTypes.h:86
const Mask_t kLeaveWindowMask
Definition GuiTypes.h:168
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
const Mask_t kEnterWindowMask
Definition GuiTypes.h:167
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
@ kButton4
Definition GuiTypes.h:215
@ kButton5
Definition GuiTypes.h:215
@ kButton3
Definition GuiTypes.h:214
@ kButton1
Definition GuiTypes.h:214
@ kAnyButton
Definition GuiTypes.h:214
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
unsigned long ULong_t
Definition RtypesCore.h:55
long Long_t
Definition RtypesCore.h:54
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
@ kButtonDown
Definition TGButton.h:54
@ kButtonDisabled
Definition TGButton.h:56
@ kButtonUp
Definition TGButton.h:53
#define gClient
Definition TGClient.h:156
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
char name[80]
Definition TGX11.cxx:110
R__EXTERN TSystem * gSystem
Definition TSystem.h:555
#define gVirtualX
Definition TVirtualX.h:337
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
@ kSB_SLIDERTRACK
@ kSB_SLIDERPOS
@ kC_VSCROLL
@ kC_HSCROLL
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:491
Bool_t IsEditable() const
Definition TGClient.h:89
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
TGPicturePool * GetPicturePool() const
Definition TGClient.h:126
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:308
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 fOptions
frame options
Definition TGFrame.h:94
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
UInt_t fHeight
frame height
Definition TGFrame.h:88
void DoRedraw() override
Redraw the frame.
Definition TGFrame.cxx:430
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition TGFrame.cxx:755
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:683
void Move(Int_t x, Int_t y) override
Move frame.
Definition TGFrame.cxx:593
Int_t GetX() const
Definition TGFrame.h:231
virtual UInt_t GetOptions() const
Definition TGFrame.h:197
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition TGFrame.cxx:2506
virtual void ChangeBackground(Pixel_t back)
Change frame background color.
Definition TGFrame.cxx:293
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
Int_t GetY() const
Definition TGFrame.h:232
static const TGGC & GetWhiteGC()
Get white graphics context.
Definition TGFrame.cxx:745
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:2479
Pixel_t fBackground
frame background color
Definition TGFrame.h:95
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition TGFrame.cxx:775
The TGHScrollBar will generate the following event messages: kC_HSCROLL, kSB_SLIDERPOS,...
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save an horizontal scrollbar as a C++ statement(s) on output stream out.
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion event in a horizontal scrollbar.
void Layout() override
Layout and move horizontal scrollbar components.
Bool_t HandleButton(Event_t *event) override
Handle a mouse button event in a horizontal scrolbar.
void SetRange(Int_t range, Int_t page_size) override
Set range of horizontal scrollbar.
TGHScrollBar(const TGWindow *p=nullptr, UInt_t w=4, UInt_t h=2, UInt_t options=kHorizontalFrame, Pixel_t back=GetDefaultFrameBackground())
Create a horizontal scrollbar widget.
void SetPosition(Int_t pos) override
Set logical slider position of horizontal scrollbar.
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t GetId() const
Definition TGObject.h:41
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
const TGPicture * GetPicture(const char *name)
Get a picture from the picture pool.
Definition TGPicture.cxx:82
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
Pixmap_t GetMask() const
Definition TGPicture.h:55
void Draw(Option_t *="") override
Default Draw method for all objects.
Definition TGPicture.h:46
UInt_t GetHeight() const
Definition TGPicture.h:53
const char * GetName() const override
Returns name of object.
Definition TGPicture.h:51
Pixmap_t GetPicture() const
Definition TGPicture.h:54
UInt_t GetWidth() const
Definition TGPicture.h:52
virtual Bool_t IsEnabled() const
Definition TGScrollBar.h:54
~TGScrollBarElement() override
destructor
const TGPicture * fPic
picture in scrollbar element
Definition TGScrollBar.h:37
Pixel_t fBgndColor
background color
Definition TGScrollBar.h:40
void DrawBorder() override
Draw border around scollbar element.
const TGPicture * fPicD
picture for disabled state of scrollbar element
Definition TGScrollBar.h:39
Int_t fStyle
modern or classic style
Definition TGScrollBar.h:42
virtual void SetEnabled(Bool_t on=kTRUE)
Enable/Disable scroll bar button chaging the state.
virtual void SetState(Int_t state)
Change state of scrollbar element (either up or down).
Pixel_t fHighColor
highlight color
Definition TGScrollBar.h:41
const TGPicture * fPicN
picture for normal state of scrollbar element
Definition TGScrollBar.h:38
Int_t fState
state of scrollbar element (button up or down)
Definition TGScrollBar.h:36
Bool_t HandleCrossing(Event_t *event) override
Handle mouse crossing event.
TGScrollBarElement(const TGScrollBarElement &)=delete
The classes in this file implement scrollbars.
Definition TGScrollBar.h:61
virtual void RangeChanged(Int_t range)
static Pixmap_t fgBckgndPixmap
Definition TGScrollBar.h:89
TTimer * fRepeat
repeat rate timer (when mouse stays pressed)
Definition TGScrollBar.h:83
TGScrollBarElement * GetTail() const
Int_t fPsize
logical page size of scrollbar
Definition TGScrollBar.h:73
Bool_t IsAccelerated() const
static Pixmap_t GetBckgndPixmap()
Static method returning scrollbar background pixmap.
Bool_t fAccelerated
kFALSE - normal, kTRUE - accelerated
Definition TGScrollBar.h:85
Int_t fSliderSize
logical slider size
Definition TGScrollBar.h:75
static Int_t fgScrollBarWidth
Definition TGScrollBar.h:90
Bool_t fDragging
in dragging mode?
Definition TGScrollBar.h:70
virtual Int_t GetRange() const
const TGPicture * fTailPic
picture in tail (down or right arrow)
Definition TGScrollBar.h:82
Bool_t HandleButton(Event_t *event) override=0
TGScrollBarElement * GetSlider() const
TGScrollBarElement * fSlider
slider
Definition TGScrollBar.h:80
TGScrollBarElement * GetHead() const
virtual void PageSizeChanged(Int_t range)
Int_t fY0
current slider position in pixels
Definition TGScrollBar.h:68
Bool_t HandleCrossing(Event_t *event) override
Handle mouse crossing event.
virtual Int_t GetPageSize() const
virtual Int_t GetPosition() const
Window_t fSubw
sub window in which mouse is pressed
Definition TGScrollBar.h:84
static Int_t GetScrollBarWidth()
Static method returning the scrollbar width.
Int_t fSmallInc
Small Increment in the sliding algorithm.
Definition TGScrollBar.h:77
Bool_t fGrabPointer
grab pointer when dragging
Definition TGScrollBar.h:71
Int_t fPos
logical current position
Definition TGScrollBar.h:74
Pixel_t fBgndColor
background color
Definition TGScrollBar.h:86
TGScrollBarElement * fHead
head button of scrollbar
Definition TGScrollBar.h:78
Int_t fYp
previous slider position in pixels
Definition TGScrollBar.h:69
void ChangeBackground(Pixel_t back) override
Change background color.
Pixel_t fHighColor
highlight color
Definition TGScrollBar.h:87
Bool_t HandleTimer(TTimer *t) override
Handle repeat timer for horizontal or vertical scrollbar.
TGScrollBar(const TGScrollBar &)=delete
TGScrollBarElement * fTail
tail button of scrollbar
Definition TGScrollBar.h:79
Int_t fRange
logical upper range of scrollbar
Definition TGScrollBar.h:72
Int_t fSliderRange
logical slider range
Definition TGScrollBar.h:76
virtual void PositionChanged(Int_t pos)
~TGScrollBar() override
Delete a scrollbar (either horizontal or vertical).
const TGPicture * fHeadPic
picture in head (up or left arrow)
Definition TGScrollBar.h:81
The TGVScrollBar will generate the following event messages: kC_VSCROLL, kSB_SLIDERPOS,...
TGVScrollBar(const TGWindow *p=nullptr, UInt_t w=2, UInt_t h=4, UInt_t options=kVerticalFrame, Pixel_t back=GetDefaultFrameBackground())
Create a vertical scrollbar.
void SetRange(Int_t range, Int_t page_size) override
Set range of vertical scrollbar.
void SetPosition(Int_t pos) override
Set logical slider position of vertical scrollbar.
Bool_t HandleButton(Event_t *event) override
Handle mouse button event in vertical scrollbar.
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion in a vertical scrollbar.
void Layout() override
Layout and move vertical scrollbar components.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save an vertical scrollbar as a C++ statement(s) on output stream out.
const TGWindow * fMsgWindow
window which handles widget events
Definition TGWidget.h:48
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual void SetBackgroundPixmap(Pixmap_t pixmap)
set background pixmap
Definition TGWindow.cxx:248
virtual void SetEditDisabled(UInt_t on=kEditDisable)
Definition TGWindow.h:113
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
@ kEditDisableHeight
window height cannot be edited
Definition TGWindow.h:62
@ kEditDisableLayout
window layout cannot be edited
Definition TGWindow.h:60
@ kEditDisableBtnEnable
window can handle mouse button events
Definition TGWindow.h:64
@ kEditDisableWidth
window width cannot be edited
Definition TGWindow.h:63
@ kEditDisableGrab
window grab cannot be edited
Definition TGWindow.h:59
@ kEditDisable
disable edit of this window
Definition TGWindow.h:57
virtual void SetWindowName(const char *name=nullptr)
Set window name.
Definition TGWindow.cxx:129
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:336
UInt_t fEditDisabled
flags used for "guibuilding"
Definition TGWindow.h:32
An abstract interface to image processing library.
Definition TImage.h:29
virtual void FillRectangle(const char *=nullptr, Int_t=0, Int_t=0, UInt_t=0, UInt_t=0)
Definition TImage.h:192
static TImage * Create()
Create an image.
Definition TImage.cxx:35
virtual void Merge(const TImage *, const char *="alphablend", Int_t=0, Int_t=0)
Definition TImage.h:172
virtual Pixmap_t GetPixmap()
Definition TImage.h:235
virtual void SetImage(const Double_t *, UInt_t, UInt_t, TImagePalette *=nullptr)
Definition TImage.h:116
virtual Pixmap_t GetMask()
Definition TImage.h:236
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:525
Bool_t Notify() override
Notify when timer times out and reset the timer.
TSBRepeatTimer(TGScrollBar *s, Long_t ms, Int_t inc)
Int_t GetSmallInc() const
TGScrollBar * fScrollBar
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition TSystem.cxx:471
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
void Reset()
Reset the timer.
Definition TTimer.cxx:159
void SetTime(Long_t milliSec)
Definition TTimer.h:91
void Remove() override
Definition TTimer.h:86
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:250
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:198
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
Int_t fY
pointer x, y coordinates in event window
Definition GuiTypes.h:178
Int_t fXRoot
Definition GuiTypes.h:179
UInt_t fState
key or button mask
Definition GuiTypes.h:181
Int_t fYRoot
coordinates relative to root
Definition GuiTypes.h:179
Int_t fX
Definition GuiTypes.h:178
UInt_t fCode
key or button code
Definition GuiTypes.h:180
Longptr_t fUser[5]
5 longs can be used by client message events NOTE: only [0], [1] and [2] may be used.
Definition GuiTypes.h:187