Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
TGListTree.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id: 2897f2e70909348e1e18681c5c7b0aee8c027744 $
2// Author: Fons Rademakers 25/02/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 TGListTree
25 \ingroup guiwidgets
26
27A list tree is a widget that can contain a number of items
28arranged in a tree structure. The items are represented by small
29folder icons that can be either open or closed.
30
31The TGListTree is user callable. The TGListTreeItem is a service
32class of the list tree.
33
34A list tree can generate the following events:
35 - kC_LISTTREE, kCT_ITEMCLICK, which button, location (y<<16|x).
36 - kC_LISTTREE, kCT_ITEMDBLCLICK, which button, location (y<<16|x).
37
38*/
39
40
41#include <cstdlib>
42#include <iostream>
43
44#include "TClass.h"
45#include "TGListTree.h"
46#include "TGPicture.h"
47#include "TGCanvas.h"
48#include "TGScrollBar.h"
49#include "TGToolTip.h"
50#include "KeySymbols.h"
51#include "TGTextEditDialogs.h"
52#include "TGResourcePool.h"
53#include "TGMsgBox.h"
54#include "TError.h"
55#include "TROOT.h"
56#include "TColor.h"
57#include "TSystem.h"
58#include "TString.h"
59#include "TObjString.h"
60#include "TGDNDManager.h"
61#include "TBufferFile.h"
62#include "TVirtualX.h"
63#include "RConfigure.h"
64#include "strlcpy.h"
65#include "snprintf.h"
66
68const TGFont *TGListTree::fgDefaultFont = nullptr;
70TGGC *TGListTree::fgDrawGC = nullptr;
71TGGC *TGListTree::fgLineGC = nullptr;
74const TGPicture *TGListTree::fgOpenPic = nullptr;
75const TGPicture *TGListTree::fgClosedPic = nullptr;
76const TGPicture *TGListTree::fgCheckedPic = nullptr;
78
79
83
84/******************************************************************************/
85/******************************************************************************/
86// TGListTreeItem
87/******************************************************************************/
88
89////////////////////////////////////////////////////////////////////////////////
90/// Constructor.
91
93 fClient(client),
94 fParent (0), fFirstchild(0), fLastchild (0), fPrevsibling(0),
95 fNextsibling(0),fOpen (kFALSE), fDNDState (0),
96 fY (0), fXtext (0), fYtext(0), fHeight(0)
97{
98}
99
100////////////////////////////////////////////////////////////////////////////////
101/// Return width of item's icon.
102
104{
105 const TGPicture *pic = GetPicture();
106 return (pic) ? pic->GetWidth() : 0;
107}
108
109/******************************************************************************/
110/******************************************************************************/
111// TGListTreeItemStd
112/******************************************************************************/
113
114////////////////////////////////////////////////////////////////////////////////
115/// Create list tree item.
116
118 const TGPicture *opened,
119 const TGPicture *closed,
121 TGListTreeItem(client)
122{
123 fText = name;
125 fChecked = kTRUE;
126
127 if (!opened)
129 else
130 ((TGPicture *)opened)->AddReference();
131
132 if (!closed)
134 else
135 ((TGPicture *)closed)->AddReference();
136
139
142
143 fActive = kFALSE;
144
146 fUserData = 0;
147
149 fColor = 0;
150 fDNDState = 0;
151}
152
153////////////////////////////////////////////////////////////////////////////////
154/// Delete list tree item.
155
157{
158 if (fOwnsData && fUserData) {
159 TObject *obj = static_cast<TObject *>(fUserData);
160 delete dynamic_cast<TObject *>(obj);
161 }
166}
167
168////////////////////////////////////////////////////////////////////////////////
169/// Return color for marking items that are active or selected.
170
175
176////////////////////////////////////////////////////////////////////////////////
177/// Add all child items of 'item' into the list 'checked'.
178
180{
181 TGListTreeItem *item = this;
182
183 while (item) {
184 if (item->IsChecked()) {
185 return kTRUE;
186 }
187 if (item->GetFirstChild()) {
188 if (item->GetFirstChild()->HasCheckedChild())
189 return kTRUE;
190 }
191 if (!first)
192 item = item->GetNextSibling();
193 else
194 break;
195 }
196 return kFALSE;
197}
198
199////////////////////////////////////////////////////////////////////////////////
200/// Add all child items of 'item' into the list 'checked'.
201
203{
204 TGListTreeItem *item = this;
205
206 while (item) {
207 if (!item->IsChecked()) {
208 return kTRUE;
209 }
210 if (item->GetFirstChild()) {
211 if (item->GetFirstChild()->HasUnCheckedChild())
212 return kTRUE;
213 }
214 if (!first)
215 item = item->GetNextSibling();
216 else
217 break;
218 }
219 return kFALSE;
220}
221
222////////////////////////////////////////////////////////////////////////////////
223/// Update the state of the node 'item' according to the children states.
224
226{
227 if ((!fChecked && HasCheckedChild(kTRUE)) ||
229 SetCheckBoxPictures(gClient->GetPicture("checked_dis_t.xpm"),
230 gClient->GetPicture("unchecked_dis_t.xpm"));
231 }
232 else {
233 SetCheckBoxPictures(gClient->GetPicture("checked_t.xpm"),
234 gClient->GetPicture("unchecked_t.xpm"));
235 }
236}
237
238////////////////////////////////////////////////////////////////////////////////
239/// Set all child items of this one checked if state=kTRUE,
240/// unchecked if state=kFALSE.
241
243{
244 if (state) {
245 if (!IsChecked())
246 CheckItem();
247 } else {
248 if (IsChecked())
249 Toggle();
250 }
252 UpdateState();
253}
254
255////////////////////////////////////////////////////////////////////////////////
256/// Set all child items of 'item' checked if state=kTRUE;
257/// unchecked if state=kFALSE.
258
260{
261 if (!item) return;
262
263 while (item) {
264 if (state){
265 if (!item->IsChecked())
266 item->CheckItem();
267 } else {
268 if (item->IsChecked())
269 item->Toggle();
270 }
271 if (item->GetFirstChild()) {
272 CheckChildren(item->GetFirstChild(), state);
273 }
274 item->UpdateState();
275 item = item->GetNextSibling();
276 }
277}
278
279////////////////////////////////////////////////////////////////////////////////
280/// Set a check box on the tree node.
281
286
287////////////////////////////////////////////////////////////////////////////////
288/// Change list tree check item icons.
289
291 const TGPicture *unchecked)
292{
295
296 if (!checked) {
297 ::Warning("TGListTreeItem::SetCheckBoxPictures", "checked picture not specified, defaulting to checked_t");
298 checked = fClient->GetPicture("checked_t.xpm");
299 } else
300 ((TGPicture *)checked)->AddReference();
301
302 if (!unchecked) {
303 ::Warning("TGListTreeItem::SetCheckBoxPictures", "unchecked picture not specified, defaulting to unchecked_t");
304 unchecked = fClient->GetPicture("unchecked_t.xpm");
305 } else
306 ((TGPicture *)unchecked)->AddReference();
307
308 fCheckedPic = checked;
310}
311
312////////////////////////////////////////////////////////////////////////////////
313/// Change list tree item icons.
314
316{
319
320 if (!opened) {
321 ::Warning("TGListTreeItem::SetPictures", "opened picture not specified, defaulting to ofolder_t");
322 opened = fClient->GetPicture("ofolder_t.xpm");
323 } else
324 ((TGPicture *)opened)->AddReference();
325
326 if (!closed) {
327 ::Warning("TGListTreeItem::SetPictures", "closed picture not specified, defaulting to folder_t");
328 closed = fClient->GetPicture("folder_t.xpm");
329 } else
330 ((TGPicture *)closed)->AddReference();
331
334}
335
336
337/******************************************************************************/
338/******************************************************************************/
339// TGListTree
340/******************************************************************************/
341
342////////////////////////////////////////////////////////////////////////////////
343/// Create a list tree widget.
344
346 Pixel_t back) :
347 TGContainer(p, w, h, options, back)
348{
349 fMsgWindow = p;
350 fCanvas = 0;
351 fTip = 0;
352 fTipItem = 0;
356 fBdown = kFALSE;
360 fDropItem = 0;
361 fLastEventState = 0;
362
365
367 fDrawGC = GetDrawGC()();
368 fLineGC = GetLineGC()();
370 fColorGC = GetColorGC()();
371
373 fDefw = fDefh = 1;
374
375 fHspacing = 2;
376 fVspacing = 2; // 0;
377 fIndent = 3; // 0;
378 fMargin = 2;
379
380 fXDND = fYDND = 0;
381 fDNDData.fData = 0;
384 fBuf = 0;
385
389
390 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
392 kNone, kNone);
393
397
398 fDNDTypeList = new Atom_t[3];
399 fDNDTypeList[0] = gVirtualX->InternAtom("application/root", kFALSE);
400 fDNDTypeList[1] = gVirtualX->InternAtom("text/uri-list", kFALSE);
401 fDNDTypeList[2] = 0;
402 gVirtualX->SetDNDAware(fId, fDNDTypeList);
405}
406
407////////////////////////////////////////////////////////////////////////////////
408/// Create a list tree widget.
409
411 TGContainer(p, options, back)
412{
413 fMsgWindow = p;
414 fTip = 0;
415 fTipItem = 0;
419 fBdown = kFALSE;
423 fDropItem = 0;
424 fLastEventState = 0;
425
428
430 fDrawGC = GetDrawGC()();
431 fLineGC = GetLineGC()();
433 fColorGC = GetColorGC()();
434
436 fDefw = fDefh = 1;
437
438 fHspacing = 2;
439 fVspacing = 2; // 0;
440 fIndent = 3; // 0;
441 fMargin = 2;
442
443 fXDND = fYDND = 0;
444 fDNDData.fData = 0;
447 fBuf = 0;
448
452
453 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
455 kNone, kNone);
456
460
461 fDNDTypeList = new Atom_t[3];
462 fDNDTypeList[0] = gVirtualX->InternAtom("application/root", kFALSE);
463 fDNDTypeList[1] = gVirtualX->InternAtom("text/uri-list", kFALSE);
464 fDNDTypeList[2] = 0;
465 gVirtualX->SetDNDAware(fId, fDNDTypeList);
468}
469
470////////////////////////////////////////////////////////////////////////////////
471/// Delete list tree widget.
472
474{
476
477 delete [] fDNDTypeList;
478 delete fTip;
479
480 item = fFirst;
481 while (item) {
483 sibling = item->fNextsibling;
484 delete item;
485 item = sibling;
486 }
487}
488
489//--- text utility functions
490
491////////////////////////////////////////////////////////////////////////////////
492/// Returns height of currently used font.
493
495{
496 if (!fgDefaultFont)
497 fgDefaultFont = gClient->GetResourcePool()->GetIconFont();
498 return fgDefaultFont->TextHeight();
499}
500
501////////////////////////////////////////////////////////////////////////////////
502/// Returns ascent of currently used font.
503
505{
507 if (!fgDefaultFont)
508 fgDefaultFont = gClient->GetResourcePool()->GetIconFont();
509 fgDefaultFont->GetFontMetrics(&m);
510 return m.fAscent;
511}
512
513////////////////////////////////////////////////////////////////////////////////
514/// Returns text width relative to currently used font.
515
517{
518 if (!fgDefaultFont)
519 fgDefaultFont = gClient->GetResourcePool()->GetIconFont();
520 return fgDefaultFont->TextWidth(c);
521}
522
523//---- highlighting utilities
524
525////////////////////////////////////////////////////////////////////////////////
526/// Highlight tree item.
527
529{
530 if (item) {
531 if ((item == fSelected) && !state) {
532 fSelected = 0;
533 if (draw) DrawItemName(fId, item);
534 } else if (state != item->IsActive()) { // !!!! leave active alone ...
535 item->SetActive(state);
536 if (draw) DrawItemName(fId, item);
537 }
538 }
539}
540
541////////////////////////////////////////////////////////////////////////////////
542/// Highlight item children.
543
545{
546 while (item) {
547 HighlightItem(item, state, draw);
548 if (item->fFirstchild)
549 HighlightChildren(item->fFirstchild, state, (item->IsOpen()) ? draw : kFALSE);
550 item = item->fNextsibling;
551 }
552}
553
554////////////////////////////////////////////////////////////////////////////////
555/// Unselect all items.
556
562
563////////////////////////////////////////////////////////////////////////////////
564/// Handle button events in the list tree.
565
567{
569
570 if (fTip) fTip->Hide();
571
572 Int_t page = 0;
573 if (event->fCode == kButton4 || event->fCode == kButton5) {
574 if (!fCanvas) return kTRUE;
575 if (fCanvas->GetContainer()->GetHeight()) {
576// page = Int_t(Float_t(fCanvas->GetViewPort()->GetHeight() *
577// fCanvas->GetViewPort()->GetHeight()) /
578// fCanvas->GetContainer()->GetHeight());
579 // choose page size either 1/5 of viewport or 5 lines (90)
580 Int_t r = fCanvas->GetViewPort()->GetHeight() / 5;
581 page = TMath::Min(r, 90);
582 }
583 }
584
585 if (event->fCode == kButton4) {
586 //scroll up
588 if (newpos < 0) newpos = 0;
590 return kTRUE;
591 }
592 if (event->fCode == kButton5) {
593 // scroll down
596 return kTRUE;
597 }
598
599 if (event->fType == kButtonPress) {
600 if ((item = FindItem(event->fY)) != 0) {
601 if (event->fCode == kButton1) {
602 Int_t minx, maxx;
603 Int_t minxchk = 0, maxxchk = 0;
604 if (item->HasCheckBox() && item->GetCheckBoxPicture()) {
605 minxchk = (item->fXtext - item->GetCheckBoxPicture()->GetWidth());
606 maxxchk = (item->fXtext - 4);
607 maxx = maxxchk - Int_t(item->GetPicWidth()) - 8;
608 minx = minxchk - Int_t(item->GetPicWidth()) - 16;
609 }
610 else {
611 maxx = (item->fXtext - Int_t(item->GetPicWidth())) - 8;
612 minx = (item->fXtext - Int_t(item->GetPicWidth())) - 16;
613 }
614 if ((item->HasCheckBox()) && (event->fX < maxxchk) &&
615 (event->fX > minxchk))
616 {
618 if (fCheckMode == kRecursive) {
619 CheckAllChildren(item, item->IsChecked());
620 }
622 Checked((TObject *)item->GetUserData(), item->IsChecked());
623 return kTRUE;
624 }
625 if ((event->fX < maxx) && (event->fX > minx)) {
626 item->SetOpen(!item->IsOpen());
628 return kTRUE;
629 }
630 }
631 // DND specific
632 if (event->fCode == kButton1) {
633 fXDND = event->fX;
634 fYDND = event->fY;
635 fBdown = kTRUE;
636 }
637 if (!fUserControlled) {
640 //item->fActive = kTRUE; // this is done below w/redraw
644 event->fCode, (event->fYRoot << 16) | event->fXRoot);
645 }
646 else {
649 }
650 Clicked(item, event->fCode);
651 Clicked(item, event->fCode, event->fXRoot, event->fYRoot);
652 Clicked(item, event->fCode, event->fState, event->fXRoot, event->fYRoot);
653 }
654 }
655 if (event->fType == kButtonRelease) {
656 fBdown = kFALSE;
657 }
658 return kTRUE;
659}
660
661////////////////////////////////////////////////////////////////////////////////
662/// Handle double click event in the list tree (only for kButton1).
663
665{
666 TGListTreeItem *item = 0;
667
668 if (event->fCode == kButton4 || event->fCode == kButton5) {
669 return kFALSE;
670 }
671 // If fDisableOpen is set, only send message and emit signals.
672 // It allows user to customize handling of double click events.
673 if (fDisableOpen && event->fCode == kButton1 && (item = FindItem(event->fY)) != 0) {
675 event->fCode, (event->fYRoot << 16) | event->fXRoot);
676 DoubleClicked(item, event->fCode);
677 DoubleClicked(item, event->fCode, event->fXRoot, event->fYRoot);
678 return kTRUE;
679 }
680 item = FindItem(event->fY);
681
682 // Otherwise, just use default behaviour (open item).
683 if (event->fCode == kButton1 && item) {
685 item->SetOpen(!item->IsOpen());
686 if (!fUserControlled) {
687 if (item != fSelected) { // huh?!
688 if (fSelected) fSelected->SetActive(kFALSE); // !!!!
691 }
692 }
694 event->fCode, (event->fYRoot << 16) | event->fXRoot);
695 DoubleClicked(item, event->fCode);
696 DoubleClicked(item, event->fCode, event->fXRoot, event->fYRoot);
697 }
698 if (!fUserControlled)
699 fSelected = item;
700 return kTRUE;
701}
702
703////////////////////////////////////////////////////////////////////////////////
704/// Handle mouse crossing event.
705
707{
708 if (event->fType == kLeaveNotify) {
709 if (fTip) {
710 fTip->Hide();
711 fTipItem = 0;
712 }
713 if (!fUserControlled) {
714 if (fCurrent)
715 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
716 if (fBelowMouse)
717 DrawOutline(fId, fBelowMouse, 0xffffff, kTRUE);
718 fCurrent = 0;
719 }
720 if (fBelowMouse) {
721 fBelowMouse = 0;
722 MouseOver(0);
723 MouseOver(0, event->fState);
724 }
725 }
727 return kTRUE;
728}
729
730////////////////////////////////////////////////////////////////////////////////
731/// Handle dragging position events.
732
734 Int_t /*xroot*/, Int_t /*yroot*/)
735{
736 static TGListTreeItem *olditem = 0;
738 if ((item = FindItem(y)) != 0) {
739 if (item->IsDNDTarget()) {
740 fDropItem = item;
741 if (olditem)
744 olditem = item;
745 return action;
746 }
747 }
748 fDropItem = 0;
749 if (olditem) {
751 olditem = 0;
752 }
753 return kNone;
754}
755
756////////////////////////////////////////////////////////////////////////////////
757/// Handle drag enter events.
758
760{
761 Atom_t ret = kNone;
762 for (int i = 0; typelist[i] != kNone; ++i) {
763 if (typelist[i] == fDNDTypeList[0])
764 ret = fDNDTypeList[0];
765 if (typelist[i] == fDNDTypeList[1])
766 ret = fDNDTypeList[1];
767 }
768 return ret;
769}
770
771////////////////////////////////////////////////////////////////////////////////
772/// Handle drag leave events.
773
778
779////////////////////////////////////////////////////////////////////////////////
780/// Handle drop events.
781
783{
786 //ClearHighlighted();
787 return kTRUE;
788}
789
790////////////////////////////////////////////////////////////////////////////////
791/// Emit DataDropped() signal.
792
794{
795 Longptr_t args[2];
796
797 args[0] = (Longptr_t)item;
798 args[1] = (Longptr_t)data;
799
800 Emit("DataDropped(TGListTreeItem*,TDNDData*)", args);
801}
802
803////////////////////////////////////////////////////////////////////////////////
804/// Handle mouse motion event. Used to set tool tip, to emit
805/// MouseOver() signal and for DND handling.
806
808{
811
812 if (gDNDManager->IsDragging()) {
813 gDNDManager->Drag(event->fXRoot, event->fYRoot,
815 } else if ((item = FindItem(event->fY)) != 0) {
816 if (!fUserControlled) {
817 if (fCurrent)
818 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
819 if (fBelowMouse)
820 DrawOutline(fId, fBelowMouse, 0xffffff, kTRUE);
822 fCurrent = item;
823 }
824 if (item != fBelowMouse) {
828 }
829
830 if (item->HasCheckBox() && item->GetCheckBoxPicture()) {
831 if ((event->fX < (item->fXtext - 4) &&
832 (event->fX > (item->fXtext - (Int_t)item->GetCheckBoxPicture()->GetWidth()))))
833 {
834 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kPointer));
835 return kTRUE;
836 }
837 else {
838 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kHand));
839 }
840 }
841 if (!gDNDManager->IsDragging()) {
842 if (fBdown && ((abs(event->fX - fXDND) > 2) || (abs(event->fY - fYDND) > 2))) {
843 if (gDNDManager && item->IsDNDSource()) {
845 fBuf->Reset();
846 // !!!!! Here check virtual Bool_t HandlesDragAndDrop()
847 // and let the item handle this.
848 if (item->GetUserData()) {
849 TObject *obj = static_cast<TObject *>(item->GetUserData());
850 if (dynamic_cast<TObject *>(obj)) {
851 TObjString *ostr = dynamic_cast<TObjString *>(obj);
852 if (ostr) {
853 TString& str = ostr->String();
854 if (str.BeginsWith("file://")) {
856 fDNDData.fData = (void *)strdup(str.Data());
857 fDNDData.fDataLength = str.Length()+1;
858 }
859 }
860 else {
862 fBuf->WriteObject((TObject *)item->GetUserData());
865 }
866 }
867 }
868 else {
870 TString str = TString::Format("file://%s/%s\r\n",
872 item->GetText());
873 fDNDData.fData = (void *)strdup(str.Data());
874 fDNDData.fDataLength = str.Length()+1;
875 }
876 if (item->GetPicture()) {
877 TString xmpname = item->GetPicture()->GetName();
878 if (xmpname.EndsWith("_t.xpm"))
879 xmpname.ReplaceAll("_t.xpm", "_s.xpm");
880 if (xmpname.EndsWith("_t.xpm__16x16"))
881 xmpname.ReplaceAll("_t.xpm__16x16", "_s.xpm");
882 const TGPicture *pic = fClient->GetPicture(xmpname.Data());
883 if (!pic) pic = item->GetPicture();
884 if (pic) SetDragPixmap(pic);
885 }
886 gDNDManager->StartDrag(this, event->fXRoot, event->fYRoot);
887 }
888 }
889 }
890 if (gDNDManager->IsDragging()) {
891 gDNDManager->Drag(event->fXRoot, event->fYRoot,
893 } else {
894 if (fTipItem == item) return kTRUE;
895 if (!fUserControlled) { // !!!! what is this? It was called above once?
897 MouseOver(item, event->fState);
898 }
899 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kHand));
900 }
901
902 if (fTip)
903 fTip->Hide();
904
905 if (item->GetTipTextLength() > 0) {
906
907 SetToolTipText(item->GetTipText(), item->fXtext,
908 item->fY - pos.fY + item->fHeight, 1000);
909
910 } else if (fAutoTips && item->GetUserData()) {
911 // must derive from TObject (in principle user can put pointer
912 // to anything in user data field). Add check.
913 TObject *obj = (TObject *)item->GetUserData();
914 if (obj && obj->IsA()->IsTObject()) {
915 SetToolTipText(obj->GetTitle(), item->fXtext,
916 item->fY - pos.fY + item->fHeight, 1000);
917 }
918 }
919 fTipItem = item;
920 } else {
921 if (fBelowMouse) {
922 fBelowMouse = 0;
925 }
926 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kPointer));
927 }
928 return kTRUE;
929}
930
931////////////////////////////////////////////////////////////////////////////////
932/// The key press event handler converts a key press to some line editor
933/// action.
934
936{
937 char input[10];
939 TGListTreeItem *item = 0;
940
941 fLastEventState = event->fState;
942 if (fTip) fTip->Hide();
943
944 if (event->fType == kGKeyPress) {
945 gVirtualX->LookupString(event, input, sizeof(input), keysym);
946
947 if (!event->fState && (EKeySym)keysym == kKey_Escape) {
949 }
950
951 item = fCurrent;
952 if (!item) return kFALSE;
953
955 KeyPressed(item, keysym, event->fState);
956
958 return kTRUE;
959
960 switch ((EKeySym)keysym) {
961 case kKey_Enter:
962 case kKey_Return:
963 event->fType = kButtonPress;
964 event->fCode = kButton1;
965
966 if (fSelected == item) {
967 // treat 'Enter' and 'Return' as a double click
969 item->SetOpen(!item->IsOpen());
971 } else {
972 // treat 'Enter' and 'Return' as a click
976 fSelected = item;
979 Clicked(item, 1);
980 Clicked(item, 1, event->fXRoot, event->fYRoot);
981 Clicked(item, 1, event->fState, event->fXRoot, event->fYRoot);
982 }
983 break;
984 case kKey_Space:
985 if (item->HasCheckBox()) {
987 if (fCheckMode == kRecursive) {
988 CheckAllChildren(item, item->IsChecked());
989 }
991 Checked((TObject *)item->GetUserData(), item->IsChecked());
992 }
993 break;
994 case kKey_F3:
995 Search(kFALSE);
996 break;
997 case kKey_F5:
998 Layout();
999 break;
1000 case kKey_F7:
1001 Search();
1002 break;
1003 case kKey_Left:
1004 ClearViewPort();
1005 item->SetOpen(kFALSE);
1006 break;
1007 case kKey_Right:
1008 ClearViewPort();
1009 item->SetOpen(kTRUE);
1010 break;
1011 case kKey_Up:
1012 LineUp(event->fState & kKeyShiftMask);
1013 break;
1014 case kKey_Down:
1015 LineDown(event->fState & kKeyShiftMask);
1016 break;
1017 case kKey_PageUp:
1018 PageUp(event->fState & kKeyShiftMask);
1019 break;
1020 case kKey_PageDown:
1021 PageDown(event->fState & kKeyShiftMask);
1022 break;
1023 case kKey_Home:
1024 Home(event->fState & kKeyShiftMask);
1025 break;
1026 case kKey_End:
1027 End(event->fState & kKeyShiftMask);
1028 break;
1029 default:
1030 break;
1031 }
1032 if (event->fState & kKeyControlMask) { // Ctrl key modifier pressed
1033 switch((EKeySym)keysym & ~0x20) { // treat upper and lower the same
1034 case kKey_F:
1035 Search();
1036 break;
1037 case kKey_G:
1038 Search(kFALSE);
1039 break;
1040 default:
1041 return kTRUE;
1042 }
1043 }
1044
1045 }
1046 return kTRUE;
1047}
1048
1049////////////////////////////////////////////////////////////////////////////////
1050/// Signal emitted when pointer is over entry.
1051
1053{
1054 Emit("MouseOver(TGListTreeItem*)", (Longptr_t)entry);
1055}
1056
1057////////////////////////////////////////////////////////////////////////////////
1058/// Signal emitted when pointer is over entry.
1059
1061{
1062 Longptr_t args[2];
1063 args[0] = (Longptr_t)entry;
1064 args[1] = mask;
1065 Emit("MouseOver(TGListTreeItem*,UInt_t)", args);
1066}
1067
1068////////////////////////////////////////////////////////////////////////////////
1069/// Signal emitted when keyboard key pressed
1070///
1071/// entry - selected item
1072/// keysym - defined in "KeySymbols.h"
1073/// mask - modifier key mask, defined in "GuiTypes.h"
1074///
1075/// const Mask_t kKeyShiftMask = BIT(0);
1076/// const Mask_t kKeyLockMask = BIT(1);
1077/// const Mask_t kKeyControlMask = BIT(2);
1078/// const Mask_t kKeyMod1Mask = BIT(3); // typically the Alt key
1079/// const Mask_t kButton1Mask = BIT(8);
1080/// const Mask_t kButton2Mask = BIT(9);
1081/// const Mask_t kButton3Mask = BIT(10);
1082/// const Mask_t kButton4Mask = BIT(11);
1083/// const Mask_t kButton5Mask = BIT(12);
1084/// const Mask_t kAnyModifier = BIT(15);
1085
1087{
1088 Longptr_t args[3];
1089 args[0] = (Longptr_t)entry;
1090 args[1] = (Longptr_t)keysym;
1091 args[2] = (Longptr_t)mask;
1092 Emit("KeyPressed(TGListTreeItem*,UInt_t,UInt_t)", args);
1094}
1095
1096////////////////////////////////////////////////////////////////////////////////
1097/// Emit ReturnPressed() signal.
1098
1100{
1101 Emit("ReturnPressed(TGListTreeItem*)", (Longptr_t)entry);
1102}
1103
1104////////////////////////////////////////////////////////////////////////////////
1105/// Emit Checked() signal.
1106
1108{
1109 Longptr_t args[2];
1110
1111 args[0] = (Longptr_t)entry;
1112 args[1] = on;
1113
1114 Emit("Checked(TObject*,Bool_t)", args);
1115}
1116
1117////////////////////////////////////////////////////////////////////////////////
1118/// Emit Clicked() signal.
1119
1121{
1122 Longptr_t args[2];
1123
1124 args[0] = (Longptr_t)entry;
1125 args[1] = btn;
1126
1127 Emit("Clicked(TGListTreeItem*,Int_t)", args);
1128}
1129
1130////////////////////////////////////////////////////////////////////////////////
1131/// Emit Clicked() signal.
1132
1134{
1135 Longptr_t args[4];
1136
1137 args[0] = (Longptr_t)entry;
1138 args[1] = btn;
1139 args[2] = x;
1140 args[3] = y;
1141
1142 Emit("Clicked(TGListTreeItem*,Int_t,Int_t,Int_t)", args);
1143}
1144
1145////////////////////////////////////////////////////////////////////////////////
1146/// Emit Clicked() signal.
1147
1149{
1150 Longptr_t args[5];
1151
1152 args[0] = (Longptr_t)entry;
1153 args[1] = btn;
1154 args[2] = mask;
1155 args[3] = x;
1156 args[4] = y;
1157
1158 Emit("Clicked(TGListTreeItem*,Int_t,UInt_t,Int_t,Int_t)", args);
1159}
1160
1161////////////////////////////////////////////////////////////////////////////////
1162/// Emit DoubleClicked() signal.
1163
1165{
1166 Longptr_t args[2];
1167
1168 args[0] = (Longptr_t)entry;
1169 args[1] = btn;
1170
1171 Emit("DoubleClicked(TGListTreeItem*,Int_t)", args);
1172}
1173
1174////////////////////////////////////////////////////////////////////////////////
1175/// Emit DoubleClicked() signal.
1176
1178{
1179 Longptr_t args[4];
1180
1181 args[0] = (Longptr_t)entry;
1182 args[1] = btn;
1183 args[2] = x;
1184 args[3] = y;
1185
1186 Emit("DoubleClicked(TGListTreeItem*,Int_t,Int_t,Int_t)", args);
1187}
1188
1189////////////////////////////////////////////////////////////////////////////////
1190/// Move content to the top.
1191
1192void TGListTree::Home(Bool_t /*select*/)
1193{
1195}
1196
1197////////////////////////////////////////////////////////////////////////////////
1198/// Move content to the bottom.
1199
1200void TGListTree::End(Bool_t /*select*/)
1201{
1203}
1204
1205////////////////////////////////////////////////////////////////////////////////
1206/// Move content one page up.
1207
1209{
1210 if (!fCanvas) return;
1211
1213
1215 if (newpos<0) newpos = 0;
1216
1218}
1219
1220////////////////////////////////////////////////////////////////////////////////
1221/// Move content one page down.
1222
1224{
1225 if (!fCanvas) return;
1226
1228
1230
1232}
1233
1234////////////////////////////////////////////////////////////////////////////////
1235/// Move content one item-size up.
1236
1238{
1239 Int_t height = 0;
1240 if (!fCurrent) return;
1241
1243 const TGPicture *pic1 = fCurrent->GetPicture();
1244 if (pic1) height = pic1->GetHeight() + fVspacing;
1245 else height = fVspacing + 16;
1246 Int_t findy = (fCurrent->fY - height) + (fMargin - pos.fY);
1247 TGListTreeItem *next = FindItem(findy);
1248 if (next && (next != fCurrent)) {
1249 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
1250 if (findy <= 2*height) {
1252 if (newpos<0) newpos = 0;
1254 }
1255 DrawOutline(fId, next);
1256 fCurrent = next;
1257 }
1258}
1259
1260////////////////////////////////////////////////////////////////////////////////
1261/// Move content one item-size down.
1262
1264{
1265 Int_t height;
1266 if (!fCurrent) return;
1267
1270 const TGPicture *pic1 = fCurrent->GetPicture();
1271 if (pic1) height = pic1->GetHeight() + fVspacing;
1272 else height = fVspacing + 16;
1273 Int_t findy = (fCurrent->fY + height) + (fMargin - pos.fY);
1274 TGListTreeItem *next = FindItem(findy);
1275 if (next && (next != fCurrent)) {
1276 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
1277 if (findy >= ((Int_t)dim.fHeight - 2*height)) {
1279 if (newpos<0) newpos = 0;
1281 }
1282 DrawOutline(fId, next);
1283 fCurrent = next;
1284 }
1285}
1286
1287////////////////////////////////////////////////////////////////////////////////
1288/// Move content to position of item. If item is 0, move to position
1289/// of currently selected item.
1290
1292{
1293 TGListTreeItem *it = item;
1294
1295 if (!it) it = fSelected;
1296 if (!it) {
1297 HighlightItem(fFirst); // recursive call of this function
1298 return;
1299 }
1300
1301 Int_t y = 0;
1302 Int_t yparent = 0;
1303 Int_t vh = 0;
1304 Int_t v = 0;
1305
1306 if (it) {
1307 y = it->fY;
1308 if (it->GetParent()) yparent = it->GetParent()->fY;
1309 }
1310
1311 if (y==0) y = yparent; // item->fY not initiated yet
1312
1313 if (fCanvas->GetVScrollbar()->IsMapped()) {
1315
1316 if (y<fCanvas->GetVScrollbar()->GetPosition()) {
1319 } else if (y+(Int_t)it->fHeight>vh) {
1321 y+(Int_t)it->fHeight-(Int_t)fViewPort->GetHeight()/2);
1322 if (v<0) v = 0;
1324 }
1325 }
1326}
1327
1328////////////////////////////////////////////////////////////////////////////////
1329/// Invokes search dialog. Looks for item with the entered name.
1330
1332{
1333 Int_t ret = 0;
1334 char msg[256];
1335 static TString buf;
1336
1338 srch->fBuffer = (char *)StrDup(buf.Data());
1339
1341 if (close || buf.IsNull())
1342 new TGSearchDialog(fClient->GetDefaultRoot(), fCanvas, 400, 150, srch, &ret);
1343 else if (!buf.IsNull()) ret = 1;
1344
1345 if (ret) {
1346 item = FindItemByPathname(srch->fBuffer);
1347 if (!item) {
1348 snprintf(msg, 255, "Couldn't find \"%s\"", srch->fBuffer);
1349 gVirtualX->Bell(20);
1350 new TGMsgBox(fClient->GetDefaultRoot(), fCanvas, "Container", msg,
1352 } else {
1355 }
1356 }
1357 buf = srch->fBuffer;
1358 delete srch;
1359}
1360
1361//---- drawing functions
1362
1363////////////////////////////////////////////////////////////////////////////////
1364/// Redraw list tree.
1365
1367{
1368 static GContext_t gcBg = 0;
1369
1370 // sanity checks
1371 if (y > (Int_t)fViewPort->GetHeight()) {
1372 return;
1373 }
1374
1375 y = y < 0 ? 0 : y;
1377
1378 // more sanity checks
1379 if (((Int_t)w < 1) || (w > 32768) || ((Int_t)h < 1)) {
1380 return;
1381 }
1382
1383 Pixmap_t pixmap = gVirtualX->CreatePixmap(fId, w, fViewPort->GetHeight());
1384
1385 if (!gcBg) {
1387 gcValues.fForeground = fBackground;
1388 gcValues.fForeground = fBackground;
1389 gcValues.fGraphicsExposures = kTRUE;
1391 gcBg = gVirtualX->CreateGC(fId, &gcValues);
1392 }
1393
1394 gVirtualX->SetForeground(gcBg, fBackground);
1395 gVirtualX->FillRectangle(pixmap, gcBg, 0, 0, w, fViewPort->GetHeight());
1396
1398
1399 gVirtualX->CopyArea(pixmap, fId, gcBg, 0, y, w, fViewPort->GetHeight(), 0, y);
1400
1401 gVirtualX->DeletePixmap(pixmap);
1402 gVirtualX->Update(kFALSE);
1403}
1404
1405////////////////////////////////////////////////////////////////////////////////
1406/// Draw list tree widget.
1407
1409{
1411 Int_t x, y, xbranch;
1413
1414 // Overestimate the expose region to be sure to draw an item that gets
1415 // cut by the region
1418 old_width = fDefw;
1419 old_height = fDefh;
1420 fDefw = fDefh = 1;
1421
1423 x = 2-pos.fX;
1424 y = fMargin;
1425 item = fFirst;
1426
1427 while (item) {
1428 xbranch = -1;
1429
1430 DrawItem(id, item, x, y, &xbranch, &width, &height);
1431
1432 width += pos.fX + x + fHspacing + fMargin;
1433
1434 if (width > fDefw) fDefw = width;
1435
1436 y += height + fVspacing;
1437 if (item->fFirstchild && item->IsOpen()) {
1438 y = DrawChildren(id, item->fFirstchild, x, y, xbranch);
1439 }
1440
1441 item = item->fNextsibling;
1442 }
1443
1444 fDefh = y + fMargin;
1445
1446 if ((old_width != fDefw) || (old_height != fDefh)) {
1447 fCanvas->Layout();
1448 }
1449}
1450
1451////////////////////////////////////////////////////////////////////////////////
1452/// Draw children of item in list tree.
1453
1456{
1458 Int_t xbranch;
1460
1461 x += fIndent + (Int_t)item->fParent->GetPicWidth();
1462 while (item) {
1463 xbranch = xroot;
1464
1465 DrawItem(id, item, x, y, &xbranch, &width, &height);
1466
1467 width += pos.fX + x + fHspacing + fMargin;
1468 if (width > fDefw) fDefw = width;
1469
1470 y += height + fVspacing;
1471 if ((item->fFirstchild) && (item->IsOpen())) {
1472 y = DrawChildren(id, item->fFirstchild, x, y, xbranch);
1473 }
1474
1475 item = item->fNextsibling;
1476 }
1477 return y;
1478}
1479
1480////////////////////////////////////////////////////////////////////////////////
1481/// Draw list tree item.
1482
1485{
1487 Int_t xpic2 = 0;
1488 UInt_t height;
1489 const TGPicture *pic1 = item->GetPicture();
1490 const TGPicture *pic2 = item->GetCheckBoxPicture();
1491
1492 // Compute the height of this line
1493 height = FontHeight();
1494
1495 xpic1 = x;
1496 xtext = x + fHspacing + (Int_t)item->GetPicWidth();
1497 if (pic2) {
1498 if (pic2->GetHeight() > height) {
1499 height = pic2->GetHeight();
1500 }
1501 if (pic1) xpic2 = xpic1 + pic1->GetWidth() + 1;
1502 else xpic2 = xpic1 + 1;
1503 xtext += pic2->GetWidth();
1504 }
1505 if (pic1) {
1506 if (pic1->GetHeight() > height) {
1507 ytext = y + (Int_t)((pic1->GetHeight() - height) >> 1);
1508 height = pic1->GetHeight();
1509 ypic1 = y;
1510 } else {
1511 ytext = y;
1512 ypic1 = y + (Int_t)((height - pic1->GetHeight()) >> 1);
1513 }
1514 xbranch = xpic1 + (Int_t)(pic1->GetWidth() >> 1);
1515 ybranch = ypic1 + (Int_t)pic1->GetHeight();
1516 yline = ypic1 + (Int_t)(pic1->GetHeight() >> 1);
1517 } else {
1518 ypic1 = ytext = y;
1519 xbranch = xpic1 + (Int_t)(item->GetPicWidth() >> 1);
1520 ybranch = ypic1 + (Int_t)(height >> 1);
1521 yline = ypic1 + (Int_t)(height >> 1);
1522 }
1523
1524 // height must be even, otherwise our dashed line wont appear properly
1525 //++height; height &= ~1;
1526
1527 // Save the basic graphics info for use by other functions
1528 item->fY = y;
1529 item->fXtext = xtext;
1530 item->fYtext = ytext;
1531 item->fHeight = height;
1532
1533 // projected coordinates
1536 Int_t yp = y - pos.fY;
1537 Int_t ylinep = yline - pos.fY;
1538 Int_t ybranchp = ybranch - pos.fY;
1539 Int_t ypicp = ypic1 - pos.fY;
1540
1541 if ((yp >= fExposeTop) && (yp <= (Int_t)dim.fHeight))
1542 {
1543 DrawItemName(id, item);
1544 if (*xroot >= 0) {
1545 xc = *xroot;
1546
1547 if (item->fNextsibling) {
1548 gVirtualX->DrawLine(id, fLineGC, xc, yp, xc, yp+height);
1549 } else {
1550 gVirtualX->DrawLine(id, fLineGC, xc, yp, xc, ylinep);
1551 }
1552
1553 TGListTreeItem *p = item->fParent;
1554 while (p) {
1555 xc -= (fIndent + (Int_t)item->GetPicWidth());
1556 if (p->fNextsibling) {
1557 gVirtualX->DrawLine(id, fLineGC, xc, yp, xc, yp+height);
1558 }
1559 p = p->fParent;
1560 }
1561 gVirtualX->DrawLine(id, fLineGC, *xroot, ylinep, xpic1, ylinep);
1562 DrawNode(id, item, *xroot, yline);
1563 }
1564 if (item->IsOpen() && item->fFirstchild) {
1565 gVirtualX->DrawLine(id, fLineGC, xbranch, ybranchp, xbranch,
1566 yp+height);
1567 }
1568 if (pic1)
1569 pic1->Draw(id, fDrawGC, xpic1, ypicp);
1570 if (pic2)
1571 pic2->Draw(id, fDrawGC, xpic2, ypicp);
1572 }
1573
1574 *xroot = xbranch;
1575 *retwidth = TextWidth(item->GetText()) + item->GetPicWidth();
1576 *retheight = height;
1577}
1578
1579////////////////////////////////////////////////////////////////////////////////
1580/// Draw a outline of color 'col' around an item.
1581
1583 Bool_t clear)
1584{
1587
1588 if (clear) {
1589 gVirtualX->SetForeground(fDrawGC, fCanvas->GetContainer()->GetBackground());
1590 //ClearViewPort(); // time consuming!!!
1591 }
1592 else
1593 gVirtualX->SetForeground(fDrawGC, col);
1594
1595#ifdef R__HAS_COCOA
1596 gVirtualX->DrawRectangle(id, fDrawGC, 1, item->fY - pos.fY, dim.fWidth-2, item->fHeight + 1);
1597#else
1598 gVirtualX->DrawRectangle(id, fDrawGC, 1, item->fYtext-pos.fY-2,
1599 dim.fWidth-3, FontHeight()+4);
1600#endif
1601 gVirtualX->SetForeground(fDrawGC, fgBlackPixel);
1602}
1603
1604////////////////////////////////////////////////////////////////////////////////
1605/// Draw active item with its active color.
1606
1608{
1609 UInt_t width;
1612
1613 width = dim.fWidth-2;
1614 gVirtualX->SetForeground(fDrawGC, item->GetActiveColor());
1615
1616#ifdef R__HAS_COCOA
1617 gVirtualX->FillRectangle(id, fDrawGC, 1, item->fY - pos.fY, width, item->fHeight + 1);
1618#else
1619 gVirtualX->FillRectangle(id, fDrawGC, 1, item->fYtext-pos.fY-1, width,
1620 FontHeight()+3);
1621#endif
1622 gVirtualX->SetForeground(fDrawGC, fgBlackPixel);
1623 gVirtualX->DrawString(id, fActiveGC, item->fXtext,
1624 item->fYtext - pos.fY + FontAscent(),
1625 item->GetText(), item->GetTextLength());
1626}
1627
1628////////////////////////////////////////////////////////////////////////////////
1629/// Draw name of list tree item.
1630
1632{
1635
1636 if (item->IsActive()) {
1637 DrawActive(id, item);
1638 }
1639 else { // if (!item->IsActive() && (item != fSelected)) {
1640 gVirtualX->FillRectangle(id, fHighlightGC, item->fXtext,
1641 item->fYtext-pos.fY, dim.fWidth-item->fXtext-2,
1642 FontHeight()+1);
1643 gVirtualX->DrawString(id, fDrawGC,
1644 item->fXtext, item->fYtext-pos.fY + FontAscent(),
1645 item->GetText(), item->GetTextLength());
1646 }
1647 if (item == fCurrent) {
1648 DrawOutline(id, item);
1649 }
1650
1651 if (fColorMode != 0 && item->HasColor()) {
1652 UInt_t width = TextWidth(item->GetText());
1653 gVirtualX->SetForeground(fColorGC, TColor::Number2Pixel(item->GetColor()));
1655 Int_t y = item->fYtext-pos.fY + FontAscent() + 2;
1656 gVirtualX->DrawLine(id, fColorGC, item->fXtext, y,
1657 item->fXtext + width, y);
1658 }
1659 if (fColorMode & kColorBox) {
1660 Int_t x = item->fXtext + width + 4;
1661 Int_t y = item->fYtext - pos.fY + 3;
1662 Int_t h = FontAscent() - 4;
1663 gVirtualX->FillRectangle(id, fColorGC, x, y, h, h);
1664 gVirtualX->DrawRectangle(id, fDrawGC, x, y, h, h);
1665 }
1666 }
1667}
1668
1669////////////////////////////////////////////////////////////////////////////////
1670/// Draw node (little + in box).
1671
1673{
1675 Int_t yp = y - pos.fY;
1676
1677 if (item->fFirstchild) {
1678 gVirtualX->DrawLine(id, fHighlightGC, x, yp-2, x, yp+2);
1679 gVirtualX->SetForeground(fHighlightGC, fgBlackPixel);
1680 gVirtualX->DrawLine(id, fHighlightGC, x-2, yp, x+2, yp);
1681 if (!item->IsOpen())
1682 gVirtualX->DrawLine(id, fHighlightGC, x, yp-2, x, yp+2);
1683 gVirtualX->SetForeground(fHighlightGC, fGrayPixel);
1684 gVirtualX->DrawLine(id, fHighlightGC, x-4, yp-4, x+4, yp-4);
1685 gVirtualX->DrawLine(id, fHighlightGC, x+4, yp-4, x+4, yp+4);
1686 gVirtualX->DrawLine(id, fHighlightGC, x-4, yp+4, x+4, yp+4);
1687 gVirtualX->DrawLine(id, fHighlightGC, x-4, yp-4, x-4, yp+4);
1688 gVirtualX->SetForeground(fHighlightGC, fgWhitePixel);
1689 }
1690}
1691
1692////////////////////////////////////////////////////////////////////////////////
1693/// Set tool tip text associated with this item. The delay is in
1694/// milliseconds (minimum 250). To remove tool tip call method with
1695/// delayms = 0. To change delayms you first have to call this method
1696/// with delayms=0.
1697
1699{
1700 if (delayms == 0) {
1701 delete fTip;
1702 fTip = 0;
1703 return;
1704 }
1705
1706 if (text && strlen(text)) {
1707 if (!fTip)
1708 fTip = new TGToolTip(fClient->GetDefaultRoot(), this, text, delayms);
1709 else
1710 fTip->SetText(text);
1711 fTip->SetPosition(x, y);
1712 fTip->Reset();
1713 }
1714}
1715
1716////////////////////////////////////////////////////////////////////////////////
1717/// This function removes the specified item from the linked list.
1718/// It does not do anything with the data contained in the item, though.
1719
1721{
1722 ClearViewPort();
1723
1724 // Disentangle from front (previous-sibling, parent's first child)
1725 if (item->fPrevsibling) {
1726 item->fPrevsibling->fNextsibling = item->fNextsibling;
1727 } else {
1728 if (item->fParent)
1729 item->fParent->fFirstchild = item->fNextsibling;
1730 else
1731 fFirst = item->fNextsibling;
1732 }
1733 // Disentangle from end (next-sibling, parent's last child)
1734 if (item->fNextsibling) {
1735 item->fNextsibling->fPrevsibling = item->fPrevsibling;
1736 } else {
1737 if (item->fParent)
1738 item->fParent->fLastchild = item->fPrevsibling;
1739 else
1740 fLast = item->fPrevsibling;
1741 }
1742}
1743
1744////////////////////////////////////////////////////////////////////////////////
1745/// Delete given item. Takes care of list-tree state members
1746/// fSelected, fCurrent and fBelowMouse.
1747
1749{
1750 if (fSelected == item) {
1751 fSelected = 0;
1752 }
1753 if (fCurrent == item) {
1754 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
1755 fCurrent = item->GetPrevSibling();
1756 if (! fCurrent) {
1757 fCurrent = item->GetNextSibling();
1758 if (! fCurrent)
1759 fCurrent = item->GetParent();
1760 }
1761 }
1762 if (fBelowMouse == item) {
1763 DrawOutline(fId, fBelowMouse, 0xffffff, kTRUE);
1764 fBelowMouse = 0;
1765 MouseOver(0);
1767 }
1768
1769 delete item;
1770}
1771
1772////////////////////////////////////////////////////////////////////////////////
1773/// Recursively delete all children of an item.
1774
1776{
1777 TGListTreeItem *child = item->fFirstchild;
1778
1779 while (child) {
1780 TGListTreeItem *next = child->fNextsibling;
1783 child = next;
1784 }
1785
1786 item->fFirstchild = item->fLastchild = 0;
1787}
1788
1789////////////////////////////////////////////////////////////////////////////////
1790/// Insert child in list.
1791
1793{
1794 TGListTreeItem *i;
1795
1796 item->fParent = parent;
1797 item->fNextsibling = item->fPrevsibling = 0;
1798
1799 if (parent) {
1800
1801 if (parent->fFirstchild) {
1802 if (parent->fLastchild) {
1803 i = parent->fLastchild;
1804 }
1805 else {
1806 i = parent->fFirstchild;
1807 while (i->fNextsibling) i = i->fNextsibling;
1808 }
1809 i->fNextsibling = item;
1810 item->fPrevsibling = i;
1811 } else {
1812 parent->fFirstchild = item;
1813 }
1814 parent->fLastchild = item;
1815
1816 } else { // if parent == 0, this is a top level entry
1817
1818 if (fFirst) {
1819 if (fLast) {
1820 i = fLast;
1821 }
1822 else {
1823 i = fFirst;
1824 while (i->fNextsibling) i = i->fNextsibling;
1825 }
1826 i->fNextsibling = item;
1827 item->fPrevsibling = i;
1828 } else {
1829 fFirst = item;
1830 }
1831 fLast = item;
1832 }
1833 if (item->HasCheckBox())
1835}
1836
1837////////////////////////////////////////////////////////////////////////////////
1838/// Insert a list of ALREADY LINKED children into another list
1839
1841{
1842 TGListTreeItem *next, *newnext;
1843
1844 //while (item) {
1845 // next = item->fNextsibling;
1846 // InsertChild(parent, item);
1847 // item = next;
1848 //}
1849 //return;
1850
1851 // Save the reference for the next item in the new list
1852 next = item->fNextsibling;
1853
1854 // Insert the first item in the new list into the existing list
1855 InsertChild(parent, item);
1856
1857 // The first item is inserted, with its prev and next siblings updated
1858 // to fit into the existing list. So, save the existing list reference
1859 newnext = item->fNextsibling;
1860
1861 // Now, mark the first item's next sibling to point back to the new list
1862 item->fNextsibling = next;
1863
1864 // Mark the parents of the new list to the new parent. The order of the
1865 // rest of the new list should be OK, and the second item should still
1866 // point to the first, even though the first was reparented.
1867 while (item->fNextsibling) {
1868 item->fParent = parent;
1869 item = item->fNextsibling;
1870 }
1871
1872 // Fit the end of the new list back into the existing list
1873 item->fNextsibling = newnext;
1874 if (newnext)
1875 newnext->fPrevsibling = item;
1876}
1877
1878////////////////////////////////////////////////////////////////////////////////
1879/// Search child item.
1880
1883{
1884 UInt_t height;
1885 const TGPicture *pic;
1886
1887 while (item) {
1888 // Select the pixmap to use
1889 pic = item->GetPicture();
1890
1891 // Compute the height of this line
1892 height = FontHeight();
1893 if (pic && pic->GetHeight() > height)
1894 height = pic->GetHeight();
1895
1896 if ((findy >= y) && (findy <= y + (Int_t)height)) {
1897 *finditem = item;
1898 return -1;
1899 }
1900
1901 y += (Int_t)height + fVspacing;
1902 if (item->fFirstchild && item->IsOpen()) {
1903 y = SearchChildren(item->fFirstchild, y, findy, finditem);
1904 if (*finditem) return -1;
1905 }
1906
1907 item = item->fNextsibling;
1908 }
1909
1910 return y;
1911}
1912
1913////////////////////////////////////////////////////////////////////////////////
1914/// Find item at postion findy.
1915
1917{
1918 Int_t y;
1919 UInt_t height;
1921 const TGPicture *pic;
1923
1924 y = fMargin - pos.fY;
1925 item = fFirst;
1926 finditem = 0;
1927 while (item && !finditem) {
1928 // Select the pixmap to use
1929 pic = item->GetPicture();
1930
1931 // Compute the height of this line
1932 height = FontHeight();
1933 if (pic && (pic->GetHeight() > height))
1934 height = pic->GetHeight();
1935
1936 if ((findy >= y) && (findy <= y + (Int_t)height))
1937 return item;
1938
1939 y += (Int_t)height + fVspacing;
1940 if ((item->fFirstchild) && (item->IsOpen())) {
1941 y = SearchChildren(item->fFirstchild, y, findy, &finditem);
1942 //if (finditem) return finditem;
1943 }
1944 item = item->fNextsibling;
1945 }
1946
1947 return finditem;
1948}
1949
1950//----- Public Functions
1951
1952////////////////////////////////////////////////////////////////////////////////
1953/// Add given item to list tree.
1954
1956{
1957 InsertChild(parent, item);
1958
1959 if ((parent == 0) || (parent && parent->IsOpen()))
1960 ClearViewPort();
1961}
1962
1963////////////////////////////////////////////////////////////////////////////////
1964/// Add item to list tree. Returns new item.
1965
1967 const TGPicture *open, const TGPicture *closed,
1969{
1971
1972 item = new TGListTreeItemStd(fClient, string, open, closed, checkbox);
1973 InsertChild(parent, item);
1974
1975 if ((parent == 0) || (parent && parent->IsOpen()))
1976 ClearViewPort();
1977 return item;
1978}
1979
1980////////////////////////////////////////////////////////////////////////////////
1981/// Add item to list tree. If item with same userData already exists
1982/// don't add it. Returns new item.
1983
1985 void *userData, const TGPicture *open,
1986 const TGPicture *closed,
1988{
1990 if (!item) {
1991 item = AddItem(parent, string, open, closed, checkbox);
1992 if (item) item->SetUserData(userData);
1993 }
1994
1995 return item;
1996}
1997
1998////////////////////////////////////////////////////////////////////////////////
1999/// Rename item in list tree.
2000
2002{
2003 if (item) {
2004 item->Rename(string);
2005 }
2006
2007 DoRedraw();
2008}
2009
2010////////////////////////////////////////////////////////////////////////////////
2011/// Delete item from list tree.
2012
2014{
2015 if (!fUserControlled)
2016 fCurrent = fBelowMouse = 0;
2017
2021
2022 fClient->NeedRedraw(this);
2023
2024 return 1;
2025}
2026
2027////////////////////////////////////////////////////////////////////////////////
2028/// Open item in list tree (i.e. show child items).
2029
2031{
2032 if (item) {
2033 item->SetOpen(kTRUE);
2034 DoRedraw(); // force layout
2036 }
2037}
2038
2039////////////////////////////////////////////////////////////////////////////////
2040/// Close item in list tree (i.e. hide child items).
2041
2043{
2044 if (item) {
2045 item->SetOpen(kFALSE);
2046 DoRedraw(); // force layout
2048 }
2049}
2050
2051////////////////////////////////////////////////////////////////////////////////
2052/// Delete item with fUserData == ptr. Search tree downwards starting
2053/// at item.
2054
2056{
2057 if (item && ptr) {
2058 if (item->GetUserData() == ptr) {
2060 } else {
2061 if (item->IsOpen() && item->fFirstchild) {
2062 RecursiveDeleteItem(item->fFirstchild, ptr);
2063 }
2064 RecursiveDeleteItem(item->fNextsibling, ptr);
2065 }
2066 }
2067 return 1;
2068}
2069
2070////////////////////////////////////////////////////////////////////////////////
2071/// Set tooltip text for this item. By default an item for which the
2072/// userData is a pointer to an TObject the TObject::GetTitle() will
2073/// be used to get the tip text.
2074
2076{
2077 if (item) {
2078 item->SetTipText(string);
2079 }
2080}
2081
2082////////////////////////////////////////////////////////////////////////////////
2083/// Delete children of item from list.
2084
2086{
2087 if (!fUserControlled)
2088 fCurrent = fBelowMouse = 0;
2089
2091
2092 DoRedraw();
2093
2094 return 1;
2095}
2096
2097////////////////////////////////////////////////////////////////////////////////
2098/// Make newparent the new parent of item.
2099
2101{
2102 // Remove the item from its old location.
2104
2105 // The item is now unattached. Reparent it.
2107
2108 DoRedraw();
2109
2110 return 1;
2111}
2112
2113////////////////////////////////////////////////////////////////////////////////
2114/// Make newparent the new parent of the children of item.
2115
2118{
2119 TGListTreeItem *first;
2120
2121 if (item->fFirstchild) {
2122 first = item->fFirstchild;
2123 item->fFirstchild = 0;
2124
2125 InsertChildren(newparent, first);
2126
2127 DoRedraw();
2128 return 1;
2129 }
2130 return 0;
2131}
2132
2133////////////////////////////////////////////////////////////////////////////////
2134
2135extern "C"
2136Int_t Compare(const void *item1, const void *item2)
2137{
2138 return strcmp((*((TGListTreeItem **) item1))->GetText(),
2139 (*((TGListTreeItem **) item2))->GetText());
2140}
2141
2142////////////////////////////////////////////////////////////////////////////////
2143/// Sort items starting with item.
2144
2146{
2147 TGListTreeItem *first, *parent, **list;
2148 size_t i, count;
2149
2150 // Get first child in list;
2151 while (item->fPrevsibling) item = item->fPrevsibling;
2152
2153 first = item;
2154 parent = first->fParent;
2155
2156 // Count the children
2157 count = 1;
2158 while (item->fNextsibling) item = item->fNextsibling, count++;
2159 if (count <= 1) return 1;
2160
2161 list = new TGListTreeItem* [count];
2162 list[0] = first;
2163 count = 1;
2164 while (first->fNextsibling) {
2165 list[count] = first->fNextsibling;
2166 count++;
2167 first = first->fNextsibling;
2168 }
2169
2170 ::qsort(list, count, sizeof(TGListTreeItem*), ::Compare);
2171
2172 list[0]->fPrevsibling = 0;
2173 for (i = 0; i < count; i++) {
2174 if (i < count - 1)
2175 list[i]->fNextsibling = list[i + 1];
2176 if (i > 0)
2177 list[i]->fPrevsibling = list[i - 1];
2178 }
2179 list[count - 1]->fNextsibling = 0;
2180 if (parent) {
2181 parent->fFirstchild = list[0];
2182 parent->fLastchild = list[count-1];
2183 }
2184 else {
2185 fFirst = list[0];
2186 fLast = list[count-1];
2187 }
2188
2189 delete [] list;
2190
2191 DoRedraw();
2192
2193 return 1;
2194}
2195
2196////////////////////////////////////////////////////////////////////////////////
2197/// Sort siblings of item.
2198
2203
2204////////////////////////////////////////////////////////////////////////////////
2205/// Sort children of item.
2206
2208{
2209 TGListTreeItem *first;
2210
2211 if (item) {
2212 first = item->fFirstchild;
2213 if (first) {
2214 SortSiblings(first);
2215 }
2216 } else {
2217 if (fFirst) {
2218 first = fFirst->fFirstchild;
2219 if (first) {
2220 SortSiblings(first);
2221 }
2222 }
2223 }
2224 DoRedraw();
2225 return 1;
2226}
2227
2228////////////////////////////////////////////////////////////////////////////////
2229/// Find sibling of item by name.
2230
2232{
2233 // Get first child in list
2234 if (item) {
2235 while (item->fPrevsibling) {
2236 item = item->fPrevsibling;
2237 }
2238
2239 while (item) {
2240 if (strcmp(item->GetText(), name) == 0) {
2241 return item;
2242 }
2243 item = item->fNextsibling;
2244 }
2245 return item;
2246 }
2247 return 0;
2248}
2249
2250////////////////////////////////////////////////////////////////////////////////
2251/// Find sibling of item by userData.
2252
2254{
2255 // Get first child in list
2256 if (item) {
2257 while (item->fPrevsibling) {
2258 item = item->fPrevsibling;
2259 }
2260
2261 while (item) {
2262 if (item->GetUserData() == userData) {
2263 return item;
2264 }
2265 item = item->fNextsibling;
2266 }
2267 return item;
2268 }
2269 return 0;
2270}
2271
2272////////////////////////////////////////////////////////////////////////////////
2273/// Find child of item by name.
2274
2276{
2277 // Get first child in list
2278 if (item && item->fFirstchild) {
2279 item = item->fFirstchild;
2280 } else if (!item && fFirst) {
2281 item = fFirst;
2282 } else {
2283 item = 0;
2284 }
2285
2286 while (item) {
2287 if (strcmp(item->GetText(), name) == 0) {
2288 return item;
2289 }
2290 item = item->fNextsibling;
2291 }
2292 return 0;
2293}
2294
2295////////////////////////////////////////////////////////////////////////////////
2296/// Find child of item by userData.
2297
2299{
2300 // Get first child in list
2301 if (item && item->fFirstchild) {
2302 item = item->fFirstchild;
2303 } else if (!item && fFirst) {
2304 item = fFirst;
2305 } else {
2306 item = 0;
2307 }
2308
2309 while (item) {
2310 if (item->GetUserData() == userData) {
2311 return item;
2312 }
2313 item = item->fNextsibling;
2314 }
2315 return 0;
2316}
2317
2318////////////////////////////////////////////////////////////////////////////////
2319/// Find item by pathname. Pathname is in the form of /xx/yy/zz. If zz
2320/// in path /xx/yy is found it returns item, 0 otherwise.
2321
2323{
2324 if (!path || !*path) return 0;
2325
2326 const char *p = path, *s;
2327 char dirname[1024];
2328 TGListTreeItem *item = 0;
2329 item = FindChildByName(item, "/");
2330 if (!gVirtualX->InheritsFrom("TGX11")) {
2331 // on Windows, use the current drive instead of root (/)
2332 TList *curvol = gSystem->GetVolumes("cur");
2333 if (curvol) {
2334 TNamed *drive = (TNamed *)curvol->At(0);
2335 item = FindChildByName(0, TString::Format("%s\", drive->GetName()));
2336 delete curvol;
2337 }
2338 }
2341
2342 while (1) {
2343 while (*p && *p == '/') p++;
2344 if (!*p) break;
2345
2346 s = strchr(p, '/');
2347
2348 if (!s) {
2349 strlcpy(dirname, p, 1024);
2350 } else {
2351 strlcpy(dirname, p, (s-p)+1);
2352 }
2353
2355
2356 if (!diritem && dirname[0]) {
2357 fulldir += "/";
2358 fulldir += dirname;
2359
2360 if ((diritem=FindChildByName(0, fulldir.Data()))) {
2361 if (!s || !s[0]) return diritem;
2362 p = ++s;
2363 item = diritem;
2364 continue;
2365 }
2366 }
2367
2368 if (!s || !s[0]) return item;
2369 p = ++s;
2370 }
2371 return 0;
2372}
2373
2374////////////////////////////////////////////////////////////////////////////////
2375/// Highlight item.
2376
2383
2384////////////////////////////////////////////////////////////////////////////////
2385/// Un highlight items.
2386
2391
2392////////////////////////////////////////////////////////////////////////////////
2393/// Get pathname from item. Use depth to limit path name to last
2394/// depth levels. By default depth is not limited.
2395
2397{
2398 char tmppath[1024];
2399
2400 *path = '\0';
2401 while (item) {
2402 snprintf(tmppath, 1023, "/%s%s", item->GetText(), path);
2403 strlcpy(path, tmppath, 1024);
2404 item = item->fParent;
2405 if (--depth == 0 && item) {
2406 snprintf(tmppath, 1023, "...%s", path);
2407 strlcpy(path, tmppath, 1024);
2408 return;
2409 }
2410 }
2411}
2412
2413////////////////////////////////////////////////////////////////////////////////
2414/// Return gray draw color in use.
2415
2417{
2418 static Bool_t init = kFALSE;
2419 if (!init) {
2420 if (!gClient->GetColorByName("#808080", fgGrayPixel))
2422 init = kTRUE;
2423 }
2424 return fgGrayPixel;
2425}
2426
2427////////////////////////////////////////////////////////////////////////////////
2428/// Return default font structure in use.
2429
2431{
2432 if (!fgDefaultFont)
2433 fgDefaultFont = gClient->GetResourcePool()->GetIconFont();
2434 return fgDefaultFont->GetFontStruct();
2435}
2436
2437////////////////////////////////////////////////////////////////////////////////
2438/// Return default graphics context in use.
2439
2441{
2442 if (!fgActiveGC) {
2444
2447 gcv.fLineStyle = kLineSolid;
2448 gcv.fLineWidth = 0;
2449 gcv.fFillStyle = kFillSolid;
2450 gcv.fFont = fgDefaultFont->GetFontHandle();
2451 gcv.fBackground = fgDefaultSelectedBackground;
2452 const TGGC *selgc = gClient->GetResourcePool()->GetSelectedGC();
2453 if (selgc)
2454 gcv.fForeground = selgc->GetForeground();
2455 else
2456 gcv.fForeground = fgWhitePixel;
2457 fgActiveGC = gClient->GetGC(&gcv, kTRUE);
2458 }
2459 return *fgActiveGC;
2460}
2461
2462////////////////////////////////////////////////////////////////////////////////
2463/// Return default graphics context in use.
2464
2466{
2467 if (!fgDrawGC) {
2469
2472 gcv.fLineStyle = kLineSolid;
2473 gcv.fLineWidth = 0;
2474 gcv.fFillStyle = kFillSolid;
2475 gcv.fFont = fgDefaultFont->GetFontHandle();
2476 gcv.fBackground = fgWhitePixel;
2477 gcv.fForeground = fgBlackPixel;
2478
2479 fgDrawGC = gClient->GetGC(&gcv, kTRUE);
2480 }
2481 return *fgDrawGC;
2482}
2483
2484////////////////////////////////////////////////////////////////////////////////
2485/// Return graphics context in use for line drawing.
2486
2488{
2489 if (!fgLineGC) {
2491
2494 gcv.fLineStyle = kLineOnOffDash;
2495 gcv.fLineWidth = 0;
2496 gcv.fFillStyle = kFillSolid;
2497 gcv.fFont = fgDefaultFont->GetFontHandle();
2498 gcv.fBackground = fgWhitePixel;
2499 gcv.fForeground = GetGrayPixel();
2500
2501 fgLineGC = gClient->GetGC(&gcv, kTRUE);
2502 fgLineGC->SetDashOffset(0);
2503 fgLineGC->SetDashList("\x1\x1", 2);
2504 }
2505 return *fgLineGC;
2506}
2507
2508////////////////////////////////////////////////////////////////////////////////
2509/// Return graphics context for highlighted frame background.
2510
2512{
2513 if (!fgHighlightGC) {
2515
2518 gcv.fLineStyle = kLineSolid;
2519 gcv.fLineWidth = 0;
2520 gcv.fFillStyle = kFillSolid;
2521 gcv.fFont = fgDefaultFont->GetFontHandle();
2522 gcv.fBackground = fgDefaultSelectedBackground;
2523 gcv.fForeground = fgWhitePixel;
2524
2525 fgHighlightGC = gClient->GetGC(&gcv, kTRUE);
2526 }
2527 return *fgHighlightGC;
2528}
2529
2530////////////////////////////////////////////////////////////////////////////////
2531/// Return graphics context for highlighted frame background.
2532
2534{
2535 if (!fgColorGC) {
2537
2540 gcv.fLineStyle = kLineSolid;
2541 gcv.fLineWidth = 1;
2542 gcv.fFillStyle = kFillSolid;
2543 gcv.fBackground = fgDefaultSelectedBackground;
2544 gcv.fForeground = fgWhitePixel;
2545
2546 fgColorGC = gClient->GetGC(&gcv, kTRUE);
2547 }
2548 return *fgColorGC;
2549}
2550
2551////////////////////////////////////////////////////////////////////////////////
2552/// Returns the icon used by items in open state.
2553
2555{
2556 if (!fgOpenPic)
2557 fgOpenPic = gClient->GetPicture("ofolder_t.xpm");
2558 ((TGPicture *)fgOpenPic)->AddReference();
2559 return fgOpenPic;
2560}
2561
2562////////////////////////////////////////////////////////////////////////////////
2563/// Returns the icon used by items in closed state.
2564
2566{
2567 if (!fgClosedPic)
2568 fgClosedPic = gClient->GetPicture("folder_t.xpm");
2569 ((TGPicture *)fgClosedPic)->AddReference();
2570 return fgClosedPic;
2571}
2572
2573////////////////////////////////////////////////////////////////////////////////
2574/// Returns the icon used for checked checkbox.
2575
2577{
2578 if (!fgCheckedPic)
2579 fgCheckedPic = gClient->GetPicture("checked_t.xpm");
2580 ((TGPicture *)fgCheckedPic)->AddReference();
2581 return fgCheckedPic;
2582}
2583
2584////////////////////////////////////////////////////////////////////////////////
2585/// Returns the icon used for unchecked checkbox.
2586
2588{
2589 if (!fgUncheckedPic)
2590 fgUncheckedPic = gClient->GetPicture("unchecked_t.xpm");
2591 ((TGPicture *)fgUncheckedPic)->AddReference();
2592 return fgUncheckedPic;
2593}
2594
2595////////////////////////////////////////////////////////////////////////////////
2596/// Save a list tree widget as a C++ statements on output stream out.
2597
2598void TGListTree::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2599{
2600 // store options and color if differ from defaults
2602
2603 out << "\n // list tree\n";
2604 out << " TGListTree *" << GetName() << " = new TGListTree(";
2605
2606 if ((fParent->GetParent())->InheritsFrom(TGCanvas::Class()))
2607 out << GetCanvas()->GetName();
2608 else
2609 out << fParent->GetName() << "," << GetWidth() << "," << GetHeight();
2610 out << extra_args << ");\n";
2611
2612 if (option && strstr(option, "keep_names"))
2613 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
2614
2615 TGListTreeItem *current = GetFirstItem();
2616
2617 out << " \n";
2618
2619 while (current) {
2620 TString var_name = current->SaveTreeItem(out, GetName(), "nullptr");
2621 if (current->IsOpen())
2622 out << " " << GetName() << "->OpenItem(" << var_name << ");\n";
2623 else
2624 out << " " << GetName() << "->CloseItem(" << var_name << ");\n";
2625
2626 if (current == fSelected)
2627 out << " " << GetName() << "->SetSelected(" << var_name << ");\n";
2628
2629 if (current->fFirstchild)
2630 SaveChildren(out, var_name, current->fFirstchild);
2631
2632 current = current->fNextsibling;
2633 }
2634
2635 out << " \n";
2636}
2637
2638////////////////////////////////////////////////////////////////////////////////
2639/// Save child items as a C++ statements on output stream out.
2640
2641void TGListTree::SaveChildren(std::ostream &out, const char *parent_var_name, TGListTreeItem *item)
2642{
2643 while (item) {
2644 TString var_name = item->SaveTreeItem(out, GetName(), parent_var_name);
2645
2646 if (item == fSelected)
2647 out << " " << GetName() << "->SetSelected(" << var_name << ");\n";
2648
2649 if (item->fFirstchild)
2650 SaveChildren(out, var_name, item->fFirstchild);
2651
2652 item = item->fNextsibling;
2653 }
2654}
2655
2656////////////////////////////////////////////////////////////////////////////////
2657/// Save a list tree item attributes as a C++ statements on output stream.
2658
2659TString TGListTreeItemStd::SaveTreeItem(std::ostream &out, const char *tree_var_name, const char *parent_var_name)
2660{
2661 static const TGPicture *oldopen = nullptr, *oldclose = nullptr, *oldcheck = nullptr, *olduncheck = nullptr;
2662 static int item_cnt = 0;
2663
2664 if (!gROOT->ClassSaved(Class())) {
2665 oldopen = oldclose = oldcheck = olduncheck = nullptr;
2666 item_cnt = 0;
2667 out << " const TGPicture *pic_litem_open = nullptr, *pic_litem_close = nullptr, *pic_litem_check = nullptr, "
2668 "*pic_litem_uncheck = nullptr;\n";
2669 }
2670
2671 TString var_name = TString::Format("list_tree_item%d", item_cnt++);
2672
2673 if (fOpenPic && (oldopen != fOpenPic)) {
2674 oldopen = fOpenPic;
2677 out << " pic_litem_open = gClient->GetPicture(\"" << picname.ReplaceSpecialCppChars() << "\");\n";
2678 }
2679 if (fClosedPic && (oldclose != fClosedPic)) {
2683 out << " pic_litem_close = gClient->GetPicture(\"" << picname.ReplaceSpecialCppChars() << "\");\n";
2684 }
2685
2686 out << " TGListTreeItem *" << var_name << " = " << tree_var_name << "->AddItem(" << parent_var_name << ", \""
2687 << TString(GetText()).ReplaceSpecialCppChars() << "\", " << (fOpenPic ? "pic_litem_open" : "nullptr") << ", "
2688 << (fClosedPic ? "pic_litem_close" : "nullptr");
2689 if (HasCheckBox())
2690 out << ", kTRUE";
2691 out << ");\n";
2692
2693 if (HasCheckBox()) {
2694 out << " " << var_name << "->CheckItem();\n";
2695 if (fCheckedPic && oldcheck != fCheckedPic) {
2699 out << " pic_litem_check = gClient->GetPicture(\"" << picname.ReplaceSpecialCppChars() << "\");\n";
2700 }
2705 out << " pic_litem_uncheck = gClient->GetPicture(\"" << picname.ReplaceSpecialCppChars() << "\");\n";
2706 }
2707 out << " " << var_name << "->SetCheckBoxPictures(" << (fCheckedPic ? "pic_litem_check" : "nullptr") << ", "
2708 << (fUncheckedPic ? "pic_litem_uncheck" : "nullptr") << ");\n";
2709 }
2710 if (fHasColor)
2711 out << " " << var_name << "->SetColor(" << fColor << ");\n";
2712
2713 if (fTipText.Length() > 0)
2714 out << " " << var_name << "->SetTipText(\"" << TString(GetTipText()).ReplaceSpecialCppChars() << "\");\n";
2715
2716 return var_name;
2717}
2718
2719////////////////////////////////////////////////////////////////////////////////
2720/// Set check button state for the node 'item'.
2721
2723{
2724 item->CheckItem(check);
2725}
2726
2727////////////////////////////////////////////////////////////////////////////////
2728/// Set check button state for the node 'item'.
2729
2731{
2732 item->SetCheckBox(on);
2733}
2734
2735////////////////////////////////////////////////////////////////////////////////
2736/// Toggle check button state of the node 'item'.
2737
2739{
2740 item->Toggle();
2741}
2742
2743////////////////////////////////////////////////////////////////////////////////
2744/// Update the state of the node 'item' according to the children states.
2745
2747{
2748 if (fAutoCheckBoxPic == kFALSE) return;
2749
2750 TGListTreeItem *parent;
2751 TGListTreeItem *current;
2752 current = item->GetFirstChild();
2753 parent = current ? current : item;
2754 // recursively check parent/children status
2755 while (parent && parent->HasCheckBox()) {
2756 if ((!parent->IsChecked() && parent->HasCheckedChild(kTRUE)) ||
2757 (parent->IsChecked() && parent->HasUnCheckedChild(kTRUE))) {
2758 parent->SetCheckBoxPictures(fClient->GetPicture("checked_dis_t.xpm"),
2759 fClient->GetPicture("unchecked_dis_t.xpm"));
2760 }
2761 else {
2762 parent->SetCheckBoxPictures(fClient->GetPicture("checked_t.xpm"),
2763 fClient->GetPicture("unchecked_t.xpm"));
2764 }
2765 parent = parent->GetParent();
2766 if (parent && fCheckMode == kRecursive) {
2767 if (!parent->IsChecked() && parent->GetFirstChild() &&
2768 !parent->GetFirstChild()->HasUnCheckedChild()) {
2769 parent->SetCheckBoxPictures(fClient->GetPicture("checked_t.xpm"),
2770 fClient->GetPicture("unchecked_t.xpm"));
2771 parent->CheckItem(kTRUE);
2772 }
2773 else if (parent->IsChecked() && parent->GetFirstChild() &&
2774 !parent->GetFirstChild()->HasCheckedChild()) {
2775 parent->SetCheckBoxPictures(fClient->GetPicture("checked_t.xpm"),
2776 fClient->GetPicture("unchecked_t.xpm"));
2777 parent->CheckItem(kFALSE);
2778 }
2779 }
2780 }
2781 if (redraw) {
2782 ClearViewPort();
2783 }
2784}
2785
2786////////////////////////////////////////////////////////////////////////////////
2787/// Find item with fUserData == ptr. Search tree downwards starting
2788/// at item.
2789
2791{
2793 if (item && ptr) {
2794 if (item->GetUserData() == ptr)
2795 return item;
2796 else {
2797 if (item->fFirstchild) {
2798 fitem = FindItemByObj(item->fFirstchild, ptr);
2799 if (fitem) return fitem;
2800 }
2801 return FindItemByObj(item->fNextsibling, ptr);
2802 }
2803 }
2804 return 0;
2805}
2806
2807////////////////////////////////////////////////////////////////////////////////
2808/// Add all checked list tree items of this list tree into
2809/// the list 'checked'. This list is not adopted and must
2810/// be deleted by the user later.
2811
2813{
2814 if (!checked || !fFirst) return;
2815 TGListTreeItem *current = fFirst;
2816 if (current->IsChecked()) {
2817 checked->Add(new TObjString(current->GetText()));
2818 }
2819 while(current) {
2820 if (current->GetFirstChild())
2821 GetCheckedChildren(checked, current->GetFirstChild());
2822 current = current->GetNextSibling();
2823 }
2824}
2825
2826////////////////////////////////////////////////////////////////////////////////
2827/// Add all child items of 'item' into the list 'checked'.
2828
2830{
2831 if (!checked || !item) return;
2832
2833 while (item) {
2834 if (item->IsChecked()) {
2835 checked->Add(new TObjString(item->GetText()));
2836 }
2837 if (item->GetFirstChild()) {
2838 GetCheckedChildren(checked, item->GetFirstChild());
2839 }
2840 item = item->GetNextSibling();
2841 }
2842}
2843
2844////////////////////////////////////////////////////////////////////////////////
2845/// Check all child items of 'item' and 'item' itself according
2846/// to the state value: kTRUE means check all, kFALSE - uncheck all.
2847
2849{
2850 if (item)
2851 item->CheckAllChildren(state);
2852}
2853
Handle_t Atom_t
WM token.
Definition GuiTypes.h:37
@ kGKeyPress
Definition GuiTypes.h:60
@ kButtonRelease
Definition GuiTypes.h:60
@ kButtonPress
Definition GuiTypes.h:60
@ kLeaveNotify
Definition GuiTypes.h:61
const Mask_t kGCBackground
Definition GuiTypes.h:289
const Mask_t kGCForeground
Definition GuiTypes.h:288
const Mask_t kGCLineStyle
Definition GuiTypes.h:291
const Mask_t kGCLineWidth
Definition GuiTypes.h:290
@ kHand
Definition GuiTypes.h:374
@ kPointer
Definition GuiTypes.h:375
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:30
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
const Mask_t kGCFillStyle
Definition GuiTypes.h:294
const Mask_t kAnyModifier
Definition GuiTypes.h:210
const Mask_t kKeyPressMask
Definition GuiTypes.h:159
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
const Mask_t kGCFont
Definition GuiTypes.h:300
const Mask_t kPointerMotionMask
Definition GuiTypes.h:163
const Mask_t kKeyShiftMask
Definition GuiTypes.h:195
@ kSunkenFrame
Definition GuiTypes.h:383
const Handle_t kNone
Definition GuiTypes.h:88
const Mask_t kKeyControlMask
Definition GuiTypes.h:197
const Mask_t kLeaveWindowMask
Definition GuiTypes.h:168
@ kFillSolid
Definition GuiTypes.h:51
@ kLineSolid
Definition GuiTypes.h:48
@ kLineOnOffDash
Definition GuiTypes.h:48
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
const Mask_t kGCGraphicsExposures
Definition GuiTypes.h:302
const Mask_t kEnterWindowMask
Definition GuiTypes.h:167
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
@ kButton4
Definition GuiTypes.h:215
@ kButton5
Definition GuiTypes.h:215
@ kButton1
Definition GuiTypes.h:214
@ kAnyButton
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
EKeySym
Definition KeySymbols.h:25
@ kKey_Right
Definition KeySymbols.h:42
@ kKey_Down
Definition KeySymbols.h:43
@ kKey_G
Definition KeySymbols.h:132
@ kKey_Space
Definition KeySymbols.h:93
@ kKey_PageDown
Definition KeySymbols.h:47
@ kKey_F
Definition KeySymbols.h:131
@ kKey_F5
Definition KeySymbols.h:61
@ kKey_Up
Definition KeySymbols.h:41
@ kKey_Return
Definition KeySymbols.h:30
@ kKey_F3
Definition KeySymbols.h:59
@ kKey_Left
Definition KeySymbols.h:40
@ kKey_Escape
Definition KeySymbols.h:26
@ kKey_Home
Definition KeySymbols.h:38
@ kKey_Enter
Definition KeySymbols.h:31
@ kKey_End
Definition KeySymbols.h:39
@ kKey_PageUp
Definition KeySymbols.h:45
@ kKey_F7
Definition KeySymbols.h:63
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
int Int_t
Definition RtypesCore.h:45
long Longptr_t
Definition RtypesCore.h:75
long Long_t
Definition RtypesCore.h:54
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:374
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:229
#define gClient
Definition TGClient.h:157
R__EXTERN TGDNDManager * gDNDManager
Int_t Compare(const void *item1, const void *item2)
@ kMBOk
Definition TGMsgBox.h:33
@ kMBIconExclamation
Definition TGMsgBox.h:24
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 data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
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 child
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
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 Atom_t Atom_t Time_t UChar_t Atom_t typelist
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char text
char name[80]
Definition TGX11.cxx:110
#define gROOT
Definition TROOT.h:406
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2557
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
#define gVirtualX
Definition TVirtualX.h:337
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
@ kCT_ITEMCLICK
@ kCT_KEY
@ kC_LISTTREE
@ kCT_ITEMDBLCLICK
#define snprintf
Definition civetweb.c:1540
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition TBufferFile.h:47
void Reset() override
Reset buffer object. Resets map and buffer offset.
void WriteObject(const TObject *obj, Bool_t cacheReuse=kTRUE) override
Write object to I/O buffer.
@ kWrite
Definition TBuffer.h:73
Int_t Length() const
Definition TBuffer.h:100
char * Buffer() const
Definition TBuffer.h:96
static ULong_t Number2Pixel(Int_t ci)
Static method that given a color index number, returns the corresponding pixel value.
Definition TColor.cxx:2446
Drag and drop data container.
Atom_t fDataType
Data type description.
Int_t fDataLength
Length of data.
void * fData
Actual data.
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition TGCanvas.h:192
TGFrame * GetContainer() const
Definition TGCanvas.h:216
virtual void SetVsbPosition(Int_t newPos)
Set position of vertical scrollbar.
virtual Int_t GetVsbPosition() const
Get position of vertical scrollbar.
TGVScrollBar * GetVScrollbar() const
Definition TGCanvas.h:219
TGViewPort * GetViewPort() const
Definition TGCanvas.h:217
void Layout() override
Create layout for canvas.
static TClass * Class()
Window client.
Definition TGClient.h:37
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition TGClient.cxx:234
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:289
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:381
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:317
Manages a content area.
Definition TGCanvas.h:31
TGCanvas * fCanvas
pointer to canvas
Definition TGCanvas.h:41
virtual void ClearViewPort()
Clear view port and redraw full content.
Definition TGCanvas.cxx:891
const TGWindow * fMsgWindow
window handling container messages
Definition TGCanvas.h:42
virtual void SetDragPixmap(const TGPicture *pic)
Set drag window pixmaps and hotpoint.
Int_t fXDND
Definition TGCanvas.h:60
TGCanvas * GetCanvas() const
Definition TGCanvas.h:99
Bool_t fBdown
Definition TGCanvas.h:61
void DoRedraw() override
Redraw content of container in the viewport region.
Definition TGCanvas.cxx:800
virtual TGDimension GetPageDimension() const
Returns page dimension.
Definition TGCanvas.cxx:751
TGViewPort * fViewPort
container viewport
Definition TGCanvas.h:40
virtual TGVScrollBar * GetVScrollbar() const
returns pointer to vert. scroll bar
Int_t fYDND
Definition TGCanvas.h:60
virtual TGPosition GetPagePosition() const
Returns page position.
Definition TGCanvas.cxx:737
Bool_t IsDragging() const
Bool_t StartDrag(TGFrame *src, Int_t x_root, Int_t y_root, Window_t grabWin=kNone)
Start dragging.
Bool_t Drag(Int_t x_root, Int_t y_root, Atom_t action, Time_t timestamp)
Process drag event.
static Atom_t GetDNDActionCopy()
Bool_t EndDrag()
End dragging.
UInt_t fHeight
Definition TGDimension.h:21
UInt_t fWidth
Definition TGDimension.h:20
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
static Pixel_t GetDefaultSelectedBackground()
Get default selected frame background.
Definition TGFrame.cxx:696
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:339
UInt_t fHeight
frame height
Definition TGFrame.h:88
static Pixel_t fgDefaultSelectedBackground
Definition TGFrame.h:102
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:645
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:2501
virtual Pixel_t GetBackground() const
Definition TGFrame.h:194
void SetDNDTarget(Bool_t onoff)
Definition TGFrame.h:272
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 Pixel_t fgBlackPixel
Definition TGFrame.h:104
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
TString fTipText
tooltip text
Definition TGListTree.h:134
const char * GetTipText() const override
Definition TGListTree.h:163
Bool_t fHasColor
true if item has assigned color
Definition TGListTree.h:141
void CheckItem(Bool_t checked=kTRUE) override
Definition TGListTree.h:178
void SetCheckBox(Bool_t on=kTRUE) override
Set a check box on the tree node.
void CheckAllChildren(Bool_t state=kTRUE) override
Set all child items of this one checked if state=kTRUE, unchecked if state=kFALSE.
void SetPictures(const TGPicture *opened, const TGPicture *closed) override
Change list tree item icons.
void Toggle() override
Definition TGListTree.h:179
const TGPicture * fCheckedPic
icon for checked item
Definition TGListTree.h:137
const TGPicture * fClosedPic
icon for closed state
Definition TGListTree.h:136
const char * GetText() const override
Definition TGListTree.h:161
Bool_t IsChecked() const override
Definition TGListTree.h:180
Bool_t fActive
true if item is active
Definition TGListTree.h:129
Color_t fColor
item's color
Definition TGListTree.h:142
Bool_t fOwnsData
true if user data has to be deleted
Definition TGListTree.h:132
static TClass * Class()
Pixel_t GetActiveColor() const override
Return color for marking items that are active or selected.
Bool_t HasCheckBox() const override
Definition TGListTree.h:177
const TGPicture * fUncheckedPic
icon for unchecked item
Definition TGListTree.h:138
Bool_t HasCheckedChild(Bool_t first=kFALSE) override
Add all child items of 'item' into the list 'checked'.
Bool_t fCheckBox
true if checkbox is visible
Definition TGListTree.h:130
void CheckChildren(TGListTreeItem *item, Bool_t state) override
Set all child items of 'item' checked if state=kTRUE; unchecked if state=kFALSE.
void * fUserData
pointer to user data structure
Definition TGListTree.h:139
void SetCheckBoxPictures(const TGPicture *checked, const TGPicture *unchecked) override
Change list tree check item icons.
Bool_t fChecked
true if item is checked
Definition TGListTree.h:131
Bool_t HasUnCheckedChild(Bool_t first=kFALSE) override
Add all child items of 'item' into the list 'checked'.
TGListTreeItemStd(const TGListTreeItemStd &)=delete
TString fText
item text
Definition TGListTree.h:133
void UpdateState() override
Update the state of the node 'item' according to the children states.
const TGPicture * fOpenPic
icon for open state
Definition TGListTree.h:135
~TGListTreeItemStd() override
Delete list tree item.
TString SaveTreeItem(std::ostream &out, const char *treevarname, const char *parent_var_name) override
Save a list tree item attributes as a C++ statements on output stream.
TGListTreeItem * GetFirstChild() const
Definition TGListTree.h:61
virtual void SetCheckBoxPictures(const TGPicture *, const TGPicture *)
Definition TGListTree.h:87
virtual const char * GetText() const =0
TGListTreeItem * fLastchild
pointer to last child item
Definition TGListTree.h:38
TGListTreeItem * fFirstchild
pointer to first child item
Definition TGListTree.h:37
TGListTreeItem * GetNextSibling() const
Definition TGListTree.h:64
virtual void CheckItem(Bool_t=kTRUE)=0
TGListTreeItem * fParent
pointer to parent
Definition TGListTree.h:36
virtual Bool_t HasCheckedChild(Bool_t=kFALSE)
Definition TGListTree.h:99
TGClient * fClient
pointer to TGClient
Definition TGListTree.h:35
TGListTreeItem * GetParent() const
Definition TGListTree.h:60
virtual TString SaveTreeItem(std::ostream &, const char *, const char *)
Definition TGListTree.h:54
TGListTreeItem(const TGListTreeItem &)=delete
virtual Bool_t HasUnCheckedChild(Bool_t=kFALSE)
Definition TGListTree.h:100
virtual void SetActive(Bool_t)
Definition TGListTree.h:71
Int_t fDNDState
EDNDFlags.
Definition TGListTree.h:44
virtual Bool_t IsOpen() const
Definition TGListTree.h:66
virtual UInt_t GetPicWidth() const
Return width of item's icon.
virtual Bool_t IsChecked() const =0
virtual const TGPicture * GetPicture() const =0
virtual Bool_t HasCheckBox() const =0
TGListTreeItem * fNextsibling
pointer to next sibling
Definition TGListTree.h:40
A list tree is a widget that can contain a number of items arranged in a tree structure.
Definition TGListTree.h:197
static const TGPicture * GetOpenPic()
Returns the icon used by items in open state.
UInt_t fLastEventState
modifier state of the last keyboard event
Definition TGListTree.h:242
GContext_t fColorGC
drawing context for main item color
Definition TGListTree.h:246
Bool_t HandleButton(Event_t *event) override
Handle button events in the list tree.
TGListTreeItem * FindItemByObj(TGListTreeItem *item, void *ptr)
Find item with fUserData == ptr.
Bool_t HandleKey(Event_t *event) override
The key press event handler converts a key press to some line editor action.
TGListTreeItem * fSelected
pointer to selected item in list
Definition TGListTree.h:214
Bool_t HandleDNDLeave() override
Handle drag leave events.
Int_t SortSiblings(TGListTreeItem *item)
Sort siblings of item.
GContext_t fLineGC
dashed line drawing context
Definition TGListTree.h:224
static const TGPicture * GetUncheckedPic()
Returns the icon used for unchecked checkbox.
void Clicked(TGFrame *, Int_t) override
Emit Clicked() signal.
Definition TGListTree.h:298
void RemoveReference(TGListTreeItem *item)
This function removes the specified item from the linked list.
UInt_t fDefw
default list width
Definition TGListTree.h:227
static Pixel_t fgGrayPixel
Definition TGListTree.h:248
void ClearHighlighted()
Un highlight items.
void PDeleteChildren(TGListTreeItem *item)
Recursively delete all children of an item.
void InsertChildren(TGListTreeItem *parent, TGListTreeItem *item)
Insert a list of ALREADY LINKED children into another list.
ECheckMode fCheckMode
how to propagate check properties through the tree
Definition TGListTree.h:245
static const TGPicture * GetClosedPic()
Returns the icon used by items in closed state.
static TGGC * fgLineGC
Definition TGListTree.h:252
void UnselectAll(Bool_t draw)
Unselect all items.
Bool_t fDisableOpen
disable branch opening on double-clicks
Definition TGListTree.h:239
Bool_t HandleCrossing(Event_t *event) override
Handle mouse crossing event.
Atom_t HandleDNDEnter(Atom_t *typelist) override
Handle drag enter events.
void InsertChild(TGListTreeItem *parent, TGListTreeItem *item)
Insert child in list.
void Search(Bool_t close=kTRUE) override
Invokes search dialog. Looks for item with the entered name.
void ToggleItem(TGListTreeItem *item)
Toggle check button state of the node 'item'.
GContext_t fDrawGC
icon drawing context
Definition TGListTree.h:223
void PageUp(Bool_t select=kFALSE) override
Move content one page up.
void RenameItem(TGListTreeItem *item, const char *string)
Rename item in list tree.
static TGGC * fgActiveGC
Definition TGListTree.h:250
GContext_t fHighlightGC
highlighted icon drawing context
Definition TGListTree.h:225
void AddItem(TGListTreeItem *parent, TGListTreeItem *item)
Add given item to list tree.
void KeyPressed(TGFrame *, UInt_t, UInt_t) override
Signal emitted when keyboard key pressed.
Definition TGListTree.h:302
Int_t DeleteChildren(TGListTreeItem *item)
Delete children of item from list.
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion event.
TGListTreeItem * FindItem(Int_t findy)
Find item at postion findy.
TGListTreeItem * fBelowMouse
pointer to item below mouses cursor
Definition TGListTree.h:216
Int_t FontHeight()
Returns height of currently used font.
void ReturnPressed(TGFrame *) override
Signal emitted when Return/Enter key pressed.
Definition TGListTree.h:297
TGListTreeItem * fLast
pointer to last item in list
Definition TGListTree.h:213
Int_t ReparentChildren(TGListTreeItem *item, TGListTreeItem *newparent)
Make newparent the new parent of the children of item.
void CheckItem(TGListTreeItem *item, Bool_t check=kTRUE)
Set check button state for the node 'item'.
Int_t DrawChildren(Handle_t id, TGListTreeItem *item, Int_t x, Int_t y, Int_t xroot)
Draw children of item in list tree.
Int_t fExposeBottom
bottom y position of visible region
Definition TGListTree.h:230
static const TGGC & GetLineGC()
Return graphics context in use for line drawing.
void CheckAllChildren(TGListTreeItem *item, Bool_t state)
Check all child items of 'item' and 'item' itself according to the state value: kTRUE means check all...
static TGGC * fgHighlightGC
Definition TGListTree.h:253
static const TGPicture * GetCheckedPic()
Returns the icon used for checked checkbox.
TDNDData fDNDData
Drag and Drop data.
Definition TGListTree.h:234
void SetCheckBox(TGListTreeItem *item, Bool_t on=kTRUE)
Set check button state for the node 'item'.
void OpenItem(TGListTreeItem *item)
Open item in list tree (i.e. show child items).
void Layout() override
Layout container entries.
Definition TGListTree.h:292
virtual void DrawActive(Handle_t id, TGListTreeItem *item)
Draw active item with its active color.
Pixel_t fGrayPixel
gray draw color
Definition TGListTree.h:221
Int_t Reparent(TGListTreeItem *item, TGListTreeItem *newparent)
Make newparent the new parent of item.
void GetChecked(TList *checked)
Add all checked list tree items of this list tree into the list 'checked'.
static TGGC * fgColorGC
Definition TGListTree.h:254
Int_t RecursiveDeleteItem(TGListTreeItem *item, void *userData)
Delete item with fUserData == ptr.
Int_t TextWidth(const char *c)
Returns text width relative to currently used font.
void DrawItem(Handle_t id, TGListTreeItem *item, Int_t x, Int_t y, Int_t *xroot, UInt_t *retwidth, UInt_t *retheight)
Draw list tree item.
TGListTreeItem * fDropItem
item on which DND is over
Definition TGListTree.h:236
void SetToolTipText(const char *text, Int_t x, Int_t y, Long_t delayms)
Set tool tip text associated with this item.
void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h) override
Redraw list tree.
TGListTreeItem * fTipItem
item for which tooltip is set
Definition TGListTree.h:232
Int_t FontAscent()
Returns ascent of currently used font.
Bool_t HandleDoubleClick(Event_t *event) override
Handle double click event in the list tree (only for kButton1).
static const TGGC & GetColorGC()
Return graphics context for highlighted frame background.
virtual void Checked(TObject *obj, Bool_t check)
Emit Checked() signal.
static const TGGC & GetDrawGC()
Return default graphics context in use.
void HighlightChildren(TGListTreeItem *item, Bool_t state, Bool_t draw)
Highlight item children.
virtual void DataDropped(TGListTreeItem *item, TDNDData *data)
Emit DataDropped() signal.
Int_t fHspacing
horizontal spacing between items
Definition TGListTree.h:217
static const TGPicture * fgClosedPic
icon for closed item
Definition TGListTree.h:256
Int_t DeleteItem(TGListTreeItem *item)
Delete item from list tree.
static const TGPicture * fgUncheckedPic
icon for unchecked item
Definition TGListTree.h:258
Int_t fMargin
number of pixels margin from left side
Definition TGListTree.h:220
static const TGGC & GetHighlightGC()
Return graphics context for highlighted frame background.
UInt_t fDefh
default list height
Definition TGListTree.h:228
void GetCheckedChildren(TList *checked, TGListTreeItem *item)
Add all child items of 'item' into the list 'checked'.
void DoubleClicked(TGFrame *, Int_t) override
Emit DoubleClicked() signal.
Definition TGListTree.h:300
static const TGPicture * fgCheckedPic
icon for checked item
Definition TGListTree.h:257
void End(Bool_t select=kFALSE) override
Move content to the bottom.
TGListTreeItem * GetFirstItem() const
Definition TGListTree.h:383
TGListTreeItem * FindChildByName(TGListTreeItem *item, const char *name)
Find child of item by name.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a list tree widget as a C++ statements on output stream out.
static const TGGC & GetActiveGC()
Return default graphics context in use.
Bool_t fEventHandled
flag used from user code to bypass standard event handling
Definition TGListTree.h:241
TGListTree(const TGListTree &)=delete
Int_t SortChildren(TGListTreeItem *item)
Sort children of item.
static const TGPicture * fgOpenPic
icon for open item
Definition TGListTree.h:255
EColorMarkupMode fColorMode
if/how to render item's main color
Definition TGListTree.h:244
Atom_t * fDNDTypeList
handles DND types
Definition TGListTree.h:235
static TGGC * fgDrawGC
Definition TGListTree.h:251
Int_t Sort(TGListTreeItem *item)
Sort items starting with item.
Bool_t fAutoCheckBoxPic
change check box picture if parent and children have diffrent state
Definition TGListTree.h:238
void DrawNode(Handle_t id, TGListTreeItem *item, Int_t x, Int_t y)
Draw node (little + in box).
TGListTreeItem * fFirst
pointer to first item in list
Definition TGListTree.h:212
void AdjustPosition() override
Move content to position of highlighted/activated frame.
Definition TGListTree.h:357
TBufferFile * fBuf
buffer used for Drag and Drop
Definition TGListTree.h:233
Bool_t HandleDNDDrop(TDNDData *data) override
Handle drop events.
TGToolTip * fTip
tooltip shown when moving over list items
Definition TGListTree.h:231
void DrawItemName(Handle_t id, TGListTreeItem *item)
Draw name of list tree item.
~TGListTree() override
Delete list tree widget.
void SaveChildren(std::ostream &out, const char *parent_var_name, TGListTreeItem *item)
Save child items as a C++ statements on output stream out.
Bool_t fUserControlled
let user decides what is the behaviour on events
Definition TGListTree.h:240
TGListTreeItem * fCurrent
pointer to current item in list
Definition TGListTree.h:215
virtual void UpdateChecked(TGListTreeItem *item, Bool_t redraw=kFALSE)
Update the state of the node 'item' according to the children states.
Int_t SearchChildren(TGListTreeItem *item, Int_t y, Int_t findy, TGListTreeItem **finditem)
Search child item.
virtual void MouseOver(TGListTreeItem *entry)
Signal emitted when pointer is over entry.
void HighlightItem(TGListTreeItem *item)
Highlight item.
Int_t fExposeTop
top y postion of visible region
Definition TGListTree.h:229
TGListTreeItem * FindSiblingByName(TGListTreeItem *item, const char *name)
Find sibling of item by name.
TGListTreeItem * FindItemByPathname(const char *path)
Find item by pathname.
void Home(Bool_t select=kFALSE) override
Move content to the top.
void LineUp(Bool_t select=kFALSE) override
Move content one item-size up.
Int_t fVspacing
vertical spacing between items
Definition TGListTree.h:218
FontStruct_t fFont
font used to draw item text
Definition TGListTree.h:226
TGListTreeItem * FindChildByData(TGListTreeItem *item, void *userData)
Find child of item by userData.
void CloseItem(TGListTreeItem *item)
Close item in list tree (i.e. hide child items).
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use.
void PDeleteItem(TGListTreeItem *item)
Delete given item.
void SetToolTipItem(TGListTreeItem *item, const char *string)
Set tooltip text for this item.
void PageDown(Bool_t select=kFALSE) override
Move content one page down.
Atom_t HandleDNDPosition(Int_t x, Int_t y, Atom_t action, Int_t xroot, Int_t yroot) override
Handle dragging position events.
void LineDown(Bool_t select=kFALSE) override
Move content one item-size down.
Int_t fIndent
number of pixels indentation
Definition TGListTree.h:219
virtual void DrawOutline(Handle_t id, TGListTreeItem *item, Pixel_t col=0xbbbbbb, Bool_t clear=kFALSE)
Draw a outline of color 'col' around an item.
Bool_t fAutoTips
assume item->fUserData is TObject and use GetTitle() for tip text
Definition TGListTree.h:237
TGListTreeItem * FindSiblingByData(TGListTreeItem *item, void *userData)
Find sibling of item by userData.
static const TGFont * fgDefaultFont
Definition TGListTree.h:249
GContext_t fActiveGC
activated (selected) drawing context
Definition TGListTree.h:222
static Pixel_t GetGrayPixel()
Return gray draw color in use.
void GetPathnameFromItem(TGListTreeItem *item, char *path, Int_t depth=0)
Get pathname from item.
void Draw(Handle_t id, Int_t yevent, Int_t hevent)
Draw list tree widget.
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
virtual Int_t GetPosition() const
virtual void SetSmallIncrement(Int_t increment)
A tooltip can be a one or multiple lines help text that is displayed in a window when the mouse curso...
Definition TGToolTip.h:24
void Hide()
Hide tool tip window.
void SetPosition(Int_t x, Int_t y)
Set popup position within specified frame (as specified in the ctor).
void SetText(const char *new_text)
Set new tool tip text.
void Reset()
Reset tool tip popup delay timer.
ROOT GUI Window base class.
Definition TGWindow.h:23
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
@ 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
virtual void SetWindowName(const char *name=nullptr)
Set window name.
Definition TGWindow.cxx:129
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition TGWindow.cxx:295
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:336
UInt_t fEditDisabled
flags used for "guibuilding"
Definition TGWindow.h:32
A doubly linked list.
Definition TList.h:38
void Add(TObject *obj) override
Definition TList.h:81
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Collectable string class.
Definition TObjString.h:28
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * GetTitle() const
Returns title of object.
Definition TObject.cxx:501
virtual TClass * IsA() const
Definition TObject.h:249
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1114
const char * Data() const
Definition TString.h:376
Bool_t IsNull() const
Definition TString.h:414
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1286
virtual TList * GetVolumes(Option_t *) const
Definition TSystem.h:465
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1075
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:883
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:250
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:198
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
Int_t fY
pointer x, y coordinates in event window
Definition GuiTypes.h:178
Int_t fXRoot
Definition GuiTypes.h:179
UInt_t fState
key or button mask
Definition GuiTypes.h:181
Int_t fYRoot
coordinates relative to root
Definition GuiTypes.h:179
Int_t fX
Definition GuiTypes.h:178
Time_t fTime
time event event occurred in ms
Definition GuiTypes.h:177
UInt_t fCode
key or button code
Definition GuiTypes.h:180
Graphics context structure.
Definition GuiTypes.h:224
th1 Draw()
TMarker m
Definition textangle.C:8