Logo ROOT  
Reference Guide
 
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
80
81/******************************************************************************/
82/******************************************************************************/
83// TGListTreeItem
84/******************************************************************************/
85
86////////////////////////////////////////////////////////////////////////////////
87/// Constructor.
88
90 fClient(client),
91 fParent (0), fFirstchild(0), fLastchild (0), fPrevsibling(0),
92 fNextsibling(0),fOpen (kFALSE), fDNDState (0),
93 fY (0), fXtext (0), fYtext(0), fHeight(0)
94{
95}
96
97////////////////////////////////////////////////////////////////////////////////
98/// Return width of item's icon.
99
101{
102 const TGPicture *pic = GetPicture();
103 return (pic) ? pic->GetWidth() : 0;
104}
105
106/******************************************************************************/
107/******************************************************************************/
108// TGListTreeItemStd
109/******************************************************************************/
110
111////////////////////////////////////////////////////////////////////////////////
112/// Create list tree item.
113
115 const TGPicture *opened,
116 const TGPicture *closed,
118 TGListTreeItem(client)
119{
120 fText = name;
122 fChecked = kTRUE;
123
124 if (!opened)
126 else
127 ((TGPicture *)opened)->AddReference();
128
129 if (!closed)
131 else
132 ((TGPicture *)closed)->AddReference();
133
136
139
140 fActive = kFALSE;
141
143 fUserData = 0;
144
146 fColor = 0;
147 fDNDState = 0;
148}
149
150////////////////////////////////////////////////////////////////////////////////
151/// Delete list tree item.
152
154{
155 if (fOwnsData && fUserData) {
156 TObject *obj = static_cast<TObject *>(fUserData);
157 delete dynamic_cast<TObject *>(obj);
158 }
163}
164
165////////////////////////////////////////////////////////////////////////////////
166/// Return color for marking items that are active or selected.
167
172
173////////////////////////////////////////////////////////////////////////////////
174/// Add all child items of 'item' into the list 'checked'.
175
177{
178 TGListTreeItem *item = this;
179
180 while (item) {
181 if (item->IsChecked()) {
182 return kTRUE;
183 }
184 if (item->GetFirstChild()) {
185 if (item->GetFirstChild()->HasCheckedChild())
186 return kTRUE;
187 }
188 if (!first)
189 item = item->GetNextSibling();
190 else
191 break;
192 }
193 return kFALSE;
194}
195
196////////////////////////////////////////////////////////////////////////////////
197/// Add all child items of 'item' into the list 'checked'.
198
200{
201 TGListTreeItem *item = this;
202
203 while (item) {
204 if (!item->IsChecked()) {
205 return kTRUE;
206 }
207 if (item->GetFirstChild()) {
208 if (item->GetFirstChild()->HasUnCheckedChild())
209 return kTRUE;
210 }
211 if (!first)
212 item = item->GetNextSibling();
213 else
214 break;
215 }
216 return kFALSE;
217}
218
219////////////////////////////////////////////////////////////////////////////////
220/// Update the state of the node 'item' according to the children states.
221
223{
224 if ((!fChecked && HasCheckedChild(kTRUE)) ||
226 SetCheckBoxPictures(gClient->GetPicture("checked_dis_t.xpm"),
227 gClient->GetPicture("unchecked_dis_t.xpm"));
228 }
229 else {
230 SetCheckBoxPictures(gClient->GetPicture("checked_t.xpm"),
231 gClient->GetPicture("unchecked_t.xpm"));
232 }
233}
234
235////////////////////////////////////////////////////////////////////////////////
236/// Set all child items of this one checked if state=kTRUE,
237/// unchecked if state=kFALSE.
238
240{
241 if (state) {
242 if (!IsChecked())
243 CheckItem();
244 } else {
245 if (IsChecked())
246 Toggle();
247 }
249 UpdateState();
250}
251
252////////////////////////////////////////////////////////////////////////////////
253/// Set all child items of 'item' checked if state=kTRUE;
254/// unchecked if state=kFALSE.
255
257{
258 if (!item) return;
259
260 while (item) {
261 if (state){
262 if (!item->IsChecked())
263 item->CheckItem();
264 } else {
265 if (item->IsChecked())
266 item->Toggle();
267 }
268 if (item->GetFirstChild()) {
269 CheckChildren(item->GetFirstChild(), state);
270 }
271 item->UpdateState();
272 item = item->GetNextSibling();
273 }
274}
275
276////////////////////////////////////////////////////////////////////////////////
277/// Set a check box on the tree node.
278
283
284////////////////////////////////////////////////////////////////////////////////
285/// Change list tree check item icons.
286
288 const TGPicture *unchecked)
289{
292
293 if (!checked) {
294 ::Warning("TGListTreeItem::SetCheckBoxPictures", "checked picture not specified, defaulting to checked_t");
295 checked = fClient->GetPicture("checked_t.xpm");
296 } else
297 ((TGPicture *)checked)->AddReference();
298
299 if (!unchecked) {
300 ::Warning("TGListTreeItem::SetCheckBoxPictures", "unchecked picture not specified, defaulting to unchecked_t");
301 unchecked = fClient->GetPicture("unchecked_t.xpm");
302 } else
303 ((TGPicture *)unchecked)->AddReference();
304
305 fCheckedPic = checked;
307}
308
309////////////////////////////////////////////////////////////////////////////////
310/// Change list tree item icons.
311
313{
316
317 if (!opened) {
318 ::Warning("TGListTreeItem::SetPictures", "opened picture not specified, defaulting to ofolder_t");
319 opened = fClient->GetPicture("ofolder_t.xpm");
320 } else
321 ((TGPicture *)opened)->AddReference();
322
323 if (!closed) {
324 ::Warning("TGListTreeItem::SetPictures", "closed picture not specified, defaulting to folder_t");
325 closed = fClient->GetPicture("folder_t.xpm");
326 } else
327 ((TGPicture *)closed)->AddReference();
328
331}
332
333
334/******************************************************************************/
335/******************************************************************************/
336// TGListTree
337/******************************************************************************/
338
339////////////////////////////////////////////////////////////////////////////////
340/// Create a list tree widget.
341
343 Pixel_t back) :
344 TGContainer(p, w, h, options, back)
345{
346 fMsgWindow = p;
347 fCanvas = 0;
348 fTip = 0;
349 fTipItem = 0;
353 fBdown = kFALSE;
357 fDropItem = 0;
358 fLastEventState = 0;
359
362
364 fDrawGC = GetDrawGC()();
365 fLineGC = GetLineGC()();
367 fColorGC = GetColorGC()();
368
370 fDefw = fDefh = 1;
371
372 fHspacing = 2;
373 fVspacing = 2; // 0;
374 fIndent = 3; // 0;
375 fMargin = 2;
376
377 fXDND = fYDND = 0;
378 fDNDData.fData = 0;
381 fBuf = 0;
382
386
387 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
389 kNone, kNone);
390
394
395 fDNDTypeList = new Atom_t[3];
396 fDNDTypeList[0] = gVirtualX->InternAtom("application/root", kFALSE);
397 fDNDTypeList[1] = gVirtualX->InternAtom("text/uri-list", kFALSE);
398 fDNDTypeList[2] = 0;
399 gVirtualX->SetDNDAware(fId, fDNDTypeList);
402}
403
404////////////////////////////////////////////////////////////////////////////////
405/// Create a list tree widget.
406
408 TGContainer(p, options, back)
409{
410 fMsgWindow = p;
411 fTip = 0;
412 fTipItem = 0;
416 fBdown = kFALSE;
420 fDropItem = 0;
421 fLastEventState = 0;
422
425
427 fDrawGC = GetDrawGC()();
428 fLineGC = GetLineGC()();
430 fColorGC = GetColorGC()();
431
433 fDefw = fDefh = 1;
434
435 fHspacing = 2;
436 fVspacing = 2; // 0;
437 fIndent = 3; // 0;
438 fMargin = 2;
439
440 fXDND = fYDND = 0;
441 fDNDData.fData = 0;
444 fBuf = 0;
445
449
450 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
452 kNone, kNone);
453
457
458 fDNDTypeList = new Atom_t[3];
459 fDNDTypeList[0] = gVirtualX->InternAtom("application/root", kFALSE);
460 fDNDTypeList[1] = gVirtualX->InternAtom("text/uri-list", kFALSE);
461 fDNDTypeList[2] = 0;
462 gVirtualX->SetDNDAware(fId, fDNDTypeList);
465}
466
467////////////////////////////////////////////////////////////////////////////////
468/// Delete list tree widget.
469
471{
473
474 delete [] fDNDTypeList;
475 delete fTip;
476
477 item = fFirst;
478 while (item) {
480 sibling = item->fNextsibling;
481 delete item;
482 item = sibling;
483 }
484}
485
486//--- text utility functions
487
488////////////////////////////////////////////////////////////////////////////////
489/// Returns height of currently used font.
490
492{
493 if (!fgDefaultFont)
494 fgDefaultFont = gClient->GetResourcePool()->GetIconFont();
495 return fgDefaultFont->TextHeight();
496}
497
498////////////////////////////////////////////////////////////////////////////////
499/// Returns ascent of currently used font.
500
502{
504 if (!fgDefaultFont)
505 fgDefaultFont = gClient->GetResourcePool()->GetIconFont();
506 fgDefaultFont->GetFontMetrics(&m);
507 return m.fAscent;
508}
509
510////////////////////////////////////////////////////////////////////////////////
511/// Returns text width relative to currently used font.
512
514{
515 if (!fgDefaultFont)
516 fgDefaultFont = gClient->GetResourcePool()->GetIconFont();
517 return fgDefaultFont->TextWidth(c);
518}
519
520//---- highlighting utilities
521
522////////////////////////////////////////////////////////////////////////////////
523/// Highlight tree item.
524
526{
527 if (item) {
528 if ((item == fSelected) && !state) {
529 fSelected = 0;
530 if (draw) DrawItemName(fId, item);
531 } else if (state != item->IsActive()) { // !!!! leave active alone ...
532 item->SetActive(state);
533 if (draw) DrawItemName(fId, item);
534 }
535 }
536}
537
538////////////////////////////////////////////////////////////////////////////////
539/// Highlight item children.
540
542{
543 while (item) {
544 HighlightItem(item, state, draw);
545 if (item->fFirstchild)
546 HighlightChildren(item->fFirstchild, state, (item->IsOpen()) ? draw : kFALSE);
547 item = item->fNextsibling;
548 }
549}
550
551////////////////////////////////////////////////////////////////////////////////
552/// Unselect all items.
553
559
560////////////////////////////////////////////////////////////////////////////////
561/// Handle button events in the list tree.
562
564{
566
567 if (fTip) fTip->Hide();
568
569 Int_t page = 0;
570 if (event->fCode == kButton4 || event->fCode == kButton5) {
571 if (!fCanvas) return kTRUE;
572 if (fCanvas->GetContainer()->GetHeight()) {
573// page = Int_t(Float_t(fCanvas->GetViewPort()->GetHeight() *
574// fCanvas->GetViewPort()->GetHeight()) /
575// fCanvas->GetContainer()->GetHeight());
576 // choose page size either 1/5 of viewport or 5 lines (90)
577 Int_t r = fCanvas->GetViewPort()->GetHeight() / 5;
578 page = std::min(r, 90);
579 }
580 }
581
582 if (event->fCode == kButton4) {
583 //scroll up
585 if (newpos < 0) newpos = 0;
587 return kTRUE;
588 }
589 if (event->fCode == kButton5) {
590 // scroll down
593 return kTRUE;
594 }
595
596 if (event->fType == kButtonPress) {
597 if ((item = FindItem(event->fY)) != 0) {
598 if (event->fCode == kButton1) {
599 Int_t minx, maxx;
600 Int_t minxchk = 0, maxxchk = 0;
601 if (item->HasCheckBox() && item->GetCheckBoxPicture()) {
602 minxchk = (item->fXtext - item->GetCheckBoxPicture()->GetWidth());
603 maxxchk = (item->fXtext - 4);
604 maxx = maxxchk - Int_t(item->GetPicWidth()) - 8;
605 minx = minxchk - Int_t(item->GetPicWidth()) - 16;
606 }
607 else {
608 maxx = (item->fXtext - Int_t(item->GetPicWidth())) - 8;
609 minx = (item->fXtext - Int_t(item->GetPicWidth())) - 16;
610 }
611 if ((item->HasCheckBox()) && (event->fX < maxxchk) &&
612 (event->fX > minxchk))
613 {
615 if (fCheckMode == kRecursive) {
616 CheckAllChildren(item, item->IsChecked());
617 }
619 Checked((TObject *)item->GetUserData(), item->IsChecked());
620 return kTRUE;
621 }
622 if ((event->fX < maxx) && (event->fX > minx)) {
623 item->SetOpen(!item->IsOpen());
625 return kTRUE;
626 }
627 }
628 // DND specific
629 if (event->fCode == kButton1) {
630 fXDND = event->fX;
631 fYDND = event->fY;
632 fBdown = kTRUE;
633 }
634 if (!fUserControlled) {
637 //item->fActive = kTRUE; // this is done below w/redraw
641 event->fCode, (event->fYRoot << 16) | event->fXRoot);
642 }
643 else {
646 }
647 Clicked(item, event->fCode);
648 Clicked(item, event->fCode, event->fXRoot, event->fYRoot);
649 Clicked(item, event->fCode, event->fState, event->fXRoot, event->fYRoot);
650 }
651 }
652 if (event->fType == kButtonRelease) {
653 fBdown = kFALSE;
654 }
655 return kTRUE;
656}
657
658////////////////////////////////////////////////////////////////////////////////
659/// Handle double click event in the list tree (only for kButton1).
660
662{
663 TGListTreeItem *item = 0;
664
665 if (event->fCode == kButton4 || event->fCode == kButton5) {
666 return kFALSE;
667 }
668 // If fDisableOpen is set, only send message and emit signals.
669 // It allows user to customize handling of double click events.
670 if (fDisableOpen && event->fCode == kButton1 && (item = FindItem(event->fY)) != 0) {
672 event->fCode, (event->fYRoot << 16) | event->fXRoot);
673 DoubleClicked(item, event->fCode);
674 DoubleClicked(item, event->fCode, event->fXRoot, event->fYRoot);
675 return kTRUE;
676 }
677 item = FindItem(event->fY);
678
679 // Otherwise, just use default behaviour (open item).
680 if (event->fCode == kButton1 && item) {
682 item->SetOpen(!item->IsOpen());
683 if (!fUserControlled) {
684 if (item != fSelected) { // huh?!
685 if (fSelected) fSelected->SetActive(kFALSE); // !!!!
688 }
689 }
691 event->fCode, (event->fYRoot << 16) | event->fXRoot);
692 DoubleClicked(item, event->fCode);
693 DoubleClicked(item, event->fCode, event->fXRoot, event->fYRoot);
694 }
695 if (!fUserControlled)
696 fSelected = item;
697 return kTRUE;
698}
699
700////////////////////////////////////////////////////////////////////////////////
701/// Handle mouse crossing event.
702
704{
705 if (event->fType == kLeaveNotify) {
706 if (fTip) {
707 fTip->Hide();
708 fTipItem = 0;
709 }
710 if (!fUserControlled) {
711 if (fCurrent)
712 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
713 if (fBelowMouse)
714 DrawOutline(fId, fBelowMouse, 0xffffff, kTRUE);
715 fCurrent = 0;
716 }
717 if (fBelowMouse) {
718 fBelowMouse = 0;
719 MouseOver(0);
720 MouseOver(0, event->fState);
721 }
722 }
724 return kTRUE;
725}
726
727////////////////////////////////////////////////////////////////////////////////
728/// Handle dragging position events.
729
731 Int_t /*xroot*/, Int_t /*yroot*/)
732{
733 static TGListTreeItem *olditem = 0;
735 if ((item = FindItem(y)) != 0) {
736 if (item->IsDNDTarget()) {
737 fDropItem = item;
738 if (olditem)
741 olditem = item;
742 return action;
743 }
744 }
745 fDropItem = 0;
746 if (olditem) {
748 olditem = 0;
749 }
750 return kNone;
751}
752
753////////////////////////////////////////////////////////////////////////////////
754/// Handle drag enter events.
755
757{
758 Atom_t ret = kNone;
759 for (int i = 0; typelist[i] != kNone; ++i) {
760 if (typelist[i] == fDNDTypeList[0])
761 ret = fDNDTypeList[0];
762 if (typelist[i] == fDNDTypeList[1])
763 ret = fDNDTypeList[1];
764 }
765 return ret;
766}
767
768////////////////////////////////////////////////////////////////////////////////
769/// Handle drag leave events.
770
775
776////////////////////////////////////////////////////////////////////////////////
777/// Handle drop events.
778
780{
783 //ClearHighlighted();
784 return kTRUE;
785}
786
787////////////////////////////////////////////////////////////////////////////////
788/// Emit DataDropped() signal.
789
791{
792 Longptr_t args[2];
793
794 args[0] = (Longptr_t)item;
795 args[1] = (Longptr_t)data;
796
797 Emit("DataDropped(TGListTreeItem*,TDNDData*)", args);
798}
799
800////////////////////////////////////////////////////////////////////////////////
801/// Handle mouse motion event. Used to set tool tip, to emit
802/// MouseOver() signal and for DND handling.
803
805{
808
809 if (gDNDManager->IsDragging()) {
810 gDNDManager->Drag(event->fXRoot, event->fYRoot,
812 } else if ((item = FindItem(event->fY)) != 0) {
813 if (!fUserControlled) {
814 if (fCurrent)
815 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
816 if (fBelowMouse)
817 DrawOutline(fId, fBelowMouse, 0xffffff, kTRUE);
819 fCurrent = item;
820 }
821 if (item != fBelowMouse) {
825 }
826
827 if (item->HasCheckBox() && item->GetCheckBoxPicture()) {
828 if ((event->fX < (item->fXtext - 4) &&
829 (event->fX > (item->fXtext - (Int_t)item->GetCheckBoxPicture()->GetWidth()))))
830 {
831 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kPointer));
832 return kTRUE;
833 }
834 else {
835 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kHand));
836 }
837 }
838 if (!gDNDManager->IsDragging()) {
839 if (fBdown && ((abs(event->fX - fXDND) > 2) || (abs(event->fY - fYDND) > 2))) {
840 if (gDNDManager && item->IsDNDSource()) {
842 fBuf->Reset();
843 // !!!!! Here check virtual Bool_t HandlesDragAndDrop()
844 // and let the item handle this.
845 if (item->GetUserData()) {
846 TObject *obj = static_cast<TObject *>(item->GetUserData());
847 if (dynamic_cast<TObject *>(obj)) {
848 TObjString *ostr = dynamic_cast<TObjString *>(obj);
849 if (ostr) {
850 TString& str = ostr->String();
851 if (str.BeginsWith("file://")) {
853 fDNDData.fData = (void *)strdup(str.Data());
854 fDNDData.fDataLength = str.Length()+1;
855 }
856 }
857 else {
859 fBuf->WriteObject((TObject *)item->GetUserData());
862 }
863 }
864 }
865 else {
867 TString str = TString::Format("file://%s/%s\r\n",
869 item->GetText());
870 fDNDData.fData = (void *)strdup(str.Data());
871 fDNDData.fDataLength = str.Length()+1;
872 }
873 if (item->GetPicture()) {
874 TString xmpname = item->GetPicture()->GetName();
875 if (xmpname.EndsWith("_t.xpm"))
876 xmpname.ReplaceAll("_t.xpm", "_s.xpm");
877 if (xmpname.EndsWith("_t.xpm__16x16"))
878 xmpname.ReplaceAll("_t.xpm__16x16", "_s.xpm");
879 const TGPicture *pic = fClient->GetPicture(xmpname.Data());
880 if (!pic) pic = item->GetPicture();
881 if (pic) SetDragPixmap(pic);
882 }
883 gDNDManager->StartDrag(this, event->fXRoot, event->fYRoot);
884 }
885 }
886 }
887 if (gDNDManager->IsDragging()) {
888 gDNDManager->Drag(event->fXRoot, event->fYRoot,
890 } else {
891 if (fTipItem == item) return kTRUE;
892 if (!fUserControlled) { // !!!! what is this? It was called above once?
894 MouseOver(item, event->fState);
895 }
896 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kHand));
897 }
898
899 if (fTip)
900 fTip->Hide();
901
902 if (item->GetTipTextLength() > 0) {
903
904 SetToolTipText(item->GetTipText(), item->fXtext,
905 item->fY - pos.fY + item->fHeight, 1000);
906
907 } else if (fAutoTips && item->GetUserData()) {
908 // must derive from TObject (in principle user can put pointer
909 // to anything in user data field). Add check.
910 TObject *obj = (TObject *)item->GetUserData();
911 if (obj && obj->IsA()->IsTObject()) {
912 SetToolTipText(obj->GetTitle(), item->fXtext,
913 item->fY - pos.fY + item->fHeight, 1000);
914 }
915 }
916 fTipItem = item;
917 } else {
918 if (fBelowMouse) {
919 fBelowMouse = 0;
922 }
923 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kPointer));
924 }
925 return kTRUE;
926}
927
928////////////////////////////////////////////////////////////////////////////////
929/// The key press event handler converts a key press to some line editor
930/// action.
931
933{
934 char input[10];
936 TGListTreeItem *item = 0;
937
938 fLastEventState = event->fState;
939 if (fTip) fTip->Hide();
940
941 if (event->fType == kGKeyPress) {
942 gVirtualX->LookupString(event, input, sizeof(input), keysym);
943
944 if (!event->fState && (EKeySym)keysym == kKey_Escape) {
946 }
947
948 item = fCurrent;
949 if (!item) return kFALSE;
950
952 KeyPressed(item, keysym, event->fState);
953
955 return kTRUE;
956
957 switch ((EKeySym)keysym) {
958 case kKey_Enter:
959 case kKey_Return:
960 event->fType = kButtonPress;
961 event->fCode = kButton1;
962
963 if (fSelected == item) {
964 // treat 'Enter' and 'Return' as a double click
966 item->SetOpen(!item->IsOpen());
968 } else {
969 // treat 'Enter' and 'Return' as a click
973 fSelected = item;
976 Clicked(item, 1);
977 Clicked(item, 1, event->fXRoot, event->fYRoot);
978 Clicked(item, 1, event->fState, event->fXRoot, event->fYRoot);
979 }
980 break;
981 case kKey_Space:
982 if (item->HasCheckBox()) {
984 if (fCheckMode == kRecursive) {
985 CheckAllChildren(item, item->IsChecked());
986 }
988 Checked((TObject *)item->GetUserData(), item->IsChecked());
989 }
990 break;
991 case kKey_F3:
992 Search(kFALSE);
993 break;
994 case kKey_F5:
995 Layout();
996 break;
997 case kKey_F7:
998 Search();
999 break;
1000 case kKey_Left:
1001 ClearViewPort();
1002 item->SetOpen(kFALSE);
1003 break;
1004 case kKey_Right:
1005 ClearViewPort();
1006 item->SetOpen(kTRUE);
1007 break;
1008 case kKey_Up:
1009 LineUp(event->fState & kKeyShiftMask);
1010 break;
1011 case kKey_Down:
1012 LineDown(event->fState & kKeyShiftMask);
1013 break;
1014 case kKey_PageUp:
1015 PageUp(event->fState & kKeyShiftMask);
1016 break;
1017 case kKey_PageDown:
1018 PageDown(event->fState & kKeyShiftMask);
1019 break;
1020 case kKey_Home:
1021 Home(event->fState & kKeyShiftMask);
1022 break;
1023 case kKey_End:
1024 End(event->fState & kKeyShiftMask);
1025 break;
1026 default:
1027 break;
1028 }
1029 if (event->fState & kKeyControlMask) { // Ctrl key modifier pressed
1030 switch((EKeySym)keysym & ~0x20) { // treat upper and lower the same
1031 case kKey_F:
1032 Search();
1033 break;
1034 case kKey_G:
1035 Search(kFALSE);
1036 break;
1037 default:
1038 return kTRUE;
1039 }
1040 }
1041
1042 }
1043 return kTRUE;
1044}
1045
1046////////////////////////////////////////////////////////////////////////////////
1047/// Signal emitted when pointer is over entry.
1048
1050{
1051 Emit("MouseOver(TGListTreeItem*)", (Longptr_t)entry);
1052}
1053
1054////////////////////////////////////////////////////////////////////////////////
1055/// Signal emitted when pointer is over entry.
1056
1058{
1059 Longptr_t args[2];
1060 args[0] = (Longptr_t)entry;
1061 args[1] = mask;
1062 Emit("MouseOver(TGListTreeItem*,UInt_t)", args);
1063}
1064
1065////////////////////////////////////////////////////////////////////////////////
1066/// Signal emitted when keyboard key pressed
1067///
1068/// entry - selected item
1069/// keysym - defined in "KeySymbols.h"
1070/// mask - modifier key mask, defined in "GuiTypes.h"
1071///
1072/// const Mask_t kKeyShiftMask = BIT(0);
1073/// const Mask_t kKeyLockMask = BIT(1);
1074/// const Mask_t kKeyControlMask = BIT(2);
1075/// const Mask_t kKeyMod1Mask = BIT(3); // typically the Alt key
1076/// const Mask_t kButton1Mask = BIT(8);
1077/// const Mask_t kButton2Mask = BIT(9);
1078/// const Mask_t kButton3Mask = BIT(10);
1079/// const Mask_t kButton4Mask = BIT(11);
1080/// const Mask_t kButton5Mask = BIT(12);
1081/// const Mask_t kAnyModifier = BIT(15);
1082
1084{
1085 Longptr_t args[3];
1086 args[0] = (Longptr_t)entry;
1087 args[1] = (Longptr_t)keysym;
1088 args[2] = (Longptr_t)mask;
1089 Emit("KeyPressed(TGListTreeItem*,UInt_t,UInt_t)", args);
1091}
1092
1093////////////////////////////////////////////////////////////////////////////////
1094/// Emit ReturnPressed() signal.
1095
1097{
1098 Emit("ReturnPressed(TGListTreeItem*)", (Longptr_t)entry);
1099}
1100
1101////////////////////////////////////////////////////////////////////////////////
1102/// Emit Checked() signal.
1103
1105{
1106 Longptr_t args[2];
1107
1108 args[0] = (Longptr_t)entry;
1109 args[1] = on;
1110
1111 Emit("Checked(TObject*,Bool_t)", args);
1112}
1113
1114////////////////////////////////////////////////////////////////////////////////
1115/// Emit Clicked() signal.
1116
1118{
1119 Longptr_t args[2];
1120
1121 args[0] = (Longptr_t)entry;
1122 args[1] = btn;
1123
1124 Emit("Clicked(TGListTreeItem*,Int_t)", args);
1125}
1126
1127////////////////////////////////////////////////////////////////////////////////
1128/// Emit Clicked() signal.
1129
1131{
1132 Longptr_t args[4];
1133
1134 args[0] = (Longptr_t)entry;
1135 args[1] = btn;
1136 args[2] = x;
1137 args[3] = y;
1138
1139 Emit("Clicked(TGListTreeItem*,Int_t,Int_t,Int_t)", args);
1140}
1141
1142////////////////////////////////////////////////////////////////////////////////
1143/// Emit Clicked() signal.
1144
1146{
1147 Longptr_t args[5];
1148
1149 args[0] = (Longptr_t)entry;
1150 args[1] = btn;
1151 args[2] = mask;
1152 args[3] = x;
1153 args[4] = y;
1154
1155 Emit("Clicked(TGListTreeItem*,Int_t,UInt_t,Int_t,Int_t)", args);
1156}
1157
1158////////////////////////////////////////////////////////////////////////////////
1159/// Emit DoubleClicked() signal.
1160
1162{
1163 Longptr_t args[2];
1164
1165 args[0] = (Longptr_t)entry;
1166 args[1] = btn;
1167
1168 Emit("DoubleClicked(TGListTreeItem*,Int_t)", args);
1169}
1170
1171////////////////////////////////////////////////////////////////////////////////
1172/// Emit DoubleClicked() signal.
1173
1175{
1176 Longptr_t args[4];
1177
1178 args[0] = (Longptr_t)entry;
1179 args[1] = btn;
1180 args[2] = x;
1181 args[3] = y;
1182
1183 Emit("DoubleClicked(TGListTreeItem*,Int_t,Int_t,Int_t)", args);
1184}
1185
1186////////////////////////////////////////////////////////////////////////////////
1187/// Move content to the top.
1188
1189void TGListTree::Home(Bool_t /*select*/)
1190{
1192}
1193
1194////////////////////////////////////////////////////////////////////////////////
1195/// Move content to the bottom.
1196
1197void TGListTree::End(Bool_t /*select*/)
1198{
1200}
1201
1202////////////////////////////////////////////////////////////////////////////////
1203/// Move content one page up.
1204
1206{
1207 if (!fCanvas) return;
1208
1210
1212 if (newpos<0) newpos = 0;
1213
1215}
1216
1217////////////////////////////////////////////////////////////////////////////////
1218/// Move content one page down.
1219
1221{
1222 if (!fCanvas) return;
1223
1225
1227
1229}
1230
1231////////////////////////////////////////////////////////////////////////////////
1232/// Move content one item-size up.
1233
1235{
1236 Int_t height = 0;
1237 if (!fCurrent) return;
1238
1240 const TGPicture *pic1 = fCurrent->GetPicture();
1241 if (pic1) height = pic1->GetHeight() + fVspacing;
1242 else height = fVspacing + 16;
1243 Int_t findy = (fCurrent->fY - height) + (fMargin - pos.fY);
1244 TGListTreeItem *next = FindItem(findy);
1245 if (next && (next != fCurrent)) {
1246 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
1247 if (findy <= 2*height) {
1249 if (newpos<0) newpos = 0;
1251 }
1252 DrawOutline(fId, next);
1253 fCurrent = next;
1254 }
1255}
1256
1257////////////////////////////////////////////////////////////////////////////////
1258/// Move content one item-size down.
1259
1261{
1262 Int_t height;
1263 if (!fCurrent) return;
1264
1267 const TGPicture *pic1 = fCurrent->GetPicture();
1268 if (pic1) height = pic1->GetHeight() + fVspacing;
1269 else height = fVspacing + 16;
1270 Int_t findy = (fCurrent->fY + height) + (fMargin - pos.fY);
1271 TGListTreeItem *next = FindItem(findy);
1272 if (next && (next != fCurrent)) {
1273 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
1274 if (findy >= ((Int_t)dim.fHeight - 2*height)) {
1276 if (newpos<0) newpos = 0;
1278 }
1279 DrawOutline(fId, next);
1280 fCurrent = next;
1281 }
1282}
1283
1284////////////////////////////////////////////////////////////////////////////////
1285/// Move content to position of item. If item is 0, move to position
1286/// of currently selected item.
1287
1289{
1290 TGListTreeItem *it = item;
1291
1292 if (!it) it = fSelected;
1293 if (!it) {
1294 HighlightItem(fFirst); // recursive call of this function
1295 return;
1296 }
1297
1298 Int_t y = 0;
1299 Int_t yparent = 0;
1300 Int_t vh = 0;
1301 Int_t v = 0;
1302
1303 if (it) {
1304 y = it->fY;
1305 if (it->GetParent()) yparent = it->GetParent()->fY;
1306 }
1307
1308 if (y==0) y = yparent; // item->fY not initiated yet
1309
1310 if (fCanvas->GetVScrollbar()->IsMapped()) {
1312
1313 if (y<fCanvas->GetVScrollbar()->GetPosition()) {
1314 v = std::max(0,y-(Int_t)fViewPort->GetHeight()/2);
1316 } else if (y+(Int_t)it->fHeight>vh) {
1317 v = std::min((Int_t)GetHeight()-(Int_t)fViewPort->GetHeight(),
1318 y+(Int_t)it->fHeight-(Int_t)fViewPort->GetHeight()/2);
1319 if (v<0) v = 0;
1321 }
1322 }
1323}
1324
1325////////////////////////////////////////////////////////////////////////////////
1326/// Invokes search dialog. Looks for item with the entered name.
1327
1329{
1330 Int_t ret = 0;
1331 char msg[256];
1332 static TString buf;
1333
1335 srch->fBuffer = (char *)StrDup(buf.Data());
1336
1338 if (close || buf.IsNull())
1339 new TGSearchDialog(fClient->GetDefaultRoot(), fCanvas, 400, 150, srch, &ret);
1340 else if (!buf.IsNull()) ret = 1;
1341
1342 if (ret) {
1343 item = FindItemByPathname(srch->fBuffer);
1344 if (!item) {
1345 snprintf(msg, 255, "Couldn't find \"%s\"", srch->fBuffer);
1346 gVirtualX->Bell(20);
1347 new TGMsgBox(fClient->GetDefaultRoot(), fCanvas, "Container", msg,
1349 } else {
1352 }
1353 }
1354 buf = srch->fBuffer;
1355 delete srch;
1356}
1357
1358//---- drawing functions
1359
1360////////////////////////////////////////////////////////////////////////////////
1361/// Redraw list tree.
1362
1364{
1365 static GContext_t gcBg = 0;
1366
1367 // sanity checks
1368 if (y > (Int_t)fViewPort->GetHeight()) {
1369 return;
1370 }
1371
1372 y = y < 0 ? 0 : y;
1374
1375 // more sanity checks
1376 if (((Int_t)w < 1) || (w > 32768) || ((Int_t)h < 1)) {
1377 return;
1378 }
1379
1380 Pixmap_t pixmap = gVirtualX->CreatePixmap(fId, w, fViewPort->GetHeight());
1381
1382 if (!gcBg) {
1384 gcValues.fForeground = fBackground;
1385 gcValues.fForeground = fBackground;
1386 gcValues.fGraphicsExposures = kTRUE;
1388 gcBg = gVirtualX->CreateGC(fId, &gcValues);
1389 }
1390
1391 gVirtualX->SetForeground(gcBg, fBackground);
1392 gVirtualX->FillRectangle(pixmap, gcBg, 0, 0, w, fViewPort->GetHeight());
1393
1395
1396 gVirtualX->CopyArea(pixmap, fId, gcBg, 0, y, w, fViewPort->GetHeight(), 0, y);
1397
1398 gVirtualX->DeletePixmap(pixmap);
1399 gVirtualX->Update(kFALSE);
1400}
1401
1402////////////////////////////////////////////////////////////////////////////////
1403/// Draw list tree widget.
1404
1406{
1408 Int_t x, y, xbranch;
1410
1411 // Overestimate the expose region to be sure to draw an item that gets
1412 // cut by the region
1415 old_width = fDefw;
1416 old_height = fDefh;
1417 fDefw = fDefh = 1;
1418
1420 x = 2-pos.fX;
1421 y = fMargin;
1422 item = fFirst;
1423
1424 while (item) {
1425 xbranch = -1;
1426
1427 DrawItem(id, item, x, y, &xbranch, &width, &height);
1428
1429 width += pos.fX + x + fHspacing + fMargin;
1430
1431 if (width > fDefw) fDefw = width;
1432
1433 y += height + fVspacing;
1434 if (item->fFirstchild && item->IsOpen()) {
1435 y = DrawChildren(id, item->fFirstchild, x, y, xbranch);
1436 }
1437
1438 item = item->fNextsibling;
1439 }
1440
1441 fDefh = y + fMargin;
1442
1443 if ((old_width != fDefw) || (old_height != fDefh)) {
1444 fCanvas->Layout();
1445 }
1446}
1447
1448////////////////////////////////////////////////////////////////////////////////
1449/// Draw children of item in list tree.
1450
1453{
1455 Int_t xbranch;
1457
1458 x += fIndent + (Int_t)item->fParent->GetPicWidth();
1459 while (item) {
1460 xbranch = xroot;
1461
1462 DrawItem(id, item, x, y, &xbranch, &width, &height);
1463
1464 width += pos.fX + x + fHspacing + fMargin;
1465 if (width > fDefw) fDefw = width;
1466
1467 y += height + fVspacing;
1468 if ((item->fFirstchild) && (item->IsOpen())) {
1469 y = DrawChildren(id, item->fFirstchild, x, y, xbranch);
1470 }
1471
1472 item = item->fNextsibling;
1473 }
1474 return y;
1475}
1476
1477////////////////////////////////////////////////////////////////////////////////
1478/// Draw list tree item.
1479
1482{
1484 Int_t xpic2 = 0;
1485 UInt_t height;
1486 const TGPicture *pic1 = item->GetPicture();
1487 const TGPicture *pic2 = item->GetCheckBoxPicture();
1488
1489 // Compute the height of this line
1490 height = FontHeight();
1491
1492 xpic1 = x;
1493 xtext = x + fHspacing + (Int_t)item->GetPicWidth();
1494 if (pic2) {
1495 if (pic2->GetHeight() > height) {
1496 height = pic2->GetHeight();
1497 }
1498 if (pic1) xpic2 = xpic1 + pic1->GetWidth() + 1;
1499 else xpic2 = xpic1 + 1;
1500 xtext += pic2->GetWidth();
1501 }
1502 if (pic1) {
1503 if (pic1->GetHeight() > height) {
1504 ytext = y + (Int_t)((pic1->GetHeight() - height) >> 1);
1505 height = pic1->GetHeight();
1506 ypic1 = y;
1507 } else {
1508 ytext = y;
1509 ypic1 = y + (Int_t)((height - pic1->GetHeight()) >> 1);
1510 }
1511 xbranch = xpic1 + (Int_t)(pic1->GetWidth() >> 1);
1512 ybranch = ypic1 + (Int_t)pic1->GetHeight();
1513 yline = ypic1 + (Int_t)(pic1->GetHeight() >> 1);
1514 } else {
1515 ypic1 = ytext = y;
1516 xbranch = xpic1 + (Int_t)(item->GetPicWidth() >> 1);
1517 ybranch = ypic1 + (Int_t)(height >> 1);
1518 yline = ypic1 + (Int_t)(height >> 1);
1519 }
1520
1521 // height must be even, otherwise our dashed line wont appear properly
1522 //++height; height &= ~1;
1523
1524 // Save the basic graphics info for use by other functions
1525 item->fY = y;
1526 item->fXtext = xtext;
1527 item->fYtext = ytext;
1528 item->fHeight = height;
1529
1530 // projected coordinates
1533 Int_t yp = y - pos.fY;
1534 Int_t ylinep = yline - pos.fY;
1535 Int_t ybranchp = ybranch - pos.fY;
1536 Int_t ypicp = ypic1 - pos.fY;
1537
1538 if ((yp >= fExposeTop) && (yp <= (Int_t)dim.fHeight))
1539 {
1540 DrawItemName(id, item);
1541 if (*xroot >= 0) {
1542 xc = *xroot;
1543
1544 if (item->fNextsibling) {
1545 gVirtualX->DrawLine(id, fLineGC, xc, yp, xc, yp+height);
1546 } else {
1547 gVirtualX->DrawLine(id, fLineGC, xc, yp, xc, ylinep);
1548 }
1549
1550 TGListTreeItem *p = item->fParent;
1551 while (p) {
1552 xc -= (fIndent + (Int_t)item->GetPicWidth());
1553 if (p->fNextsibling) {
1554 gVirtualX->DrawLine(id, fLineGC, xc, yp, xc, yp+height);
1555 }
1556 p = p->fParent;
1557 }
1558 gVirtualX->DrawLine(id, fLineGC, *xroot, ylinep, xpic1, ylinep);
1559 DrawNode(id, item, *xroot, yline);
1560 }
1561 if (item->IsOpen() && item->fFirstchild) {
1562 gVirtualX->DrawLine(id, fLineGC, xbranch, ybranchp, xbranch,
1563 yp+height);
1564 }
1565 if (pic1)
1566 pic1->Draw(id, fDrawGC, xpic1, ypicp);
1567 if (pic2)
1568 pic2->Draw(id, fDrawGC, xpic2, ypicp);
1569 }
1570
1571 *xroot = xbranch;
1572 *retwidth = TextWidth(item->GetText()) + item->GetPicWidth();
1573 *retheight = height;
1574}
1575
1576////////////////////////////////////////////////////////////////////////////////
1577/// Draw a outline of color 'col' around an item.
1578
1580 Bool_t clear)
1581{
1584
1585 if (clear) {
1586 gVirtualX->SetForeground(fDrawGC, fCanvas->GetContainer()->GetBackground());
1587 //ClearViewPort(); // time consuming!!!
1588 }
1589 else
1590 gVirtualX->SetForeground(fDrawGC, col);
1591
1592#ifdef R__HAS_COCOA
1593 gVirtualX->DrawRectangle(id, fDrawGC, 1, item->fY - pos.fY, dim.fWidth-2, item->fHeight + 1);
1594#else
1595 gVirtualX->DrawRectangle(id, fDrawGC, 1, item->fYtext-pos.fY-2,
1596 dim.fWidth-3, FontHeight()+4);
1597#endif
1598 gVirtualX->SetForeground(fDrawGC, fgBlackPixel);
1599}
1600
1601////////////////////////////////////////////////////////////////////////////////
1602/// Draw active item with its active color.
1603
1605{
1606 UInt_t width;
1609
1610 width = dim.fWidth-2;
1611 gVirtualX->SetForeground(fDrawGC, item->GetActiveColor());
1612
1613#ifdef R__HAS_COCOA
1614 gVirtualX->FillRectangle(id, fDrawGC, 1, item->fY - pos.fY, width, item->fHeight + 1);
1615#else
1616 gVirtualX->FillRectangle(id, fDrawGC, 1, item->fYtext-pos.fY-1, width,
1617 FontHeight()+3);
1618#endif
1619 gVirtualX->SetForeground(fDrawGC, fgBlackPixel);
1620 gVirtualX->DrawString(id, fActiveGC, item->fXtext,
1621 item->fYtext - pos.fY + FontAscent(),
1622 item->GetText(), item->GetTextLength());
1623}
1624
1625////////////////////////////////////////////////////////////////////////////////
1626/// Draw name of list tree item.
1627
1629{
1632
1633 if (item->IsActive()) {
1634 DrawActive(id, item);
1635 }
1636 else { // if (!item->IsActive() && (item != fSelected)) {
1637 gVirtualX->FillRectangle(id, fHighlightGC, item->fXtext,
1638 item->fYtext-pos.fY, dim.fWidth-item->fXtext-2,
1639 FontHeight()+1);
1640 gVirtualX->DrawString(id, fDrawGC,
1641 item->fXtext, item->fYtext-pos.fY + FontAscent(),
1642 item->GetText(), item->GetTextLength());
1643 }
1644 if (item == fCurrent) {
1645 DrawOutline(id, item);
1646 }
1647
1648 if (fColorMode != 0 && item->HasColor()) {
1649 UInt_t width = TextWidth(item->GetText());
1650 gVirtualX->SetForeground(fColorGC, TColor::Number2Pixel(item->GetColor()));
1652 Int_t y = item->fYtext-pos.fY + FontAscent() + 2;
1653 gVirtualX->DrawLine(id, fColorGC, item->fXtext, y,
1654 item->fXtext + width, y);
1655 }
1656 if (fColorMode & kColorBox) {
1657 Int_t x = item->fXtext + width + 4;
1658 Int_t y = item->fYtext - pos.fY + 3;
1659 Int_t h = FontAscent() - 4;
1660 gVirtualX->FillRectangle(id, fColorGC, x, y, h, h);
1661 gVirtualX->DrawRectangle(id, fDrawGC, x, y, h, h);
1662 }
1663 }
1664}
1665
1666////////////////////////////////////////////////////////////////////////////////
1667/// Draw node (little + in box).
1668
1670{
1672 Int_t yp = y - pos.fY;
1673
1674 if (item->fFirstchild) {
1675 gVirtualX->DrawLine(id, fHighlightGC, x, yp-2, x, yp+2);
1676 gVirtualX->SetForeground(fHighlightGC, fgBlackPixel);
1677 gVirtualX->DrawLine(id, fHighlightGC, x-2, yp, x+2, yp);
1678 if (!item->IsOpen())
1679 gVirtualX->DrawLine(id, fHighlightGC, x, yp-2, x, yp+2);
1680 gVirtualX->SetForeground(fHighlightGC, fGrayPixel);
1681 gVirtualX->DrawLine(id, fHighlightGC, x-4, yp-4, x+4, yp-4);
1682 gVirtualX->DrawLine(id, fHighlightGC, x+4, yp-4, x+4, yp+4);
1683 gVirtualX->DrawLine(id, fHighlightGC, x-4, yp+4, x+4, yp+4);
1684 gVirtualX->DrawLine(id, fHighlightGC, x-4, yp-4, x-4, yp+4);
1685 gVirtualX->SetForeground(fHighlightGC, fgWhitePixel);
1686 }
1687}
1688
1689////////////////////////////////////////////////////////////////////////////////
1690/// Set tool tip text associated with this item. The delay is in
1691/// milliseconds (minimum 250). To remove tool tip call method with
1692/// delayms = 0. To change delayms you first have to call this method
1693/// with delayms=0.
1694
1696{
1697 if (delayms == 0) {
1698 delete fTip;
1699 fTip = 0;
1700 return;
1701 }
1702
1703 if (text && strlen(text)) {
1704 if (!fTip)
1705 fTip = new TGToolTip(fClient->GetDefaultRoot(), this, text, delayms);
1706 else
1707 fTip->SetText(text);
1708 fTip->SetPosition(x, y);
1709 fTip->Reset();
1710 }
1711}
1712
1713////////////////////////////////////////////////////////////////////////////////
1714/// This function removes the specified item from the linked list.
1715/// It does not do anything with the data contained in the item, though.
1716
1718{
1719 ClearViewPort();
1720
1721 // Disentangle from front (previous-sibling, parent's first child)
1722 if (item->fPrevsibling) {
1723 item->fPrevsibling->fNextsibling = item->fNextsibling;
1724 } else {
1725 if (item->fParent)
1726 item->fParent->fFirstchild = item->fNextsibling;
1727 else
1728 fFirst = item->fNextsibling;
1729 }
1730 // Disentangle from end (next-sibling, parent's last child)
1731 if (item->fNextsibling) {
1732 item->fNextsibling->fPrevsibling = item->fPrevsibling;
1733 } else {
1734 if (item->fParent)
1735 item->fParent->fLastchild = item->fPrevsibling;
1736 else
1737 fLast = item->fPrevsibling;
1738 }
1739}
1740
1741////////////////////////////////////////////////////////////////////////////////
1742/// Delete given item. Takes care of list-tree state members
1743/// fSelected, fCurrent and fBelowMouse.
1744
1746{
1747 if (fSelected == item) {
1748 fSelected = 0;
1749 }
1750 if (fCurrent == item) {
1751 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
1752 fCurrent = item->GetPrevSibling();
1753 if (! fCurrent) {
1754 fCurrent = item->GetNextSibling();
1755 if (! fCurrent)
1756 fCurrent = item->GetParent();
1757 }
1758 }
1759 if (fBelowMouse == item) {
1760 DrawOutline(fId, fBelowMouse, 0xffffff, kTRUE);
1761 fBelowMouse = 0;
1762 MouseOver(0);
1764 }
1765
1766 delete item;
1767}
1768
1769////////////////////////////////////////////////////////////////////////////////
1770/// Recursively delete all children of an item.
1771
1773{
1774 TGListTreeItem *child = item->fFirstchild;
1775
1776 while (child) {
1777 TGListTreeItem *next = child->fNextsibling;
1780 child = next;
1781 }
1782
1783 item->fFirstchild = item->fLastchild = 0;
1784}
1785
1786////////////////////////////////////////////////////////////////////////////////
1787/// Insert child in list.
1788
1790{
1791 TGListTreeItem *i;
1792
1793 item->fParent = parent;
1794 item->fNextsibling = item->fPrevsibling = 0;
1795
1796 if (parent) {
1797
1798 if (parent->fFirstchild) {
1799 if (parent->fLastchild) {
1800 i = parent->fLastchild;
1801 }
1802 else {
1803 i = parent->fFirstchild;
1804 while (i->fNextsibling) i = i->fNextsibling;
1805 }
1806 i->fNextsibling = item;
1807 item->fPrevsibling = i;
1808 } else {
1809 parent->fFirstchild = item;
1810 }
1811 parent->fLastchild = item;
1812
1813 } else { // if parent == 0, this is a top level entry
1814
1815 if (fFirst) {
1816 if (fLast) {
1817 i = fLast;
1818 }
1819 else {
1820 i = fFirst;
1821 while (i->fNextsibling) i = i->fNextsibling;
1822 }
1823 i->fNextsibling = item;
1824 item->fPrevsibling = i;
1825 } else {
1826 fFirst = item;
1827 }
1828 fLast = item;
1829 }
1830 if (item->HasCheckBox())
1832}
1833
1834////////////////////////////////////////////////////////////////////////////////
1835/// Insert a list of ALREADY LINKED children into another list
1836
1838{
1839 TGListTreeItem *next, *newnext;
1840
1841 //while (item) {
1842 // next = item->fNextsibling;
1843 // InsertChild(parent, item);
1844 // item = next;
1845 //}
1846 //return;
1847
1848 // Save the reference for the next item in the new list
1849 next = item->fNextsibling;
1850
1851 // Insert the first item in the new list into the existing list
1852 InsertChild(parent, item);
1853
1854 // The first item is inserted, with its prev and next siblings updated
1855 // to fit into the existing list. So, save the existing list reference
1856 newnext = item->fNextsibling;
1857
1858 // Now, mark the first item's next sibling to point back to the new list
1859 item->fNextsibling = next;
1860
1861 // Mark the parents of the new list to the new parent. The order of the
1862 // rest of the new list should be OK, and the second item should still
1863 // point to the first, even though the first was reparented.
1864 while (item->fNextsibling) {
1865 item->fParent = parent;
1866 item = item->fNextsibling;
1867 }
1868
1869 // Fit the end of the new list back into the existing list
1870 item->fNextsibling = newnext;
1871 if (newnext)
1872 newnext->fPrevsibling = item;
1873}
1874
1875////////////////////////////////////////////////////////////////////////////////
1876/// Search child item.
1877
1880{
1881 UInt_t height;
1882 const TGPicture *pic;
1883
1884 while (item) {
1885 // Select the pixmap to use
1886 pic = item->GetPicture();
1887
1888 // Compute the height of this line
1889 height = FontHeight();
1890 if (pic && pic->GetHeight() > height)
1891 height = pic->GetHeight();
1892
1893 if ((findy >= y) && (findy <= y + (Int_t)height)) {
1894 *finditem = item;
1895 return -1;
1896 }
1897
1898 y += (Int_t)height + fVspacing;
1899 if (item->fFirstchild && item->IsOpen()) {
1900 y = SearchChildren(item->fFirstchild, y, findy, finditem);
1901 if (*finditem) return -1;
1902 }
1903
1904 item = item->fNextsibling;
1905 }
1906
1907 return y;
1908}
1909
1910////////////////////////////////////////////////////////////////////////////////
1911/// Find item at postion findy.
1912
1914{
1915 Int_t y;
1916 UInt_t height;
1918 const TGPicture *pic;
1920
1921 y = fMargin - pos.fY;
1922 item = fFirst;
1923 finditem = 0;
1924 while (item && !finditem) {
1925 // Select the pixmap to use
1926 pic = item->GetPicture();
1927
1928 // Compute the height of this line
1929 height = FontHeight();
1930 if (pic && (pic->GetHeight() > height))
1931 height = pic->GetHeight();
1932
1933 if ((findy >= y) && (findy <= y + (Int_t)height))
1934 return item;
1935
1936 y += (Int_t)height + fVspacing;
1937 if ((item->fFirstchild) && (item->IsOpen())) {
1938 y = SearchChildren(item->fFirstchild, y, findy, &finditem);
1939 //if (finditem) return finditem;
1940 }
1941 item = item->fNextsibling;
1942 }
1943
1944 return finditem;
1945}
1946
1947//----- Public Functions
1948
1949////////////////////////////////////////////////////////////////////////////////
1950/// Add given item to list tree.
1951
1953{
1954 InsertChild(parent, item);
1955
1956 if ((parent == 0) || (parent && parent->IsOpen()))
1957 ClearViewPort();
1958}
1959
1960////////////////////////////////////////////////////////////////////////////////
1961/// Add item to list tree. Returns new item.
1962
1964 const TGPicture *open, const TGPicture *closed,
1966{
1968
1969 item = new TGListTreeItemStd(fClient, string, open, closed, checkbox);
1970 InsertChild(parent, item);
1971
1972 if ((parent == 0) || (parent && parent->IsOpen()))
1973 ClearViewPort();
1974 return item;
1975}
1976
1977////////////////////////////////////////////////////////////////////////////////
1978/// Add item to list tree. If item with same userData already exists
1979/// don't add it. Returns new item.
1980
1982 void *userData, const TGPicture *open,
1983 const TGPicture *closed,
1985{
1987 if (!item) {
1988 item = AddItem(parent, string, open, closed, checkbox);
1989 if (item) item->SetUserData(userData);
1990 }
1991
1992 return item;
1993}
1994
1995////////////////////////////////////////////////////////////////////////////////
1996/// Rename item in list tree.
1997
1999{
2000 if (item) {
2001 item->Rename(string);
2002 }
2003
2004 DoRedraw();
2005}
2006
2007////////////////////////////////////////////////////////////////////////////////
2008/// Delete item from list tree.
2009
2011{
2012 if (!fUserControlled)
2013 fCurrent = fBelowMouse = 0;
2014
2018
2019 fClient->NeedRedraw(this);
2020
2021 return 1;
2022}
2023
2024////////////////////////////////////////////////////////////////////////////////
2025/// Open item in list tree (i.e. show child items).
2026
2028{
2029 if (item) {
2030 item->SetOpen(kTRUE);
2031 DoRedraw(); // force layout
2033 }
2034}
2035
2036////////////////////////////////////////////////////////////////////////////////
2037/// Close item in list tree (i.e. hide child items).
2038
2040{
2041 if (item) {
2042 item->SetOpen(kFALSE);
2043 DoRedraw(); // force layout
2045 }
2046}
2047
2048////////////////////////////////////////////////////////////////////////////////
2049/// Delete item with fUserData == ptr. Search tree downwards starting
2050/// at item.
2051
2053{
2054 if (item && ptr) {
2055 if (item->GetUserData() == ptr) {
2057 } else {
2058 if (item->IsOpen() && item->fFirstchild) {
2059 RecursiveDeleteItem(item->fFirstchild, ptr);
2060 }
2061 RecursiveDeleteItem(item->fNextsibling, ptr);
2062 }
2063 }
2064 return 1;
2065}
2066
2067////////////////////////////////////////////////////////////////////////////////
2068/// Set tooltip text for this item. By default an item for which the
2069/// userData is a pointer to an TObject the TObject::GetTitle() will
2070/// be used to get the tip text.
2071
2073{
2074 if (item) {
2075 item->SetTipText(string);
2076 }
2077}
2078
2079////////////////////////////////////////////////////////////////////////////////
2080/// Delete children of item from list.
2081
2083{
2084 if (!fUserControlled)
2085 fCurrent = fBelowMouse = 0;
2086
2088
2089 DoRedraw();
2090
2091 return 1;
2092}
2093
2094////////////////////////////////////////////////////////////////////////////////
2095/// Make newparent the new parent of item.
2096
2098{
2099 // Remove the item from its old location.
2101
2102 // The item is now unattached. Reparent it.
2104
2105 DoRedraw();
2106
2107 return 1;
2108}
2109
2110////////////////////////////////////////////////////////////////////////////////
2111/// Make newparent the new parent of the children of item.
2112
2115{
2116 TGListTreeItem *first;
2117
2118 if (item->fFirstchild) {
2119 first = item->fFirstchild;
2120 item->fFirstchild = 0;
2121
2122 InsertChildren(newparent, first);
2123
2124 DoRedraw();
2125 return 1;
2126 }
2127 return 0;
2128}
2129
2130////////////////////////////////////////////////////////////////////////////////
2131
2132extern "C"
2133Int_t Compare(const void *item1, const void *item2)
2134{
2135 return strcmp((*((TGListTreeItem **) item1))->GetText(),
2136 (*((TGListTreeItem **) item2))->GetText());
2137}
2138
2139////////////////////////////////////////////////////////////////////////////////
2140/// Sort items starting with item.
2141
2143{
2144 TGListTreeItem *first, *parent, **list;
2145 size_t i, count;
2146
2147 // Get first child in list;
2148 while (item->fPrevsibling) item = item->fPrevsibling;
2149
2150 first = item;
2151 parent = first->fParent;
2152
2153 // Count the children
2154 count = 1;
2155 while (item->fNextsibling) item = item->fNextsibling, count++;
2156 if (count <= 1) return 1;
2157
2158 list = new TGListTreeItem* [count];
2159 list[0] = first;
2160 count = 1;
2161 while (first->fNextsibling) {
2162 list[count] = first->fNextsibling;
2163 count++;
2164 first = first->fNextsibling;
2165 }
2166
2167 ::qsort(list, count, sizeof(TGListTreeItem*), ::Compare);
2168
2169 list[0]->fPrevsibling = 0;
2170 for (i = 0; i < count; i++) {
2171 if (i < count - 1)
2172 list[i]->fNextsibling = list[i + 1];
2173 if (i > 0)
2174 list[i]->fPrevsibling = list[i - 1];
2175 }
2176 list[count - 1]->fNextsibling = 0;
2177 if (parent) {
2178 parent->fFirstchild = list[0];
2179 parent->fLastchild = list[count-1];
2180 }
2181 else {
2182 fFirst = list[0];
2183 fLast = list[count-1];
2184 }
2185
2186 delete [] list;
2187
2188 DoRedraw();
2189
2190 return 1;
2191}
2192
2193////////////////////////////////////////////////////////////////////////////////
2194/// Sort siblings of item.
2195
2200
2201////////////////////////////////////////////////////////////////////////////////
2202/// Sort children of item.
2203
2205{
2206 TGListTreeItem *first;
2207
2208 if (item) {
2209 first = item->fFirstchild;
2210 if (first) {
2211 SortSiblings(first);
2212 }
2213 } else {
2214 if (fFirst) {
2215 first = fFirst->fFirstchild;
2216 if (first) {
2217 SortSiblings(first);
2218 }
2219 }
2220 }
2221 DoRedraw();
2222 return 1;
2223}
2224
2225////////////////////////////////////////////////////////////////////////////////
2226/// Find sibling of item by name.
2227
2229{
2230 // Get first child in list
2231 if (item) {
2232 while (item->fPrevsibling) {
2233 item = item->fPrevsibling;
2234 }
2235
2236 while (item) {
2237 if (strcmp(item->GetText(), name) == 0) {
2238 return item;
2239 }
2240 item = item->fNextsibling;
2241 }
2242 return item;
2243 }
2244 return 0;
2245}
2246
2247////////////////////////////////////////////////////////////////////////////////
2248/// Find sibling of item by userData.
2249
2251{
2252 // Get first child in list
2253 if (item) {
2254 while (item->fPrevsibling) {
2255 item = item->fPrevsibling;
2256 }
2257
2258 while (item) {
2259 if (item->GetUserData() == userData) {
2260 return item;
2261 }
2262 item = item->fNextsibling;
2263 }
2264 return item;
2265 }
2266 return 0;
2267}
2268
2269////////////////////////////////////////////////////////////////////////////////
2270/// Find child of item by name.
2271
2273{
2274 // Get first child in list
2275 if (item && item->fFirstchild) {
2276 item = item->fFirstchild;
2277 } else if (!item && fFirst) {
2278 item = fFirst;
2279 } else {
2280 item = 0;
2281 }
2282
2283 while (item) {
2284 if (strcmp(item->GetText(), name) == 0) {
2285 return item;
2286 }
2287 item = item->fNextsibling;
2288 }
2289 return 0;
2290}
2291
2292////////////////////////////////////////////////////////////////////////////////
2293/// Find child of item by userData.
2294
2296{
2297 // Get first child in list
2298 if (item && item->fFirstchild) {
2299 item = item->fFirstchild;
2300 } else if (!item && fFirst) {
2301 item = fFirst;
2302 } else {
2303 item = 0;
2304 }
2305
2306 while (item) {
2307 if (item->GetUserData() == userData) {
2308 return item;
2309 }
2310 item = item->fNextsibling;
2311 }
2312 return 0;
2313}
2314
2315////////////////////////////////////////////////////////////////////////////////
2316/// Find item by pathname. Pathname is in the form of /xx/yy/zz. If zz
2317/// in path /xx/yy is found it returns item, 0 otherwise.
2318
2320{
2321 if (!path || !*path) return 0;
2322
2323 const char *p = path, *s;
2324 char dirname[1024];
2325 TGListTreeItem *item = 0;
2326 item = FindChildByName(item, "/");
2327 if (!gVirtualX->InheritsFrom("TGX11")) {
2328 // on Windows, use the current drive instead of root (/)
2329 TList *curvol = gSystem->GetVolumes("cur");
2330 if (curvol) {
2331 TNamed *drive = (TNamed *)curvol->At(0);
2332 item = FindChildByName(0, TString::Format("%s\\", drive->GetName()));
2333 delete curvol;
2334 }
2335 }
2338
2339 while (1) {
2340 while (*p && *p == '/') p++;
2341 if (!*p) break;
2342
2343 s = strchr(p, '/');
2344
2345 if (!s) {
2346 strlcpy(dirname, p, 1024);
2347 } else {
2348 strlcpy(dirname, p, (s-p)+1);
2349 }
2350
2352
2353 if (!diritem && dirname[0]) {
2354 fulldir += "/";
2355 fulldir += dirname;
2356
2357 if ((diritem=FindChildByName(0, fulldir.Data()))) {
2358 if (!s || !s[0]) return diritem;
2359 p = ++s;
2360 item = diritem;
2361 continue;
2362 }
2363 }
2364
2365 if (!s || !s[0]) return item;
2366 p = ++s;
2367 }
2368 return 0;
2369}
2370
2371////////////////////////////////////////////////////////////////////////////////
2372/// Highlight item.
2373
2380
2381////////////////////////////////////////////////////////////////////////////////
2382/// Un highlight items.
2383
2388
2389////////////////////////////////////////////////////////////////////////////////
2390/// Get pathname from item. Use depth to limit path name to last
2391/// depth levels. By default depth is not limited.
2392
2394{
2395 char tmppath[1024];
2396
2397 *path = '\0';
2398 while (item) {
2399 snprintf(tmppath, 1023, "/%s%s", item->GetText(), path);
2400 strlcpy(path, tmppath, 1024);
2401 item = item->fParent;
2402 if (--depth == 0 && item) {
2403 snprintf(tmppath, 1023, "...%s", path);
2404 strlcpy(path, tmppath, 1024);
2405 return;
2406 }
2407 }
2408}
2409
2410////////////////////////////////////////////////////////////////////////////////
2411/// Return gray draw color in use.
2412
2414{
2415 static Bool_t init = kFALSE;
2416 if (!init) {
2417 if (!gClient->GetColorByName("#808080", fgGrayPixel))
2419 init = kTRUE;
2420 }
2421 return fgGrayPixel;
2422}
2423
2424////////////////////////////////////////////////////////////////////////////////
2425/// Return default font structure in use.
2426
2428{
2429 if (!fgDefaultFont)
2430 fgDefaultFont = gClient->GetResourcePool()->GetIconFont();
2431 return fgDefaultFont->GetFontStruct();
2432}
2433
2434////////////////////////////////////////////////////////////////////////////////
2435/// Return default graphics context in use.
2436
2438{
2439 if (!fgActiveGC) {
2441
2444 gcv.fLineStyle = kLineSolid;
2445 gcv.fLineWidth = 0;
2446 gcv.fFillStyle = kFillSolid;
2447 gcv.fFont = fgDefaultFont->GetFontHandle();
2448 gcv.fBackground = fgDefaultSelectedBackground;
2449 const TGGC *selgc = gClient->GetResourcePool()->GetSelectedGC();
2450 if (selgc)
2451 gcv.fForeground = selgc->GetForeground();
2452 else
2453 gcv.fForeground = fgWhitePixel;
2454 fgActiveGC = gClient->GetGC(&gcv, kTRUE);
2455 }
2456 return *fgActiveGC;
2457}
2458
2459////////////////////////////////////////////////////////////////////////////////
2460/// Return default graphics context in use.
2461
2463{
2464 if (!fgDrawGC) {
2466
2469 gcv.fLineStyle = kLineSolid;
2470 gcv.fLineWidth = 0;
2471 gcv.fFillStyle = kFillSolid;
2472 gcv.fFont = fgDefaultFont->GetFontHandle();
2473 gcv.fBackground = fgWhitePixel;
2474 gcv.fForeground = fgBlackPixel;
2475
2476 fgDrawGC = gClient->GetGC(&gcv, kTRUE);
2477 }
2478 return *fgDrawGC;
2479}
2480
2481////////////////////////////////////////////////////////////////////////////////
2482/// Return graphics context in use for line drawing.
2483
2485{
2486 if (!fgLineGC) {
2488
2491 gcv.fLineStyle = kLineOnOffDash;
2492 gcv.fLineWidth = 0;
2493 gcv.fFillStyle = kFillSolid;
2494 gcv.fFont = fgDefaultFont->GetFontHandle();
2495 gcv.fBackground = fgWhitePixel;
2496 gcv.fForeground = GetGrayPixel();
2497
2498 fgLineGC = gClient->GetGC(&gcv, kTRUE);
2499 fgLineGC->SetDashOffset(0);
2500 fgLineGC->SetDashList("\x1\x1", 2);
2501 }
2502 return *fgLineGC;
2503}
2504
2505////////////////////////////////////////////////////////////////////////////////
2506/// Return graphics context for highlighted frame background.
2507
2509{
2510 if (!fgHighlightGC) {
2512
2515 gcv.fLineStyle = kLineSolid;
2516 gcv.fLineWidth = 0;
2517 gcv.fFillStyle = kFillSolid;
2518 gcv.fFont = fgDefaultFont->GetFontHandle();
2519 gcv.fBackground = fgDefaultSelectedBackground;
2520 gcv.fForeground = fgWhitePixel;
2521
2522 fgHighlightGC = gClient->GetGC(&gcv, kTRUE);
2523 }
2524 return *fgHighlightGC;
2525}
2526
2527////////////////////////////////////////////////////////////////////////////////
2528/// Return graphics context for highlighted frame background.
2529
2531{
2532 if (!fgColorGC) {
2534
2537 gcv.fLineStyle = kLineSolid;
2538 gcv.fLineWidth = 1;
2539 gcv.fFillStyle = kFillSolid;
2540 gcv.fBackground = fgDefaultSelectedBackground;
2541 gcv.fForeground = fgWhitePixel;
2542
2543 fgColorGC = gClient->GetGC(&gcv, kTRUE);
2544 }
2545 return *fgColorGC;
2546}
2547
2548////////////////////////////////////////////////////////////////////////////////
2549/// Returns the icon used by items in open state.
2550
2552{
2553 if (!fgOpenPic)
2554 fgOpenPic = gClient->GetPicture("ofolder_t.xpm");
2555 ((TGPicture *)fgOpenPic)->AddReference();
2556 return fgOpenPic;
2557}
2558
2559////////////////////////////////////////////////////////////////////////////////
2560/// Returns the icon used by items in closed state.
2561
2563{
2564 if (!fgClosedPic)
2565 fgClosedPic = gClient->GetPicture("folder_t.xpm");
2566 ((TGPicture *)fgClosedPic)->AddReference();
2567 return fgClosedPic;
2568}
2569
2570////////////////////////////////////////////////////////////////////////////////
2571/// Returns the icon used for checked checkbox.
2572
2574{
2575 if (!fgCheckedPic)
2576 fgCheckedPic = gClient->GetPicture("checked_t.xpm");
2577 ((TGPicture *)fgCheckedPic)->AddReference();
2578 return fgCheckedPic;
2579}
2580
2581////////////////////////////////////////////////////////////////////////////////
2582/// Returns the icon used for unchecked checkbox.
2583
2585{
2586 if (!fgUncheckedPic)
2587 fgUncheckedPic = gClient->GetPicture("unchecked_t.xpm");
2588 ((TGPicture *)fgUncheckedPic)->AddReference();
2589 return fgUncheckedPic;
2590}
2591
2592////////////////////////////////////////////////////////////////////////////////
2593/// Save a list tree widget as a C++ statements on output stream out.
2594
2595void TGListTree::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2596{
2597 // store options and color if differ from defaults
2599
2600 out << "\n // list tree\n";
2601 out << " TGListTree *" << GetName() << " = new TGListTree(";
2602
2603 if ((fParent->GetParent())->InheritsFrom(TGCanvas::Class()))
2604 out << GetCanvas()->GetName();
2605 else
2606 out << fParent->GetName() << "," << GetWidth() << "," << GetHeight();
2607 out << extra_args << ");\n";
2608
2609 if (option && strstr(option, "keep_names"))
2610 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
2611
2612 TGListTreeItem *current = GetFirstItem();
2613
2614 out << " \n";
2615
2616 while (current) {
2617 TString var_name = current->SaveTreeItem(out, GetName(), "nullptr");
2618 if (current->IsOpen())
2619 out << " " << GetName() << "->OpenItem(" << var_name << ");\n";
2620 else
2621 out << " " << GetName() << "->CloseItem(" << var_name << ");\n";
2622
2623 if (current == fSelected)
2624 out << " " << GetName() << "->SetSelected(" << var_name << ");\n";
2625
2626 if (current->fFirstchild)
2627 SaveChildren(out, var_name, current->fFirstchild);
2628
2629 current = current->fNextsibling;
2630 }
2631
2632 out << " \n";
2633}
2634
2635////////////////////////////////////////////////////////////////////////////////
2636/// Save child items as a C++ statements on output stream out.
2637
2638void TGListTree::SaveChildren(std::ostream &out, const char *parent_var_name, TGListTreeItem *item)
2639{
2640 while (item) {
2641 TString var_name = item->SaveTreeItem(out, GetName(), parent_var_name);
2642
2643 if (item == fSelected)
2644 out << " " << GetName() << "->SetSelected(" << var_name << ");\n";
2645
2646 if (item->fFirstchild)
2647 SaveChildren(out, var_name, item->fFirstchild);
2648
2649 item = item->fNextsibling;
2650 }
2651}
2652
2653////////////////////////////////////////////////////////////////////////////////
2654/// Save a list tree item attributes as a C++ statements on output stream.
2655
2656TString TGListTreeItemStd::SaveTreeItem(std::ostream &out, const char *tree_var_name, const char *parent_var_name)
2657{
2658 static const TGPicture *oldopen = nullptr, *oldclose = nullptr, *oldcheck = nullptr, *olduncheck = nullptr;
2659 static int item_cnt = 0;
2660
2661 if (!gROOT->ClassSaved(Class())) {
2662 oldopen = oldclose = oldcheck = olduncheck = nullptr;
2663 item_cnt = 0;
2664 out << " const TGPicture *pic_litem_open = nullptr, *pic_litem_close = nullptr, *pic_litem_check = nullptr, "
2665 "*pic_litem_uncheck = nullptr;\n";
2666 }
2667
2668 TString var_name = TString::Format("list_tree_item%d", item_cnt++);
2669
2670 if (fOpenPic && (oldopen != fOpenPic)) {
2671 oldopen = fOpenPic;
2674 out << " pic_litem_open = gClient->GetPicture(\"" << picname.ReplaceSpecialCppChars() << "\");\n";
2675 }
2676 if (fClosedPic && (oldclose != fClosedPic)) {
2680 out << " pic_litem_close = gClient->GetPicture(\"" << picname.ReplaceSpecialCppChars() << "\");\n";
2681 }
2682
2683 out << " TGListTreeItem *" << var_name << " = " << tree_var_name << "->AddItem(" << parent_var_name << ", \""
2684 << TString(GetText()).ReplaceSpecialCppChars() << "\", " << (fOpenPic ? "pic_litem_open" : "nullptr") << ", "
2685 << (fClosedPic ? "pic_litem_close" : "nullptr");
2686 if (HasCheckBox())
2687 out << ", kTRUE";
2688 out << ");\n";
2689
2690 if (HasCheckBox()) {
2691 out << " " << var_name << "->CheckItem();\n";
2692 if (fCheckedPic && oldcheck != fCheckedPic) {
2696 out << " pic_litem_check = gClient->GetPicture(\"" << picname.ReplaceSpecialCppChars() << "\");\n";
2697 }
2702 out << " pic_litem_uncheck = gClient->GetPicture(\"" << picname.ReplaceSpecialCppChars() << "\");\n";
2703 }
2704 out << " " << var_name << "->SetCheckBoxPictures(" << (fCheckedPic ? "pic_litem_check" : "nullptr") << ", "
2705 << (fUncheckedPic ? "pic_litem_uncheck" : "nullptr") << ");\n";
2706 }
2707 if (fHasColor)
2708 out << " " << var_name << "->SetColor(" << fColor << ");\n";
2709
2710 if (fTipText.Length() > 0)
2711 out << " " << var_name << "->SetTipText(\"" << TString(GetTipText()).ReplaceSpecialCppChars() << "\");\n";
2712
2713 return var_name;
2714}
2715
2716////////////////////////////////////////////////////////////////////////////////
2717/// Set check button state for the node 'item'.
2718
2720{
2721 item->CheckItem(check);
2722}
2723
2724////////////////////////////////////////////////////////////////////////////////
2725/// Set check button state for the node 'item'.
2726
2728{
2729 item->SetCheckBox(on);
2730}
2731
2732////////////////////////////////////////////////////////////////////////////////
2733/// Toggle check button state of the node 'item'.
2734
2736{
2737 item->Toggle();
2738}
2739
2740////////////////////////////////////////////////////////////////////////////////
2741/// Update the state of the node 'item' according to the children states.
2742
2744{
2745 if (fAutoCheckBoxPic == kFALSE) return;
2746
2747 TGListTreeItem *parent;
2748 TGListTreeItem *current;
2749 current = item->GetFirstChild();
2750 parent = current ? current : item;
2751 // recursively check parent/children status
2752 while (parent && parent->HasCheckBox()) {
2753 if ((!parent->IsChecked() && parent->HasCheckedChild(kTRUE)) ||
2754 (parent->IsChecked() && parent->HasUnCheckedChild(kTRUE))) {
2755 parent->SetCheckBoxPictures(fClient->GetPicture("checked_dis_t.xpm"),
2756 fClient->GetPicture("unchecked_dis_t.xpm"));
2757 }
2758 else {
2759 parent->SetCheckBoxPictures(fClient->GetPicture("checked_t.xpm"),
2760 fClient->GetPicture("unchecked_t.xpm"));
2761 }
2762 parent = parent->GetParent();
2763 if (parent && fCheckMode == kRecursive) {
2764 if (!parent->IsChecked() && parent->GetFirstChild() &&
2765 !parent->GetFirstChild()->HasUnCheckedChild()) {
2766 parent->SetCheckBoxPictures(fClient->GetPicture("checked_t.xpm"),
2767 fClient->GetPicture("unchecked_t.xpm"));
2768 parent->CheckItem(kTRUE);
2769 }
2770 else if (parent->IsChecked() && parent->GetFirstChild() &&
2771 !parent->GetFirstChild()->HasCheckedChild()) {
2772 parent->SetCheckBoxPictures(fClient->GetPicture("checked_t.xpm"),
2773 fClient->GetPicture("unchecked_t.xpm"));
2774 parent->CheckItem(kFALSE);
2775 }
2776 }
2777 }
2778 if (redraw) {
2779 ClearViewPort();
2780 }
2781}
2782
2783////////////////////////////////////////////////////////////////////////////////
2784/// Find item with fUserData == ptr. Search tree downwards starting
2785/// at item.
2786
2788{
2790 if (item && ptr) {
2791 if (item->GetUserData() == ptr)
2792 return item;
2793 else {
2794 if (item->fFirstchild) {
2795 fitem = FindItemByObj(item->fFirstchild, ptr);
2796 if (fitem) return fitem;
2797 }
2798 return FindItemByObj(item->fNextsibling, ptr);
2799 }
2800 }
2801 return 0;
2802}
2803
2804////////////////////////////////////////////////////////////////////////////////
2805/// Add all checked list tree items of this list tree into
2806/// the list 'checked'. This list is not adopted and must
2807/// be deleted by the user later.
2808
2810{
2811 if (!checked || !fFirst) return;
2812 TGListTreeItem *current = fFirst;
2813 if (current->IsChecked()) {
2814 checked->Add(new TObjString(current->GetText()));
2815 }
2816 while(current) {
2817 if (current->GetFirstChild())
2818 GetCheckedChildren(checked, current->GetFirstChild());
2819 current = current->GetNextSibling();
2820 }
2821}
2822
2823////////////////////////////////////////////////////////////////////////////////
2824/// Add all child items of 'item' into the list 'checked'.
2825
2827{
2828 if (!checked || !item) return;
2829
2830 while (item) {
2831 if (item->IsChecked()) {
2832 checked->Add(new TObjString(item->GetText()));
2833 }
2834 if (item->GetFirstChild()) {
2835 GetCheckedChildren(checked, item->GetFirstChild());
2836 }
2837 item = item->GetNextSibling();
2838 }
2839}
2840
2841////////////////////////////////////////////////////////////////////////////////
2842/// Check all child items of 'item' and 'item' itself according
2843/// to the state value: kTRUE means check all, kFALSE - uncheck all.
2844
2846{
2847 if (item)
2848 item->CheckAllChildren(state);
2849}
2850
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
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:89
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
#define gClient
Definition TGClient.h:157
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
void Sort()
#define gROOT
Definition TROOT.h:411
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2563
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:1579
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:2445
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:233
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:288
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:380
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:316
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:888
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:797
virtual TGDimension GetPageDimension() const
Returns page dimension.
Definition TGCanvas.cxx:748
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:734
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:688
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:331
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:637
UInt_t GetHeight() const
Definition TGFrame.h:227
TString SaveCtorArgs(std::ostream &out, UInt_t dflt_options=kChildFrame, Bool_t check_white_pixel=kFALSE)
Return options and custom color as constructor args Used in the SavePrimitive methods,...
Definition TGFrame.cxx:2493
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
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:127
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition TGWindow.cxx:293
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:334
UInt_t fEditDisabled
flags used for "guibuilding"
Definition TGWindow.h:32
A doubly linked list.
Definition TList.h:38
void 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:246
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
Basic string class.
Definition TString.h:138
Ssiz_t Length() const
Definition TString.h:425
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1121
const char * Data() const
Definition TString.h:384
Bool_t IsNull() const
Definition TString.h:422
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:2384
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1285
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:1073
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:881
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
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