Logo ROOT   6.16/01
Reference Guide
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// //
25// TGScrollBar and TGScrollBarElement //
26// //
27// The classes in this file implement scrollbars. Scrollbars can be //
28// either placed horizontal or vertical. A scrollbar contains three //
29// TGScrollBarElements: The "head", "tail" and "slider". The head and //
30// tail are fixed at either end and have the typical arrows in them. //
31// //
32// The TGHScrollBar will generate the following event messages: //
33// kC_HSCROLL, kSB_SLIDERPOS, position, 0 //
34// kC_HSCROLL, kSB_SLIDERTRACK, position, 0 //
35// //
36// The TGVScrollBar will generate the following event messages: //
37// kC_VSCROLL, kSB_SLIDERPOS, position, 0 //
38// kC_VSCROLL, kSB_SLIDERTRACK, position, 0 //
39// //
40//////////////////////////////////////////////////////////////////////////
41
42#include "TGScrollBar.h"
43#include "TGResourcePool.h"
44#include "TGPicture.h"
45#include "TImage.h"
46#include "TSystem.h"
47#include "TTimer.h"
48#include "TEnv.h"
49#include "Riostream.h"
50
51
54
59
60
61////////////////////////////////////////////////////////////////////////////////
62
63class TSBRepeatTimer : public TTimer {
64private:
65 TGScrollBar *fScrollBar; // scroll bar
66 Int_t fSmallInc; // step
67public:
68 TSBRepeatTimer(TGScrollBar *s, Long_t ms, Int_t inc) : TTimer(ms, kTRUE)
69 { fScrollBar = s; fSmallInc = inc; }
70
71 Bool_t Notify();
72 Int_t GetSmallInc() const { return fSmallInc; }
73};
74
75////////////////////////////////////////////////////////////////////////////////
76/// Notify when timer times out and reset the timer.
77
78Bool_t TSBRepeatTimer::Notify()
79{
80 fScrollBar->HandleTimer(this);
81 Reset();
82 return kFALSE;
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// Constructor.
87
89 UInt_t w, UInt_t h, UInt_t options, Pixel_t back) :
90 TGFrame(p, w, h, options | kOwnBackground, back)
91{
92 fPic = fPicN = pic;
94 fPicD = 0;
95 fStyle = 0;
96 if ((gClient->GetStyle() > 1) || (p && p->InheritsFrom("TGScrollBar")))
97 fStyle = gClient->GetStyle();
98
100 fHighColor = gClient->GetResourcePool()->GetHighLightColor();
102}
103
104////////////////////////////////////////////////////////////////////////////////
105/// destructor
106
108{
109 if (fPicD) {
111 }
112}
113
114////////////////////////////////////////////////////////////////////////////////
115/// Change state of scrollbar element (either up or down).
116
118{
119 if (state != fState) {
120 switch (state) {
121 case kButtonDown:
122 fOptions &= ~kRaisedFrame;
124 break;
125 case kButtonUp:
126 case kButtonDisabled:
127 fOptions &= ~kSunkenFrame;
129 break;
130 }
131 fState = state;
132 fClient->NeedRedraw(this);
133 }
134}
135
136////////////////////////////////////////////////////////////////////////////////
137/// Enable/Disable scroll bar button chaging the state.
138
140{
141 if (on) {
142 if (fState == kButtonUp) {
143 return;
144 }
146 fPic = fPicN;
147 } else {
148 if (fState == kButtonDisabled) {
149 return;
150 }
152
153 if (!fPicD) {
154 TImage *img = TImage::Create();
155 if (!img) return;
156 TImage *img2 = TImage::Create();
157 if (!img2) {
158 if (img) delete img;
159 return;
160 }
161 TString back = gEnv->GetValue("Gui.BackgroundColor", "#c0c0c0");
162 img2->FillRectangle(back.Data(), 0, 0, fPic->GetWidth(), fPic->GetHeight());
164 Pixmap_t mask = img->GetMask();
165 img2->Merge(img, "overlay");
166
167 TString name = "disbl_";
168 name += fPic->GetName();
169 fPicD = fClient->GetPicturePool()->GetPicture(name.Data(), img2->GetPixmap(),
170 mask);
171 delete img;
172 delete img2;
173 }
174 fPic = fPicD;
175 }
176 fClient->NeedRedraw(this);
177}
178
179////////////////////////////////////////////////////////////////////////////////
180/// Draw border around scollbar element.
181
183{
184 switch (fOptions & (kSunkenFrame | kRaisedFrame)) {
185 case kSunkenFrame: // pressed
186 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, 0, fWidth-2, 0);
187 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, 0, 0, fHeight-2);
188 gVirtualX->DrawLine(fId, GetShadowGC()(), 1, 1, fWidth-3, 1);
189 gVirtualX->DrawLine(fId, GetShadowGC()(), 1, 1, 1, fHeight-3);
190
191 gVirtualX->DrawLine(fId, GetWhiteGC()(), 0, fHeight-1, fWidth-1, fHeight-1);
192 gVirtualX->DrawLine(fId, GetWhiteGC()(), fWidth-1, fHeight-1, fWidth-1, 1);
193 gVirtualX->DrawLine(fId, GetBckgndGC()(), 1, fHeight-2, fWidth-2, fHeight-2);
194 gVirtualX->DrawLine(fId, GetBckgndGC()(), fWidth-2, fHeight-2, fWidth-2, 2);
195
196 if (fPic) {
197 int x = (fWidth - fPic->GetWidth()) >> 1;
198 int y = (fHeight - fPic->GetHeight()) >> 1;
199 fPic->Draw(fId, GetBckgndGC()(), x+1, y+1); // 3, 3
200 }
201 break;
202
203 case kRaisedFrame: // normal
204 case kButtonDisabled:
205 if (fStyle > 0) {
206 // new modern (flat) version
207 if (fBackground == fHighColor) {
208 gVirtualX->DrawRectangle(fId, GetShadowGC()(), 0, 0, fWidth-1, fHeight-1);
209 }
210 else {
211 if (fPic == 0)
212 gVirtualX->DrawRectangle(fId, GetShadowGC()(), 0, 0, fWidth-1, fHeight-1);
213 else
214 gVirtualX->DrawRectangle(fId, GetBckgndGC()(), 0, 0, fWidth-1, fHeight-1);
215 }
216 if (fParent && fParent->InheritsFrom("TGHScrollBar")) {
217 if (fWidth > 20) {
218 gVirtualX->DrawLine(fId, GetShadowGC()(), (fWidth/2)-3, 4, (fWidth/2)-3, fHeight-5);
219 gVirtualX->DrawLine(fId, GetShadowGC()(), (fWidth/2), 4, (fWidth/2), fHeight-5);
220 gVirtualX->DrawLine(fId, GetShadowGC()(), (fWidth/2)+3, 4, (fWidth/2)+3, fHeight-5);
221 }
222 }
223 else if (fParent && fParent->InheritsFrom("TGVScrollBar")) {
224 if (fHeight > 20) {
225 gVirtualX->DrawLine(fId, GetShadowGC()(), 4, (fHeight/2)-3, fWidth-5, (fHeight/2)-3);
226 gVirtualX->DrawLine(fId, GetShadowGC()(), 4, (fHeight/2) , fWidth-5, (fHeight/2));
227 gVirtualX->DrawLine(fId, GetShadowGC()(), 4, (fHeight/2)+3, fWidth-5, (fHeight/2)+3);
228 }
229 }
230 else { // not used in a scroll bar (e.g. in a combo box)
231 gVirtualX->DrawRectangle(fId, GetShadowGC()(), 0, 0, fWidth-1, fHeight-1);
232 }
233 }
234 else {
235 gVirtualX->DrawLine(fId, GetBckgndGC()(), 0, 0, fWidth-2, 0);
236 gVirtualX->DrawLine(fId, GetBckgndGC()(), 0, 0, 0, fHeight-2);
237 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 1, fWidth-3, 1);
238 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 1, 1, fHeight-3);
239
240 gVirtualX->DrawLine(fId, GetShadowGC()(), 1, fHeight-2, fWidth-2, fHeight-2);
241 gVirtualX->DrawLine(fId, GetShadowGC()(), fWidth-2, fHeight-2, fWidth-2, 1);
242 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, fHeight-1, fWidth-1, fHeight-1);
243 gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth-1, fHeight-1, fWidth-1, 0);
244 }
245 if (fPic) {
246 int x = (fWidth - fPic->GetWidth()) >> 1;
247 int y = (fHeight - fPic->GetHeight()) >> 1;
248 fPic->Draw(fId, GetBckgndGC()(), x, y); // 2, 2
249 }
250 break;
251
252 default:
253 break;
254 }
255}
256
257////////////////////////////////////////////////////////////////////////////////
258/// Handle mouse crossing event.
259
261{
262 if (fStyle > 0) {
263 TGScrollBarElement *el = 0;
264 TGScrollBar *bar = 0;
265 if ((event->fType == kEnterNotify) && (fState != kButtonDisabled)) {
267 } else {
269 }
270 if (event->fType == kLeaveNotify) {
272 }
273 gVirtualX->SetWindowBackground(fId, fBgndColor);
275 DrawBorder();
276 if (fParent && fParent->InheritsFrom("TGScrollBar")) {
278 if ((el = bar->GetHead()) != this) {
280 el->DrawBorder();
281 }
282 if ((el = bar->GetTail()) != this) {
284 el->DrawBorder();
285 }
286 if ((el = bar->GetSlider()) != this) {
288 el->DrawBorder();
289 }
290 }
291 }
292 return kTRUE;
293}
294
295////////////////////////////////////////////////////////////////////////////////
296/// Constructor.
297
299 UInt_t options, Pixel_t back) :
300 TGFrame(p, w, h, options | kOwnBackground, back),
301 fX0(0), fY0(0), fXp(0), fYp(0), fDragging(kFALSE), fGrabPointer(kTRUE),
302 fRange(0), fPsize(0), fPos(0), fSliderSize(0), fSliderRange(0),
303 fSmallInc(1), fHead(0), fTail(0), fSlider(0), fHeadPic(0),
304 fTailPic(0), fRepeat(0), fSubw()
305{
307
309 fHighColor = gClient->GetResourcePool()->GetHighLightColor();
310
311 fMsgWindow = p;
312 if (gClient->GetStyle() == 0)
316}
317
318////////////////////////////////////////////////////////////////////////////////
319/// Delete a scrollbar (either horizontal or vertical).
320
322{
323 delete fHead;
324 delete fTail;
325 delete fSlider;
328 if (fRepeat) { delete fRepeat; fRepeat = 0; }
329}
330
331////////////////////////////////////////////////////////////////////////////////
332/// Handle mouse crossing event.
333
335{
336 if (gClient->GetStyle() > 0) {
337 if (event->fType == kEnterNotify) {
339 } else {
341 }
342 if (event->fType == kLeaveNotify) {
344 }
348 fHead->DrawBorder();
349 fTail->DrawBorder();
351 }
352 return kTRUE;
353}
354
355////////////////////////////////////////////////////////////////////////////////
356/// Handle repeat timer for horizontal or vertical scrollbar. Every time
357/// timer times out we move slider.
358
360{
361 // shorten time out time to 50 milli seconds
362 t->SetTime(50);
363
364 Window_t dum1, dum2;
365 Event_t ev;
366
367 ev.fCode = kButton1;
368 ev.fType = kButtonPress;
369 ev.fUser[0] = fSubw;
370
371 if (IsAccelerated()) {
372 ++fSmallInc;
373 if (fSmallInc > 100) fSmallInc = 100;
374 }
375
376 gVirtualX->QueryPointer(fId, dum1, dum2, ev.fXRoot, ev.fYRoot, ev.fX, ev.fY,
377 ev.fState);
378
379 HandleButton(&ev);
380
381 return kTRUE;
382}
383
384////////////////////////////////////////////////////////////////////////////////
385/// Static method returning scrollbar background pixmap.
386
388{
389 static Bool_t init = kFALSE;
390 if (!init) {
391 fgBckgndPixmap = gClient->GetResourcePool()->GetCheckeredPixmap();
392 init = kTRUE;
393 }
394 return fgBckgndPixmap;
395}
396
397////////////////////////////////////////////////////////////////////////////////
398/// Static method returning the scrollbar width.
399
401{
402 return fgScrollBarWidth;
403}
404
405////////////////////////////////////////////////////////////////////////////////
406/// Change background color
407
409{
411 fHead->ChangeBackground(back);
412 fTail->ChangeBackground(back);
414}
415
416////////////////////////////////////////////////////////////////////////////////
417/// Create a horizontal scrollbar widget.
418
420 UInt_t options, ULong_t back) :
421 TGScrollBar(p, w, h, options, back)
422{
423 fHeadPic = fClient->GetPicture("arrow_left.xpm");
424 fTailPic = fClient->GetPicture("arrow_right.xpm");
425
426 if (!fHeadPic || !fTailPic) {
427 Error("TGHScrollBar", "arrow_*.xpm not found");
428 return;
429 }
436
439
442 fPos = 0;
443
444 fRange = TMath::Max((Int_t) w - (fgScrollBarWidth << 1), 1);
445 fPsize = fRange >> 1;
446
447 fSliderSize = 50;
448 fSliderRange = 1;
449
454}
455
456////////////////////////////////////////////////////////////////////////////////
457/// Layout and move horizontal scrollbar components.
458
460{
461 // Should also recalculate the slider size and range, etc.
462 fHead->Move(0, 0);
466
467 if (fSlider->GetX() != fX0) {
468 fSlider->Move(fX0, 0);
471 }
472}
473
474////////////////////////////////////////////////////////////////////////////////
475/// Handle a mouse button event in a horizontal scrolbar.
476
478{
479 Int_t newpos;
480
481 if (event->fCode == kButton4) {
482 if (!fHead->IsEnabled()) {
483 return kFALSE;
484 }
485 //scroll left
486 newpos = fPos - fPsize;
487 if (newpos<0) newpos = 0;
488 SetPosition(newpos);
489 return kTRUE;
490 }
491 if (event->fCode == kButton5) {
492 if (!fTail->IsEnabled()) {
493 return kFALSE;
494 }
495 // scroll right
496 newpos = fPos + fPsize;
497 SetPosition(newpos);
498 return kTRUE;
499 }
500
501 if (event->fType == kButtonPress) {
502 if (event->fCode == kButton3) {
503 fX0 = event->fX - fSliderSize/2;
507 fPos = (Int_t)pos;
508
509 fPos = TMath::Max(fPos, 0);
511 fSlider->Move(fX0, 0);
512
515 return kTRUE;
516 }
517
518 // fUser[0] contains the subwindow (child) in which the event occured
519 // (see GX11Gui.cxx)
520 Window_t subw = (Window_t)event->fUser[0];
521
522 if (subw == fSlider->GetId()) {
523 fXp = event->fX - fX0;
524 fYp = event->fY - fY0;
526
527 } else {
528
529 if (!fRepeat)
530 fRepeat = new TSBRepeatTimer(this, 400, fSmallInc); // 500
531 fRepeat->Reset();
533 fSubw = subw;
534
535 if (subw == fHead->GetId()) {
536 //if (!fHead->IsEnabled()) {
537 // return kFALSE;
538 //}
540 fPos -= fSmallInc;
541 } else if (subw == fTail->GetId()) {
542 //if (!fTail->IsEnabled()) {
543 // return kFALSE;
544 // }
546 fPos += fSmallInc;
547 } else if (event->fX > fgScrollBarWidth && event->fX < fX0)
548 fPos -= fPsize;
549 else if (event->fX > fX0+fSliderSize && event->fX < (Int_t)fWidth-fgScrollBarWidth)
550 fPos += fPsize;
551
552 fPos = TMath::Max(fPos, 0);
554
556
559
560 fSlider->Move(fX0, 0);
561
564 }
565
566 // last argument kFALSE forces all specified events to this window
570 kTRUE, kFALSE);
571 } else {
574
575 if (fRepeat) {
576 fRepeat->Remove();
577 fRepeat->SetTime(400); // might have been shortened in HandleTimer()
578 fSmallInc = ((TSBRepeatTimer*)fRepeat)->GetSmallInc();
579 }
580
582
583 fPos = TMath::Max(fPos, 0);
585
588
589 if (fGrabPointer)
590 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
591 }
592 return kTRUE;
593}
594
595////////////////////////////////////////////////////////////////////////////////
596/// Handle mouse motion event in a horizontal scrollbar.
597
599{
600 if (fDragging) {
601 fX0 = event->fX - fXp;
602 fY0 = event->fY - fYp;
603
606 fSlider->Move(fX0, 0);
608 fPos = (Int_t)pos;
609
610 fPos = TMath::Max(fPos, 0);
612
615 }
616 return kTRUE;
617}
618
619////////////////////////////////////////////////////////////////////////////////
620/// Set range of horizontal scrollbar.
621
622void TGHScrollBar::SetRange(Int_t range, Int_t page_size)
623{
624 fRange = TMath::Max(range, 1);
625 fPsize = TMath::Max(page_size, 0);
626 fPos = TMath::Max(fPos, 0);
628
630 fRange, (UInt_t) 6);
632
634 (UInt_t) 1);
635
639
640 fSlider->Move(fX0, 0);
643
644 // fPos = (fX0 - fgScrollBarWidth) * (fRange-fPsize) / fSliderRange;
645
650}
651
652////////////////////////////////////////////////////////////////////////////////
653/// Set logical slider position of horizontal scrollbar.
654
656{
657 fPos = TMath::Max(pos, 0);
659
663
664 fSlider->Move(fX0, 0);
667
670}
671
672
673////////////////////////////////////////////////////////////////////////////////
674/// Create a vertical scrollbar.
675
677 UInt_t options, ULong_t back) :
678 TGScrollBar(p, w, h, options, back)
679{
680 fHeadPic = fClient->GetPicture("arrow_up.xpm");
681 fTailPic = fClient->GetPicture("arrow_down.xpm");
682
683 if (!fHeadPic || !fTailPic) {
684 Error("TGVScrollBar", "arrow_*.xpm not found");
685 return;
686 }
693
696
699 fPos = 0;
700
701 fRange = TMath::Max((Int_t) h - (fgScrollBarWidth << 1), 1);
702 fPsize = fRange >> 1;
703
704 fSliderSize = 50;
705 fSliderRange = 1;
706
711}
712
713////////////////////////////////////////////////////////////////////////////////
714/// Layout and move vertical scrollbar components.
715
717{
718 // Should recalculate fSliderSize, fSliderRange, fX0, fY0, etc. too...
719 fHead->Move(0, 0);
723
724 if (fSlider->GetY() != fY0) {
725 fSlider->Move(0, fY0);
728 }
729}
730
731////////////////////////////////////////////////////////////////////////////////
732/// Handle mouse button event in vertical scrollbar.
733
735{
736 Int_t newpos;
737
738 if (event->fCode == kButton4) {
739 if (!fHead->IsEnabled()) {
740 return kFALSE;
741 }
742 //scroll up
743 newpos = fPos - fPsize;
744 if (newpos<0) newpos = 0;
745 SetPosition(newpos);
746 return kTRUE;
747 }
748 if (event->fCode == kButton5) {
749 if (!fTail->IsEnabled()) {
750 return kFALSE;
751 }
752
753 // scroll down
754 newpos = fPos + fPsize;
755 SetPosition(newpos);
756 return kTRUE;
757 }
758
759 if (event->fType == kButtonPress) {
760 if (event->fCode == kButton3) {
761 fY0 = event->fY - fSliderSize/2;
765 fPos = (Int_t)pos;
766
767 fPos = TMath::Max(fPos, 0);
769 fSlider->Move(0, fY0);
770
773 return kTRUE;
774 }
775
776 // fUser[0] contains the subwindow (child) in which the event occured
777 // (see GX11Gui.cxx)
778 Window_t subw = (Window_t)event->fUser[0];
779
780 if (subw == fSlider->GetId()) {
781 fXp = event->fX - fX0;
782 fYp = event->fY - fY0;
784
785 } else {
786
787 if (!fRepeat)
788 fRepeat = new TSBRepeatTimer(this, 400, fSmallInc); // 500
789 fRepeat->Reset();
791 fSubw = subw;
792
793 if (subw == fHead->GetId()) {
794 //if (!fHead->IsEnabled()) {
795 // return kFALSE;
796 // }
798 fPos -= fSmallInc;
799 } else if (subw == fTail->GetId()) {
800 //if (!fTail->IsEnabled()) {
801 // return kFALSE;
802 //}
804 fPos += fSmallInc;
805 } else if (event->fY > fgScrollBarWidth && event->fY < fY0)
806 fPos -= fPsize;
807 else if (event->fY > fY0+fSliderSize && event->fY < (Int_t)fHeight-fgScrollBarWidth)
808 fPos += fPsize;
809
810 fPos = TMath::Max(fPos, 0);
812
814 fY0 = (Int_t)y0;
815
818
819 fSlider->Move(0, fY0);
820
823 }
824
825 // last argument kFALSE forces all specified events to this window
829 kTRUE, kFALSE);
830 } else {
833
834 if (fRepeat) {
835 fRepeat->Remove();
836 fRepeat->SetTime(400); // might have been shortened in HandleTimer()
837 fSmallInc = ((TSBRepeatTimer*)fRepeat)->GetSmallInc();
838 }
839
841
842 fPos = TMath::Max(fPos, 0);
844
847
848 if (fGrabPointer) {
849 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
850 }
851 }
852 return kTRUE;
853}
854
855////////////////////////////////////////////////////////////////////////////////
856/// Handle mouse motion in a vertical scrollbar.
857
859{
860 if (fDragging) {
861 fX0 = event->fX - fXp;
862 fY0 = event->fY - fYp;
863
866 fSlider->Move(0, fY0);
868 fPos = (Int_t)pos;
869
870 fPos = TMath::Max(fPos, 0);
872
875 }
876 return kTRUE;
877}
878
879////////////////////////////////////////////////////////////////////////////////
880/// Set range of vertical scrollbar.
881
882void TGVScrollBar::SetRange(Int_t range, Int_t page_size)
883{
884 fRange = TMath::Max(range, 1);
885 fPsize = TMath::Max(page_size, 0);
886 fPos = TMath::Max(fPos, 0);
888
890 fRange, (UInt_t) 6);
892
894 (UInt_t)1);
895
897 fY0 = (Int_t)y0;
900
901 fSlider->Move(0, fY0);
904
905 // fPos = (fY0 - fgScrollBarWidth) * (fRange-fPsize) / fSliderRange;
906
907
912}
913
914////////////////////////////////////////////////////////////////////////////////
915/// Set logical slider position of vertical scrollbar.
916
918{
919 fPos = TMath::Max(pos, 0);
921
923 fY0 = (Int_t)y0;
926
927 fSlider->Move(0, fY0);
930
933}
934
935////////////////////////////////////////////////////////////////////////////////
936/// Save an horizontal scrollbar as a C++ statement(s) on output stream out.
937
938void TGHScrollBar::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
939{
941
942 out <<" TGHScrollBar *";
943 out << GetName() << " = new TGHScrollBar(" << fParent->GetName()
944 << "," << GetWidth() << "," << GetHeight();
945
947 if (!GetOptions()) {
948 out <<");" << std::endl;
949 } else {
950 out << "," << GetOptionString() <<");" << std::endl;
951 }
952 } else {
953 out << "," << GetOptionString() << ",ucolor);" << std::endl;
954 }
955 if (option && strstr(option, "keep_names"))
956 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
957
958 out << " " << GetName() <<"->SetRange(" << GetRange() << "," << GetPageSize() << ");" << std::endl;
959 out << " " << GetName() <<"->SetPosition(" << GetPosition() << ");" << std::endl;
960}
961
962////////////////////////////////////////////////////////////////////////////////
963/// Save an vertical scrollbar as a C++ statement(s) on output stream out.
964
965void TGVScrollBar::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
966{
968
969 out<<" TGVScrollBar *";
970 out << GetName() <<" = new TGVScrollBar("<< fParent->GetName()
971 << "," << GetWidth() << "," << GetHeight();
972
974
975 if (!GetOptions()) {
976 out <<");" << std::endl;
977 } else {
978 out << "," << GetOptionString() <<");" << std::endl;
979 }
980 } else {
981 out << "," << GetOptionString() << ",ucolor);" << std::endl;
982 }
983 if (option && strstr(option, "keep_names"))
984 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
985
986 out << " " << GetName() <<"->SetRange(" << GetRange() << "," << GetPageSize() << ");" << std::endl;
987 out << " " << GetName() <<"->SetPosition(" << GetPosition() << ");" << std::endl;
988}
@ kDefaultScrollBarWidth
Definition: GuiTypes.h:85
@ kButtonPress
Definition: GuiTypes.h:59
@ kEnterNotify
Definition: GuiTypes.h:60
@ kLeaveNotify
Definition: GuiTypes.h:60
const Mask_t kButtonPressMask
Definition: GuiTypes.h:160
const Mask_t kAnyModifier
Definition: GuiTypes.h:209
Handle_t Pixmap_t
Definition: GuiTypes.h:29
const Mask_t kPointerMotionMask
Definition: GuiTypes.h:162
const Handle_t kNone
Definition: GuiTypes.h:87
const Mask_t kLeaveWindowMask
Definition: GuiTypes.h:167
const Mask_t kButtonReleaseMask
Definition: GuiTypes.h:161
const Mask_t kEnterWindowMask
Definition: GuiTypes.h:166
ULong_t Pixel_t
Definition: GuiTypes.h:39
@ kButton4
Definition: GuiTypes.h:214
@ kButton5
Definition: GuiTypes.h:214
@ kButton3
Definition: GuiTypes.h:213
@ kButton1
Definition: GuiTypes.h:213
@ kAnyButton
Definition: GuiTypes.h:213
Handle_t Window_t
Definition: GuiTypes.h:28
#define h(i)
Definition: RSha256.hxx:106
static Int_t init()
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
unsigned long ULong_t
Definition: RtypesCore.h:51
long Long_t
Definition: RtypesCore.h:50
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:363
R__EXTERN TEnv * gEnv
Definition: TEnv.h:171
@ kButtonDown
Definition: TGButton.h:54
@ kButtonDisabled
Definition: TGButton.h:56
@ kButtonUp
Definition: TGButton.h:53
#define gClient
Definition: TGClient.h:166
@ kRaisedFrame
Definition: TGFrame.h:62
@ kSunkenFrame
Definition: TGFrame.h:61
@ kOwnBackground
Definition: TGFrame.h:69
R__EXTERN TSystem * gSystem
Definition: TSystem.h:540
#define gVirtualX
Definition: TVirtualX.h:345
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:98
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:135
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition: TGClient.cxx:308
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 the frame.
Definition: TGFrame.cxx:412
static const TGGC & GetBlackGC()
Get black graphics context.
Definition: TGFrame.cxx:717
UInt_t fOptions
Definition: TGFrame.h:141
UInt_t fHeight
Definition: TGFrame.h:135
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition: TGFrame.cxx:737
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
Definition: TGFrame.cxx:627
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:665
Int_t GetX() const
Definition: TGFrame.h:278
virtual UInt_t GetOptions() const
Definition: TGFrame.h:244
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition: TGFrame.cxx:2460
virtual void ChangeBackground(Pixel_t back)
Change frame background color.
Definition: TGFrame.cxx:275
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition: TGFrame.cxx:747
virtual void Move(Int_t x, Int_t y)
Move frame.
Definition: TGFrame.cxx:575
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
UInt_t fWidth
Definition: TGFrame.h:134
UInt_t GetHeight() const
Definition: TGFrame.h:272
Int_t GetY() const
Definition: TGFrame.h:279
static const TGGC & GetWhiteGC()
Get white graphics context.
Definition: TGFrame.cxx:727
UInt_t GetWidth() const
Definition: TGFrame.h:271
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition: TGFrame.cxx:2433
Pixel_t fBackground
Definition: TGFrame.h:142
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition: TGFrame.cxx:757
virtual void Layout()
Layout and move horizontal scrollbar components.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an horizontal scrollbar as a C++ statement(s) on output stream out.
TGHScrollBar(const TGWindow *p=0, UInt_t w=4, UInt_t h=2, UInt_t options=kHorizontalFrame, Pixel_t back=GetDefaultFrameBackground())
Create a horizontal scrollbar widget.
virtual Bool_t HandleButton(Event_t *event)
Handle a mouse button event in a horizontal scrolbar.
virtual void SetRange(Int_t range, Int_t page_size)
Set range of horizontal scrollbar.
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in a horizontal scrollbar.
virtual void SetPosition(Int_t pos)
Set logical slider position of horizontal scrollbar.
TGClient * fClient
Definition: TGObject.h:37
Handle_t GetId() const
Definition: TGObject.h:47
Handle_t fId
Definition: TGObject.h:36
const TGPicture * GetPicture(const char *name)
Get a picture from the picture pool.
Definition: TGPicture.cxx:80
Pixmap_t GetMask() const
Definition: TGPicture.h:66
const char * GetName() const
Returns name of object.
Definition: TGPicture.h:62
UInt_t GetHeight() const
Definition: TGPicture.h:64
void Draw(Option_t *="")
Default Draw method for all objects.
Definition: TGPicture.h:57
Pixmap_t GetPicture() const
Definition: TGPicture.h:65
UInt_t GetWidth() const
Definition: TGPicture.h:63
virtual Bool_t IsEnabled() const
Definition: TGScrollBar.h:73
virtual void DrawBorder()
Draw border around scollbar element.
virtual ~TGScrollBarElement()
destructor
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
const TGPicture * fPic
Definition: TGScrollBar.h:56
const TGPicture * fPicD
Definition: TGScrollBar.h:58
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).
const TGPicture * fPicN
Definition: TGScrollBar.h:57
TGScrollBarElement(const TGScrollBarElement &)
virtual void RangeChanged(Int_t range)
Definition: TGScrollBar.h:149
static Pixmap_t fgBckgndPixmap
Definition: TGScrollBar.h:108
TGScrollBar(const TGScrollBar &)
TTimer * fRepeat
Definition: TGScrollBar.h:102
Int_t fPsize
Definition: TGScrollBar.h:92
Bool_t IsAccelerated() const
Definition: TGScrollBar.h:141
static Pixmap_t GetBckgndPixmap()
Static method returning scrollbar background pixmap.
virtual Bool_t HandleButton(Event_t *event)=0
Bool_t fAccelerated
Definition: TGScrollBar.h:104
Int_t fSliderSize
Definition: TGScrollBar.h:94
static Int_t fgScrollBarWidth
Definition: TGScrollBar.h:109
Bool_t fDragging
Definition: TGScrollBar.h:89
virtual Int_t GetRange() const
Definition: TGScrollBar.h:134
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
const TGPicture * fTailPic
Definition: TGScrollBar.h:101
TGScrollBarElement * fSlider
Definition: TGScrollBar.h:99
virtual ~TGScrollBar()
Delete a scrollbar (either horizontal or vertical).
virtual void PageSizeChanged(Int_t range)
Definition: TGScrollBar.h:150
virtual Bool_t HandleTimer(TTimer *t)
Handle repeat timer for horizontal or vertical scrollbar.
virtual Int_t GetPageSize() const
Definition: TGScrollBar.h:133
virtual Int_t GetPosition() const
Definition: TGScrollBar.h:132
Window_t fSubw
Definition: TGScrollBar.h:103
static Int_t GetScrollBarWidth()
Static method returning the scrollbar width.
Int_t fSmallInc
Definition: TGScrollBar.h:96
Bool_t fGrabPointer
Definition: TGScrollBar.h:90
Int_t fPos
Definition: TGScrollBar.h:93
Pixel_t fBgndColor
Definition: TGScrollBar.h:105
TGScrollBarElement * fHead
Definition: TGScrollBar.h:97
Pixel_t fHighColor
Definition: TGScrollBar.h:106
virtual void ChangeBackground(Pixel_t back)
Change background color.
TGScrollBarElement * fTail
Definition: TGScrollBar.h:98
Int_t fRange
Definition: TGScrollBar.h:91
Int_t fSliderRange
Definition: TGScrollBar.h:95
virtual void PositionChanged(Int_t pos)
Definition: TGScrollBar.h:148
const TGPicture * fHeadPic
Definition: TGScrollBar.h:100
TGVScrollBar(const TGWindow *p=0, UInt_t w=2, UInt_t h=4, UInt_t options=kVerticalFrame, Pixel_t back=GetDefaultFrameBackground())
Create a vertical scrollbar.
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion in a vertical scrollbar.
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in vertical scrollbar.
virtual void SetPosition(Int_t pos)
Set logical slider position of vertical scrollbar.
virtual void Layout()
Layout and move vertical scrollbar components.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save an vertical scrollbar as a C++ statement(s) on output stream out.
virtual void SetRange(Int_t range, Int_t page_size)
Set range of vertical scrollbar.
const TGWindow * fMsgWindow
Definition: TGWidget.h:60
virtual void SetWindowName(const char *name=0)
Set window name.
Definition: TGWindow.cxx:118
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:221
virtual void SetEditDisabled(UInt_t on=kEditDisable)
Definition: TGWindow.h:117
const TGWindow * fParent
Definition: TGWindow.h:37
@ kEditDisableHeight
Definition: TGWindow.h:64
@ kEditDisableLayout
Definition: TGWindow.h:62
@ kEditDisableBtnEnable
Definition: TGWindow.h:66
@ kEditDisableWidth
Definition: TGWindow.h:65
@ kEditDisableGrab
Definition: TGWindow.h:61
@ kEditDisable
Definition: TGWindow.h:59
UInt_t fEditDisabled
Definition: TGWindow.h:41
virtual void SetBackgroundPixmap(Pixmap_t pixmap)
Definition: TGWindow.h:102
An abstract interface to image processing library.
Definition: TImage.h:29
virtual void SetImage(const Double_t *, UInt_t, UInt_t, TImagePalette *=0)
Definition: TImage.h:116
static TImage * Create()
Create an image.
Definition: TImage.cxx:36
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 FillRectangle(const char *=0, Int_t=0, Int_t=0, UInt_t=0, UInt_t=0)
Definition: TImage.h:192
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:443
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
Basic string class.
Definition: TString.h:131
const char * Data() const
Definition: TString.h:364
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition: TSystem.cxx:480
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
void Reset()
Reset the timer.
Definition: TTimer.cxx:157
void SetTime(Long_t milliSec)
Definition: TTimer.h:90
virtual Bool_t Notify()
Notify when timer times out.
Definition: TTimer.cxx:143
void Remove()
Definition: TTimer.h:85
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
static constexpr double ms
static constexpr double s
static constexpr double bar
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180
EGEventType fType
Definition: GuiTypes.h:174
Int_t fY
Definition: GuiTypes.h:177
Int_t fXRoot
Definition: GuiTypes.h:178
UInt_t fState
Definition: GuiTypes.h:180
Int_t fYRoot
Definition: GuiTypes.h:178
Int_t fX
Definition: GuiTypes.h:177
Long_t fUser[5]
Definition: GuiTypes.h:186
UInt_t fCode
Definition: GuiTypes.h:179