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// //
25// TGListBox, TGLBContainer, TGLBEntry and TGTextLBEntry //
26// //
27// A listbox is a box, possibly with scrollbar, containing entries. //
28// Currently entries are simple text strings (TGTextLBEntry). //
29// A TGListBox looks a lot like a TGCanvas. It has a TGViewPort //
30// containing a TGLBContainer which contains the entries and it also //
31// has a vertical scrollbar which becomes visible if there are more //
32// items than fit in the visible part of the container. //
33// //
34// The TGListBox is user callable. The other classes are service //
35// classes of the listbox. //
36// //
37// Selecting an item in the listbox will generate the event: //
38// kC_COMMAND, kCM_LISTBOX, listbox id, item id. //
39// //
40//////////////////////////////////////////////////////////////////////////
41
42#include "TGPicture.h"
43#include "TGListBox.h"
44#include "TGResourcePool.h"
45#include "TSystem.h"
46#include "TMath.h"
47#include "TVirtualX.h"
48
49#include <cstdlib>
50#include <iostream>
51
52
55
61
62////////////////////////////////////////////////////////////////////////////////
63/// Base class entry constructor.
64
65TGLBEntry::TGLBEntry(const TGWindow *p, Int_t id, UInt_t options, Pixel_t back) :
66 TGFrame(p, 10, 10, options | kOwnBackground, back)
67{
69 fEntryId = id;
70 fBkcolor = back;
72
74}
75
76////////////////////////////////////////////////////////////////////////////////
77/// Toggle active state of listbox entry.
78
80{
81 if (fActive == a) return;
82 fActive = a;
83 DoRedraw();
84}
85
86////////////////////////////////////////////////////////////////////////////////
87/// Toggle active state of listbox entry.
88
90{
92 DoRedraw();
93}
94
95
96//////////////////////////////////////////////////////////////////////////
97// //
98// TGTextLBEntry //
99// //
100// Text string listbox entries. //
101// A TGTextLBEntry is for TGListBox internal use. //
102// //
103//////////////////////////////////////////////////////////////////////////
104
105////////////////////////////////////////////////////////////////////////////////
106/// Create a text listbox entry. The TGString is adopted.
107
109 GContext_t norm, FontStruct_t font, UInt_t options, ULong_t back) :
110 TGLBEntry(p, id, options, back)
111{
112 fText = s;
114 fFontStruct = font;
115 fNormGC = norm;
116 fTWidth = 0;
117
118 int max_ascent, max_descent;
119
120 if (fText) fTWidth = gVirtualX->TextWidth(fFontStruct, fText->GetString(), fText->GetLength());
121 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
122 fTHeight = max_ascent + max_descent;
123 Resize(fTWidth, fTHeight + 1);
126}
127
128////////////////////////////////////////////////////////////////////////////////
129/// Delete text listbox entry.
130
132{
133 if (fText) delete fText;
134}
135
136////////////////////////////////////////////////////////////////////////////////
137/// Draw text listbox entry on window/pixmap.
138
140{
141 int max_ascent, max_descent;
142
143 y += (fHeight - fTHeight) >> 1;
144
145 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
146
147 if (fActive) {
149 gVirtualX->FillRectangle(id,fNormGC, x, y, fWidth, fHeight);
151 fText->Draw(id, fNormGC, x + 3, y + max_ascent);
152 } else {
153 gVirtualX->SetForeground(fNormGC, fBkcolor);
154 gVirtualX->FillRectangle(id, fNormGC, x, y, fWidth, fHeight);
155 gVirtualX->SetForeground(fNormGC, GetForeground());
156 fText->Draw(id, fNormGC, x + 3, y + max_ascent);
157 }
158}
159
160////////////////////////////////////////////////////////////////////////////////
161/// Redraw text listbox entry.
162
164{
165 if (fId) DrawCopy(fId, 0, 0);
166}
167
168////////////////////////////////////////////////////////////////////////////////
169/// Set or change text in text entry.
170
172{
173 if (fText) delete fText;
174 fText = new_text;
176
177 int max_ascent, max_descent;
179 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
180 fTHeight = max_ascent + max_descent;
181
182 Resize(fTWidth + 3, fTHeight + 1);
183
184 DoRedraw();
185}
186
187////////////////////////////////////////////////////////////////////////////////
188/// Return default font structure in use for a text listbox entry.
189
191{
192 if (!fgDefaultFont)
193 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
195}
196
197////////////////////////////////////////////////////////////////////////////////
198/// Return default graphics context in use for a text listbox entry.
199
201{
202 if (!fgDefaultGC)
203 fgDefaultGC = new TGGC(*gClient->GetResourcePool()->GetFrameGC());
204 return *fgDefaultGC;
205}
206
207//////////////////////////////////////////////////////////////////////////
208// //
209// TGLineLBEntry //
210// //
211// Line style and width listbox entries. //
212// //
213//////////////////////////////////////////////////////////////////////////
214
215////////////////////////////////////////////////////////////////////////////////
216/// Create the line style listbox entry.
217
218TGLineLBEntry::TGLineLBEntry(const TGWindow *p, Int_t id, const char *str,
219 UInt_t w, Style_t style, UInt_t options, ULong_t back) :
220 TGTextLBEntry(p, new TGString(str), id, GetDefaultGC()(),
221 GetDefaultFontStruct(), options, back)
222{
223 GCValues_t gcv;
224
226 fLineWidth = gcv.fLineWidth = w;
228 gcv.fDashLen = 2;
229 gcv.fDashOffset = 0;
230 memcpy(gcv.fDashes, "\x5\x5", 3);
232 fLineGC = fClient->GetGC(&gcv, kTRUE);
234
235 int max_ascent, max_descent;
236
237 fTWidth = gVirtualX->TextWidth(GetDefaultFontStruct(), "8", 1);
238 fTWidth += 15; // for drawing
239 gVirtualX->GetFontProperties(GetDefaultFontStruct(),
240 max_ascent, max_descent);
241 fTHeight = max_ascent + max_descent;
242 fLineLength = 0;
243
244 Resize(fTWidth, fTHeight + 1);
247}
248
249////////////////////////////////////////////////////////////////////////////////
250/// Delete line style listbox entry.
251
253{
255}
256
257////////////////////////////////////////////////////////////////////////////////
258/// Update line style listbox entry.
259
261{
263
265 fLineGC = ((TGLineLBEntry *)e)->GetLineGC();
267}
268
269////////////////////////////////////////////////////////////////////////////////
270/// Set the line style corresponding to the TPad line styles.
271
273{
274 static const char* dashed = "\x3\x3";
275 static const char* dotted= "\x1\x2";
276 static const char* dasheddotted = "\x3\x4\x1\x4";
277 static const char* ls05 = "\x5\x3\x1\x3";
278 static const char* ls06 = "\x5\x3\x1\x3\x1\x3\x1\x3";
279 static const char* ls07 = "\x5\x5";
280 static const char* ls08 = "\x5\x3\x1\x3\x1\x3";
281 static const char* ls09 = "\x20\x5";
282 static const char* ls10 = "\x20\x10\x1\x10";
283
284
285 if (linestyle <= 1) {
287 } else {
288 switch (linestyle) {
289 case 2:
290 fLineGC->SetDashList(dashed, 2);
291 break;
292 case 3:
293 fLineGC->SetDashList(dotted, 2);
294 break;
295 case 4:
296 fLineGC->SetDashList(dasheddotted, 4);
297 break;
298 case 5:
299 fLineGC->SetDashList(ls05, 4);
300 break;
301 case 6:
302 fLineGC->SetDashList(ls06, 8);
303 break;
304 case 7:
305 fLineGC->SetDashList(ls07, 2);
306 break;
307 case 8:
308 fLineGC->SetDashList(ls08, 6);
309 break;
310 case 9:
311 fLineGC->SetDashList(ls09, 2);
312 break;
313 case 10:
314 fLineGC->SetDashList(ls10, 4);
315 break;
316 }
317 }
318 fLineGC->SetCapStyle(0); // flat cap
319 fLineStyle = linestyle;
320}
321
322////////////////////////////////////////////////////////////////////////////////
323/// Set or change line witdh in an entry.
324
326{
329}
330
331////////////////////////////////////////////////////////////////////////////////
332/// Draw copy on window/pixmap.
333
335{
337 if (!strcmp(TGTextLBEntry::GetTitle(),"None")) return;
338 if (fActive) {
339 gVirtualX->SetForeground(fLineGC->GetGC(),
341 } else {
342 gVirtualX->SetForeground(fLineGC->GetGC(),
344 }
345 gVirtualX->DrawLine(id, fLineGC->GetGC(), x + fTWidth + 5, y + fHeight/2,
346 x + fWidth - 5, y + fHeight/2);
347}
348
349////////////////////////////////////////////////////////////////////////////////
350/// Redraw line style listbox entry.
351
353{
354 if (fId) DrawCopy(fId, 0, 0);
355}
356
357//////////////////////////////////////////////////////////////////////////
358// //
359// TGIconLBEntry //
360// //
361// Icon + text listbox entry. //
362// //
363//////////////////////////////////////////////////////////////////////////
364
365////////////////////////////////////////////////////////////////////////////////
366/// Create the icon & text listbox entry.
367
368TGIconLBEntry::TGIconLBEntry(const TGWindow *p, Int_t id, const char *str,
369 const TGPicture *pic,
370 UInt_t /*w*/, Style_t /*style*/, UInt_t options, ULong_t back) :
371 TGTextLBEntry(p, new TGString(str), id, GetDefaultGC()(),
372 GetDefaultFontStruct(), options, back)
373{
374 int max_ascent, max_descent;
375
376 fPicture = pic;
377 if (fPicture) {
378 fTWidth += fPicture->GetWidth() + 4;
379 ((TGPicture *)fPicture)->AddReference();
380 }
381 else
382 fTWidth += 20;
383 gVirtualX->GetFontProperties(GetDefaultFontStruct(),
384 max_ascent, max_descent);
385 fTHeight = max_ascent + max_descent;
388
389 Resize(fTWidth, fTHeight + 1);
392}
393
394////////////////////////////////////////////////////////////////////////////////
395/// Delete icon & text listbox entry.
396
398{
400}
401
402////////////////////////////////////////////////////////////////////////////////
403/// Update icon & text listbox entry.
404
406{
408}
409
410////////////////////////////////////////////////////////////////////////////////
411/// Draw copy on window/pixmap.
412
414{
415 Int_t off_x = 0;
416 if (fPicture) {
417 fPicture->Draw(id, fNormGC, x + 2, y);
418 off_x = fPicture->GetWidth() + 4;
419 }
420 TGTextLBEntry::DrawCopy(id, x + off_x, y);
421}
422
423////////////////////////////////////////////////////////////////////////////////
424/// Redraw icon & text listbox entry.
425
427{
428 if (fId) DrawCopy(fId, 0, 0);
429}
430
431////////////////////////////////////////////////////////////////////////////////
432/// Change the icon of listbox entry containing icon & text.
433
435{
437
438 if (pic) ((TGPicture *)pic)->AddReference();
439
440 fPicture = pic;
441}
442
443/////////////////////////////////////////////////////////////////////////////////
444class TGLBFrameElement : public TGFrameElement {
445public:
446 TGLBFrameElement(TGFrame *f, TGLayoutHints *l) : TGFrameElement(f, l) {}
447 virtual ~TGLBFrameElement() {}
448
449 Bool_t IsSortable() const { return kTRUE; }
450 Int_t Compare(const TObject *obj) const {
451 if (!fFrame->InheritsFrom(TGTextLBEntry::Class())) {
452 return 0;
453 }
456
457
458 double d1, d2;
459 const char *t1 = f1->GetText()->Data();
460 const char *t2 = f2->GetText()->Data();
461
462 if ((d1 = atof(t1)) && (d2 = atof(t2))) {
463 return (d1 > d2);
464 } else {
465 return strcmp(t1, t2);
466 }
467 return 0;
468 }
469};
470
471//////////////////////////////////////////////////////////////////////////
472// //
473// TGLBContainer //
474// //
475// A Composite frame that contains a list of TGLBEnties. //
476// A TGLBContainer is for TGListBox internal use. //
477// //
478//////////////////////////////////////////////////////////////////////////
479
480////////////////////////////////////////////////////////////////////////////////
481/// Create a listbox container.
482
484 UInt_t options, ULong_t back) :
485 TGContainer(p, w, h, options, back)
486{
487 fLastActive = 0;
488 fMsgWindow = p;
491 fListBox = 0;
492
495}
496
497////////////////////////////////////////////////////////////////////////////////
498/// Delete the listbox container.
499
501{
502 Cleanup();
503}
504
505////////////////////////////////////////////////////////////////////////////////
506/// Layout container
507
509{
512}
513
514////////////////////////////////////////////////////////////////////////////////
515/// redraw
516
518{
519 return TGContainer::DoRedraw();
520}
521
522////////////////////////////////////////////////////////////////////////////////
523/// Add listbox entry with hints to container. To show entry call
524/// MapSubwindows() and Layout().
525
527{
528 // DEPRECATED: the color should always be set in the TGLBEntry ctor
529 //lbe->SetBackgroundColor(fgWhitePixel);
530
531 TGLBFrameElement *nw = new TGLBFrameElement(lbe, lhints ? lhints : fgDefaultHints);
532 fList->Add(nw);
534}
535
536////////////////////////////////////////////////////////////////////////////////
537/// Insert listbox entry after specified entry with id afterID. If afterID = -1
538/// then add entry at head of list. To show entry call MapSubwindows() and
539/// Layout().
540
542{
543 // DEPRECATED: the color should always be set in the TGLBEntry ctor
544 //lbe->SetBackgroundColor(fgWhitePixel);
545
546 TGLBEntry *e;
547 TGFrameElement *el, *nw;
548 TIter next(fList);
549
550 while ((el = (TGFrameElement *) next())) {
551 e = (TGLBEntry *) el->fFrame;
552 if (e->EntryId() == afterID) break;
553 }
554
555 if (!el && afterID != -1) {
556 nw = new TGLBFrameElement(lbe, lhints ? lhints : fgDefaultHints);
557 fList->Add(nw);
558 } else {
559 nw = new TGLBFrameElement(lbe, lhints);
560 nw->fFrame = lbe;
561 nw->fLayout = lhints;
562 nw->fState = 1;
563 //lbe->SetFrameElement(nw);
564
565 if (afterID == -1)
566 fList->AddFirst(nw);
567 else
568 fList->AddAfter(el, nw);
569 }
571}
572
573////////////////////////////////////////////////////////////////////////////////
574/// Insert listbox entry before the list box entry with a higher id.
575/// To show entry call MapSubwindows() and Layout().
576
578{
579 // DEPRECATED: the color should always be set in the TGLBEntry ctor
580 //lbe->SetBackgroundColor(fgWhitePixel);
581
582 TGLBEntry *e;
583 TGFrameElement *el, *nw;
584 TIter next(fList);
585
586 while ((el = (TGFrameElement *) next())) {
587 e = (TGLBEntry *) el->fFrame;
588 if (e->EntryId() > lbe->EntryId()) break;
589 }
590
591 if (!el) {
592 nw = new TGLBFrameElement(lbe, lhints ? lhints : fgDefaultHints);
593 fList->Add(nw);
594 } else {
595 nw = new TGLBFrameElement(lbe, lhints);
596 nw->fFrame = lbe;
597 nw->fLayout = lhints;
598 nw->fState = 1;
599 //lbe->SetFrameElement(nw);
600
601 fList->AddBefore(el, nw);
602 }
604}
605
606////////////////////////////////////////////////////////////////////////////////
607/// Remove the entry with specified id from the listbox container.
608/// To update the listbox call Layout().
609
611{
612 TGLBEntry *e;
613 TGFrameElement *el;
615
616 TIter next(fList);
617
618 while ((el = (TGFrameElement *) next())) {
619 e = (TGLBEntry *) el->fFrame;
620 l = el->fLayout;
621 if (e->EntryId() == id) {
622 if (fLastActive == e) fLastActive = 0;
623 e->DestroyWindow();
624 fList->Remove(el); // avoid calling RemoveFrame(e)
625 delete el; // item
626 delete e;
627 delete l;
628 break;
629 }
630 }
632}
633
634////////////////////////////////////////////////////////////////////////////////
635/// Remove entries from from_ID to to_ID (including).
636/// To update the listbox call Layout().
637
639{
640 TGLBEntry *e;
641 TGFrameElement *el;
643
644 TIter next(fList);
645
646 while ((el = (TGFrameElement *) next())) {
647 e = (TGLBEntry *) el->fFrame;
648 l = el->fLayout;
649 if ((e->EntryId() >= from_ID) && (e->EntryId() <= to_ID)) {
650 if (fLastActive == e) fLastActive = 0;
651 e->DestroyWindow();
652 fList->Remove(el); // avoid calling RemoveFrame(e)
653 delete el; // idem
654 delete e;
655 delete l;
656 }
657 }
659}
660
661////////////////////////////////////////////////////////////////////////////////
662/// Remove all entries in this container.
663
665{
666 TGLBEntry *e;
667 TGFrameElement *el;
669
670 TIter next(fList);
671
672 while ((el = (TGFrameElement *) next())) {
673 e = (TGLBEntry *) el->fFrame;
674 l = el->fLayout;
675 if (fLastActive == e) fLastActive = 0;
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;
701 TGFrameElement *el;
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;
715 fLastActiveEl = el;
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;
741 TGFrameElement *el;
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;
760 TGFrameElement *el;
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{
776 TGFrameElement *el;
777
778 fMultiSelect = multi;
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
795{
796 return fListBox ? fListBox->GetVScrollbar() : 0;
797}
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;
819 TGFrameElement *el;
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;
867 fLastActiveEl = el;
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;
898 fLastActiveEl = el;
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;
956 TGFrameElement *el;
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;
1030 Bool_t changed = kFALSE;
1031
1034
1035 Window_t dum1, dum2;
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
1080{
1082 fLastActive = (TGLBEntry *)el->fFrame;
1083}
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;
1094 TGFrameElement *el;
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// //
1110// TGListBox //
1111// //
1112// A listbox contains a container frame which is viewed through a //
1113// viewport. If the container is larger than the viewport than a //
1114// vertical scrollbar is added. //
1115// //
1116// Selecting an item in the listbox will generate the event: //
1117// kC_COMMAND, kCM_LISTBOX, listbox id, item id. //
1118// //
1119//////////////////////////////////////////////////////////////////////////
1120
1121////////////////////////////////////////////////////////////////////////////////
1122/// Create a listbox.
1123
1125 UInt_t options, ULong_t back) :
1126 TGCompositeFrame(p, 10, 10, options, back)
1127{
1128 fMsgWindow = p;
1129 fWidgetId = id;
1130
1131 fItemVsize = 1;
1133
1134 InitListBox();
1135}
1136
1137////////////////////////////////////////////////////////////////////////////////
1138/// Delete a listbox widget.
1139
1141{
1142 if (!MustCleanup()) {
1143 delete fVScrollbar;
1144 delete fVport;
1145 delete fLbc;
1146 }
1147}
1148
1149////////////////////////////////////////////////////////////////////////////////
1150/// Initiate the internal classes of a list box.
1151
1153{
1158 fLbc->Associate(this);
1159 fLbc->SetListBox(this);
1161
1162 AddFrame(fVport, 0);
1164
1165 fVScrollbar->Associate(this);
1166
1171
1176
1177 // layout manager is not used
1178 delete fLayoutManager;
1179 fLayoutManager = 0;
1180}
1181
1182////////////////////////////////////////////////////////////////////////////////
1183/// Draw borders of the list box widget.
1184
1186{
1188
1190 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, fWidth-2, 0);
1191 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, 0, fHeight-2);
1192 gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, fWidth-3, 1);
1193 gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, 1, fHeight-3);
1194 if (gClient->GetStyle() > 1) break;
1195 gVirtualX->DrawLine(fId, GetHilightGC()(), 0, fHeight-1, fWidth-1, fHeight-1);
1196 gVirtualX->DrawLine(fId, GetHilightGC()(), fWidth-1, fHeight-1, fWidth-1, 0);
1197 gVirtualX->DrawLine(fId, GetBckgndGC()(), 1, fHeight-2, fWidth-2, fHeight-2);
1198 gVirtualX->DrawLine(fId, GetBckgndGC()(), fWidth-2, 1, fWidth-2, fHeight-2);
1199 break;
1200
1201 default:
1203 break;
1204 }
1205}
1206
1207////////////////////////////////////////////////////////////////////////////////
1208/// Add entry with specified string and id to listbox. The id will be
1209/// used in the event processing routine when the item is selected.
1210/// The string will be adopted by the listbox.
1211
1213{
1214 TGTextLBEntry *lbe;
1215 TGLayoutHints *lhints;
1216
1217 lbe = new TGTextLBEntry(fLbc, s, id);
1218 lhints = new TGLayoutHints(kLHintsExpandX | kLHintsTop);
1220 fLbc->AddEntry(lbe, lhints);
1221}
1222
1223////////////////////////////////////////////////////////////////////////////////
1224/// Add entry with specified string and id to listbox. The id will be
1225/// used in the event processing routine when the item is selected.
1226
1227void TGListBox::AddEntry(const char *s, Int_t id)
1228{
1229 AddEntry(new TGString(s), id);
1230}
1231
1232////////////////////////////////////////////////////////////////////////////////
1233/// Add specified TGLBEntry and TGLayoutHints to listbox. The
1234/// entry and layout will be adopted and later deleted by the listbox.
1235
1237{
1239 fLbc->AddEntry(lbe, lhints);
1240}
1241
1242////////////////////////////////////////////////////////////////////////////////
1243/// Add entry with specified string and id to listbox sorted by increasing id.
1244/// This sorting works proberly only if EntrySort functions are used to add
1245/// entries without mixing them with other add or insert functions. The id will be
1246/// used in the event processing routine when the item is selected.
1247/// The string will be adopted by the listbox.
1248
1250{
1251 TGTextLBEntry *lbe;
1252 TGLayoutHints *lhints;
1253
1254 lbe = new TGTextLBEntry(fLbc, s, id);
1255 lhints = new TGLayoutHints(kLHintsExpandX | kLHintsTop);
1257 fLbc->AddEntrySort(lbe, lhints);
1258}
1259
1260////////////////////////////////////////////////////////////////////////////////
1261/// Add entry with specified string and id to listbox sorted by increasing id.
1262/// This sorting works proberly only if EntrySort functions are used to add
1263/// entries without mixing them with other add or insert functions. The id will be
1264/// used in the event processing routine when the item is selected.
1265
1266void TGListBox::AddEntrySort(const char *s, Int_t id)
1267{
1268 AddEntrySort(new TGString(s), id);
1269}
1270
1271////////////////////////////////////////////////////////////////////////////////
1272/// Add specified TGLBEntry and TGLayoutHints to listbox sorted by increasing id.
1273/// This sorting works proberly only if EntrySort functions are used to add
1274/// entries without mixing them with other add or insert functions. The
1275/// entry and layout will be adopted and later deleted by the listbox.
1276
1278{
1280 fLbc->AddEntrySort(lbe, lhints);
1281}
1282
1283////////////////////////////////////////////////////////////////////////////////
1284/// Insert entry with specified string and id behind the entry with afterID.
1285/// The string will be adopted and later deleted by the listbox.
1286
1288{
1289 TGTextLBEntry *lbe;
1290 TGLayoutHints *lhints;
1291
1292 lbe = new TGTextLBEntry(fLbc, s, id);
1293 lhints = new TGLayoutHints(kLHintsExpandX | kLHintsTop);
1295 fLbc->InsertEntry(lbe, lhints, afterID);
1296}
1297
1298////////////////////////////////////////////////////////////////////////////////
1299/// Insert entry with specified string and id behind the entry with afterID.
1300
1301void TGListBox::InsertEntry(const char *s, Int_t id, Int_t afterID)
1302{
1303 InsertEntry(new TGString(s), id, afterID);
1304}
1305
1306////////////////////////////////////////////////////////////////////////////////
1307/// method used to add entry via context menu
1308
1309void TGListBox::NewEntry(const char *s)
1310{
1311 Int_t selected = fLbc->GetSelected();
1312
1313 // no selected entry or the last entry
1314 if ((selected < 0) || (selected == GetNumberOfEntries())) {
1316 } else {
1317 InsertEntry(s, GetNumberOfEntries()+1, selected);
1318 }
1319 Layout();
1320}
1321
1322////////////////////////////////////////////////////////////////////////////////
1323/// remove entry with id.
1324/// If id = -1 - the selected entry/entries is/are removed.
1325///
1326
1328{
1329 if (id >= 0) {
1330 fLbc->RemoveEntry(id);
1331 Layout();
1332 return;
1333 }
1334 if (!fLbc->GetMultipleSelections()) {
1336 Layout();
1337 return;
1338 }
1339 TList li;
1341 TGLBEntry *e;
1342 TIter next(&li);
1343
1344 while ((e = (TGLBEntry*)next())) {
1345 fLbc->RemoveEntry(e->EntryId());
1346 }
1347 Layout();
1348}
1349
1350////////////////////////////////////////////////////////////////////////////////
1351/// Remove all entries.
1352
1354{
1355 fLbc->RemoveAll();
1356 Layout();
1357}
1358
1359////////////////////////////////////////////////////////////////////////////////
1360/// Remove a range of entries defined by from_ID and to_ID.
1361
1363{
1364 fLbc->RemoveEntries(from_ID, to_ID);
1365 Layout();
1366}
1367
1368////////////////////////////////////////////////////////////////////////////////
1369/// Insert the specified TGLBEntry and layout hints behind afterID.
1370/// The entry and layout will be adopted and later deleted by the listbox.
1371
1372void TGListBox::InsertEntry(TGLBEntry *lbe, TGLayoutHints *lhints, int afterID)
1373{
1375 fLbc->InsertEntry(lbe, lhints, afterID);
1376}
1377
1378////////////////////////////////////////////////////////////////////////////////
1379/// Returns list box entry with specified id.
1380
1382{
1383 TIter next(fLbc->GetList());
1384 TGFrameElement *el;
1385
1386 while ((el = (TGFrameElement *)next())) {
1387 TGLBEntry *lbe = (TGLBEntry *)el->fFrame;
1388 if (lbe->EntryId() == id) return lbe;
1389 }
1390 return 0;
1391}
1392
1393////////////////////////////////////////////////////////////////////////////////
1394/// Scroll the entry with id to the top of the listbox.
1395
1397{
1398 Int_t idPos;
1399
1400 idPos = fLbc->GetPos(id);
1401
1402 // id not found in list of entries
1403 if (idPos < 0)
1404 return;
1405
1406 // call layout to define the range of the scroll bars
1407 Layout();
1408
1409 // SetPosition will send a message which will handled by
1410 // the function TGListBox::ProcessMessage. Now ProcessMessage will
1411 // set the viewport. SetPosition also will check that the idPos is
1412 // not out of range.
1413 fVScrollbar->SetPosition(idPos);
1414}
1415
1416////////////////////////////////////////////////////////////////////////////////
1417/// Resize the listbox widget. If fIntegralHeight is true make the height
1418/// an integral number of the maximum height of a single entry.
1419
1421{
1422 if (fIntegralHeight)
1424 + (fBorderWidth << 1);
1425
1427 DoRedraw();
1428}
1429
1430////////////////////////////////////////////////////////////////////////////////
1431/// Move and resize the listbox widget.
1432
1434{
1435 if (fIntegralHeight)
1437 + (fBorderWidth << 1);
1439 DoRedraw();
1440}
1441
1442////////////////////////////////////////////////////////////////////////////////
1443/// Return default size of listbox widget.
1444
1446{
1447 UInt_t h;
1448
1449 if (fIntegralHeight)
1451 + (fBorderWidth << 1);
1452 else
1453 h = fHeight;
1454
1455 return TGDimension(fWidth, h);
1456}
1457
1458////////////////////////////////////////////////////////////////////////////////
1459/// Layout the listbox components.
1460
1462{
1463 TGFrame *container;
1464 UInt_t cw, ch, tch;
1465 Bool_t need_vsb;
1466
1467 need_vsb = kFALSE;
1468
1469 container = fVport->GetContainer();
1470
1471 // test whether we need vertical scrollbar or not
1472
1473 cw = fWidth - (fBorderWidth << 1);
1474 ch = fHeight - (fBorderWidth << 1);
1475
1476 container->SetWidth(cw);
1477 container->SetHeight(ch);
1478
1479 if (container->GetDefaultHeight() > ch) {
1480 need_vsb = kTRUE;
1482 if ((Int_t) cw < 0) {
1483 Warning("Layout", "width would become too small, setting to 10");
1484 cw = 10;
1485 }
1486 container->SetWidth(cw);
1487 }
1488
1490 container->Layout();
1491
1492 tch = TMath::Max(container->GetDefaultHeight(), ch);
1493 container->SetHeight(0); // force a resize in TGFrame::Resize
1494 container->Resize(cw, tch);
1495 //fVport->SetPos(0, 0);
1496
1497 if (need_vsb) {
1500 } else {
1503 }
1504
1507 //fClient->NeedRedraw(container);
1508 ((TGContainer *)container)->ClearViewPort();
1509}
1510
1511////////////////////////////////////////////////////////////////////////////////
1512/// Sort entries by name
1513
1515{
1516 fLbc->GetList()->Sort(ascend);
1517 Layout();
1519}
1520
1521////////////////////////////////////////////////////////////////////////////////
1522/// Return id of selected listbox item.
1523
1525{
1527 return ct->GetSelected();
1528}
1529
1530////////////////////////////////////////////////////////////////////////////////
1531/// Adds all selected entries (TGLBEntry) of the list box into
1532/// the list selected.
1533
1535{
1536 fLbc->GetSelectedEntries(selected);
1537}
1538
1539////////////////////////////////////////////////////////////////////////////////
1540/// Change background to all entries
1541
1543{
1544 fBackground = back;
1545
1546 TIter next(fLbc->GetList());
1547 TGFrameElement *el;
1548
1549 while ((el = (TGFrameElement *)next())) {
1550 TGLBEntry *lbe = (TGLBEntry *)el->fFrame;
1551 lbe->SetBackgroundColor(back);
1552 }
1554}
1555
1556////////////////////////////////////////////////////////////////////////////////
1557/// Process messages generated by the listbox container and forward
1558/// messages to the listbox message handling window.
1559
1561{
1562 switch (GET_MSG(msg)) {
1563 case kC_VSCROLL:
1564 switch (GET_SUBMSG(msg)) {
1565 case kSB_SLIDERTRACK:
1566 case kSB_SLIDERPOS:
1567 fVport->SetVPos(Int_t(-parm1 * fItemVsize));
1568 break;
1569 }
1570 break;
1571
1572 case kC_CONTAINER:
1573 switch (GET_SUBMSG(msg)) {
1574 case kCT_ITEMCLICK:
1575 {
1577 fWidgetId, parm1);
1579 TGLBEntry *entry = GetSelectedEntry();
1580 if (entry) {
1581 if (entry->InheritsFrom(TGTextLBEntry::Class())) {
1582 const char *text;
1583 text = ((TGTextLBEntry*)entry)->GetText()->GetString();
1584 Selected(text);
1585 }
1586 Selected(fWidgetId, (Int_t) parm1);
1587 Selected((Int_t) parm1);
1588 }
1589 }
1590 break;
1591 case kCT_ITEMDBLCLICK:
1592 if (!GetMultipleSelections()) {
1593 TGLBEntry *entry = GetSelectedEntry();
1594 if (entry) {
1595 if (entry->InheritsFrom(TGTextLBEntry::Class())) {
1596 const char *text;
1597 text = ((TGTextLBEntry*)entry)->GetText()->GetString();
1599 }
1600 DoubleClicked(fWidgetId, (Int_t) parm1);
1601 DoubleClicked((Int_t) parm1);
1602 }
1603 }
1604 break;
1605 }
1606 break;
1607
1608 default:
1609 break;
1610
1611 }
1612 return kTRUE;
1613}
1614
1615////////////////////////////////////////////////////////////////////////////////
1616/// Emit Selected signal with list box id and entry id.
1617
1619{
1620 Long_t args[2];
1621
1622 args[0] = widgetId;
1623 args[1] = id;
1624
1625 Emit("Selected(Int_t,Int_t)", args);
1626}
1627
1628////////////////////////////////////////////////////////////////////////////////
1629/// Emit DoubleClicked signal with list box id and entry id.
1630
1632{
1633 Long_t args[2];
1634
1635 args[0] = widgetId;
1636 args[1] = id;
1637
1638 Emit("DoubleClicked(Int_t,Int_t)", args);
1639}
1640
1641////////////////////////////////////////////////////////////////////////////////
1642/// Find entry by name.
1643
1645{
1646 TList *list = fLbc->GetList();
1647 TGFrameElement *el = (TGFrameElement *)list->First();
1648 while (el) {
1649 if (el->fFrame->GetTitle() == TString(name))
1650 return (TGLBEntry *)el->fFrame;
1651 el = (TGFrameElement *)list->After(el);
1652 }
1653 return 0;
1654}
1655
1656////////////////////////////////////////////////////////////////////////////////
1657/// Save a list box widget as a C++ statement(s) on output stream out.
1658
1659void TGListBox::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1660{
1661 if (fBackground != GetWhitePixel()) SaveUserColor(out, option);
1662
1663 out << std::endl << " // list box" << std::endl;
1664
1665 out<<" TGListBox *";
1666 out << GetName() << " = new TGListBox(" << fParent->GetName();
1667
1668 if (fBackground == GetWhitePixel()) {
1669 if (GetOptions() == (kSunkenFrame | kDoubleBorder)) {
1670 if (fWidgetId == -1) {
1671 out <<");" << std::endl;
1672 } else {
1673 out << "," << fWidgetId << ");" << std::endl;
1674 }
1675 } else {
1676 out << "," << fWidgetId << "," << GetOptionString() <<");" << std::endl;
1677 }
1678 } else {
1679 out << "," << fWidgetId << "," << GetOptionString() << ",ucolor);" << std::endl;
1680 }
1681 if (option && strstr(option, "keep_names"))
1682 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
1683
1684 if (!fLbc->GetList()) return;
1685
1686 TGFrameElement *el;
1687 TIter next(fLbc->GetList());
1688
1689 while ((el = (TGFrameElement *) next())) {
1690 out << " " << GetName() << "->AddEntry(";
1691 el->fFrame->SavePrimitive(out, option);
1692 out << ");"<< std::endl;
1693 }
1694 out << " " << GetName() << "->Resize(" << GetWidth() << "," << GetHeight()
1695 << ");" << std::endl;
1696}
1697
1698////////////////////////////////////////////////////////////////////////////////
1699/// Save a list box entry widget as a C++ statement(s) on output stream out.
1700
1701void TGTextLBEntry::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
1702{
1703 TString content = GetText()->GetString();
1704 content.ReplaceAll('\\', "\\\\");
1705 content.ReplaceAll("\"", "\\\"");
1706 char quote = '"';
1707 out << quote << content << quote << "," << EntryId();
1708}
@ 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
ULong_t Handle_t
Generic resource handle.
Definition GuiTypes.h:26
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
const Mask_t kGCDashList
Definition GuiTypes.h:307
const Mask_t kGCFillStyle
Definition GuiTypes.h:294
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
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
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
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
#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
int Int_t
Definition RtypesCore.h:45
const Bool_t kFALSE
Definition RtypesCore.h:92
unsigned long ULong_t
Definition RtypesCore.h:55
long Long_t
Definition RtypesCore.h:54
bool Bool_t
Definition RtypesCore.h:63
double Double_t
Definition RtypesCore.h:59
long long Long64_t
Definition RtypesCore.h:73
short Style_t
Definition RtypesCore.h:80
const Bool_t kTRUE
Definition RtypesCore.h:91
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:364
include TDocParser_001 C image html pict1_TDocParser_001 png width
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:231
#define gClient
Definition TGClient.h:166
@ kLHintsTop
Definition TGLayout.h:34
@ kLHintsExpandX
Definition TGLayout.h:37
XFontStruct * id
Definition TGX11.cxx:109
char name[80]
Definition TGX11.cxx:110
R__EXTERN TSystem * gSystem
Definition TSystem.h:559
#define gVirtualX
Definition TVirtualX.h:338
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
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:98
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get graphics context from the gc pool.
Definition TGClient.cxx:319
void FreeGC(const TGGC *gc)
Free a graphics context.
Definition TGClient.cxx:327
const TGResourcePool * GetResourcePool() const
Definition TGClient.h:133
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:307
TGLayoutManager * fLayoutManager
Definition TGFrame.h:327
virtual TList * GetList() const
Definition TGFrame.h:346
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1102
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:952
virtual Int_t MustCleanup() const
Definition TGFrame.h:397
Bool_t fMapSubwindows
Definition TGFrame.h:331
TList * fList
Definition TGFrame.h:328
virtual void SetEditDisabled(UInt_t on=1)
Set edit disable flag for this frame and subframes.
Definition TGFrame.cxx:1007
static TGLayoutHints * fgDefaultHints
Definition TGFrame.h:333
virtual void ActivateItem(TGFrameElement *el)
Activate item.
Definition TGCanvas.cxx:697
TTimer * fScrollTimer
Definition TGCanvas.h:60
virtual void ClearViewPort()
Clear view port and redraw full content.
Definition TGCanvas.cxx:887
const TGWindow * fMsgWindow
Definition TGCanvas.h:52
Bool_t fScrolling
Definition TGCanvas.h:69
virtual void DoRedraw()
Redraw content of container in the viewport region.
Definition TGCanvas.cxx:796
virtual TGDimension GetPageDimension() const
Returns page dimension.
Definition TGCanvas.cxx:747
virtual void Layout()
Layout container entries.
Definition TGCanvas.cxx:418
TGViewPort * fViewPort
Definition TGCanvas.h:50
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle double click mouse event.
virtual void DoubleClicked(TGFrame *f, Int_t btn)
Emit DoubleClicked() signal.
Definition TGCanvas.cxx:534
virtual TGPosition GetPagePosition() const
Returns page position.
Definition TGCanvas.cxx:733
TGFrameElement * fLastActiveEl
Definition TGCanvas.h:53
UInt_t fHeight
Definition TGDimension.h:30
FontStruct_t GetFontStruct() const
Definition TGFont.h:193
TGLayoutHints * fLayout
Definition TGLayout.h:121
TGFrame * fFrame
Definition TGLayout.h:119
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:324
virtual void DoRedraw()
Redraw the frame.
Definition TGFrame.cxx:415
static const TGGC & GetBlackGC()
Get black graphics context.
Definition TGFrame.cxx:720
UInt_t fOptions
Definition TGFrame.h:118
void RemoveInput(UInt_t emask)
Remove events specified in emask from the events the frame should handle.
Definition TGFrame.cxx:333
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:694
UInt_t fHeight
Definition TGFrame.h:112
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:214
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:215
virtual void DrawBorder()
Draw frame border.
Definition TGFrame.cxx:406
Int_t fBorderWidth
Definition TGFrame.h:117
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a frame widget as a C++ statement(s) on output stream out.
Definition TGFrame.cxx:3192
static Pixel_t fgDefaultSelectedBackground
Definition TGFrame.h:126
virtual void Activate(Bool_t)
Definition TGFrame.h:234
virtual Pixel_t GetForeground() const
Return frame foreground color.
Definition TGFrame.cxx:288
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition TGFrame.cxx:740
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
Definition TGFrame.cxx:630
virtual UInt_t GetOptions() const
Definition TGFrame.h:221
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition TGFrame.cxx:2465
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:750
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:590
UInt_t fWidth
Definition TGFrame.h:111
UInt_t GetHeight() const
Definition TGFrame.h:249
virtual void Layout()
Definition TGFrame.h:223
virtual void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0)
Move and/or resize the frame.
Definition TGFrame.cxx:614
virtual void SetWidth(UInt_t w)
Definition TGFrame.h:270
virtual void MapWindow()
map window
Definition TGFrame.h:228
static Pixel_t fgWhitePixel
Definition TGFrame.h:127
UInt_t GetWidth() const
Definition TGFrame.h:248
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition TGFrame.cxx:2438
virtual void SetHeight(UInt_t h)
Definition TGFrame.h:271
Pixel_t fBackground
Definition TGFrame.h:119
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition TGFrame.cxx:760
virtual void UnmapWindow()
unmap window
Definition TGFrame.h:230
Definition TGGC.h:31
GContext_t GetGC() const
Definition TGGC.h:50
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
virtual void DoRedraw()
Redraw icon & text listbox entry.
virtual void SetPicture(const TGPicture *pic=nullptr)
Change the icon of listbox entry containing icon & text.
virtual ~TGIconLBEntry()
Delete icon & text listbox entry.
TGIconLBEntry(const TGIconLBEntry &)=delete
virtual void Update(TGLBEntry *e)
Update icon & text listbox entry.
const TGPicture * fPicture
Definition TGListBox.h:190
virtual void DrawCopy(Handle_t id, Int_t x, Int_t y)
Draw copy on window/pixmap.
virtual void RemoveAll()
Remove all entries in this container.
TGLBContainer(const TGLBContainer &)=delete
Bool_t fMultiSelect
Definition TGListBox.h:233
virtual Bool_t GetSelection(Int_t id)
Returns kTrue if entry id is selected.
virtual void Layout()
Layout container.
virtual void SetListBox(TGListBox *lb)
Definition TGListBox.h:255
virtual void OnAutoScroll()
Autoscroll while close to & beyond The Wall.
Int_t fChangeStatus
Definition TGListBox.h:234
virtual Int_t GetSelected() const
Returns id of selected entry.
virtual void ActivateItem(TGFrameElement *el)
Activate item.
virtual Bool_t GetMultipleSelections() const
Definition TGListBox.h:274
virtual ~TGLBContainer()
Delete the listbox container.
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in listbox container.
virtual TGLBEntry * Select(Int_t id, Bool_t sel)
Select / deselect the entry with the specified id.
TGLBEntry * fLastActive
Definition TGListBox.h:231
virtual void RemoveEntries(Int_t from_ID, Int_t to_ID)
Remove entries from from_ID to to_ID (including).
virtual void Associate(const TGWindow *w)
Definition TGListBox.h:254
TGListBox * fListBox
Definition TGListBox.h:232
virtual void AddEntry(TGLBEntry *lbe, TGLayoutHints *lhints)
Add listbox entry with hints to container.
virtual TGVScrollBar * GetVScrollbar() const
Return a pointer to vertical scroll bar.
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 SetVsbPosition(Int_t newPos)
Set new vertical scroll bar position.
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.
virtual void DoRedraw()
redraw
virtual void SetMultipleSelections(Bool_t multi)
Enables and disables multiple selections of entries.
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in the listbox container.
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle double click mouse event in the listbox container.
Pixel_t fBkcolor
Definition TGListBox.h:55
virtual void SetBackgroundColor(Pixel_t col)
Set background color (override from TGWindow base class).
Definition TGListBox.h:69
Int_t fEntryId
Definition TGListBox.h:54
virtual void Activate(Bool_t a)
Toggle active state of listbox entry.
Definition TGListBox.cxx:79
virtual void Toggle()
Toggle active state of listbox entry.
Definition TGListBox.cxx:89
Int_t EntryId() const
Definition TGListBox.h:67
Bool_t fActive
Definition TGListBox.h:56
virtual void DoRedraw()
Redraw the frame.
Definition TGListBox.h:58
TGLBEntry(const TGWindow *p=0, Int_t id=-1, UInt_t options=kHorizontalFrame, Pixel_t back=GetWhitePixel())
Base class entry constructor.
Definition TGListBox.cxx:65
Style_t fLineStyle
Definition TGListBox.h:149
TGGC * fLineGC
Definition TGListBox.h:151
virtual void DoRedraw()
Redraw line style listbox entry.
UInt_t fLineLength
Definition TGListBox.h:150
UInt_t fLineWidth
Definition TGListBox.h:148
virtual ~TGLineLBEntry()
Delete line style listbox entry.
virtual void SetLineWidth(Int_t width)
Set or change line witdh in an entry.
virtual void DrawCopy(Handle_t id, Int_t x, Int_t y)
Draw copy on window/pixmap.
virtual void SetLineStyle(Style_t style)
Set the line style corresponding to the TPad line styles.
TGLineLBEntry(const TGLineLBEntry &)=delete
virtual void Update(TGLBEntry *e)
Update line style listbox entry.
virtual void InitListBox()
Initiate the internal classes of a list box.
Bool_t fIntegralHeight
Definition TGListBox.h:296
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 ~TGListBox()
Delete a listbox widget.
virtual void SortByName(Bool_t ascend=kTRUE)
Sort entries by name.
virtual void Resize(UInt_t w, UInt_t h)
Resize the listbox widget.
virtual TGVScrollBar * GetVScrollbar() const
Definition TGListBox.h:337
TGViewPort * fVport
Definition TGListBox.h:298
UInt_t fItemVsize
Definition TGListBox.h:295
virtual Int_t GetNumberOfEntries() const
Definition TGListBox.h:330
TGLBContainer * fLbc
Definition TGListBox.h:297
virtual TGDimension GetDefaultSize() const
Return default size of listbox widget.
virtual void DrawBorder()
Draw borders of the list box widget.
virtual TGLBEntry * GetSelectedEntry() const
Definition TGListBox.h:355
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
virtual Int_t GetSelected() const
Return id of selected listbox item.
virtual void SetTopEntry(Int_t id=-1)
Scroll the entry with id to the top of the listbox.
virtual void AddEntry(TGString *s, Int_t id)
Add entry with specified string and id to listbox.
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 MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h)
Move and resize the listbox widget.
virtual void RemoveAll()
Remove all entries.
virtual void SelectionChanged()
Definition TGListBox.h:367
virtual Bool_t GetMultipleSelections() const
Definition TGListBox.h:328
void SetContainer(TGFrame *f)
Definition TGListBox.h:301
TGVScrollBar * fVScrollbar
Definition TGListBox.h:299
virtual void ChangeBackground(Pixel_t back)
Change background to all entries.
virtual TGLBEntry * GetEntry(Int_t id) const
Returns list box entry with specified id.
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process messages generated by the listbox container and forward messages to the listbox message handl...
virtual TGViewPort * GetViewPort() const
Definition TGListBox.h:335
virtual TGFrame * GetContainer() const
Definition TGListBox.h:334
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a list box widget as a C++ statement(s) on output stream out.
virtual void Layout()
Layout the listbox components.
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.
virtual TGLBEntry * FindEntry(const char *s) const
Find entry by name.
virtual void Selected(Int_t widgetId, Int_t id)
Emit Selected signal with list box id and entry id.
TGClient * fClient
Definition TGObject.h:37
Handle_t fId
Definition TGObject.h:36
UInt_t GetHeight() const
Definition TGPicture.h:64
void Draw(Option_t *="")
Default Draw method for all objects.
Definition TGPicture.h:57
UInt_t GetWidth() const
Definition TGPicture.h:63
Pixel_t GetBlackColor() const
Pixel_t GetSelectedFgndColor() const
virtual Int_t GetPosition() const
virtual void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0)
Move and/or resize the frame.
Int_t GetLength() const
Definition TGString.h:39
const char * GetString() const
Definition TGString.h:40
virtual void Draw(Drawable_t id, GContext_t gc, Int_t x, Int_t y)
Draw string.
Definition TGString.cxx:51
UInt_t fTWidth
Definition TGListBox.h:87
Bool_t fTextChanged
Definition TGListBox.h:89
const TGString * GetText() const
Definition TGListBox.h:114
GContext_t fNormGC
Definition TGListBox.h:90
static const TGFont * fgDefaultFont
Definition TGListBox.h:95
UInt_t fTHeight
Definition TGListBox.h:88
TGString * fText
Definition TGListBox.h:86
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a list box entry widget as a C++ statement(s) on output stream out.
FontStruct_t fFontStruct
Definition TGListBox.h:91
virtual const char * GetTitle() const
Returns title of object.
Definition TGListBox.h:116
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use for a text listbox entry.
virtual ~TGTextLBEntry()
Delete text listbox entry.
virtual void Update(TGLBEntry *e)
Definition TGListBox.h:120
static const TGGC & GetDefaultGC()
Return default graphics context in use for a text listbox entry.
TGTextLBEntry(const TGTextLBEntry &)=delete
virtual void DoRedraw()
Redraw text listbox entry.
static TGGC * fgDefaultGC
Definition TGListBox.h:96
virtual void DrawCopy(Handle_t id, Int_t x, Int_t y)
Draw text listbox entry on window/pixmap.
void SetText(TGString *new_text)
Set or change text in text entry.
virtual void SetPosition(Int_t pos)
Set logical slider position of vertical scrollbar.
virtual void SetRange(Int_t range, Int_t page_size)
Set range of vertical scrollbar.
TGFrame * GetContainer() const
Definition TGCanvas.h:183
virtual void SetVPos(Int_t ypos)
Moves content of container frame in vertical direction.
Definition TGCanvas.cxx:225
Int_t fWidgetId
Definition TGWidget.h:56
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:82
const TGWindow * fMsgWindow
Definition TGWidget.h:58
virtual void SetWindowName(const char *name=0)
Set window name.
Definition TGWindow.cxx:128
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:335
virtual void SetEditDisabled(UInt_t on=kEditDisable)
Definition TGWindow.h:114
const TGWindow * fParent
Definition TGWindow.h:36
@ kEditDisableLayout
Definition TGWindow.h:61
@ kEditDisableBtnEnable
Definition TGWindow.h:65
@ kEditDisableGrab
Definition TGWindow.h:60
@ kEditDisable
Definition TGWindow.h:58
@ kEditDisableKeyEnable
Definition TGWindow.h:66
virtual void DestroyWindow()
destroy window
Definition TGWindow.cxx:191
const TGWindow * GetParent() const
Definition TGWindow.h:84
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition TGWindow.cxx:294
UInt_t fEditDisabled
Definition TGWindow.h:40
A doubly linked list.
Definition TList.h:44
virtual void Add(TObject *obj)
Definition TList.h:87
virtual TObject * After(const TObject *obj) const
Returns the object after object obj.
Definition TList.cxx:330
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition TList.cxx:822
virtual void AddFirst(TObject *obj)
Add object at the beginning of the list.
Definition TList.cxx:100
virtual void AddAfter(const TObject *after, TObject *obj)
Insert object after object after in the list.
Definition TList.cxx:250
virtual void AddBefore(const TObject *before, TObject *obj)
Insert object before object before in the list.
Definition TList.cxx:196
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:659
virtual void Sort(Bool_t order=kSortAscending)
Sort linked list.
Definition TList.cxx:937
Mother of all ROOT objects.
Definition TObject.h:37
virtual Bool_t IsSortable() const
Definition TObject.h:146
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:445
virtual const char * GetTitle() const
Returns title of object.
Definition TObject.cxx:403
virtual Int_t Compare(const TObject *obj) const
Compare abstract method.
Definition TObject.cxx:161
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:136
const char * Data() const
Definition TString.h:369
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:692
virtual TTime Now()
Get current time in milliseconds since 0:00 Jan 1 1995.
Definition TSystem.cxx:464
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition TSystem.cxx:472
virtual TTimer * RemoveTimer(TTimer *t)
Remove timer from list of system timers.
Definition TSystem.cxx:482
void Reset()
Reset the timer.
Definition TTimer.cxx:157
TText * text
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)
Definition TMathBase.h:212
Double_t Ceil(Double_t x)
Definition TMath.h:695
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
Long_t fUser[5]
5 longs can be used by client message events NOTE: only [0], [1] and [2] may be used.
Definition GuiTypes.h:187
UInt_t fCode
key or button code
Definition GuiTypes.h:180
Graphics context structure.
Definition GuiTypes.h:224
Int_t fDashOffset
patterned/dashed line information
Definition GuiTypes.h:248
Int_t fLineWidth
line width
Definition GuiTypes.h:229
Mask_t fMask
bit mask specifying which fields are valid
Definition GuiTypes.h:251
Int_t fLineStyle
kLineSolid, kLineOnOffDash, kLineDoubleDash
Definition GuiTypes.h:230
Char_t fDashes[8]
dash pattern list (dash length per byte)
Definition GuiTypes.h:249
Int_t fFillStyle
kFillSolid, kFillTiled, kFillStippled, kFillOpaeueStippled
Definition GuiTypes.h:234
Int_t fDashLen
number of dashes in fDashes
Definition GuiTypes.h:250
TCanvas * style()
Definition style.C:1
auto * l
Definition textangle.C:4
auto * t1
Definition textangle.C:20