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/// \param p The parent window
308/// \param w The scrollbar width
309/// \param h The scrollbar height
310/// \param options A bitmask of options (\see EFrameType)
311/// \param back The background color
312/// \param headPicName Filename of the "head" picture (e.g. left arrow for a horizontal scrollbar)
313/// \param tailPicName Filename of the "tail" picture (e.g. right arrow for a horizontal scrollbar)
315 UInt_t options, Pixel_t back, const char *headPicName, const char *tailPicName) :
316 TGFrame(p, w, h, options | kOwnBackground, back),
317 fX0(0), fY0(0), fXp(0), fYp(0), fDragging(kFALSE), fGrabPointer(kTRUE),
318 fRange(0), fPsize(0), fPos(0), fSliderSize(0), fSliderRange(0),
319 fSmallInc(1), fHead(0), fTail(0), fSlider(0), fHeadPic(0),
320 fTailPic(0), fRepeat(0), fSubw()
321{
323
325 fHighColor = gClient->GetResourcePool()->GetHighLightColor();
326
327 fMsgWindow = p;
328 if (gClient->GetStyle() == 0)
332
333 fHeadPic = fClient->GetPictureOrEmpty(headPicName);
334 fTailPic = fClient->GetPictureOrEmpty(tailPicName);
335
342
345
348 fPos = 0;
349
350 fSliderSize = 50;
351 fSliderRange = 1;
352
357}
358
359////////////////////////////////////////////////////////////////////////////////
360/// Delete a scrollbar (either horizontal or vertical).
361
363{
364 delete fHead;
365 delete fTail;
366 delete fSlider;
369 if (fRepeat) { delete fRepeat; fRepeat = 0; }
370}
371
372////////////////////////////////////////////////////////////////////////////////
373/// Handle mouse crossing event.
374
376{
377 if (gClient->GetStyle() > 0) {
378 if (event->fType == kEnterNotify) {
380 } else {
382 }
383 if (event->fType == kLeaveNotify) {
385 }
389 fHead->DrawBorder();
390 fTail->DrawBorder();
392 }
393 return kTRUE;
394}
395
396////////////////////////////////////////////////////////////////////////////////
397/// Handle repeat timer for horizontal or vertical scrollbar. Every time
398/// timer times out we move slider.
399
401{
402 // shorten time out time to 50 milli seconds
403 t->SetTime(50);
404
405 Window_t dum1, dum2;
406 Event_t ev;
407
408 ev.fCode = kButton1;
409 ev.fType = kButtonPress;
410 ev.fUser[0] = fSubw;
411
412 if (IsAccelerated()) {
413 ++fSmallInc;
414 if (fSmallInc > 100) fSmallInc = 100;
415 }
416
417 gVirtualX->QueryPointer(fId, dum1, dum2, ev.fXRoot, ev.fYRoot, ev.fX, ev.fY,
418 ev.fState);
419
420 HandleButton(&ev);
421
422 return kTRUE;
423}
424
425////////////////////////////////////////////////////////////////////////////////
426/// Static method returning scrollbar background pixmap.
427
429{
430 static Bool_t init = kFALSE;
431 if (!init) {
432 fgBckgndPixmap = gClient->GetResourcePool()->GetCheckeredPixmap();
433 init = kTRUE;
434 }
435 return fgBckgndPixmap;
436}
437
438////////////////////////////////////////////////////////////////////////////////
439/// Static method returning the scrollbar width.
440
442{
443 return fgScrollBarWidth;
444}
445
446////////////////////////////////////////////////////////////////////////////////
447/// Change background color
448
450{
452 fHead->ChangeBackground(back);
453 fTail->ChangeBackground(back);
455}
456
457////////////////////////////////////////////////////////////////////////////////
458/// Create a horizontal scrollbar widget.
459
461 UInt_t options, ULong_t back) :
462 TGScrollBar(p, w, h, options, back, "arrow_left.xpm", "arrow_right.xpm")
463{
464 fRange = TMath::Max((Int_t) w - (fgScrollBarWidth << 1), 1);
465 fPsize = fRange >> 1;
467}
468
469////////////////////////////////////////////////////////////////////////////////
470/// Layout and move horizontal scrollbar components.
471
473{
474 // Should also recalculate the slider size and range, etc.
475 fHead->Move(0, 0);
479
480 if (fSlider->GetX() != fX0) {
481 fSlider->Move(fX0, 0);
484 }
485}
486
487////////////////////////////////////////////////////////////////////////////////
488/// Handle a mouse button event in a horizontal scrolbar.
489
491{
492 Int_t newpos;
493
494 if (event->fCode == kButton4) {
495 if (!fHead->IsEnabled()) {
496 return kFALSE;
497 }
498 //scroll left
499 newpos = fPos - fPsize;
500 if (newpos<0) newpos = 0;
501 SetPosition(newpos);
502 return kTRUE;
503 }
504 if (event->fCode == kButton5) {
505 if (!fTail->IsEnabled()) {
506 return kFALSE;
507 }
508 // scroll right
509 newpos = fPos + fPsize;
510 SetPosition(newpos);
511 return kTRUE;
512 }
513
514 if (event->fType == kButtonPress) {
515 if (event->fCode == kButton3) {
516 fX0 = event->fX - fSliderSize/2;
520 fPos = (Int_t)pos;
521
522 fPos = TMath::Max(fPos, 0);
524 fSlider->Move(fX0, 0);
525
528 return kTRUE;
529 }
530
531 // fUser[0] contains the subwindow (child) in which the event occured
532 // (see GX11Gui.cxx)
533 Window_t subw = (Window_t)event->fUser[0];
534
535 if (subw == fSlider->GetId()) {
536 fXp = event->fX - fX0;
537 fYp = event->fY - fY0;
539
540 } else {
541
542 if (!fRepeat)
543 fRepeat = new TSBRepeatTimer(this, 400, fSmallInc); // 500
544 fRepeat->Reset();
546 fSubw = subw;
547
548 if (subw == fHead->GetId()) {
549 //if (!fHead->IsEnabled()) {
550 // return kFALSE;
551 //}
553 fPos -= fSmallInc;
554 } else if (subw == fTail->GetId()) {
555 //if (!fTail->IsEnabled()) {
556 // return kFALSE;
557 // }
559 fPos += fSmallInc;
560 } else if (event->fX > fgScrollBarWidth && event->fX < fX0)
561 fPos -= fPsize;
562 else if (event->fX > fX0+fSliderSize && event->fX < (Int_t)fWidth-fgScrollBarWidth)
563 fPos += fPsize;
564
565 fPos = TMath::Max(fPos, 0);
567
569
572
573 fSlider->Move(fX0, 0);
574
577 }
578
579 // last argument kFALSE forces all specified events to this window
583 kTRUE, kFALSE);
584 } else {
587
588 if (fRepeat) {
589 fRepeat->Remove();
590 fRepeat->SetTime(400); // might have been shortened in HandleTimer()
591 fSmallInc = ((TSBRepeatTimer*)fRepeat)->GetSmallInc();
592 }
593
595
596 fPos = TMath::Max(fPos, 0);
598
601
602 if (fGrabPointer)
603 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
604 }
605 return kTRUE;
606}
607
608////////////////////////////////////////////////////////////////////////////////
609/// Handle mouse motion event in a horizontal scrollbar.
610
612{
613 if (fDragging) {
614 fX0 = event->fX - fXp;
615 fY0 = event->fY - fYp;
616
619 fSlider->Move(fX0, 0);
621 fPos = (Int_t)pos;
622
623 fPos = TMath::Max(fPos, 0);
625
628 }
629 return kTRUE;
630}
631
632////////////////////////////////////////////////////////////////////////////////
633/// Set range of horizontal scrollbar.
634
635void TGHScrollBar::SetRange(Int_t range, Int_t page_size)
636{
637 fRange = TMath::Max(range, 1);
638 fPsize = TMath::Max(page_size, 0);
639 fPos = TMath::Max(fPos, 0);
641
643 fRange, (UInt_t) 6);
645
647 (UInt_t) 1);
648
652
653 fSlider->Move(fX0, 0);
656
657 // fPos = (fX0 - fgScrollBarWidth) * (fRange-fPsize) / fSliderRange;
658
663}
664
665////////////////////////////////////////////////////////////////////////////////
666/// Set logical slider position of horizontal scrollbar.
667
669{
670 fPos = TMath::Max(pos, 0);
672
676
677 fSlider->Move(fX0, 0);
680
683}
684
685
686////////////////////////////////////////////////////////////////////////////////
687/// Create a vertical scrollbar.
688
690 UInt_t options, ULong_t back) :
691 TGScrollBar(p, w, h, options, back, "arrow_up.xpm", "arrow_down.xpm")
692{
693 fRange = TMath::Max((Int_t) h - (fgScrollBarWidth << 1), 1);
694 fPsize = fRange >> 1;
696}
697
698////////////////////////////////////////////////////////////////////////////////
699/// Layout and move vertical scrollbar components.
700
702{
703 // Should recalculate fSliderSize, fSliderRange, fX0, fY0, etc. too...
704 fHead->Move(0, 0);
708
709 if (fSlider->GetY() != fY0) {
710 fSlider->Move(0, fY0);
713 }
714}
715
716////////////////////////////////////////////////////////////////////////////////
717/// Handle mouse button event in vertical scrollbar.
718
720{
721 Int_t newpos;
722
723 if (event->fCode == kButton4) {
724 if (!fHead->IsEnabled()) {
725 return kFALSE;
726 }
727 //scroll up
728 newpos = fPos - fPsize;
729 if (newpos<0) newpos = 0;
730 SetPosition(newpos);
731 return kTRUE;
732 }
733 if (event->fCode == kButton5) {
734 if (!fTail->IsEnabled()) {
735 return kFALSE;
736 }
737
738 // scroll down
739 newpos = fPos + fPsize;
740 SetPosition(newpos);
741 return kTRUE;
742 }
743
744 if (event->fType == kButtonPress) {
745 if (event->fCode == kButton3) {
746 fY0 = event->fY - fSliderSize/2;
750 fPos = (Int_t)pos;
751
752 fPos = TMath::Max(fPos, 0);
754 fSlider->Move(0, fY0);
755
758 return kTRUE;
759 }
760
761 // fUser[0] contains the subwindow (child) in which the event occured
762 // (see GX11Gui.cxx)
763 Window_t subw = (Window_t)event->fUser[0];
764
765 if (subw == fSlider->GetId()) {
766 fXp = event->fX - fX0;
767 fYp = event->fY - fY0;
769
770 } else {
771
772 if (!fRepeat)
773 fRepeat = new TSBRepeatTimer(this, 400, fSmallInc); // 500
774 fRepeat->Reset();
776 fSubw = subw;
777
778 if (subw == fHead->GetId()) {
779 //if (!fHead->IsEnabled()) {
780 // return kFALSE;
781 // }
783 fPos -= fSmallInc;
784 } else if (subw == fTail->GetId()) {
785 //if (!fTail->IsEnabled()) {
786 // return kFALSE;
787 //}
789 fPos += fSmallInc;
790 } else if (event->fY > fgScrollBarWidth && event->fY < fY0)
791 fPos -= fPsize;
792 else if (event->fY > fY0+fSliderSize && event->fY < (Int_t)fHeight-fgScrollBarWidth)
793 fPos += fPsize;
794
795 fPos = TMath::Max(fPos, 0);
797
799 fY0 = (Int_t)y0;
800
803
804 fSlider->Move(0, fY0);
805
808 }
809
810 // last argument kFALSE forces all specified events to this window
814 kTRUE, kFALSE);
815 } else {
818
819 if (fRepeat) {
820 fRepeat->Remove();
821 fRepeat->SetTime(400); // might have been shortened in HandleTimer()
822 fSmallInc = ((TSBRepeatTimer*)fRepeat)->GetSmallInc();
823 }
824
826
827 fPos = TMath::Max(fPos, 0);
829
832
833 if (fGrabPointer) {
834 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
835 }
836 }
837 return kTRUE;
838}
839
840////////////////////////////////////////////////////////////////////////////////
841/// Handle mouse motion in a vertical scrollbar.
842
844{
845 if (fDragging) {
846 fX0 = event->fX - fXp;
847 fY0 = event->fY - fYp;
848
851 fSlider->Move(0, fY0);
853 fPos = (Int_t)pos;
854
855 fPos = TMath::Max(fPos, 0);
857
860 }
861 return kTRUE;
862}
863
864////////////////////////////////////////////////////////////////////////////////
865/// Set range of vertical scrollbar.
866
867void TGVScrollBar::SetRange(Int_t range, Int_t page_size)
868{
869 fRange = TMath::Max(range, 1);
870 fPsize = TMath::Max(page_size, 0);
871 fPos = TMath::Max(fPos, 0);
873
875 fRange, (UInt_t) 6);
877
879 (UInt_t)1);
880
882 fY0 = (Int_t)y0;
885
886 fSlider->Move(0, fY0);
889
890 // fPos = (fY0 - fgScrollBarWidth) * (fRange-fPsize) / fSliderRange;
891
892
897}
898
899////////////////////////////////////////////////////////////////////////////////
900/// Set logical slider position of vertical scrollbar.
901
903{
904 fPos = TMath::Max(pos, 0);
906
908 fY0 = (Int_t)y0;
911
912 fSlider->Move(0, fY0);
915
918}
919
920////////////////////////////////////////////////////////////////////////////////
921/// Save an horizontal scrollbar as a C++ statement(s) on output stream out.
922
923void TGHScrollBar::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
924{
926
927 out <<" TGHScrollBar *";
928 out << GetName() << " = new TGHScrollBar(" << fParent->GetName()
929 << "," << GetWidth() << "," << GetHeight();
930
932 if (!GetOptions()) {
933 out <<");" << std::endl;
934 } else {
935 out << "," << GetOptionString() <<");" << std::endl;
936 }
937 } else {
938 out << "," << GetOptionString() << ",ucolor);" << std::endl;
939 }
940 if (option && strstr(option, "keep_names"))
941 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
942
943 out << " " << GetName() <<"->SetRange(" << GetRange() << "," << GetPageSize() << ");" << std::endl;
944 out << " " << GetName() <<"->SetPosition(" << GetPosition() << ");" << std::endl;
945}
946
947////////////////////////////////////////////////////////////////////////////////
948/// Save an vertical scrollbar as a C++ statement(s) on output stream out.
949
950void TGVScrollBar::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
951{
953
954 out<<" TGVScrollBar *";
955 out << GetName() <<" = new TGVScrollBar("<< fParent->GetName()
956 << "," << GetWidth() << "," << GetHeight();
957
959
960 if (!GetOptions()) {
961 out <<");" << std::endl;
962 } else {
963 out << "," << GetOptionString() <<");" << std::endl;
964 }
965 } else {
966 out << "," << GetOptionString() << ",ucolor);" << std::endl;
967 }
968 if (option && strstr(option, "keep_names"))
969 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
970
971 out << " " << GetName() <<"->SetRange(" << GetRange() << "," << GetPageSize() << ");" << std::endl;
972 out << " " << GetName() <<"->SetPosition(" << GetPosition() << ");" << std::endl;
973}
@ 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:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:382
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
@ kButtonDown
Definition TGButton.h:54
@ kButtonDisabled
Definition TGButton.h:56
@ kButtonUp
Definition TGButton.h:53
#define gClient
Definition TGClient.h:157
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:561
#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 * GetPictureOrEmpty(const char *name)
Like TGPicturePool::GetPicture() but, instead of returning null when the picture is not found,...
Definition TGClient.cxx:297
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:381
TGPicturePool * GetPicturePool() const
Definition TGClient.h:126
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:317
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:83
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:542
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