Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGListBox.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 12/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 TGListBox
25 \ingroup guiwidgets
26
27A listbox is a box, possibly with scrollbar, containing entries.
28Currently entries are simple text strings (TGTextLBEntry).
29A TGListBox looks a lot like a TGCanvas. It has a TGViewPort
30containing a TGLBContainer which contains the entries and it also
31has a vertical scrollbar which becomes visible if there are more
32items than fit in the visible part of the container.
33
34The TGListBox is user callable. The other classes are service
35classes of the listbox.
36
37A listbox contains a container frame which is viewed through a
38viewport. If the container is larger than the viewport than a
39vertical scrollbar is added.
40
41Selecting an item in the listbox will generate the event:
42 - kC_COMMAND, kCM_LISTBOX, listbox id, item id.
43
44\class TGLBEntry
45\ingroup guiwidgets
46
47Basic listbox entries.
48Listbox entries are created by a TGListBox and not by the user.
49
50\class TGTextLBEntry
51\ingroup guiwidgets
52
53Text string listbox entries.
54A TGTextLBEntry is for TGListBox internal use.
55
56\class TGLineLBEntry
57\ingroup guiwidgets
58
59Line style and width listbox entries.
60Line example and width number
61
62\class TGIconLBEntry
63\ingroup guiwidgets
64
65Icon + text listbox entry.
66
67\class TGLBContainer
68\ingroup guiwidgets
69
70A Composite frame that contains a list of TGLBEnties.
71A TGLBContainer is for TGListBox internal use.
72
73*/
74
75
76#include "TGPicture.h"
77#include "TGListBox.h"
78#include "TGResourcePool.h"
79#include "TSystem.h"
80#include "TMath.h"
81#include "TVirtualX.h"
82
83#include <cstdlib>
84#include <iostream>
85
86
89
90
91////////////////////////////////////////////////////////////////////////////////
92/// Base class entry constructor.
93
94TGLBEntry::TGLBEntry(const TGWindow *p, Int_t id, UInt_t options, Pixel_t back) :
95 TGFrame(p, 10, 10, options | kOwnBackground, back)
96{
98 fEntryId = id;
99 fBkcolor = back;
101
103}
104
105////////////////////////////////////////////////////////////////////////////////
106/// Toggle active state of listbox entry.
107
109{
110 if (fActive == a) return;
111 fActive = a;
112 DoRedraw();
113}
114
115////////////////////////////////////////////////////////////////////////////////
116/// Toggle active state of listbox entry.
117
119{
120 fActive = !fActive;
121 DoRedraw();
122}
123
124
125////////////////////////////////////////////////////////////////////////////////
126/// Create a text listbox entry. The TGString is adopted.
127
129 GContext_t norm, FontStruct_t font, UInt_t options, Pixel_t back) :
130 TGLBEntry(p, id, options, back)
131{
132 fText = s;
134 fFontStruct = font;
135 fNormGC = norm;
136 fTWidth = 0;
137
139
140 if (fText) fTWidth = gVirtualX->TextWidth(fFontStruct, fText->GetString(), fText->GetLength());
141 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
143 Resize(fTWidth, fTHeight + 1);
146}
147
148////////////////////////////////////////////////////////////////////////////////
149/// Delete text listbox entry.
150
152{
153 if (fText) delete fText;
154}
155
156////////////////////////////////////////////////////////////////////////////////
157/// Draw text listbox entry on window/pixmap.
158
160{
162
163 y += (fHeight - fTHeight) >> 1;
164
165 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
166
167 if (fActive) {
169 gVirtualX->FillRectangle(id,fNormGC, x, y, fWidth, fHeight);
170 gVirtualX->SetForeground(fNormGC, fClient->GetResourcePool()->GetSelectedFgndColor());
171 fText->Draw(id, fNormGC, x + 3, y + max_ascent);
172 } else {
173 gVirtualX->SetForeground(fNormGC, fBkcolor);
174 gVirtualX->FillRectangle(id, fNormGC, x, y, fWidth, fHeight);
175 gVirtualX->SetForeground(fNormGC, GetForeground());
176 fText->Draw(id, fNormGC, x + 3, y + max_ascent);
177 }
178}
179
180////////////////////////////////////////////////////////////////////////////////
181/// Redraw text listbox entry.
182
184{
185 if (fId) DrawCopy(fId, 0, 0);
186}
187
188////////////////////////////////////////////////////////////////////////////////
189/// Set or change text in text entry.
190
192{
193 if (fText) delete fText;
194 fText = new_text;
196
199 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
201
202 Resize(fTWidth + 3, fTHeight + 1);
203
204 DoRedraw();
205}
206
207////////////////////////////////////////////////////////////////////////////////
208/// Return default font structure in use for a text listbox entry.
209
211{
212 if (!fgDefaultFont)
213 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
214 return fgDefaultFont->GetFontStruct();
215}
216
217////////////////////////////////////////////////////////////////////////////////
218/// Return default graphics context in use for a text listbox entry.
219
221{
222 if (!fgDefaultGC)
223 fgDefaultGC = new TGGC(*gClient->GetResourcePool()->GetFrameGC());
224 return *fgDefaultGC;
225}
226
227
228////////////////////////////////////////////////////////////////////////////////
229/// Create the line style listbox entry.
230
231TGLineLBEntry::TGLineLBEntry(const TGWindow *p, Int_t id, const char *str,
232 UInt_t w, Style_t style, UInt_t options, Pixel_t back) :
233 TGTextLBEntry(p, new TGString(str), id, GetDefaultGC()(),
234 GetDefaultFontStruct(), options, back)
235{
237
239 fLineWidth = gcv.fLineWidth = w;
240 gcv.fFillStyle = kFillSolid;
241 gcv.fDashLen = 2;
242 gcv.fDashOffset = 0;
243 memcpy(gcv.fDashes, "\x5\x5", 3);
244 gcv.fLineStyle = kLineOnOffDash;
247
249
250 fTWidth = gVirtualX->TextWidth(GetDefaultFontStruct(), "8", 1);
251 fTWidth += 15; // for drawing
252 gVirtualX->GetFontProperties(GetDefaultFontStruct(),
255 fLineLength = 0;
256
257 Resize(fTWidth, fTHeight + 1);
260}
261
262////////////////////////////////////////////////////////////////////////////////
263/// Delete line style listbox entry.
264
269
270////////////////////////////////////////////////////////////////////////////////
271/// Update line style listbox entry.
272
274{
276
278 fLineGC = ((TGLineLBEntry *)e)->GetLineGC();
280}
281
282////////////////////////////////////////////////////////////////////////////////
283/// Set the line style corresponding to the TPad line styles.
284
286{
287 static const char* dashed = "\x3\x3";
288 static const char* dotted= "\x1\x2";
289 static const char* dasheddotted = "\x3\x4\x1\x4";
290 static const char* ls05 = "\x5\x3\x1\x3";
291 static const char* ls06 = "\x5\x3\x1\x3\x1\x3\x1\x3";
292 static const char* ls07 = "\x5\x5";
293 static const char* ls08 = "\x5\x3\x1\x3\x1\x3";
294 static const char* ls09 = "\x20\x5";
295 static const char* ls10 = "\x20\x10\x1\x10";
296
297
298 if (linestyle <= 1) {
300 } else {
301 switch (linestyle) {
302 case 2:
304 break;
305 case 3:
307 break;
308 case 4:
310 break;
311 case 5:
313 break;
314 case 6:
316 break;
317 case 7:
319 break;
320 case 8:
322 break;
323 case 9:
325 break;
326 case 10:
328 break;
329 }
330 }
331 fLineGC->SetCapStyle(0); // flat cap
333}
334
335////////////////////////////////////////////////////////////////////////////////
336/// Set or change line width in an entry.
337
343
344////////////////////////////////////////////////////////////////////////////////
345/// Draw copy on window/pixmap.
346
348{
350 if (!strcmp(TGTextLBEntry::GetTitle(),"None")) return;
351 if (fActive) {
352 gVirtualX->SetForeground(fLineGC->GetGC(),
353 fClient->GetResourcePool()->GetSelectedFgndColor());
354 } else {
355 gVirtualX->SetForeground(fLineGC->GetGC(),
356 fClient->GetResourcePool()->GetBlackColor());
357 }
358 gVirtualX->DrawLine(id, fLineGC->GetGC(), x + fTWidth + 5, y + fHeight/2,
359 x + fWidth - 5, y + fHeight/2);
360}
361
362////////////////////////////////////////////////////////////////////////////////
363/// Redraw line style listbox entry.
364
366{
367 if (fId) DrawCopy(fId, 0, 0);
368}
369
370
371////////////////////////////////////////////////////////////////////////////////
372/// Create the icon & text listbox entry.
373
374TGIconLBEntry::TGIconLBEntry(const TGWindow *p, Int_t id, const char *str,
375 const TGPicture *pic,
376 UInt_t /*w*/, Style_t /*style*/, UInt_t options, Pixel_t back) :
377 TGTextLBEntry(p, new TGString(str), id, GetDefaultGC()(),
378 GetDefaultFontStruct(), options, back)
379{
381
382 fPicture = pic;
383 if (fPicture) {
384 fTWidth += fPicture->GetWidth() + 4;
385 ((TGPicture *)fPicture)->AddReference();
386 }
387 else
388 fTWidth += 20;
389 gVirtualX->GetFontProperties(GetDefaultFontStruct(),
392 if (fPicture && fPicture->GetHeight() > fTHeight)
393 fTHeight = fPicture->GetHeight();
394
395 Resize(fTWidth, fTHeight + 1);
398}
399
400////////////////////////////////////////////////////////////////////////////////
401/// Delete icon & text listbox entry.
402
407
408////////////////////////////////////////////////////////////////////////////////
409/// Update icon & text listbox entry.
410
415
416////////////////////////////////////////////////////////////////////////////////
417/// Draw copy on window/pixmap.
418
420{
421 Int_t off_x = 0;
422 if (fPicture) {
423 fPicture->Draw(id, fNormGC, x + 2, y);
424 off_x = fPicture->GetWidth() + 4;
425 }
427}
428
429////////////////////////////////////////////////////////////////////////////////
430/// Redraw icon & text listbox entry.
431
433{
434 if (fId) DrawCopy(fId, 0, 0);
435}
436
437////////////////////////////////////////////////////////////////////////////////
438/// Change the icon of listbox entry containing icon & text.
439
441{
443
444 if (pic) ((TGPicture *)pic)->AddReference();
445
446 fPicture = pic;
447}
448
449/////////////////////////////////////////////////////////////////////////////////
451public:
453 ~TGLBFrameElement() override {}
454
455 Bool_t IsSortable() const override { return kTRUE; }
456 Int_t Compare(const TObject *obj) const override
457 {
459 return 0;
460 }
463
464
465 double d1, d2;
466 const char *t1 = f1->GetText()->Data();
467 const char *t2 = f2->GetText()->Data();
468
469 if ((d1 = atof(t1)) && (d2 = atof(t2))) {
470 return (d1 > d2);
471 } else {
472 return strcmp(t1, t2);
473 }
474 return 0;
475 }
476};
477
478
479////////////////////////////////////////////////////////////////////////////////
480/// Create a listbox container.
481
495
496////////////////////////////////////////////////////////////////////////////////
497/// Delete the listbox container.
498
503
504////////////////////////////////////////////////////////////////////////////////
505/// Layout container
506
512
513////////////////////////////////////////////////////////////////////////////////
514/// redraw
515
517{
518 return TGContainer::DoRedraw();
519}
520
521////////////////////////////////////////////////////////////////////////////////
522/// Add listbox entry with hints to container. To show entry call
523/// MapSubwindows() and Layout().
524
526{
527 // DEPRECATED: the color should always be set in the TGLBEntry ctor
528 //lbe->SetBackgroundColor(fgWhitePixel);
529
531 fList->Add(nw);
533}
534
535////////////////////////////////////////////////////////////////////////////////
536/// Insert listbox entry after specified entry with id afterID. If afterID = -1
537/// then add entry at head of list. To show entry call MapSubwindows() and
538/// Layout().
539
541{
542 // DEPRECATED: the color should always be set in the TGLBEntry ctor
543 //lbe->SetBackgroundColor(fgWhitePixel);
544
545 TGLBEntry *e;
547 TIter next(fList);
548
549 while ((el = (TGFrameElement *) next())) {
550 e = (TGLBEntry *) el->fFrame;
551 if (e->EntryId() == afterID) break;
552 }
553
554 if (!el && afterID != -1) {
556 fList->Add(nw);
557 } else {
559 nw->fFrame = lbe;
560 nw->fLayout = lhints;
561 nw->fState = 1;
562 //lbe->SetFrameElement(nw);
563
564 if (afterID == -1)
565 fList->AddFirst(nw);
566 else
567 fList->AddAfter(el, nw);
568 }
570}
571
572////////////////////////////////////////////////////////////////////////////////
573/// Insert listbox entry before the list box entry with a higher id.
574/// To show entry call MapSubwindows() and Layout().
575
577{
578 // DEPRECATED: the color should always be set in the TGLBEntry ctor
579 //lbe->SetBackgroundColor(fgWhitePixel);
580
581 TGLBEntry *e;
583 TIter next(fList);
584
585 while ((el = (TGFrameElement *) next())) {
586 e = (TGLBEntry *) el->fFrame;
587 if (e->EntryId() > lbe->EntryId()) break;
588 }
589
590 if (!el) {
592 fList->Add(nw);
593 } else {
595 nw->fFrame = lbe;
596 nw->fLayout = lhints;
597 nw->fState = 1;
598 //lbe->SetFrameElement(nw);
599
600 fList->AddBefore(el, nw);
601 }
603}
604
605////////////////////////////////////////////////////////////////////////////////
606/// Remove the entry with specified id from the listbox container.
607/// To update the listbox call Layout().
608
610{
611 TGLBEntry *e;
614
615 TIter next(fList);
616
617 while ((el = (TGFrameElement *) next())) {
618 e = (TGLBEntry *) el->fFrame;
619 l = el->fLayout;
620 if (e->EntryId() == id) {
621 if (fLastActive == e) fLastActive = 0;
622 e->DestroyWindow();
623 fList->Remove(el); // avoid calling RemoveFrame(e)
624 delete el; // item
625 delete e;
626 delete l;
627 break;
628 }
629 }
631}
632
633////////////////////////////////////////////////////////////////////////////////
634/// Remove entries from from_ID to to_ID (including).
635/// To update the listbox call Layout().
636
638{
639 TGLBEntry *e;
642
643 TIter next(fList);
644
645 while ((el = (TGFrameElement *) next())) {
646 e = (TGLBEntry *) el->fFrame;
647 l = el->fLayout;
648 if ((e->EntryId() >= from_ID) && (e->EntryId() <= to_ID)) {
649 if (fLastActive == e) fLastActive = 0;
650 e->DestroyWindow();
651 fList->Remove(el); // avoid calling RemoveFrame(e)
652 delete el; // idem
653 delete e;
654 delete l;
655 }
656 }
658}
659
660////////////////////////////////////////////////////////////////////////////////
661/// Remove all entries in this container.
662
664{
665 TGLBEntry *e;
668
669 TIter next(fList);
670
671 while ((el = (TGFrameElement *) next())) {
672 e = (TGLBEntry *) el->fFrame;
673 l = el->fLayout;
674 if (fLastActive == e) fLastActive = 0;
675 if (e)
676 e->DestroyWindow();
677 fList->Remove(el); // avoid calling RemoveFrame(e)
678 delete el; // item
679 delete e;
680 delete l;
681 }
683}
684
685////////////////////////////////////////////////////////////////////////////////
686/// Select the entry with the specified id.
687/// Returns the selected TGLBEntry.
688
690{
691 return Select(id, kTRUE);
692}
693
694////////////////////////////////////////////////////////////////////////////////
695/// Select / deselect the entry with the specified id.
696/// Returns the selected TGLBEntry.
697
699{
700 TGLBEntry *f;
702
703 if (!fMultiSelect && fLastActive) {
705 fLastActive = 0;
706 }
707
708 TIter next(fList);
709 while ((el = (TGFrameElement *) next())) {
710 f = (TGLBEntry *) el->fFrame;
711 if (f->EntryId() == id) {
712 f->Activate(sel);
713 if (fMultiSelect == kFALSE && sel == kTRUE) {
714 fLastActive = f;
716 }
718 return f;
719 }
720 }
721
722 return 0;
723}
724
725////////////////////////////////////////////////////////////////////////////////
726/// Returns id of selected entry. In case of no selected entry or
727/// if multi selection is switched on returns -1.
728
730{
731 if (fLastActive == 0) return -1;
732 return fLastActive->EntryId();
733}
734
735////////////////////////////////////////////////////////////////////////////////
736/// Returns kTrue if entry id is selected.
737
739{
740 TGLBEntry *f;
742
743 TIter next(fList);
744 while ((el = (TGFrameElement *) next())) {
745 f = (TGLBEntry *) el->fFrame;
746 if (f->EntryId() == id)
747 return f->IsActive();
748 }
749
750 return kFALSE;
751}
752
753////////////////////////////////////////////////////////////////////////////////
754/// Adds all selected entries (TGLBEntry) of the list box into
755/// the list selected.
756
758{
759 TGLBEntry *f;
761
762 TIter next(fList);
763 while ((el = (TGFrameElement *) next())) {
764 f = (TGLBEntry *) el->fFrame;
765 if (f->IsActive()) {
766 selected->Add(f);
767 }
768 }
769}
770
771////////////////////////////////////////////////////////////////////////////////
772/// Enables and disables multiple selections of entries.
773
775{
777
779 if (!fMultiSelect) {
780 // deselect all entries
781 TIter next(fList);
782 while ((el = (TGFrameElement *) next())) {
783 ((TGLBEntry *)(el->fFrame))->Activate(kFALSE);
784 }
785 }
786 fLastActive = 0;
787 fLastActiveEl = 0;
789}
790
791////////////////////////////////////////////////////////////////////////////////
792/// Return a pointer to vertical scroll bar.
793
798
799////////////////////////////////////////////////////////////////////////////////
800/// Set new vertical scroll bar position.
801
803{
805
806 if (vb && vb->IsMapped()) {
807 vb->SetPosition(newPos);
808 }
809}
810
811////////////////////////////////////////////////////////////////////////////////
812/// Handle mouse button event in the listbox container.
813
815{
816 int xf0, yf0, xff, yff;
817
818 TGLBEntry *f;
820 TGLBEntry *last = fLastActive;
821
823 Int_t x = pos.fX + event->fX;
824 Int_t y = pos.fY + event->fY;
825 Bool_t activate = kFALSE;
826
827 // do not handle "context menu button" during guibuilding
828 if (fClient->IsEditable() && (event->fCode == kButton3)) {
829 return kTRUE;
830 }
831
833
834 if ((event->fCode == kButton4) && vb){
835 // scroll 2 lines up (a button down is always followed by a button up)
836 Int_t newpos = vb->GetPosition() - 1;
837 if (newpos < 0) newpos = 0;
838 vb->SetPosition(newpos);
840 return kTRUE;
841 }
842 if ((event->fCode == kButton5) && vb) {
843 // scroll 2 lines down (a button down is always followed by a button up)
844 Int_t newpos = vb->GetPosition() + 1;
845 vb->SetPosition(newpos);
847 return kTRUE;
848 }
849
850 gVirtualX->SetInputFocus(fId);
851
852 if (fMultiSelect) {
853 if (event->fType == kButtonPress) {
854 TIter next(fList);
855 while ((el = (TGFrameElement *) next())) {
856 f = (TGLBEntry *) el->fFrame;
857 xf0 = f->GetX();
858 yf0 = f->GetY();
859 xff = xf0 + f->GetWidth();
860 yff = yf0 + f->GetHeight();
861
862 activate = fMapSubwindows ? (f->GetId() == (Window_t)event->fUser[0]) :
863 (x > xf0) && (x < xff) && (y > yf0) && (y < yff);
864
865 if (activate) {
866 fLastActive = f;
868 f->Toggle();
869 fChangeStatus = f->IsActive() ? 1 : 0;
871 f->EntryId(), 0);
872 break;
873 }
874 }
875 } else {
876 fChangeStatus = -1;
877 }
878 } else {
879 if (event->fType == kButtonPress) {
880 if (fLastActive) {
882 fLastActive = 0;
883 }
884 TIter next(fList);
885 while ((el = (TGFrameElement *) next())) {
886 f = (TGLBEntry *) el->fFrame;
887 xf0 = f->GetX();
888 yf0 = f->GetY();
889 xff = xf0 + f->GetWidth();
890 yff = yf0 + f->GetHeight();
891
892 activate = fMapSubwindows ? (f->GetId() == (Window_t)event->fUser[0]) :
893 (x > xf0) && (x < xff) && (y > yf0) && (y < yff) && !f->IsActive();
894
895 if (activate) {
896 f->Activate(kTRUE);
897 fLastActive = f;
899 } else {
900 f->Activate(kFALSE);
901 }
902 }
903 } else {
904 if (fLastActive) {
905 f = fLastActive;
907 f->EntryId(), 0);
908 }
909 }
910 }
911 if (event->fType == kButtonRelease) {
914 }
915 if (fChangeStatus || (last != fLastActive))
917 // trick to avoid mouse move events between the mouse click
918 // and the unmapping...
919 if (fListBox->GetParent()->InheritsFrom("TGComboBoxPopup"))
921 return kTRUE;
922}
923
924////////////////////////////////////////////////////////////////////////////////
925/// Handle double click mouse event in the listbox container.
926
928{
929 if (!fMultiSelect) {
930 if (fLastActive) {
933 f->EntryId(), 0);
934 DoubleClicked(f, ev->fCode);
935 DoubleClicked(f, ev->fCode, ev->fXRoot, ev->fYRoot);
936 }
937 return kTRUE;
938 }
940}
941
942////////////////////////////////////////////////////////////////////////////////
943/// Handle mouse motion event in listbox container.
944
946{
947 int xf0, yf0, xff, yff;
948
949 static Long64_t was = gSystem->Now();
950 Long64_t now = gSystem->Now();
951
952 if ((now-was) < 50) return kFALSE;
953 was = now;
954
955 TGLBEntry *f;
959 Int_t x = pos.fX + event->fX;
960 Int_t y = pos.fY + event->fY;
961 Bool_t activate = kFALSE;
962 TGLBEntry *last = fLastActive;
963
964 if (fMultiSelect) {
965
966 if ((event->fY < 10) || (event->fY > Int_t(dim.fHeight) - 10)) {
967 if (!fScrolling) {
970 }
972 }
973 else if (fChangeStatus >= 0) {
974 TIter next(fList);
975 while ((el = (TGFrameElement *) next())) {
976 f = (TGLBEntry *) el->fFrame;
977 xf0 = f->GetX();
978 yf0 = f->GetY();
979 xff = xf0 + f->GetWidth();
980 yff = yf0 + f->GetHeight();
981 activate = fMapSubwindows ? (f->GetId() == (Window_t)event->fUser[0]) :
982 (x > xf0) && (x < xff) && (y > yf0) && (y < yff);
983
984 if (activate) {
985 if (fChangeStatus != (f->IsActive() ? 1 : 0)) {
986 f->Toggle();
989 f->EntryId(), 0);
990 }
991 break;
992 }
993 }
994 }
995 } else if (fListBox->GetParent()->InheritsFrom("TGComboBoxPopup")) {
996 TIter next(fList);
997 while ((el = (TGFrameElement *) next())) {
998 f = (TGLBEntry *) el->fFrame;
999 xf0 = f->GetX();
1000 yf0 = f->GetY();
1001 xff = xf0 + f->GetWidth();
1002 yff = yf0 + f->GetHeight();
1003
1004 activate = fMapSubwindows ? (f->GetId() == (Window_t)event->fUser[0]) :
1005 (x > xf0) && (x < xff) && (y > yf0) && (y < yff) && !f->IsActive();
1006
1007 if (activate) {
1008 f->Activate(kTRUE);
1009 fLastActive = f;
1010 fLastActiveEl = el;
1011 } else {
1012 f->Activate(kFALSE);
1013 }
1014 if (last != fLastActive) {
1015 ClearViewPort();
1016 }
1017 }
1018 }
1019 return kTRUE;
1020}
1021
1022////////////////////////////////////////////////////////////////////////////////
1023/// Autoscroll while close to & beyond The Wall
1024
1026{
1027 TGFrameElement* el = 0;
1028 TGLBEntry *f = 0;
1029 Int_t yf0, yff;
1031
1034
1036 Event_t ev;
1037 ev.fType = kButtonPress;
1038 Int_t x, y;
1039
1040 // Where's the cursor?
1041 gVirtualX->QueryPointer(fId,dum1,dum2,ev.fXRoot,ev.fYRoot,x,y,ev.fState);
1043 if (vb && y > 0 && y < 10) {
1044 // scroll 1 line up
1045 Int_t newpos = vb->GetPosition() - 1;
1046 if (newpos < 0) newpos = 0;
1047 vb->SetPosition(newpos);
1048 changed = kTRUE;
1049 }
1050 else if (vb && y > (Int_t)dim.fHeight - 10 && y < (Int_t)dim.fHeight) {
1051 // scroll 1 line down
1052 Int_t newpos = vb->GetPosition() + 1;
1053 vb->SetPosition(newpos);
1054 changed = kTRUE;
1055 }
1056 if (changed && fChangeStatus >= 0) {
1057 pos = GetPagePosition();
1058 TIter next(fList);
1059 while ((el = (TGFrameElement *) next())) {
1060 f = (TGLBEntry *) el->fFrame;
1061 yf0 = f->GetY();
1062 yff = yf0 + f->GetHeight();
1063 if ((y + pos.fY > yf0) && (y + pos.fY < yff)) {
1064 if (fChangeStatus != (f->IsActive() ? 1 : 0)) {
1065 f->Toggle();
1066 ClearViewPort();
1068 f->EntryId(), 0);
1069 }
1070 break;
1071 }
1072 }
1073 }
1074}
1075
1076////////////////////////////////////////////////////////////////////////////////
1077/// Activate item.
1078
1084
1085////////////////////////////////////////////////////////////////////////////////
1086/// Returns the position in the list box of the entry id.
1087/// The first position has position no 0. Returns -1 if entry id
1088/// is not in the list of entries.
1089
1091{
1092 Int_t pos = 0;
1093 TGLBEntry *f;
1095
1096 TIter next(fList);
1097 while ((el = (TGFrameElement *) next())) {
1098 f = (TGLBEntry *) el->fFrame;
1099 if (f->EntryId() == id)
1100 return pos;
1101 pos++;
1102 }
1103
1104 return -1;
1105}
1106
1107
1108////////////////////////////////////////////////////////////////////////////////
1109/// Create a listbox.
1110
1112 UInt_t options, Pixel_t back) :
1113 TGCompositeFrame(p, 10, 10, options, back)
1114{
1115 fMsgWindow = p;
1116 fWidgetId = id;
1117
1118 fItemVsize = 1;
1120
1121 InitListBox();
1122}
1123
1124////////////////////////////////////////////////////////////////////////////////
1125/// Delete a listbox widget.
1126
1128{
1129 if (!MustCleanup()) {
1130 delete fVScrollbar;
1131 delete fVport;
1132 delete fLbc;
1133 }
1134}
1135
1136////////////////////////////////////////////////////////////////////////////////
1137/// Initiate the internal classes of a list box.
1138
1168
1169////////////////////////////////////////////////////////////////////////////////
1170/// Draw borders of the list box widget.
1171
1173{
1175
1177 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, fWidth-2, 0);
1178 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, 0, fHeight-2);
1179 gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, fWidth-3, 1);
1180 gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, 1, fHeight-3);
1181 if (gClient->GetStyle() > 1) break;
1182 gVirtualX->DrawLine(fId, GetHilightGC()(), 0, fHeight-1, fWidth-1, fHeight-1);
1183 gVirtualX->DrawLine(fId, GetHilightGC()(), fWidth-1, fHeight-1, fWidth-1, 0);
1184 gVirtualX->DrawLine(fId, GetBckgndGC()(), 1, fHeight-2, fWidth-2, fHeight-2);
1185 gVirtualX->DrawLine(fId, GetBckgndGC()(), fWidth-2, 1, fWidth-2, fHeight-2);
1186 break;
1187
1188 default:
1190 break;
1191 }
1192}
1193
1194////////////////////////////////////////////////////////////////////////////////
1195/// Add entry with specified string and id to listbox. The id will be
1196/// used in the event processing routine when the item is selected.
1197/// The string will be adopted by the listbox.
1198
1200{
1203
1204 lbe = new TGTextLBEntry(fLbc, s, id);
1206 fItemVsize = TMath::Max(fItemVsize, lbe->GetDefaultHeight());
1208}
1209
1210////////////////////////////////////////////////////////////////////////////////
1211/// Add entry with specified string and id to listbox. The id will be
1212/// used in the event processing routine when the item is selected.
1213
1214void TGListBox::AddEntry(const char *s, Int_t id)
1215{
1216 AddEntry(new TGString(s), id);
1217}
1218
1219////////////////////////////////////////////////////////////////////////////////
1220/// Add specified TGLBEntry and TGLayoutHints to listbox. The
1221/// entry and layout will be adopted and later deleted by the listbox.
1222
1224{
1225 fItemVsize = TMath::Max(fItemVsize, lbe->GetDefaultHeight());
1227}
1228
1229////////////////////////////////////////////////////////////////////////////////
1230/// Add entry with specified string and id to listbox sorted by increasing id.
1231/// This sorting works properly only if EntrySort functions are used to add
1232/// entries without mixing them with other add or insert functions. The id will be
1233/// used in the event processing routine when the item is selected.
1234/// The string will be adopted by the listbox.
1235
1237{
1240
1241 lbe = new TGTextLBEntry(fLbc, s, id);
1243 fItemVsize = TMath::Max(fItemVsize, lbe->GetDefaultHeight());
1245}
1246
1247////////////////////////////////////////////////////////////////////////////////
1248/// Add entry with specified string and id to listbox sorted by increasing id.
1249/// This sorting works properly only if EntrySort functions are used to add
1250/// entries without mixing them with other add or insert functions. The id will be
1251/// used in the event processing routine when the item is selected.
1252
1253void TGListBox::AddEntrySort(const char *s, Int_t id)
1254{
1255 AddEntrySort(new TGString(s), id);
1256}
1257
1258////////////////////////////////////////////////////////////////////////////////
1259/// Add specified TGLBEntry and TGLayoutHints to listbox sorted by increasing id.
1260/// This sorting works properly only if EntrySort functions are used to add
1261/// entries without mixing them with other add or insert functions. The
1262/// entry and layout will be adopted and later deleted by the listbox.
1263
1269
1270////////////////////////////////////////////////////////////////////////////////
1271/// Insert entry with specified string and id behind the entry with afterID.
1272/// The string will be adopted and later deleted by the listbox.
1273
1275{
1278
1279 lbe = new TGTextLBEntry(fLbc, s, id);
1281 fItemVsize = TMath::Max(fItemVsize, lbe->GetDefaultHeight());
1283}
1284
1285////////////////////////////////////////////////////////////////////////////////
1286/// Insert entry with specified string and id behind the entry with afterID.
1287
1289{
1290 InsertEntry(new TGString(s), id, afterID);
1291}
1292
1293////////////////////////////////////////////////////////////////////////////////
1294/// method used to add entry via context menu
1295
1296void TGListBox::NewEntry(const char *s)
1297{
1298 Int_t selected = fLbc->GetSelected();
1299
1300 // no selected entry or the last entry
1301 if ((selected < 0) || (selected == GetNumberOfEntries())) {
1303 } else {
1304 InsertEntry(s, GetNumberOfEntries()+1, selected);
1305 }
1306 Layout();
1307}
1308
1309////////////////////////////////////////////////////////////////////////////////
1310/// remove entry with id.
1311/// If id = -1 - the selected entry/entries is/are removed.
1312///
1313
1315{
1316 if (id >= 0) {
1317 fLbc->RemoveEntry(id);
1318 Layout();
1319 return;
1320 }
1321 if (!fLbc->GetMultipleSelections()) {
1323 Layout();
1324 return;
1325 }
1326 TList li;
1328 TGLBEntry *e;
1329 TIter next(&li);
1330
1331 while ((e = (TGLBEntry*)next())) {
1332 fLbc->RemoveEntry(e->EntryId());
1333 }
1334 Layout();
1335}
1336
1337////////////////////////////////////////////////////////////////////////////////
1338/// Remove all entries.
1339
1341{
1342 fLbc->RemoveAll();
1343 Layout();
1344}
1345
1346////////////////////////////////////////////////////////////////////////////////
1347/// Remove a range of entries defined by from_ID and to_ID.
1348
1354
1355////////////////////////////////////////////////////////////////////////////////
1356/// Insert the specified TGLBEntry and layout hints behind afterID.
1357/// The entry and layout will be adopted and later deleted by the listbox.
1358
1364
1365////////////////////////////////////////////////////////////////////////////////
1366/// Returns list box entry with specified id.
1367
1369{
1370 TIter next(fLbc->GetList());
1372
1373 while ((el = (TGFrameElement *)next())) {
1374 TGLBEntry *lbe = (TGLBEntry *)el->fFrame;
1375 if (lbe->EntryId() == id) return lbe;
1376 }
1377 return 0;
1378}
1379
1380////////////////////////////////////////////////////////////////////////////////
1381/// Scroll the entry with id to the top of the listbox.
1382
1384{
1385 Int_t idPos;
1386
1387 idPos = fLbc->GetPos(id);
1388
1389 // id not found in list of entries
1390 if (idPos < 0)
1391 return;
1392
1393 // call layout to define the range of the scroll bars
1394 Layout();
1395
1396 // SetPosition will send a message which will handled by
1397 // the function TGListBox::ProcessMessage. Now ProcessMessage will
1398 // set the viewport. SetPosition also will check that the idPos is
1399 // not out of range.
1401}
1402
1403////////////////////////////////////////////////////////////////////////////////
1404/// Resize the listbox widget. If fIntegralHeight is true make the height
1405/// an integral number of the maximum height of a single entry.
1406
1408{
1409 if (fIntegralHeight)
1411 + (fBorderWidth << 1);
1412
1414 DoRedraw();
1415}
1416
1417////////////////////////////////////////////////////////////////////////////////
1418/// Move and resize the listbox widget.
1419
1428
1429////////////////////////////////////////////////////////////////////////////////
1430/// Return default size of listbox widget.
1431
1433{
1434 UInt_t h;
1435
1436 if (fIntegralHeight)
1438 + (fBorderWidth << 1);
1439 else
1440 h = fHeight;
1441
1442 return TGDimension(fWidth, h);
1443}
1444
1445////////////////////////////////////////////////////////////////////////////////
1446/// Layout the listbox components.
1447
1449{
1451 UInt_t cw, ch, tch;
1453
1454 need_vsb = kFALSE;
1455
1457
1458 // test whether we need vertical scrollbar or not
1459
1460 cw = fWidth - (fBorderWidth << 1);
1461 ch = fHeight - (fBorderWidth << 1);
1462
1463 container->SetWidth(cw);
1464 container->SetHeight(ch);
1465
1466 if (container->GetDefaultHeight() > ch) {
1467 need_vsb = kTRUE;
1469 if ((Int_t) cw < 0) {
1470 Warning("Layout", "width would become too small, setting to 10");
1471 cw = 10;
1472 }
1473 container->SetWidth(cw);
1474 }
1475
1477 container->Layout();
1478
1479 tch = TMath::Max(container->GetDefaultHeight(), ch);
1480 container->SetHeight(0); // force a resize in TGFrame::Resize
1481 container->Resize(cw, tch);
1482 //fVport->SetPos(0, 0);
1483
1484 if (need_vsb) {
1487 } else {
1490 }
1491
1494 //fClient->NeedRedraw(container);
1495 ((TGContainer *)container)->ClearViewPort();
1496}
1497
1498////////////////////////////////////////////////////////////////////////////////
1499/// Sort entries by name
1500
1502{
1503 fLbc->GetList()->Sort(ascend);
1504 Layout();
1506}
1507
1508////////////////////////////////////////////////////////////////////////////////
1509/// Return id of selected listbox item.
1510
1512{
1514 return ct->GetSelected();
1515}
1516
1517////////////////////////////////////////////////////////////////////////////////
1518/// Adds all selected entries (TGLBEntry) of the list box into
1519/// the list selected.
1520
1522{
1523 fLbc->GetSelectedEntries(selected);
1524}
1525
1526////////////////////////////////////////////////////////////////////////////////
1527/// Change background to all entries
1528
1530{
1531 fBackground = back;
1532
1533 TIter next(fLbc->GetList());
1535
1536 while ((el = (TGFrameElement *)next())) {
1537 TGLBEntry *lbe = (TGLBEntry *)el->fFrame;
1538 lbe->SetBackgroundColor(back);
1539 }
1541}
1542
1543////////////////////////////////////////////////////////////////////////////////
1544/// Process messages generated by the listbox container and forward
1545/// messages to the listbox message handling window.
1546
1548{
1549 switch (GET_MSG(msg)) {
1550 case kC_VSCROLL:
1551 switch (GET_SUBMSG(msg)) {
1552 case kSB_SLIDERTRACK:
1553 case kSB_SLIDERPOS:
1555 break;
1556 }
1557 break;
1558
1559 case kC_CONTAINER:
1560 switch (GET_SUBMSG(msg)) {
1561 case kCT_ITEMCLICK:
1562 {
1564 fWidgetId, parm1);
1567 if (entry) {
1568 if (entry->InheritsFrom(TGTextLBEntry::Class())) {
1569 const char *text;
1570 text = ((TGTextLBEntry*)entry)->GetText()->GetString();
1571 Selected(text);
1572 }
1574 Selected((Int_t) parm1);
1575 }
1576 }
1577 break;
1578 case kCT_ITEMDBLCLICK:
1579 if (!GetMultipleSelections()) {
1581 if (entry) {
1582 if (entry->InheritsFrom(TGTextLBEntry::Class())) {
1583 const char *text;
1584 text = ((TGTextLBEntry*)entry)->GetText()->GetString();
1586 }
1589 }
1590 }
1591 break;
1592 }
1593 break;
1594
1595 default:
1596 break;
1597
1598 }
1599 return kTRUE;
1600}
1601
1602////////////////////////////////////////////////////////////////////////////////
1603/// Emit Selected signal with list box id and entry id.
1604
1606{
1607 Longptr_t args[2];
1608
1609 args[0] = widgetId;
1610 args[1] = id;
1611
1612 Emit("Selected(Int_t,Int_t)", args);
1613}
1614
1615////////////////////////////////////////////////////////////////////////////////
1616/// Emit DoubleClicked signal with list box id and entry id.
1617
1619{
1620 Longptr_t args[2];
1621
1622 args[0] = widgetId;
1623 args[1] = id;
1624
1625 Emit("DoubleClicked(Int_t,Int_t)", args);
1626}
1627
1628////////////////////////////////////////////////////////////////////////////////
1629/// Find entry by name.
1630
1632{
1633 TList *list = fLbc->GetList();
1634 TGFrameElement *el = (TGFrameElement *)list->First();
1635 while (el) {
1636 if (el->fFrame->GetTitle() == TString(name))
1637 return (TGLBEntry *)el->fFrame;
1638 el = (TGFrameElement *)list->After(el);
1639 }
1640 return 0;
1641}
1642
1643////////////////////////////////////////////////////////////////////////////////
1644/// Save a list box widget as a C++ statement(s) on output stream out.
1645
1646void TGListBox::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1647{
1648 // store options and color if differ from defaults
1650
1651 out << "\n // list box\n";
1652 out << " TGListBox *" << GetName() << " = new TGListBox(" << fParent->GetName();
1653 if (!extra_args.IsNull() || (fWidgetId != -1))
1654 out << ", " << fWidgetId << extra_args;
1655 out << ");\n";
1656
1657 if (option && strstr(option, "keep_names"))
1658 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
1659
1660 if (!fLbc->GetList())
1661 return;
1662
1663 TIter next(fLbc->GetList());
1664 while (auto el = static_cast<TGFrameElement *>(next())) {
1665 out << " " << GetName() << "->AddEntry(";
1666 el->fFrame->SavePrimitive(out, option);
1667 out << ");\n";
1668 }
1669 out << " " << GetName() << "->Resize(" << GetWidth() << "," << GetHeight() << ");\n";
1670}
1671
1672////////////////////////////////////////////////////////////////////////////////
1673/// Save a list box entry widget as a C++ statement(s) on output stream out.
1674
1675void TGTextLBEntry::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
1676{
1677 out << "\"" << TString(GetText()->GetString()).ReplaceSpecialCppChars() << "\", " << EntryId();
1678}
@ kButtonRelease
Definition GuiTypes.h:60
@ kButtonPress
Definition GuiTypes.h:60
const Mask_t kGCLineStyle
Definition GuiTypes.h:291
const Mask_t kGCLineWidth
Definition GuiTypes.h:290
const Mask_t kButtonMotionMask
Definition GuiTypes.h:164
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
const Mask_t kGCDashList
Definition GuiTypes.h:307
const Mask_t kGCFillStyle
Definition GuiTypes.h:294
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
const Mask_t kPointerMotionMask
Definition GuiTypes.h:163
@ kChildFrame
Definition GuiTypes.h:379
@ kRaisedFrame
Definition GuiTypes.h:384
@ kSunkenFrame
Definition GuiTypes.h:383
@ kVerticalFrame
Definition GuiTypes.h:381
@ kDoubleBorder
Definition GuiTypes.h:385
@ kOwnBackground
Definition GuiTypes.h:391
@ kDefaultScrollBarWidth
Definition GuiTypes.h:86
@ kFillSolid
Definition GuiTypes.h:51
@ kLineSolid
Definition GuiTypes.h:48
@ kLineOnOffDash
Definition GuiTypes.h:48
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
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
ULongptr_t Handle_t
Generic resource handle.
Definition GuiTypes.h:26
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
#define f(i)
Definition RSha256.hxx:104
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
short Style_t
Style number (short)
Definition RtypesCore.h:96
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:89
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
#define gClient
Definition TGClient.h:157
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
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 Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t sel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t width
Option_t Option_t style
Option_t Option_t TPoint TPoint const char text
char name[80]
Definition TGX11.cxx:110
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
#define gVirtualX
Definition TVirtualX.h:337
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
Int_t GET_MSG(Long_t val)
@ kSB_SLIDERTRACK
@ kSB_SLIDERPOS
@ kC_VSCROLL
@ kCT_ITEMCLICK
@ kC_COMMAND
@ kCM_LISTBOX
@ kCT_ITEMDBLCLICK
@ kC_CONTAINER
Int_t GET_SUBMSG(Long_t val)
Bool_t IsEditable() const
Definition TGClient.h:89
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get graphics context from the gc pool.
Definition TGClient.cxx:328
void FreeGC(const TGGC *gc)
Free a graphics context.
Definition TGClient.cxx:336
const TGResourcePool * GetResourcePool() const
Definition TGClient.h:124
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:316
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
TGLayoutManager * fLayoutManager
layout manager
Definition TGFrame.h:293
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
virtual TList * GetList() const
Definition TGFrame.h:312
Int_t MustCleanup() const override
Definition TGFrame.h:362
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:959
Bool_t fMapSubwindows
kTRUE - map subwindows
Definition TGFrame.h:297
TList * fList
container of frame elements
Definition TGFrame.h:294
static TGLayoutHints * fgDefaultHints
Definition TGFrame.h:299
void SetEditDisabled(UInt_t on=1) override
Set edit disable flag for this frame and subframes.
Definition TGFrame.cxx:1014
Manages a content area.
Definition TGCanvas.h:31
virtual void ActivateItem(TGFrameElement *el)
Activate item.
Definition TGCanvas.cxx:698
TTimer * fScrollTimer
autoscroll timer
Definition TGCanvas.h:50
Bool_t HandleDoubleClick(Event_t *event) override
Handle double click mouse event.
virtual void ClearViewPort()
Clear view port and redraw full content.
Definition TGCanvas.cxx:888
const TGWindow * fMsgWindow
window handling container messages
Definition TGCanvas.h:42
void Layout() override
Layout container entries.
Definition TGCanvas.cxx:419
void DoRedraw() override
Redraw content of container in the viewport region.
Definition TGCanvas.cxx:797
Bool_t fScrolling
kTRUE - when scrolling is ON
Definition TGCanvas.h:59
virtual TGDimension GetPageDimension() const
Returns page dimension.
Definition TGCanvas.cxx:748
TGViewPort * fViewPort
container viewport
Definition TGCanvas.h:40
virtual void DoubleClicked(TGFrame *f, Int_t btn)
Emit DoubleClicked() signal.
Definition TGCanvas.cxx:535
virtual TGPosition GetPagePosition() const
Returns page position.
Definition TGCanvas.cxx:734
TGFrameElement * fLastActiveEl
last active item
Definition TGCanvas.h:43
UInt_t fHeight
Definition TGDimension.h:21
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
TGFrame * fFrame
Definition TGLayout.h:112
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:331
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and/or resize the frame.
Definition TGFrame.cxx:621
static const TGGC & GetBlackGC()
Get black graphics context.
Definition TGFrame.cxx:727
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:597
void RemoveInput(UInt_t emask)
Remove events specified in emask from the events the frame should handle.
Definition TGFrame.cxx:340
UInt_t fHeight
frame height
Definition TGFrame.h:88
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:192
virtual void DrawBorder()
Draw frame border.
Definition TGFrame.cxx:413
Int_t fBorderWidth
frame border width
Definition TGFrame.h:93
static Pixel_t fgDefaultSelectedBackground
Definition TGFrame.h:102
virtual void Activate(Bool_t)
Definition TGFrame.h:212
void DoRedraw() override
Redraw the frame.
Definition TGFrame.cxx:422
void MapWindow() override
map window
Definition TGFrame.h:206
virtual Pixel_t GetForeground() const
Return frame foreground color.
Definition TGFrame.cxx:295
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition TGFrame.cxx:747
void UnmapWindow() override
unmap window
Definition TGFrame.h:208
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:637
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:757
UInt_t fWidth
frame width
Definition TGFrame.h:87
UInt_t GetHeight() const
Definition TGFrame.h:227
TString SaveCtorArgs(std::ostream &out, UInt_t dflt_options=kChildFrame, Bool_t check_white_pixel=kFALSE)
Return options and custom color as constructor args Used in the SavePrimitive methods,...
Definition TGFrame.cxx:2493
static Pixel_t fgWhitePixel
Definition TGFrame.h:103
UInt_t GetWidth() const
Definition TGFrame.h:226
Pixel_t fBackground
frame background color
Definition TGFrame.h:95
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition TGFrame.cxx:767
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
GContext_t GetGC() const
Definition TGGC.h:41
void SetLineWidth(Int_t v)
Set line width.
Definition TGGC.cxx:299
void SetCapStyle(Int_t v)
Set cap style (kCapNotLast, kCapButt, kCapRound, kCapProjecting).
Definition TGGC.cxx:321
void SetDashList(const char v[], Int_t len)
Set dash pattern. First use SetDashOffset() if not 0.
Definition TGGC.cxx:487
void SetLineStyle(Int_t v)
Set line style (kLineSolid, kLineOnOffDash, kLineDoubleDash).
Definition TGGC.cxx:310
void DoRedraw() override
Redraw icon & text listbox entry.
~TGIconLBEntry() override
Delete icon & text listbox entry.
virtual void SetPicture(const TGPicture *pic=nullptr)
Change the icon of listbox entry containing icon & text.
void DrawCopy(Handle_t id, Int_t x, Int_t y) override
Draw copy on window/pixmap.
TGIconLBEntry(const TGIconLBEntry &)=delete
const TGPicture * fPicture
Definition TGListBox.h:139
void Update(TGLBEntry *e) override
Update icon & text listbox entry.
A Composite frame that contains a list of TGLBEnties.
Definition TGListBox.h:163
TGLBContainer(const TGLBContainer &)=delete
Bool_t fMultiSelect
true if multi selection is switched on
Definition TGListBox.h:174
virtual Bool_t GetSelection(Int_t id)
Returns kTrue if entry id is selected.
void OnAutoScroll() override
Autoscroll while close to & beyond The Wall.
virtual void SetListBox(TGListBox *lb)
Definition TGListBox.h:196
void RemoveAll() override
Remove all entries in this container.
void SetVsbPosition(Int_t newPos) override
Set new vertical scroll bar position.
TGVScrollBar * GetVScrollbar() const override
Return a pointer to vertical scroll bar.
Int_t fChangeStatus
defines the changes (select or unselect) while the mouse moves over a multi selectable list box
Definition TGListBox.h:175
virtual Int_t GetSelected() const
Returns id of selected entry.
Bool_t HandleButton(Event_t *event) override
Handle mouse button event in the listbox container.
virtual Bool_t GetMultipleSelections() const
Definition TGListBox.h:215
void Layout() override
Layout container.
void ActivateItem(TGFrameElement *el) override
Activate item.
virtual TGLBEntry * Select(Int_t id, Bool_t sel)
Select / deselect the entry with the specified id.
TGLBEntry * fLastActive
last active listbox entry in single selection listbox
Definition TGListBox.h:172
Bool_t HandleDoubleClick(Event_t *event) override
Handle double click mouse event in the listbox container.
virtual void RemoveEntries(Int_t from_ID, Int_t to_ID)
Remove entries from from_ID to to_ID (including).
TGListBox * fListBox
list box which contains this container
Definition TGListBox.h:173
virtual void AddEntry(TGLBEntry *lbe, TGLayoutHints *lhints)
Add listbox entry with hints to container.
virtual Int_t GetPos(Int_t id)
Returns the position in the list box of the entry id.
virtual void AddEntrySort(TGLBEntry *lbe, TGLayoutHints *lhints)
Insert listbox entry before the list box entry with a higher id.
virtual void InsertEntry(TGLBEntry *lbe, TGLayoutHints *lhints, Int_t afterID)
Insert listbox entry after specified entry with id afterID.
virtual void RemoveEntry(Int_t id)
Remove the entry with specified id from the listbox container.
virtual void GetSelectedEntries(TList *selected)
Adds all selected entries (TGLBEntry) of the list box into the list selected.
void DoRedraw() override
redraw
void Associate(const TGWindow *w) override
Definition TGListBox.h:195
~TGLBContainer() override
Delete the listbox container.
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion event in listbox container.
virtual void SetMultipleSelections(Bool_t multi)
Enables and disables multiple selections of entries.
Basic listbox entries.
Definition TGListBox.h:24
Pixel_t fBkcolor
entry background color
Definition TGListBox.h:28
Int_t fEntryId
message id of listbox entry
Definition TGListBox.h:27
void DoRedraw() override
Redraw the frame.
Definition TGListBox.h:31
virtual void Toggle()
Toggle active state of listbox entry.
Int_t EntryId() const
Definition TGListBox.h:40
Bool_t fActive
true if entry is active
Definition TGListBox.h:29
TGLBEntry(const TGWindow *p=nullptr, Int_t id=-1, UInt_t options=kHorizontalFrame, Pixel_t back=GetWhitePixel())
Base class entry constructor.
Definition TGListBox.cxx:94
void Activate(Bool_t a) override
Toggle active state of listbox entry.
TGLBFrameElement(TGFrame *f, TGLayoutHints *l)
Int_t Compare(const TObject *obj) const override
Compare abstract method.
~TGLBFrameElement() override
Bool_t IsSortable() const override
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
Line style and width listbox entries.
Definition TGListBox.h:97
Style_t fLineStyle
line style
Definition TGListBox.h:105
TGGC * fLineGC
line graphics context
Definition TGListBox.h:107
UInt_t fLineLength
line length
Definition TGListBox.h:106
UInt_t fLineWidth
line width
Definition TGListBox.h:104
void DrawCopy(Handle_t id, Int_t x, Int_t y) override
Draw copy on window/pixmap.
void DoRedraw() override
Redraw line style listbox entry.
void Update(TGLBEntry *e) override
Update line style listbox entry.
virtual void SetLineWidth(Int_t width)
Set or change line width in an entry.
virtual void SetLineStyle(Style_t style)
Set the line style corresponding to the TPad line styles.
~TGLineLBEntry() override
Delete line style listbox entry.
TGLineLBEntry(const TGLineLBEntry &)=delete
virtual void InitListBox()
Initiate the internal classes of a list box.
Bool_t fIntegralHeight
true if height should be multiple of fItemVsize
Definition TGListBox.h:229
virtual void AddEntrySort(TGString *s, Int_t id)
Add entry with specified string and id to listbox sorted by increasing id.
TGListBox(const TGListBox &)=delete
virtual void SortByName(Bool_t ascend=kTRUE)
Sort entries by name.
virtual TGVScrollBar * GetVScrollbar() const
Definition TGListBox.h:270
TGViewPort * fVport
listbox viewport (see TGCanvas.h)
Definition TGListBox.h:231
UInt_t fItemVsize
maximum height of single entry
Definition TGListBox.h:228
TGDimension GetDefaultSize() const override
Return default size of listbox widget.
virtual Int_t GetNumberOfEntries() const
Definition TGListBox.h:263
TGLBContainer * fLbc
listbox container
Definition TGListBox.h:230
virtual TGLBEntry * GetSelectedEntry() const
Definition TGListBox.h:288
virtual void RemoveEntry(Int_t id=-1)
remove entry with id.
virtual void NewEntry(const char *s="Entry")
method used to add entry via context menu
void Resize(UInt_t w, UInt_t h) override
Resize the listbox widget.
virtual Int_t GetSelected() const
Return id of selected listbox item.
~TGListBox() override
Delete a listbox widget.
void MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h) override
Move and resize the listbox widget.
virtual void SetTopEntry(Int_t id=-1)
Scroll the entry with id to the top of the listbox.
void ChangeBackground(Pixel_t back) override
Change background to all entries.
virtual void AddEntry(TGString *s, Int_t id)
Add entry with specified string and id to listbox.
void Layout() override
Layout the listbox components.
virtual void DoubleClicked(Int_t widgetId, Int_t id)
Emit DoubleClicked signal with list box id and entry id.
virtual void InsertEntry(TGString *s, Int_t id, Int_t afterID)
Insert entry with specified string and id behind the entry with afterID.
virtual void SelectionChanged()
Definition TGListBox.h:300
virtual Bool_t GetMultipleSelections() const
Definition TGListBox.h:261
void SetContainer(TGFrame *f)
Definition TGListBox.h:234
TGVScrollBar * fVScrollbar
vertical scrollbar
Definition TGListBox.h:232
void DrawBorder() override
Draw borders of the list box widget.
virtual TGLBEntry * GetEntry(Int_t id) const
Returns list box entry with specified id.
virtual TGViewPort * GetViewPort() const
Definition TGListBox.h:268
virtual TGFrame * GetContainer() const
Definition TGListBox.h:267
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a list box widget as a C++ statement(s) on output stream out.
virtual void GetSelectedEntries(TList *selected)
Adds all selected entries (TGLBEntry) of the list box into the list selected.
virtual void RemoveEntries(Int_t from_ID, Int_t to_ID)
Remove a range of entries defined by from_ID and to_ID.
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Process messages generated by the listbox container and forward messages to the listbox message handl...
virtual TGLBEntry * FindEntry(const char *s) const
Find entry by name.
void RemoveAll() override
Remove all entries.
virtual void Selected(Int_t widgetId, Int_t id)
Emit Selected signal with list box id and entry id.
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
Int_t fY
y position
Definition TGDimension.h:39
Int_t fX
x position
Definition TGDimension.h:38
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and/or resize the frame.
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition TGString.h:20
Int_t GetLength() const
Definition TGString.h:29
const char * GetString() const
Definition TGString.h:30
virtual void Draw(Drawable_t id, GContext_t gc, Int_t x, Int_t y)
Draw string.
Definition TGString.cxx:54
Text string listbox entries.
Definition TGListBox.h:48
UInt_t fTWidth
text width
Definition TGListBox.h:52
Bool_t fTextChanged
true if text has been changed
Definition TGListBox.h:54
const TGString * GetText() const
Definition TGListBox.h:79
GContext_t fNormGC
text drawing graphics context
Definition TGListBox.h:55
static const TGFont * fgDefaultFont
Definition TGListBox.h:60
void DoRedraw() override
Redraw text listbox entry.
void SavePrimitive(std::ostream &out, Option_t *="") override
Save a list box entry widget as a C++ statement(s) on output stream out.
void DrawCopy(Handle_t id, Int_t x, Int_t y) override
Draw text listbox entry on window/pixmap.
const char * GetTitle() const override
Returns title of object.
Definition TGListBox.h:81
UInt_t fTHeight
text height
Definition TGListBox.h:53
~TGTextLBEntry() override
Delete text listbox entry.
TGString * fText
entry text string
Definition TGListBox.h:51
void Update(TGLBEntry *e) override
Definition TGListBox.h:85
FontStruct_t fFontStruct
font used to draw string
Definition TGListBox.h:56
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use for a text listbox entry.
static const TGGC & GetDefaultGC()
Return default graphics context in use for a text listbox entry.
static TClass * Class()
TGTextLBEntry(const TGTextLBEntry &)=delete
static TGGC * fgDefaultGC
Definition TGListBox.h:61
void SetText(TGString *new_text)
Set or change text in text entry.
The TGVScrollBar will generate the following event messages: kC_VSCROLL, kSB_SLIDERPOS,...
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.
TGFrame * GetContainer() const
Definition TGCanvas.h:173
virtual void SetVPos(Int_t ypos)
Moves content of container frame in vertical direction.
Definition TGCanvas.cxx:226
Int_t fWidgetId
the widget id (used for event processing)
Definition TGWidget.h:46
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:72
const TGWindow * fMsgWindow
window which handles widget events
Definition TGWidget.h:48
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual void SetEditDisabled(UInt_t on=kEditDisable)
Definition TGWindow.h:113
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
@ kEditDisableLayout
window layout cannot be edited
Definition TGWindow.h:60
@ kEditDisableBtnEnable
window can handle mouse button events
Definition TGWindow.h:64
@ kEditDisableGrab
window grab cannot be edited
Definition TGWindow.h:59
@ kEditDisable
disable edit of this window
Definition TGWindow.h:57
@ kEditDisableKeyEnable
window can handle keyboard events
Definition TGWindow.h:65
virtual void DestroyWindow()
destroy window
Definition TGWindow.cxx:190
virtual void SetWindowName(const char *name=nullptr)
Set window name.
Definition TGWindow.cxx:127
const TGWindow * GetParent() const
Definition TGWindow.h:83
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:334
UInt_t fEditDisabled
flags used for "guibuilding"
Definition TGWindow.h:32
A doubly linked list.
Definition TList.h:38
void AddAfter(const TObject *after, TObject *obj) override
Insert object after object after in the list.
Definition TList.cxx:247
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:819
void AddBefore(const TObject *before, TObject *obj) override
Insert object before object before in the list.
Definition TList.cxx:193
void AddFirst(TObject *obj) override
Add object at the beginning of the list.
Definition TList.cxx:97
Mother of all ROOT objects.
Definition TObject.h:41
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:543
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
void AddReference()
Definition TRefCnt.h:40
Basic string class.
Definition TString.h:138
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1121
virtual TTime Now()
Get current time in milliseconds since 0:00 Jan 1 1995.
Definition TSystem.cxx:461
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition TSystem.cxx:469
virtual TTimer * RemoveTimer(TTimer *t)
Remove timer from list of system timers.
Definition TSystem.cxx:479
void Reset()
Reset the timer.
Definition TTimer.cxx:162
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
TF1 * f1
Definition legend1.C:11
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:251
Double_t Ceil(Double_t x)
Rounds x upward, returning the smallest integral value that is not less than x.
Definition TMath.h:679
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
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
Graphics context structure.
Definition GuiTypes.h:224
TLine l
Definition textangle.C:4
auto * t1
Definition textangle.C:20