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// //
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 "TVirtualX.h"
50
51#include <iostream>
52
53
56
61
62
63////////////////////////////////////////////////////////////////////////////////
64
65class TSBRepeatTimer : public TTimer {
66private:
67 TGScrollBar *fScrollBar; // scroll bar
68 Int_t fSmallInc; // step
69public:
70 TSBRepeatTimer(TGScrollBar *s, Long_t ms, Int_t inc) : TTimer(ms, kTRUE)
71 { fScrollBar = s; fSmallInc = inc; }
72
73 Bool_t Notify();
74 Int_t GetSmallInc() const { return fSmallInc; }
75};
76
77////////////////////////////////////////////////////////////////////////////////
78/// Notify when timer times out and reset the timer.
79
80Bool_t TSBRepeatTimer::Notify()
81{
82 fScrollBar->HandleTimer(this);
83 Reset();
84 return kFALSE;
85}
86
87////////////////////////////////////////////////////////////////////////////////
88/// Constructor.
89
91 UInt_t w, UInt_t h, UInt_t options, Pixel_t back) :
92 TGFrame(p, w, h, options | kOwnBackground, back)
93{
94 fPic = fPicN = pic;
96 fPicD = 0;
97 fStyle = 0;
98 if ((gClient->GetStyle() > 1) || (p && p->InheritsFrom("TGScrollBar")))
99 fStyle = gClient->GetStyle();
100
102 fHighColor = gClient->GetResourcePool()->GetHighLightColor();
104}
105
106////////////////////////////////////////////////////////////////////////////////
107/// destructor
108
110{
111 if (fPicD) {
113 }
114}
115
116////////////////////////////////////////////////////////////////////////////////
117/// Change state of scrollbar element (either up or down).
118
120{
121 if (state != fState) {
122 switch (state) {
123 case kButtonDown:
124 fOptions &= ~kRaisedFrame;
126 break;
127 case kButtonUp:
128 case kButtonDisabled:
129 fOptions &= ~kSunkenFrame;
131 break;
132 }
133 fState = state;
134 fClient->NeedRedraw(this);
135 }
136}
137
138////////////////////////////////////////////////////////////////////////////////
139/// Enable/Disable scroll bar button chaging the state.
140
142{
143 if (on) {
144 if (fState == kButtonUp) {
145 return;
146 }
148 fPic = fPicN;
149 } else {
150 if (fState == kButtonDisabled) {
151 return;
152 }
154
155 if (!fPicD) {
156 TImage *img = TImage::Create();
157 if (!img) return;
158 TImage *img2 = TImage::Create();
159 if (!img2) {
160 if (img) delete img;
161 return;
162 }
163 TString back = gEnv->GetValue("Gui.BackgroundColor", "#c0c0c0");
164 img2->FillRectangle(back.Data(), 0, 0, fPic->GetWidth(), fPic->GetHeight());
166 Pixmap_t mask = img->GetMask();
167 img2->Merge(img, "overlay");
168
169 TString name = "disbl_";
170 name += fPic->GetName();
171 fPicD = fClient->GetPicturePool()->GetPicture(name.Data(), img2->GetPixmap(),
172 mask);
173 delete img;
174 delete img2;
175 }
176 fPic = fPicD;
177 }
178 fClient->NeedRedraw(this);
179}
180
181////////////////////////////////////////////////////////////////////////////////
182/// Draw border around scollbar element.
183
185{
186 switch (fOptions & (kSunkenFrame | kRaisedFrame)) {
187 case kSunkenFrame: // pressed
188 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, 0, fWidth-2, 0);
189 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, 0, 0, fHeight-2);
190 gVirtualX->DrawLine(fId, GetShadowGC()(), 1, 1, fWidth-3, 1);
191 gVirtualX->DrawLine(fId, GetShadowGC()(), 1, 1, 1, fHeight-3);
192
193 gVirtualX->DrawLine(fId, GetWhiteGC()(), 0, fHeight-1, fWidth-1, fHeight-1);
194 gVirtualX->DrawLine(fId, GetWhiteGC()(), fWidth-1, fHeight-1, fWidth-1, 1);
195 gVirtualX->DrawLine(fId, GetBckgndGC()(), 1, fHeight-2, fWidth-2, fHeight-2);
196 gVirtualX->DrawLine(fId, GetBckgndGC()(), fWidth-2, fHeight-2, fWidth-2, 2);
197
198 if (fPic) {
199 int x = (fWidth - fPic->GetWidth()) >> 1;
200 int y = (fHeight - fPic->GetHeight()) >> 1;
201 fPic->Draw(fId, GetBckgndGC()(), x+1, y+1); // 3, 3
202 }
203 break;
204
205 case kRaisedFrame: // normal
206 case kButtonDisabled:
207 if (fStyle > 0) {
208 // new modern (flat) version
209 if (fBackground == fHighColor) {
210 gVirtualX->DrawRectangle(fId, GetShadowGC()(), 0, 0, fWidth-1, fHeight-1);
211 }
212 else {
213 if (fPic == 0)
214 gVirtualX->DrawRectangle(fId, GetShadowGC()(), 0, 0, fWidth-1, fHeight-1);
215 else
216 gVirtualX->DrawRectangle(fId, GetBckgndGC()(), 0, 0, fWidth-1, fHeight-1);
217 }
218 if (fParent && fParent->InheritsFrom("TGHScrollBar")) {
219 if (fWidth > 20) {
220 gVirtualX->DrawLine(fId, GetShadowGC()(), (fWidth/2)-3, 4, (fWidth/2)-3, fHeight-5);
221 gVirtualX->DrawLine(fId, GetShadowGC()(), (fWidth/2), 4, (fWidth/2), fHeight-5);
222 gVirtualX->DrawLine(fId, GetShadowGC()(), (fWidth/2)+3, 4, (fWidth/2)+3, fHeight-5);
223 }
224 }
225 else if (fParent && fParent->InheritsFrom("TGVScrollBar")) {
226 if (fHeight > 20) {
227 gVirtualX->DrawLine(fId, GetShadowGC()(), 4, (fHeight/2)-3, fWidth-5, (fHeight/2)-3);
228 gVirtualX->DrawLine(fId, GetShadowGC()(), 4, (fHeight/2) , fWidth-5, (fHeight/2));
229 gVirtualX->DrawLine(fId, GetShadowGC()(), 4, (fHeight/2)+3, fWidth-5, (fHeight/2)+3);
230 }
231 }
232 else { // not used in a scroll bar (e.g. in a combo box)
233 gVirtualX->DrawRectangle(fId, GetShadowGC()(), 0, 0, fWidth-1, fHeight-1);
234 }
235 }
236 else {
237 gVirtualX->DrawLine(fId, GetBckgndGC()(), 0, 0, fWidth-2, 0);
238 gVirtualX->DrawLine(fId, GetBckgndGC()(), 0, 0, 0, fHeight-2);
239 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 1, fWidth-3, 1);
240 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 1, 1, fHeight-3);
241
242 gVirtualX->DrawLine(fId, GetShadowGC()(), 1, fHeight-2, fWidth-2, fHeight-2);
243 gVirtualX->DrawLine(fId, GetShadowGC()(), fWidth-2, fHeight-2, fWidth-2, 1);
244 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, fHeight-1, fWidth-1, fHeight-1);
245 gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth-1, fHeight-1, fWidth-1, 0);
246 }
247 if (fPic) {
248 int x = (fWidth - fPic->GetWidth()) >> 1;
249 int y = (fHeight - fPic->GetHeight()) >> 1;
250 fPic->Draw(fId, GetBckgndGC()(), x, y); // 2, 2
251 }
252 break;
253
254 default:
255 break;
256 }
257}
258
259////////////////////////////////////////////////////////////////////////////////
260/// Handle mouse crossing event.
261
263{
264 if (fStyle > 0) {
265 TGScrollBarElement *el = 0;
266 TGScrollBar *bar = 0;
267 if ((event->fType == kEnterNotify) && (fState != kButtonDisabled)) {
269 } else {
271 }
272 if (event->fType == kLeaveNotify) {
274 }
275 gVirtualX->SetWindowBackground(fId, fBgndColor);
277 DrawBorder();
278 if (fParent && fParent->InheritsFrom("TGScrollBar")) {
279 bar = (TGScrollBar *)fParent;
280 if ((el = bar->GetHead()) != this) {
282 el->DrawBorder();
283 }
284 if ((el = bar->GetTail()) != this) {
286 el->DrawBorder();
287 }
288 if ((el = bar->GetSlider()) != this) {
290 el->DrawBorder();
291 }
292 }
293 }
294 return kTRUE;
295}
296
297////////////////////////////////////////////////////////////////////////////////
298/// Constructor.
299
301 UInt_t options, Pixel_t back) :
302 TGFrame(p, w, h, options | kOwnBackground, back),
303 fX0(0), fY0(0), fXp(0), fYp(0), fDragging(kFALSE), fGrabPointer(kTRUE),
304 fRange(0), fPsize(0), fPos(0), fSliderSize(0), fSliderRange(0),
305 fSmallInc(1), fHead(0), fTail(0), fSlider(0), fHeadPic(0),
306 fTailPic(0), fRepeat(0), fSubw()
307{
309
311 fHighColor = gClient->GetResourcePool()->GetHighLightColor();
312
313 fMsgWindow = p;
314 if (gClient->GetStyle() == 0)
318}
319
320////////////////////////////////////////////////////////////////////////////////
321/// Delete a scrollbar (either horizontal or vertical).
322
324{
325 delete fHead;
326 delete fTail;
327 delete fSlider;
330 if (fRepeat) { delete fRepeat; fRepeat = 0; }
331}
332
333////////////////////////////////////////////////////////////////////////////////
334/// Handle mouse crossing event.
335
337{
338 if (gClient->GetStyle() > 0) {
339 if (event->fType == kEnterNotify) {
341 } else {
343 }
344 if (event->fType == kLeaveNotify) {
346 }
350 fHead->DrawBorder();
351 fTail->DrawBorder();
353 }
354 return kTRUE;
355}
356
357////////////////////////////////////////////////////////////////////////////////
358/// Handle repeat timer for horizontal or vertical scrollbar. Every time
359/// timer times out we move slider.
360
362{
363 // shorten time out time to 50 milli seconds
364 t->SetTime(50);
365
366 Window_t dum1, dum2;
367 Event_t ev;
368
369 ev.fCode = kButton1;
370 ev.fType = kButtonPress;
371 ev.fUser[0] = fSubw;
372
373 if (IsAccelerated()) {
374 ++fSmallInc;
375 if (fSmallInc > 100) fSmallInc = 100;
376 }
377
378 gVirtualX->QueryPointer(fId, dum1, dum2, ev.fXRoot, ev.fYRoot, ev.fX, ev.fY,
379 ev.fState);
380
381 HandleButton(&ev);
382
383 return kTRUE;
384}
385
386////////////////////////////////////////////////////////////////////////////////
387/// Static method returning scrollbar background pixmap.
388
390{
391 static Bool_t init = kFALSE;
392 if (!init) {
393 fgBckgndPixmap = gClient->GetResourcePool()->GetCheckeredPixmap();
394 init = kTRUE;
395 }
396 return fgBckgndPixmap;
397}
398
399////////////////////////////////////////////////////////////////////////////////
400/// Static method returning the scrollbar width.
401
403{
404 return fgScrollBarWidth;
405}
406
407////////////////////////////////////////////////////////////////////////////////
408/// Change background color
409
411{
413 fHead->ChangeBackground(back);
414 fTail->ChangeBackground(back);
416}
417
418////////////////////////////////////////////////////////////////////////////////
419/// Create a horizontal scrollbar widget.
420
422 UInt_t options, ULong_t back) :
423 TGScrollBar(p, w, h, options, back)
424{
425 fHeadPic = fClient->GetPicture("arrow_left.xpm");
426 fTailPic = fClient->GetPicture("arrow_right.xpm");
427
428 if (!fHeadPic || !fTailPic) {
429 Error("TGHScrollBar", "arrow_*.xpm not found");
430 return;
431 }
438
441
444 fPos = 0;
445
446 fRange = TMath::Max((Int_t) w - (fgScrollBarWidth << 1), 1);
447 fPsize = fRange >> 1;
448
449 fSliderSize = 50;
450 fSliderRange = 1;
451
456}
457
458////////////////////////////////////////////////////////////////////////////////
459/// Layout and move horizontal scrollbar components.
460
462{
463 // Should also recalculate the slider size and range, etc.
464 fHead->Move(0, 0);
468
469 if (fSlider->GetX() != fX0) {
470 fSlider->Move(fX0, 0);
473 }
474}
475
476////////////////////////////////////////////////////////////////////////////////
477/// Handle a mouse button event in a horizontal scrolbar.
478
480{
481 Int_t newpos;
482
483 if (event->fCode == kButton4) {
484 if (!fHead->IsEnabled()) {
485 return kFALSE;
486 }
487 //scroll left
488 newpos = fPos - fPsize;
489 if (newpos<0) newpos = 0;
490 SetPosition(newpos);
491 return kTRUE;
492 }
493 if (event->fCode == kButton5) {
494 if (!fTail->IsEnabled()) {
495 return kFALSE;
496 }
497 // scroll right
498 newpos = fPos + fPsize;
499 SetPosition(newpos);
500 return kTRUE;
501 }
502
503 if (event->fType == kButtonPress) {
504 if (event->fCode == kButton3) {
505 fX0 = event->fX - fSliderSize/2;
509 fPos = (Int_t)pos;
510
511 fPos = TMath::Max(fPos, 0);
513 fSlider->Move(fX0, 0);
514
517 return kTRUE;
518 }
519
520 // fUser[0] contains the subwindow (child) in which the event occured
521 // (see GX11Gui.cxx)
522 Window_t subw = (Window_t)event->fUser[0];
523
524 if (subw == fSlider->GetId()) {
525 fXp = event->fX - fX0;
526 fYp = event->fY - fY0;
528
529 } else {
530
531 if (!fRepeat)
532 fRepeat = new TSBRepeatTimer(this, 400, fSmallInc); // 500
533 fRepeat->Reset();
535 fSubw = subw;
536
537 if (subw == fHead->GetId()) {
538 //if (!fHead->IsEnabled()) {
539 // return kFALSE;
540 //}
542 fPos -= fSmallInc;
543 } else if (subw == fTail->GetId()) {
544 //if (!fTail->IsEnabled()) {
545 // return kFALSE;
546 // }
548 fPos += fSmallInc;
549 } else if (event->fX > fgScrollBarWidth && event->fX < fX0)
550 fPos -= fPsize;
551 else if (event->fX > fX0+fSliderSize && event->fX < (Int_t)fWidth-fgScrollBarWidth)
552 fPos += fPsize;
553
554 fPos = TMath::Max(fPos, 0);
556
558
561
562 fSlider->Move(fX0, 0);
563
566 }
567
568 // last argument kFALSE forces all specified events to this window
572 kTRUE, kFALSE);
573 } else {
576
577 if (fRepeat) {
578 fRepeat->Remove();
579 fRepeat->SetTime(400); // might have been shortened in HandleTimer()
580 fSmallInc = ((TSBRepeatTimer*)fRepeat)->GetSmallInc();
581 }
582
584
585 fPos = TMath::Max(fPos, 0);
587
590
591 if (fGrabPointer)
592 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
593 }
594 return kTRUE;
595}
596
597////////////////////////////////////////////////////////////////////////////////
598/// Handle mouse motion event in a horizontal scrollbar.
599
601{
602 if (fDragging) {
603 fX0 = event->fX - fXp;
604 fY0 = event->fY - fYp;
605
608 fSlider->Move(fX0, 0);
610 fPos = (Int_t)pos;
611
612 fPos = TMath::Max(fPos, 0);
614
617 }
618 return kTRUE;
619}
620
621////////////////////////////////////////////////////////////////////////////////
622/// Set range of horizontal scrollbar.
623
624void TGHScrollBar::SetRange(Int_t range, Int_t page_size)
625{
626 fRange = TMath::Max(range, 1);
627 fPsize = TMath::Max(page_size, 0);
628 fPos = TMath::Max(fPos, 0);
630
632 fRange, (UInt_t) 6);
634
636 (UInt_t) 1);
637
641
642 fSlider->Move(fX0, 0);
645
646 // fPos = (fX0 - fgScrollBarWidth) * (fRange-fPsize) / fSliderRange;
647
652}
653
654////////////////////////////////////////////////////////////////////////////////
655/// Set logical slider position of horizontal scrollbar.
656
658{
659 fPos = TMath::Max(pos, 0);
661
665
666 fSlider->Move(fX0, 0);
669
672}
673
674
675////////////////////////////////////////////////////////////////////////////////
676/// Create a vertical scrollbar.
677
679 UInt_t options, ULong_t back) :
680 TGScrollBar(p, w, h, options, back)
681{
682 fHeadPic = fClient->GetPicture("arrow_up.xpm");
683 fTailPic = fClient->GetPicture("arrow_down.xpm");
684
685 if (!fHeadPic || !fTailPic) {
686 Error("TGVScrollBar", "arrow_*.xpm not found");
687 return;
688 }
695
698
701 fPos = 0;
702
703 fRange = TMath::Max((Int_t) h - (fgScrollBarWidth << 1), 1);
704 fPsize = fRange >> 1;
705
706 fSliderSize = 50;
707 fSliderRange = 1;
708
713}
714
715////////////////////////////////////////////////////////////////////////////////
716/// Layout and move vertical scrollbar components.
717
719{
720 // Should recalculate fSliderSize, fSliderRange, fX0, fY0, etc. too...
721 fHead->Move(0, 0);
725
726 if (fSlider->GetY() != fY0) {
727 fSlider->Move(0, fY0);
730 }
731}
732
733////////////////////////////////////////////////////////////////////////////////
734/// Handle mouse button event in vertical scrollbar.
735
737{
738 Int_t newpos;
739
740 if (event->fCode == kButton4) {
741 if (!fHead->IsEnabled()) {
742 return kFALSE;
743 }
744 //scroll up
745 newpos = fPos - fPsize;
746 if (newpos<0) newpos = 0;
747 SetPosition(newpos);
748 return kTRUE;
749 }
750 if (event->fCode == kButton5) {
751 if (!fTail->IsEnabled()) {
752 return kFALSE;
753 }
754
755 // scroll down
756 newpos = fPos + fPsize;
757 SetPosition(newpos);
758 return kTRUE;
759 }
760
761 if (event->fType == kButtonPress) {
762 if (event->fCode == kButton3) {
763 fY0 = event->fY - fSliderSize/2;
767 fPos = (Int_t)pos;
768
769 fPos = TMath::Max(fPos, 0);
771 fSlider->Move(0, fY0);
772
775 return kTRUE;
776 }
777
778 // fUser[0] contains the subwindow (child) in which the event occured
779 // (see GX11Gui.cxx)
780 Window_t subw = (Window_t)event->fUser[0];
781
782 if (subw == fSlider->GetId()) {
783 fXp = event->fX - fX0;
784 fYp = event->fY - fY0;
786
787 } else {
788
789 if (!fRepeat)
790 fRepeat = new TSBRepeatTimer(this, 400, fSmallInc); // 500
791 fRepeat->Reset();
793 fSubw = subw;
794
795 if (subw == fHead->GetId()) {
796 //if (!fHead->IsEnabled()) {
797 // return kFALSE;
798 // }
800 fPos -= fSmallInc;
801 } else if (subw == fTail->GetId()) {
802 //if (!fTail->IsEnabled()) {
803 // return kFALSE;
804 //}
806 fPos += fSmallInc;
807 } else if (event->fY > fgScrollBarWidth && event->fY < fY0)
808 fPos -= fPsize;
809 else if (event->fY > fY0+fSliderSize && event->fY < (Int_t)fHeight-fgScrollBarWidth)
810 fPos += fPsize;
811
812 fPos = TMath::Max(fPos, 0);
814
816 fY0 = (Int_t)y0;
817
820
821 fSlider->Move(0, fY0);
822
825 }
826
827 // last argument kFALSE forces all specified events to this window
831 kTRUE, kFALSE);
832 } else {
835
836 if (fRepeat) {
837 fRepeat->Remove();
838 fRepeat->SetTime(400); // might have been shortened in HandleTimer()
839 fSmallInc = ((TSBRepeatTimer*)fRepeat)->GetSmallInc();
840 }
841
843
844 fPos = TMath::Max(fPos, 0);
846
849
850 if (fGrabPointer) {
851 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
852 }
853 }
854 return kTRUE;
855}
856
857////////////////////////////////////////////////////////////////////////////////
858/// Handle mouse motion in a vertical scrollbar.
859
861{
862 if (fDragging) {
863 fX0 = event->fX - fXp;
864 fY0 = event->fY - fYp;
865
868 fSlider->Move(0, fY0);
870 fPos = (Int_t)pos;
871
872 fPos = TMath::Max(fPos, 0);
874
877 }
878 return kTRUE;
879}
880
881////////////////////////////////////////////////////////////////////////////////
882/// Set range of vertical scrollbar.
883
884void TGVScrollBar::SetRange(Int_t range, Int_t page_size)
885{
886 fRange = TMath::Max(range, 1);
887 fPsize = TMath::Max(page_size, 0);
888 fPos = TMath::Max(fPos, 0);
890
892 fRange, (UInt_t) 6);
894
896 (UInt_t)1);
897
899 fY0 = (Int_t)y0;
902
903 fSlider->Move(0, fY0);
906
907 // fPos = (fY0 - fgScrollBarWidth) * (fRange-fPsize) / fSliderRange;
908
909
914}
915
916////////////////////////////////////////////////////////////////////////////////
917/// Set logical slider position of vertical scrollbar.
918
920{
921 fPos = TMath::Max(pos, 0);
923
925 fY0 = (Int_t)y0;
928
929 fSlider->Move(0, fY0);
932
935}
936
937////////////////////////////////////////////////////////////////////////////////
938/// Save an horizontal scrollbar as a C++ statement(s) on output stream out.
939
940void TGHScrollBar::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
941{
943
944 out <<" TGHScrollBar *";
945 out << GetName() << " = new TGHScrollBar(" << fParent->GetName()
946 << "," << GetWidth() << "," << GetHeight();
947
949 if (!GetOptions()) {
950 out <<");" << std::endl;
951 } else {
952 out << "," << GetOptionString() <<");" << std::endl;
953 }
954 } else {
955 out << "," << GetOptionString() << ",ucolor);" << std::endl;
956 }
957 if (option && strstr(option, "keep_names"))
958 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
959
960 out << " " << GetName() <<"->SetRange(" << GetRange() << "," << GetPageSize() << ");" << std::endl;
961 out << " " << GetName() <<"->SetPosition(" << GetPosition() << ");" << std::endl;
962}
963
964////////////////////////////////////////////////////////////////////////////////
965/// Save an vertical scrollbar as a C++ statement(s) on output stream out.
966
967void TGVScrollBar::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
968{
970
971 out<<" TGVScrollBar *";
972 out << GetName() <<" = new TGVScrollBar("<< fParent->GetName()
973 << "," << GetWidth() << "," << GetHeight();
974
976
977 if (!GetOptions()) {
978 out <<");" << std::endl;
979 } else {
980 out << "," << GetOptionString() <<");" << std::endl;
981 }
982 } else {
983 out << "," << GetOptionString() << ",ucolor);" << std::endl;
984 }
985 if (option && strstr(option, "keep_names"))
986 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
987
988 out << " " << GetName() <<"->SetRange(" << GetRange() << "," << GetPageSize() << ");" << std::endl;
989 out << " " << GetName() <<"->SetPosition(" << GetPosition() << ");" << std::endl;
990}
@ kButtonPress
Definition GuiTypes.h:60
@ kEnterNotify
Definition GuiTypes.h:61
@ kLeaveNotify
Definition GuiTypes.h:61
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
const Mask_t kAnyModifier
Definition GuiTypes.h:210
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:30
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
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
#define h(i)
Definition RSha256.hxx:106
int Int_t
Definition RtypesCore.h:45
const Bool_t kFALSE
Definition RtypesCore.h:92
unsigned long ULong_t
Definition RtypesCore.h:55
long Long_t
Definition RtypesCore.h:54
bool Bool_t
Definition RtypesCore.h:63
const Bool_t kTRUE
Definition RtypesCore.h:91
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:364
R__EXTERN TEnv * gEnv
Definition TEnv.h:171
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:187
@ kButtonDown
Definition TGButton.h:54
@ kButtonDisabled
Definition TGButton.h:56
@ kButtonUp
Definition TGButton.h:53
#define gClient
Definition TGClient.h:166
char name[80]
Definition TGX11.cxx:110
R__EXTERN TSystem * gSystem
Definition TSystem.h:559
#define gVirtualX
Definition TVirtualX.h:338
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:288
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:371
TGPicturePool * GetPicturePool() const
Definition TGClient.h:135
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:307
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:324
virtual void DoRedraw()
Redraw the frame.
Definition TGFrame.cxx:415
static const TGGC & GetBlackGC()
Get black graphics context.
Definition TGFrame.cxx:720
UInt_t fOptions
Definition TGFrame.h:118
UInt_t fHeight
Definition TGFrame.h:112
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition TGFrame.cxx:740
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
Definition TGFrame.cxx:630
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:668
Int_t GetX() const
Definition TGFrame.h:255
virtual UInt_t GetOptions() const
Definition TGFrame.h:221
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition TGFrame.cxx:2465
virtual void ChangeBackground(Pixel_t back)
Change frame background color.
Definition TGFrame.cxx:278
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:750
virtual void Move(Int_t x, Int_t y)
Move frame.
Definition TGFrame.cxx:578
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:590
UInt_t fWidth
Definition TGFrame.h:111
UInt_t GetHeight() const
Definition TGFrame.h:249
Int_t GetY() const
Definition TGFrame.h:256
static const TGGC & GetWhiteGC()
Get white graphics context.
Definition TGFrame.cxx:730
UInt_t GetWidth() const
Definition TGFrame.h:248
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition TGFrame.cxx:2438
Pixel_t fBackground
Definition TGFrame.h:119
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition TGFrame.cxx:760
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.
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.
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.
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 &)=delete
virtual void RangeChanged(Int_t range)
static Pixmap_t fgBckgndPixmap
TTimer * fRepeat
TGScrollBarElement * GetTail() const
Bool_t IsAccelerated() const
static Pixmap_t GetBckgndPixmap()
Static method returning scrollbar background pixmap.
virtual Bool_t HandleButton(Event_t *event)=0
Bool_t fAccelerated
Int_t fSliderSize
Definition TGScrollBar.h:94
static Int_t fgScrollBarWidth
Bool_t fDragging
Definition TGScrollBar.h:89
virtual Int_t GetRange() const
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
const TGPicture * fTailPic
TGScrollBarElement * GetSlider() const
TGScrollBarElement * fSlider
Definition TGScrollBar.h:99
virtual ~TGScrollBar()
Delete a scrollbar (either horizontal or vertical).
TGScrollBarElement * GetHead() const
virtual void PageSizeChanged(Int_t range)
virtual Bool_t HandleTimer(TTimer *t)
Handle repeat timer for horizontal or vertical scrollbar.
virtual Int_t GetPageSize() const
virtual Int_t GetPosition() const
Window_t fSubw
static Int_t GetScrollBarWidth()
Static method returning the scrollbar width.
Int_t fSmallInc
Definition TGScrollBar.h:96
Bool_t fGrabPointer
Definition TGScrollBar.h:90
Pixel_t fBgndColor
TGScrollBarElement * fHead
Definition TGScrollBar.h:97
Pixel_t fHighColor
virtual void ChangeBackground(Pixel_t back)
Change background color.
TGScrollBar(const TGScrollBar &)=delete
TGScrollBarElement * fTail
Definition TGScrollBar.h:98
Int_t fSliderRange
Definition TGScrollBar.h:95
virtual void PositionChanged(Int_t pos)
const TGPicture * fHeadPic
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.
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:58
virtual void SetWindowName(const char *name=0)
Set window name.
Definition TGWindow.cxx:128
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:335
virtual void SetBackgroundPixmap(Pixmap_t pixmap)
set background pixmap
Definition TGWindow.cxx:247
virtual void SetEditDisabled(UInt_t on=kEditDisable)
Definition TGWindow.h:114
const TGWindow * fParent
Definition TGWindow.h:36
@ kEditDisableHeight
Definition TGWindow.h:63
@ kEditDisableLayout
Definition TGWindow.h:61
@ kEditDisableBtnEnable
Definition TGWindow.h:65
@ kEditDisableWidth
Definition TGWindow.h:64
@ kEditDisableGrab
Definition TGWindow.h:60
@ kEditDisable
Definition TGWindow.h:58
UInt_t fEditDisabled
Definition TGWindow.h:40
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: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 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:445
Basic string class.
Definition TString.h:136
const char * Data() const
Definition TString.h:369
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition TSystem.cxx:472
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
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
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
Long_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
UInt_t fCode
key or button code
Definition GuiTypes.h:180