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 const TGPicture *pic1 = nullptr, *pic2 = nullptr;
225 if ((!fChecked && HasCheckedChild(kTRUE)) ||
227 pic1 = gClient->GetPicture("checked_dis_t.xpm");
228 pic2 = gClient->GetPicture("unchecked_dis_t.xpm");
229 }
230 else {
231 pic1 = gClient->GetPicture("checked_t.xpm");
232 pic2 = gClient->GetPicture("unchecked_t.xpm");
233 }
235 gClient->FreePicture(pic1);
236 gClient->FreePicture(pic2);
237}
238
239////////////////////////////////////////////////////////////////////////////////
240/// Set all child items of this one checked if state=kTRUE,
241/// unchecked if state=kFALSE.
242
244{
245 if (state) {
246 if (!IsChecked())
247 CheckItem();
248 } else {
249 if (IsChecked())
250 Toggle();
251 }
253 UpdateState();
254}
255
256////////////////////////////////////////////////////////////////////////////////
257/// Set all child items of 'item' checked if state=kTRUE;
258/// unchecked if state=kFALSE.
259
261{
262 if (!item) return;
263
264 while (item) {
265 if (state){
266 if (!item->IsChecked())
267 item->CheckItem();
268 } else {
269 if (item->IsChecked())
270 item->Toggle();
271 }
272 if (item->GetFirstChild()) {
273 CheckChildren(item->GetFirstChild(), state);
274 }
275 item->UpdateState();
276 item = item->GetNextSibling();
277 }
278}
279
280////////////////////////////////////////////////////////////////////////////////
281/// Set a check box on the tree node.
282
287
288////////////////////////////////////////////////////////////////////////////////
289/// Change list tree check item icons.
290
292 const TGPicture *unchecked)
293{
296
297 if (!checked) {
298 ::Warning("TGListTreeItem::SetCheckBoxPictures", "checked picture not specified, defaulting to checked_t");
299 checked = fClient->GetPicture("checked_t.xpm");
300 } else
301 ((TGPicture *)checked)->AddReference();
302
303 if (!unchecked) {
304 ::Warning("TGListTreeItem::SetCheckBoxPictures", "unchecked picture not specified, defaulting to unchecked_t");
305 unchecked = fClient->GetPicture("unchecked_t.xpm");
306 } else
307 ((TGPicture *)unchecked)->AddReference();
308
309 fCheckedPic = checked;
311}
312
313////////////////////////////////////////////////////////////////////////////////
314/// Change list tree item icons.
315
317{
320
321 if (!opened) {
322 ::Warning("TGListTreeItem::SetPictures", "opened picture not specified, defaulting to ofolder_t");
323 opened = fClient->GetPicture("ofolder_t.xpm");
324 } else
325 ((TGPicture *)opened)->AddReference();
326
327 if (!closed) {
328 ::Warning("TGListTreeItem::SetPictures", "closed picture not specified, defaulting to folder_t");
329 closed = fClient->GetPicture("folder_t.xpm");
330 } else
331 ((TGPicture *)closed)->AddReference();
332
335}
336
337
338/******************************************************************************/
339/******************************************************************************/
340// TGListTree
341/******************************************************************************/
342
343////////////////////////////////////////////////////////////////////////////////
344/// Create a list tree widget.
345
347 Pixel_t back) :
348 TGContainer(p, w, h, options, back)
349{
350 fMsgWindow = p;
351 fCanvas = 0;
352 fTip = 0;
353 fTipItem = 0;
357 fBdown = kFALSE;
361 fDropItem = 0;
362 fLastEventState = 0;
363
366
368 fDrawGC = GetDrawGC()();
369 fLineGC = GetLineGC()();
371 fColorGC = GetColorGC()();
372
374 fDefw = fDefh = 1;
375
376 fHspacing = 2;
377 fVspacing = 2; // 0;
378 fIndent = 3; // 0;
379 fMargin = 2;
380
381 fXDND = fYDND = 0;
382 fDNDData.fData = 0;
385 fBuf = 0;
386
390
391 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
393 kNone, kNone);
394
398
399 fDNDTypeList = new Atom_t[3];
400 fDNDTypeList[0] = gVirtualX->InternAtom("application/root", kFALSE);
401 fDNDTypeList[1] = gVirtualX->InternAtom("text/uri-list", kFALSE);
402 fDNDTypeList[2] = 0;
403 gVirtualX->SetDNDAware(fId, fDNDTypeList);
406}
407
408////////////////////////////////////////////////////////////////////////////////
409/// Create a list tree widget.
410
412 TGContainer(p, options, back)
413{
414 fMsgWindow = p;
415 fTip = 0;
416 fTipItem = 0;
420 fBdown = kFALSE;
424 fDropItem = 0;
425 fLastEventState = 0;
426
429
431 fDrawGC = GetDrawGC()();
432 fLineGC = GetLineGC()();
434 fColorGC = GetColorGC()();
435
437 fDefw = fDefh = 1;
438
439 fHspacing = 2;
440 fVspacing = 2; // 0;
441 fIndent = 3; // 0;
442 fMargin = 2;
443
444 fXDND = fYDND = 0;
445 fDNDData.fData = 0;
448 fBuf = 0;
449
453
454 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
456 kNone, kNone);
457
461
462 fDNDTypeList = new Atom_t[3];
463 fDNDTypeList[0] = gVirtualX->InternAtom("application/root", kFALSE);
464 fDNDTypeList[1] = gVirtualX->InternAtom("text/uri-list", kFALSE);
465 fDNDTypeList[2] = 0;
466 gVirtualX->SetDNDAware(fId, fDNDTypeList);
469}
470
471////////////////////////////////////////////////////////////////////////////////
472/// Delete list tree widget.
473
475{
477
478 delete [] fDNDTypeList;
479 delete fTip;
480
481 item = fFirst;
482 while (item) {
484 sibling = item->fNextsibling;
485 delete item;
486 item = sibling;
487 }
488}
489
490//--- text utility functions
491
492////////////////////////////////////////////////////////////////////////////////
493/// Returns height of currently used font.
494
496{
497 if (!fgDefaultFont)
498 fgDefaultFont = gClient->GetResourcePool()->GetIconFont();
499 return fgDefaultFont->TextHeight();
500}
501
502////////////////////////////////////////////////////////////////////////////////
503/// Returns ascent of currently used font.
504
506{
508 if (!fgDefaultFont)
509 fgDefaultFont = gClient->GetResourcePool()->GetIconFont();
510 fgDefaultFont->GetFontMetrics(&m);
511 return m.fAscent;
512}
513
514////////////////////////////////////////////////////////////////////////////////
515/// Returns text width relative to currently used font.
516
518{
519 if (!fgDefaultFont)
520 fgDefaultFont = gClient->GetResourcePool()->GetIconFont();
521 return fgDefaultFont->TextWidth(c);
522}
523
524//---- highlighting utilities
525
526////////////////////////////////////////////////////////////////////////////////
527/// Highlight tree item.
528
530{
531 if (item) {
532 if ((item == fSelected) && !state) {
533 fSelected = 0;
534 if (draw) DrawItemName(fId, item);
535 } else if (state != item->IsActive()) { // !!!! leave active alone ...
536 item->SetActive(state);
537 if (draw) DrawItemName(fId, item);
538 }
539 }
540}
541
542////////////////////////////////////////////////////////////////////////////////
543/// Highlight item children.
544
546{
547 while (item) {
548 HighlightItem(item, state, draw);
549 if (item->fFirstchild)
550 HighlightChildren(item->fFirstchild, state, (item->IsOpen()) ? draw : kFALSE);
551 item = item->fNextsibling;
552 }
553}
554
555////////////////////////////////////////////////////////////////////////////////
556/// Unselect all items.
557
563
564////////////////////////////////////////////////////////////////////////////////
565/// Handle button events in the list tree.
566
568{
570
571 if (fTip) fTip->Hide();
572
573 Int_t page = 0;
574 if (event->fCode == kButton4 || event->fCode == kButton5) {
575 if (!fCanvas) return kTRUE;
576 if (fCanvas->GetContainer()->GetHeight()) {
577// page = Int_t(Float_t(fCanvas->GetViewPort()->GetHeight() *
578// fCanvas->GetViewPort()->GetHeight()) /
579// fCanvas->GetContainer()->GetHeight());
580 // choose page size either 1/5 of viewport or 5 lines (90)
581 Int_t r = fCanvas->GetViewPort()->GetHeight() / 5;
582 page = std::min(r, 90);
583 }
584 }
585
586 if (event->fCode == kButton4) {
587 //scroll up
589 if (newpos < 0) newpos = 0;
591 return kTRUE;
592 }
593 if (event->fCode == kButton5) {
594 // scroll down
597 return kTRUE;
598 }
599
600 if (event->fType == kButtonPress) {
601 if ((item = FindItem(event->fY)) != 0) {
602 if (event->fCode == kButton1) {
603 Int_t minx, maxx;
604 Int_t minxchk = 0, maxxchk = 0;
605 if (item->HasCheckBox() && item->GetCheckBoxPicture()) {
606 minxchk = (item->fXtext - item->GetCheckBoxPicture()->GetWidth());
607 maxxchk = (item->fXtext - 4);
608 maxx = maxxchk - Int_t(item->GetPicWidth()) - 8;
609 minx = minxchk - Int_t(item->GetPicWidth()) - 16;
610 }
611 else {
612 maxx = (item->fXtext - Int_t(item->GetPicWidth())) - 8;
613 minx = (item->fXtext - Int_t(item->GetPicWidth())) - 16;
614 }
615 if ((item->HasCheckBox()) && (event->fX < maxxchk) &&
616 (event->fX > minxchk))
617 {
619 if (fCheckMode == kRecursive) {
620 CheckAllChildren(item, item->IsChecked());
621 }
623 Checked((TObject *)item->GetUserData(), item->IsChecked());
624 return kTRUE;
625 }
626 if ((event->fX < maxx) && (event->fX > minx)) {
627 item->SetOpen(!item->IsOpen());
629 return kTRUE;
630 }
631 }
632 // DND specific
633 if (event->fCode == kButton1) {
634 fXDND = event->fX;
635 fYDND = event->fY;
636 fBdown = kTRUE;
637 }
638 if (!fUserControlled) {
641 //item->fActive = kTRUE; // this is done below w/redraw
645 event->fCode, (event->fYRoot << 16) | event->fXRoot);
646 }
647 else {
650 }
651 Clicked(item, event->fCode);
652 Clicked(item, event->fCode, event->fXRoot, event->fYRoot);
653 Clicked(item, event->fCode, event->fState, event->fXRoot, event->fYRoot);
654 }
655 }
656 if (event->fType == kButtonRelease) {
657 fBdown = kFALSE;
658 }
659 return kTRUE;
660}
661
662////////////////////////////////////////////////////////////////////////////////
663/// Handle double click event in the list tree (only for kButton1).
664
666{
667 TGListTreeItem *item = 0;
668
669 if (event->fCode == kButton4 || event->fCode == kButton5) {
670 return kFALSE;
671 }
672 // If fDisableOpen is set, only send message and emit signals.
673 // It allows user to customize handling of double click events.
674 if (fDisableOpen && event->fCode == kButton1 && (item = FindItem(event->fY)) != 0) {
676 event->fCode, (event->fYRoot << 16) | event->fXRoot);
677 DoubleClicked(item, event->fCode);
678 DoubleClicked(item, event->fCode, event->fXRoot, event->fYRoot);
679 return kTRUE;
680 }
681 item = FindItem(event->fY);
682
683 // Otherwise, just use default behaviour (open item).
684 if (event->fCode == kButton1 && item) {
686 item->SetOpen(!item->IsOpen());
687 if (!fUserControlled) {
688 if (item != fSelected) { // huh?!
689 if (fSelected) fSelected->SetActive(kFALSE); // !!!!
692 }
693 }
695 event->fCode, (event->fYRoot << 16) | event->fXRoot);
696 DoubleClicked(item, event->fCode);
697 DoubleClicked(item, event->fCode, event->fXRoot, event->fYRoot);
698 }
699 if (!fUserControlled)
700 fSelected = item;
701 return kTRUE;
702}
703
704////////////////////////////////////////////////////////////////////////////////
705/// Handle mouse crossing event.
706
708{
709 if (event->fType == kLeaveNotify) {
710 if (fTip) {
711 fTip->Hide();
712 fTipItem = 0;
713 }
714 if (!fUserControlled) {
715 if (fCurrent)
716 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
717 if (fBelowMouse)
718 DrawOutline(fId, fBelowMouse, 0xffffff, kTRUE);
719 fCurrent = 0;
720 }
721 if (fBelowMouse) {
722 fBelowMouse = 0;
723 MouseOver(0);
724 MouseOver(0, event->fState);
725 }
726 }
728 return kTRUE;
729}
730
731////////////////////////////////////////////////////////////////////////////////
732/// Handle dragging position events.
733
735 Int_t /*xroot*/, Int_t /*yroot*/)
736{
737 static TGListTreeItem *olditem = 0;
739 if ((item = FindItem(y)) != 0) {
740 if (item->IsDNDTarget()) {
741 fDropItem = item;
742 if (olditem)
745 olditem = item;
746 return action;
747 }
748 }
749 fDropItem = 0;
750 if (olditem) {
752 olditem = 0;
753 }
754 return kNone;
755}
756
757////////////////////////////////////////////////////////////////////////////////
758/// Handle drag enter events.
759
761{
762 Atom_t ret = kNone;
763 for (int i = 0; typelist[i] != kNone; ++i) {
764 if (typelist[i] == fDNDTypeList[0])
765 ret = fDNDTypeList[0];
766 if (typelist[i] == fDNDTypeList[1])
767 ret = fDNDTypeList[1];
768 }
769 return ret;
770}
771
772////////////////////////////////////////////////////////////////////////////////
773/// Handle drag leave events.
774
779
780////////////////////////////////////////////////////////////////////////////////
781/// Handle drop events.
782
784{
787 //ClearHighlighted();
788 return kTRUE;
789}
790
791////////////////////////////////////////////////////////////////////////////////
792/// Emit DataDropped() signal.
793
795{
796 Longptr_t args[2];
797
798 args[0] = (Longptr_t)item;
799 args[1] = (Longptr_t)data;
800
801 Emit("DataDropped(TGListTreeItem*,TDNDData*)", args);
802}
803
804////////////////////////////////////////////////////////////////////////////////
805/// Handle mouse motion event. Used to set tool tip, to emit
806/// MouseOver() signal and for DND handling.
807
809{
812
813 if (gDNDManager->IsDragging()) {
814 gDNDManager->Drag(event->fXRoot, event->fYRoot,
816 } else if ((item = FindItem(event->fY)) != 0) {
817 if (!fUserControlled) {
818 if (fCurrent)
819 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
820 if (fBelowMouse)
821 DrawOutline(fId, fBelowMouse, 0xffffff, kTRUE);
823 fCurrent = item;
824 }
825 if (item != fBelowMouse) {
829 }
830
831 if (item->HasCheckBox() && item->GetCheckBoxPicture()) {
832 if ((event->fX < (item->fXtext - 4) &&
833 (event->fX > (item->fXtext - (Int_t)item->GetCheckBoxPicture()->GetWidth()))))
834 {
835 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kPointer));
836 return kTRUE;
837 }
838 else {
839 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kHand));
840 }
841 }
842 if (!gDNDManager->IsDragging()) {
843 if (fBdown && ((abs(event->fX - fXDND) > 2) || (abs(event->fY - fYDND) > 2))) {
844 if (gDNDManager && item->IsDNDSource()) {
846 fBuf->Reset();
847 // !!!!! Here check virtual Bool_t HandlesDragAndDrop()
848 // and let the item handle this.
849 if (item->GetUserData()) {
850 TObject *obj = static_cast<TObject *>(item->GetUserData());
851 if (dynamic_cast<TObject *>(obj)) {
852 TObjString *ostr = dynamic_cast<TObjString *>(obj);
853 if (ostr) {
854 TString& str = ostr->String();
855 if (str.BeginsWith("file://")) {
857 fDNDData.fData = (void *)strdup(str.Data());
858 fDNDData.fDataLength = str.Length()+1;
859 }
860 }
861 else {
863 fBuf->WriteObject((TObject *)item->GetUserData());
866 }
867 }
868 }
869 else {
871 TString str = TString::Format("file://%s/%s\r\n",
873 item->GetText());
874 fDNDData.fData = (void *)strdup(str.Data());
875 fDNDData.fDataLength = str.Length()+1;
876 }
877 if (item->GetPicture()) {
878 TString xmpname = item->GetPicture()->GetName();
879 if (xmpname.EndsWith("_t.xpm"))
880 xmpname.ReplaceAll("_t.xpm", "_s.xpm");
881 if (xmpname.EndsWith("_t.xpm__16x16"))
882 xmpname.ReplaceAll("_t.xpm__16x16", "_s.xpm");
883 const TGPicture *pic = fClient->GetPicture(xmpname.Data());
884 if (!pic) pic = item->GetPicture();
885 if (pic) SetDragPixmap(pic);
886 }
887 gDNDManager->StartDrag(this, event->fXRoot, event->fYRoot);
888 }
889 }
890 }
891 if (gDNDManager->IsDragging()) {
892 gDNDManager->Drag(event->fXRoot, event->fYRoot,
894 } else {
895 if (fTipItem == item) return kTRUE;
896 if (!fUserControlled) { // !!!! what is this? It was called above once?
898 MouseOver(item, event->fState);
899 }
900 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kHand));
901 }
902
903 if (fTip)
904 fTip->Hide();
905
906 if (item->GetTipTextLength() > 0) {
907
908 SetToolTipText(item->GetTipText(), item->fXtext,
909 item->fY - pos.fY + item->fHeight, 1000);
910
911 } else if (fAutoTips && item->GetUserData()) {
912 // must derive from TObject (in principle user can put pointer
913 // to anything in user data field). Add check.
914 TObject *obj = (TObject *)item->GetUserData();
915 if (obj && obj->IsA()->IsTObject()) {
916 SetToolTipText(obj->GetTitle(), item->fXtext,
917 item->fY - pos.fY + item->fHeight, 1000);
918 }
919 }
920 fTipItem = item;
921 } else {
922 if (fBelowMouse) {
923 fBelowMouse = 0;
926 }
927 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kPointer));
928 }
929 return kTRUE;
930}
931
932////////////////////////////////////////////////////////////////////////////////
933/// The key press event handler converts a key press to some line editor
934/// action.
935
937{
938 char input[10];
940 TGListTreeItem *item = 0;
941
942 fLastEventState = event->fState;
943 if (fTip) fTip->Hide();
944
945 if (event->fType == kGKeyPress) {
946 gVirtualX->LookupString(event, input, sizeof(input), keysym);
947
948 if (!event->fState && (EKeySym)keysym == kKey_Escape) {
950 }
951
952 item = fCurrent;
953 if (!item) return kFALSE;
954
956 KeyPressed(item, keysym, event->fState);
957
959 return kTRUE;
960
961 switch ((EKeySym)keysym) {
962 case kKey_Enter:
963 case kKey_Return:
964 event->fType = kButtonPress;
965 event->fCode = kButton1;
966
967 if (fSelected == item) {
968 // treat 'Enter' and 'Return' as a double click
970 item->SetOpen(!item->IsOpen());
972 } else {
973 // treat 'Enter' and 'Return' as a click
977 fSelected = item;
980 Clicked(item, 1);
981 Clicked(item, 1, event->fXRoot, event->fYRoot);
982 Clicked(item, 1, event->fState, event->fXRoot, event->fYRoot);
983 }
984 break;
985 case kKey_Space:
986 if (item->HasCheckBox()) {
988 if (fCheckMode == kRecursive) {
989 CheckAllChildren(item, item->IsChecked());
990 }
992 Checked((TObject *)item->GetUserData(), item->IsChecked());
993 }
994 break;
995 case kKey_F3:
996 Search(kFALSE);
997 break;
998 case kKey_F5:
999 Layout();
1000 break;
1001 case kKey_F7:
1002 Search();
1003 break;
1004 case kKey_Left:
1005 ClearViewPort();
1006 item->SetOpen(kFALSE);
1007 break;
1008 case kKey_Right:
1009 ClearViewPort();
1010 item->SetOpen(kTRUE);
1011 break;
1012 case kKey_Up:
1013 LineUp(event->fState & kKeyShiftMask);
1014 break;
1015 case kKey_Down:
1016 LineDown(event->fState & kKeyShiftMask);
1017 break;
1018 case kKey_PageUp:
1019 PageUp(event->fState & kKeyShiftMask);
1020 break;
1021 case kKey_PageDown:
1022 PageDown(event->fState & kKeyShiftMask);
1023 break;
1024 case kKey_Home:
1025 Home(event->fState & kKeyShiftMask);
1026 break;
1027 case kKey_End:
1028 End(event->fState & kKeyShiftMask);
1029 break;
1030 default:
1031 break;
1032 }
1033 if (event->fState & kKeyControlMask) { // Ctrl key modifier pressed
1034 switch((EKeySym)keysym & ~0x20) { // treat upper and lower the same
1035 case kKey_F:
1036 Search();
1037 break;
1038 case kKey_G:
1039 Search(kFALSE);
1040 break;
1041 default:
1042 return kTRUE;
1043 }
1044 }
1045
1046 }
1047 return kTRUE;
1048}
1049
1050////////////////////////////////////////////////////////////////////////////////
1051/// Signal emitted when pointer is over entry.
1052
1054{
1055 Emit("MouseOver(TGListTreeItem*)", (Longptr_t)entry);
1056}
1057
1058////////////////////////////////////////////////////////////////////////////////
1059/// Signal emitted when pointer is over entry.
1060
1062{
1063 Longptr_t args[2];
1064 args[0] = (Longptr_t)entry;
1065 args[1] = mask;
1066 Emit("MouseOver(TGListTreeItem*,UInt_t)", args);
1067}
1068
1069////////////////////////////////////////////////////////////////////////////////
1070/// Signal emitted when keyboard key pressed
1071///
1072/// entry - selected item
1073/// keysym - defined in "KeySymbols.h"
1074/// mask - modifier key mask, defined in "GuiTypes.h"
1075///
1076/// const Mask_t kKeyShiftMask = BIT(0);
1077/// const Mask_t kKeyLockMask = BIT(1);
1078/// const Mask_t kKeyControlMask = BIT(2);
1079/// const Mask_t kKeyMod1Mask = BIT(3); // typically the Alt key
1080/// const Mask_t kButton1Mask = BIT(8);
1081/// const Mask_t kButton2Mask = BIT(9);
1082/// const Mask_t kButton3Mask = BIT(10);
1083/// const Mask_t kButton4Mask = BIT(11);
1084/// const Mask_t kButton5Mask = BIT(12);
1085/// const Mask_t kAnyModifier = BIT(15);
1086
1088{
1089 Longptr_t args[3];
1090 args[0] = (Longptr_t)entry;
1091 args[1] = (Longptr_t)keysym;
1092 args[2] = (Longptr_t)mask;
1093 Emit("KeyPressed(TGListTreeItem*,UInt_t,UInt_t)", args);
1095}
1096
1097////////////////////////////////////////////////////////////////////////////////
1098/// Emit ReturnPressed() signal.
1099
1101{
1102 Emit("ReturnPressed(TGListTreeItem*)", (Longptr_t)entry);
1103}
1104
1105////////////////////////////////////////////////////////////////////////////////
1106/// Emit Checked() signal.
1107
1109{
1110 Longptr_t args[2];
1111
1112 args[0] = (Longptr_t)entry;
1113 args[1] = on;
1114
1115 Emit("Checked(TObject*,Bool_t)", args);
1116}
1117
1118////////////////////////////////////////////////////////////////////////////////
1119/// Emit Clicked() signal.
1120
1122{
1123 Longptr_t args[2];
1124
1125 args[0] = (Longptr_t)entry;
1126 args[1] = btn;
1127
1128 Emit("Clicked(TGListTreeItem*,Int_t)", args);
1129}
1130
1131////////////////////////////////////////////////////////////////////////////////
1132/// Emit Clicked() signal.
1133
1135{
1136 Longptr_t args[4];
1137
1138 args[0] = (Longptr_t)entry;
1139 args[1] = btn;
1140 args[2] = x;
1141 args[3] = y;
1142
1143 Emit("Clicked(TGListTreeItem*,Int_t,Int_t,Int_t)", args);
1144}
1145
1146////////////////////////////////////////////////////////////////////////////////
1147/// Emit Clicked() signal.
1148
1150{
1151 Longptr_t args[5];
1152
1153 args[0] = (Longptr_t)entry;
1154 args[1] = btn;
1155 args[2] = mask;
1156 args[3] = x;
1157 args[4] = y;
1158
1159 Emit("Clicked(TGListTreeItem*,Int_t,UInt_t,Int_t,Int_t)", args);
1160}
1161
1162////////////////////////////////////////////////////////////////////////////////
1163/// Emit DoubleClicked() signal.
1164
1166{
1167 Longptr_t args[2];
1168
1169 args[0] = (Longptr_t)entry;
1170 args[1] = btn;
1171
1172 Emit("DoubleClicked(TGListTreeItem*,Int_t)", args);
1173}
1174
1175////////////////////////////////////////////////////////////////////////////////
1176/// Emit DoubleClicked() signal.
1177
1179{
1180 Longptr_t args[4];
1181
1182 args[0] = (Longptr_t)entry;
1183 args[1] = btn;
1184 args[2] = x;
1185 args[3] = y;
1186
1187 Emit("DoubleClicked(TGListTreeItem*,Int_t,Int_t,Int_t)", args);
1188}
1189
1190////////////////////////////////////////////////////////////////////////////////
1191/// Move content to the top.
1192
1193void TGListTree::Home(Bool_t /*select*/)
1194{
1196}
1197
1198////////////////////////////////////////////////////////////////////////////////
1199/// Move content to the bottom.
1200
1201void TGListTree::End(Bool_t /*select*/)
1202{
1204}
1205
1206////////////////////////////////////////////////////////////////////////////////
1207/// Move content one page up.
1208
1210{
1211 if (!fCanvas) return;
1212
1214
1216 if (newpos<0) newpos = 0;
1217
1219}
1220
1221////////////////////////////////////////////////////////////////////////////////
1222/// Move content one page down.
1223
1225{
1226 if (!fCanvas) return;
1227
1229
1231
1233}
1234
1235////////////////////////////////////////////////////////////////////////////////
1236/// Move content one item-size up.
1237
1239{
1240 Int_t height = 0;
1241 if (!fCurrent) return;
1242
1244 const TGPicture *pic1 = fCurrent->GetPicture();
1245 if (pic1) height = pic1->GetHeight() + fVspacing;
1246 else height = fVspacing + 16;
1247 Int_t findy = (fCurrent->fY - height) + (fMargin - pos.fY);
1248 TGListTreeItem *next = FindItem(findy);
1249 if (next && (next != fCurrent)) {
1250 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
1251 if (findy <= 2*height) {
1253 if (newpos<0) newpos = 0;
1255 }
1256 DrawOutline(fId, next);
1257 fCurrent = next;
1258 }
1259}
1260
1261////////////////////////////////////////////////////////////////////////////////
1262/// Move content one item-size down.
1263
1265{
1266 Int_t height;
1267 if (!fCurrent) return;
1268
1271 const TGPicture *pic1 = fCurrent->GetPicture();
1272 if (pic1) height = pic1->GetHeight() + fVspacing;
1273 else height = fVspacing + 16;
1274 Int_t findy = (fCurrent->fY + height) + (fMargin - pos.fY);
1275 TGListTreeItem *next = FindItem(findy);
1276 if (next && (next != fCurrent)) {
1277 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
1278 if (findy >= ((Int_t)dim.fHeight - 2*height)) {
1280 if (newpos<0) newpos = 0;
1282 }
1283 DrawOutline(fId, next);
1284 fCurrent = next;
1285 }
1286}
1287
1288////////////////////////////////////////////////////////////////////////////////
1289/// Move content to position of item. If item is 0, move to position
1290/// of currently selected item.
1291
1293{
1294 TGListTreeItem *it = item;
1295
1296 if (!it) it = fSelected;
1297 if (!it) {
1298 HighlightItem(fFirst); // recursive call of this function
1299 return;
1300 }
1301
1302 Int_t y = 0;
1303 Int_t yparent = 0;
1304 Int_t vh = 0;
1305 Int_t v = 0;
1306
1307 if (it) {
1308 y = it->fY;
1309 if (it->GetParent()) yparent = it->GetParent()->fY;
1310 }
1311
1312 if (y==0) y = yparent; // item->fY not initiated yet
1313
1314 if (fCanvas->GetVScrollbar()->IsMapped()) {
1316
1317 if (y<fCanvas->GetVScrollbar()->GetPosition()) {
1318 v = std::max(0,y-(Int_t)fViewPort->GetHeight()/2);
1320 } else if (y+(Int_t)it->fHeight>vh) {
1321 v = std::min((Int_t)GetHeight()-(Int_t)fViewPort->GetHeight(),
1322 y+(Int_t)it->fHeight-(Int_t)fViewPort->GetHeight()/2);
1323 if (v<0) v = 0;
1325 }
1326 }
1327}
1328
1329////////////////////////////////////////////////////////////////////////////////
1330/// Invokes search dialog. Looks for item with the entered name.
1331
1333{
1334 Int_t ret = 0;
1335 char msg[256];
1336 static TString buf;
1337
1339 srch->fBuffer = (char *)StrDup(buf.Data());
1340
1342 if (close || buf.IsNull())
1343 new TGSearchDialog(fClient->GetDefaultRoot(), fCanvas, 400, 150, srch, &ret);
1344 else if (!buf.IsNull()) ret = 1;
1345
1346 if (ret) {
1347 item = FindItemByPathname(srch->fBuffer);
1348 if (!item) {
1349 snprintf(msg, 255, "Couldn't find \"%s\"", srch->fBuffer);
1350 gVirtualX->Bell(20);
1351 new TGMsgBox(fClient->GetDefaultRoot(), fCanvas, "Container", msg,
1353 } else {
1356 }
1357 }
1358 buf = srch->fBuffer;
1359 delete srch;
1360}
1361
1362//---- drawing functions
1363
1364////////////////////////////////////////////////////////////////////////////////
1365/// Redraw list tree.
1366
1368{
1369 static GContext_t gcBg = 0;
1370
1371 // sanity checks
1372 if (y > (Int_t)fViewPort->GetHeight()) {
1373 return;
1374 }
1375
1376 y = y < 0 ? 0 : y;
1378
1379 // more sanity checks
1380 if (((Int_t)w < 1) || (w > 32768) || ((Int_t)h < 1)) {
1381 return;
1382 }
1383
1384 Pixmap_t pixmap = gVirtualX->CreatePixmap(fId, w, fViewPort->GetHeight());
1385
1386 if (!gcBg) {
1388 gcValues.fForeground = fBackground;
1389 gcValues.fForeground = fBackground;
1390 gcValues.fGraphicsExposures = kTRUE;
1392 gcBg = gVirtualX->CreateGC(fId, &gcValues);
1393 }
1394
1395 gVirtualX->SetForeground(gcBg, fBackground);
1396 gVirtualX->FillRectangle(pixmap, gcBg, 0, 0, w, fViewPort->GetHeight());
1397
1399
1400 gVirtualX->CopyArea(pixmap, fId, gcBg, 0, y, w, fViewPort->GetHeight(), 0, y);
1401
1402 gVirtualX->DeletePixmap(pixmap);
1403 gVirtualX->Update(kFALSE);
1404}
1405
1406////////////////////////////////////////////////////////////////////////////////
1407/// Draw list tree widget.
1408
1410{
1412 Int_t x, y, xbranch;
1414
1415 // Overestimate the expose region to be sure to draw an item that gets
1416 // cut by the region
1419 old_width = fDefw;
1420 old_height = fDefh;
1421 fDefw = fDefh = 1;
1422
1424 x = 2-pos.fX;
1425 y = fMargin;
1426 item = fFirst;
1427
1428 while (item) {
1429 xbranch = -1;
1430
1431 DrawItem(id, item, x, y, &xbranch, &width, &height);
1432
1433 width += pos.fX + x + fHspacing + fMargin;
1434
1435 if (width > fDefw) fDefw = width;
1436
1437 y += height + fVspacing;
1438 if (item->fFirstchild && item->IsOpen()) {
1439 y = DrawChildren(id, item->fFirstchild, x, y, xbranch);
1440 }
1441
1442 item = item->fNextsibling;
1443 }
1444
1445 fDefh = y + fMargin;
1446
1447 if ((old_width != fDefw) || (old_height != fDefh)) {
1448 fCanvas->Layout();
1449 }
1450}
1451
1452////////////////////////////////////////////////////////////////////////////////
1453/// Draw children of item in list tree.
1454
1457{
1459 Int_t xbranch;
1461
1462 x += fIndent + (Int_t)item->fParent->GetPicWidth();
1463 while (item) {
1464 xbranch = xroot;
1465
1466 DrawItem(id, item, x, y, &xbranch, &width, &height);
1467
1468 width += pos.fX + x + fHspacing + fMargin;
1469 if (width > fDefw) fDefw = width;
1470
1471 y += height + fVspacing;
1472 if ((item->fFirstchild) && (item->IsOpen())) {
1473 y = DrawChildren(id, item->fFirstchild, x, y, xbranch);
1474 }
1475
1476 item = item->fNextsibling;
1477 }
1478 return y;
1479}
1480
1481////////////////////////////////////////////////////////////////////////////////
1482/// Draw list tree item.
1483
1486{
1488 Int_t xpic2 = 0;
1489 UInt_t height;
1490 const TGPicture *pic1 = item->GetPicture();
1491 const TGPicture *pic2 = item->GetCheckBoxPicture();
1492
1493 // Compute the height of this line
1494 height = FontHeight();
1495
1496 xpic1 = x;
1497 xtext = x + fHspacing + (Int_t)item->GetPicWidth();
1498 if (pic2) {
1499 if (pic2->GetHeight() > height) {
1500 height = pic2->GetHeight();
1501 }
1502 if (pic1) xpic2 = xpic1 + pic1->GetWidth() + 1;
1503 else xpic2 = xpic1 + 1;
1504 xtext += pic2->GetWidth();
1505 }
1506 if (pic1) {
1507 if (pic1->GetHeight() > height) {
1508 ytext = y + (Int_t)((pic1->GetHeight() - height) >> 1);
1509 height = pic1->GetHeight();
1510 ypic1 = y;
1511 } else {
1512 ytext = y;
1513 ypic1 = y + (Int_t)((height - pic1->GetHeight()) >> 1);
1514 }
1515 xbranch = xpic1 + (Int_t)(pic1->GetWidth() >> 1);
1516 ybranch = ypic1 + (Int_t)pic1->GetHeight();
1517 yline = ypic1 + (Int_t)(pic1->GetHeight() >> 1);
1518 } else {
1519 ypic1 = ytext = y;
1520 xbranch = xpic1 + (Int_t)(item->GetPicWidth() >> 1);
1521 ybranch = ypic1 + (Int_t)(height >> 1);
1522 yline = ypic1 + (Int_t)(height >> 1);
1523 }
1524
1525 // height must be even, otherwise our dashed line wont appear properly
1526 //++height; height &= ~1;
1527
1528 // Save the basic graphics info for use by other functions
1529 item->fY = y;
1530 item->fXtext = xtext;
1531 item->fYtext = ytext;
1532 item->fHeight = height;
1533
1534 // projected coordinates
1537 Int_t yp = y - pos.fY;
1538 Int_t ylinep = yline - pos.fY;
1539 Int_t ybranchp = ybranch - pos.fY;
1540 Int_t ypicp = ypic1 - pos.fY;
1541
1542 if ((yp >= fExposeTop) && (yp <= (Int_t)dim.fHeight))
1543 {
1544 DrawItemName(id, item);
1545 if (*xroot >= 0) {
1546 xc = *xroot;
1547
1548 if (item->fNextsibling) {
1549 gVirtualX->DrawLine(id, fLineGC, xc, yp, xc, yp+height);
1550 } else {
1551 gVirtualX->DrawLine(id, fLineGC, xc, yp, xc, ylinep);
1552 }
1553
1554 TGListTreeItem *p = item->fParent;
1555 while (p) {
1556 xc -= (fIndent + (Int_t)item->GetPicWidth());
1557 if (p->fNextsibling) {
1558 gVirtualX->DrawLine(id, fLineGC, xc, yp, xc, yp+height);
1559 }
1560 p = p->fParent;
1561 }
1562 gVirtualX->DrawLine(id, fLineGC, *xroot, ylinep, xpic1, ylinep);
1563 DrawNode(id, item, *xroot, yline);
1564 }
1565 if (item->IsOpen() && item->fFirstchild) {
1566 gVirtualX->DrawLine(id, fLineGC, xbranch, ybranchp, xbranch,
1567 yp+height);
1568 }
1569 if (pic1)
1570 pic1->Draw(id, fDrawGC, xpic1, ypicp);
1571 if (pic2)
1572 pic2->Draw(id, fDrawGC, xpic2, ypicp);
1573 }
1574
1575 *xroot = xbranch;
1576 *retwidth = TextWidth(item->GetText()) + item->GetPicWidth();
1577 *retheight = height;
1578}
1579
1580////////////////////////////////////////////////////////////////////////////////
1581/// Draw a outline of color 'col' around an item.
1582
1584 Bool_t clear)
1585{
1588
1589 if (clear) {
1590 gVirtualX->SetForeground(fDrawGC, fCanvas->GetContainer()->GetBackground());
1591 //ClearViewPort(); // time consuming!!!
1592 }
1593 else
1594 gVirtualX->SetForeground(fDrawGC, col);
1595
1596#ifdef R__HAS_COCOA
1597 gVirtualX->DrawRectangle(id, fDrawGC, 1, item->fY - pos.fY, dim.fWidth-2, item->fHeight + 1);
1598#else
1599 gVirtualX->DrawRectangle(id, fDrawGC, 1, item->fYtext-pos.fY-2,
1600 dim.fWidth-3, FontHeight()+4);
1601#endif
1602 gVirtualX->SetForeground(fDrawGC, fgBlackPixel);
1603}
1604
1605////////////////////////////////////////////////////////////////////////////////
1606/// Draw active item with its active color.
1607
1609{
1610 UInt_t width;
1613
1614 width = dim.fWidth-2;
1615 gVirtualX->SetForeground(fDrawGC, item->GetActiveColor());
1616
1617#ifdef R__HAS_COCOA
1618 gVirtualX->FillRectangle(id, fDrawGC, 1, item->fY - pos.fY, width, item->fHeight + 1);
1619#else
1620 gVirtualX->FillRectangle(id, fDrawGC, 1, item->fYtext-pos.fY-1, width,
1621 FontHeight()+3);
1622#endif
1623 gVirtualX->SetForeground(fDrawGC, fgBlackPixel);
1624 gVirtualX->DrawString(id, fActiveGC, item->fXtext,
1625 item->fYtext - pos.fY + FontAscent(),
1626 item->GetText(), item->GetTextLength());
1627}
1628
1629////////////////////////////////////////////////////////////////////////////////
1630/// Draw name of list tree item.
1631
1633{
1636
1637 if (item->IsActive()) {
1638 DrawActive(id, item);
1639 }
1640 else { // if (!item->IsActive() && (item != fSelected)) {
1641 gVirtualX->FillRectangle(id, fHighlightGC, item->fXtext,
1642 item->fYtext-pos.fY, dim.fWidth-item->fXtext-2,
1643 FontHeight()+1);
1644 gVirtualX->DrawString(id, fDrawGC,
1645 item->fXtext, item->fYtext-pos.fY + FontAscent(),
1646 item->GetText(), item->GetTextLength());
1647 }
1648 if (item == fCurrent) {
1649 DrawOutline(id, item);
1650 }
1651
1652 if (fColorMode != 0 && item->HasColor()) {
1653 UInt_t width = TextWidth(item->GetText());
1654 gVirtualX->SetForeground(fColorGC, TColor::Number2Pixel(item->GetColor()));
1656 Int_t y = item->fYtext-pos.fY + FontAscent() + 2;
1657 gVirtualX->DrawLine(id, fColorGC, item->fXtext, y,
1658 item->fXtext + width, y);
1659 }
1660 if (fColorMode & kColorBox) {
1661 Int_t x = item->fXtext + width + 4;
1662 Int_t y = item->fYtext - pos.fY + 3;
1663 Int_t h = FontAscent() - 4;
1664 gVirtualX->FillRectangle(id, fColorGC, x, y, h, h);
1665 gVirtualX->DrawRectangle(id, fDrawGC, x, y, h, h);
1666 }
1667 }
1668}
1669
1670////////////////////////////////////////////////////////////////////////////////
1671/// Draw node (little + in box).
1672
1674{
1676 Int_t yp = y - pos.fY;
1677
1678 if (item->fFirstchild) {
1679 gVirtualX->DrawLine(id, fHighlightGC, x, yp-2, x, yp+2);
1680 gVirtualX->SetForeground(fHighlightGC, fgBlackPixel);
1681 gVirtualX->DrawLine(id, fHighlightGC, x-2, yp, x+2, yp);
1682 if (!item->IsOpen())
1683 gVirtualX->DrawLine(id, fHighlightGC, x, yp-2, x, yp+2);
1684 gVirtualX->SetForeground(fHighlightGC, fGrayPixel);
1685 gVirtualX->DrawLine(id, fHighlightGC, x-4, yp-4, x+4, yp-4);
1686 gVirtualX->DrawLine(id, fHighlightGC, x+4, yp-4, x+4, yp+4);
1687 gVirtualX->DrawLine(id, fHighlightGC, x-4, yp+4, x+4, yp+4);
1688 gVirtualX->DrawLine(id, fHighlightGC, x-4, yp-4, x-4, yp+4);
1689 gVirtualX->SetForeground(fHighlightGC, fgWhitePixel);
1690 }
1691}
1692
1693////////////////////////////////////////////////////////////////////////////////
1694/// Set tool tip text associated with this item. The delay is in
1695/// milliseconds (minimum 250). To remove tool tip call method with
1696/// delayms = 0. To change delayms you first have to call this method
1697/// with delayms=0.
1698
1700{
1701 if (delayms == 0) {
1702 delete fTip;
1703 fTip = 0;
1704 return;
1705 }
1706
1707 if (text && strlen(text)) {
1708 if (!fTip)
1709 fTip = new TGToolTip(fClient->GetDefaultRoot(), this, text, delayms);
1710 else
1711 fTip->SetText(text);
1712 fTip->SetPosition(x, y);
1713 fTip->Reset();
1714 }
1715}
1716
1717////////////////////////////////////////////////////////////////////////////////
1718/// This function removes the specified item from the linked list.
1719/// It does not do anything with the data contained in the item, though.
1720
1722{
1723 ClearViewPort();
1724
1725 // Disentangle from front (previous-sibling, parent's first child)
1726 if (item->fPrevsibling) {
1727 item->fPrevsibling->fNextsibling = item->fNextsibling;
1728 } else {
1729 if (item->fParent)
1730 item->fParent->fFirstchild = item->fNextsibling;
1731 else
1732 fFirst = item->fNextsibling;
1733 }
1734 // Disentangle from end (next-sibling, parent's last child)
1735 if (item->fNextsibling) {
1736 item->fNextsibling->fPrevsibling = item->fPrevsibling;
1737 } else {
1738 if (item->fParent)
1739 item->fParent->fLastchild = item->fPrevsibling;
1740 else
1741 fLast = item->fPrevsibling;
1742 }
1743}
1744
1745////////////////////////////////////////////////////////////////////////////////
1746/// Delete given item. Takes care of list-tree state members
1747/// fSelected, fCurrent and fBelowMouse.
1748
1750{
1751 if (fSelected == item) {
1752 fSelected = 0;
1753 }
1754 if (fCurrent == item) {
1755 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
1756 fCurrent = item->GetPrevSibling();
1757 if (! fCurrent) {
1758 fCurrent = item->GetNextSibling();
1759 if (! fCurrent)
1760 fCurrent = item->GetParent();
1761 }
1762 }
1763 if (fBelowMouse == item) {
1764 DrawOutline(fId, fBelowMouse, 0xffffff, kTRUE);
1765 fBelowMouse = 0;
1766 MouseOver(0);
1768 }
1769
1770 delete item;
1771}
1772
1773////////////////////////////////////////////////////////////////////////////////
1774/// Recursively delete all children of an item.
1775
1777{
1778 TGListTreeItem *child = item->fFirstchild;
1779
1780 while (child) {
1781 TGListTreeItem *next = child->fNextsibling;
1784 child = next;
1785 }
1786
1787 item->fFirstchild = item->fLastchild = 0;
1788}
1789
1790////////////////////////////////////////////////////////////////////////////////
1791/// Insert child in list.
1792
1794{
1795 TGListTreeItem *i;
1796
1797 item->fParent = parent;
1798 item->fNextsibling = item->fPrevsibling = 0;
1799
1800 if (parent) {
1801
1802 if (parent->fFirstchild) {
1803 if (parent->fLastchild) {
1804 i = parent->fLastchild;
1805 }
1806 else {
1807 i = parent->fFirstchild;
1808 while (i->fNextsibling) i = i->fNextsibling;
1809 }
1810 i->fNextsibling = item;
1811 item->fPrevsibling = i;
1812 } else {
1813 parent->fFirstchild = item;
1814 }
1815 parent->fLastchild = item;
1816
1817 } else { // if parent == 0, this is a top level entry
1818
1819 if (fFirst) {
1820 if (fLast) {
1821 i = fLast;
1822 }
1823 else {
1824 i = fFirst;
1825 while (i->fNextsibling) i = i->fNextsibling;
1826 }
1827 i->fNextsibling = item;
1828 item->fPrevsibling = i;
1829 } else {
1830 fFirst = item;
1831 }
1832 fLast = item;
1833 }
1834 if (item->HasCheckBox())
1836}
1837
1838////////////////////////////////////////////////////////////////////////////////
1839/// Insert a list of ALREADY LINKED children into another list
1840
1842{
1843 TGListTreeItem *next, *newnext;
1844
1845 //while (item) {
1846 // next = item->fNextsibling;
1847 // InsertChild(parent, item);
1848 // item = next;
1849 //}
1850 //return;
1851
1852 // Save the reference for the next item in the new list
1853 next = item->fNextsibling;
1854
1855 // Insert the first item in the new list into the existing list
1856 InsertChild(parent, item);
1857
1858 // The first item is inserted, with its prev and next siblings updated
1859 // to fit into the existing list. So, save the existing list reference
1860 newnext = item->fNextsibling;
1861
1862 // Now, mark the first item's next sibling to point back to the new list
1863 item->fNextsibling = next;
1864
1865 // Mark the parents of the new list to the new parent. The order of the
1866 // rest of the new list should be OK, and the second item should still
1867 // point to the first, even though the first was reparented.
1868 while (item->fNextsibling) {
1869 item->fParent = parent;
1870 item = item->fNextsibling;
1871 }
1872
1873 // Fit the end of the new list back into the existing list
1874 item->fNextsibling = newnext;
1875 if (newnext)
1876 newnext->fPrevsibling = item;
1877}
1878
1879////////////////////////////////////////////////////////////////////////////////
1880/// Search child item.
1881
1884{
1885 UInt_t height;
1886 const TGPicture *pic;
1887
1888 while (item) {
1889 // Select the pixmap to use
1890 pic = item->GetPicture();
1891
1892 // Compute the height of this line
1893 height = FontHeight();
1894 if (pic && pic->GetHeight() > height)
1895 height = pic->GetHeight();
1896
1897 if ((findy >= y) && (findy <= y + (Int_t)height)) {
1898 *finditem = item;
1899 return -1;
1900 }
1901
1902 y += (Int_t)height + fVspacing;
1903 if (item->fFirstchild && item->IsOpen()) {
1904 y = SearchChildren(item->fFirstchild, y, findy, finditem);
1905 if (*finditem) return -1;
1906 }
1907
1908 item = item->fNextsibling;
1909 }
1910
1911 return y;
1912}
1913
1914////////////////////////////////////////////////////////////////////////////////
1915/// Find item at postion findy.
1916
1918{
1919 Int_t y;
1920 UInt_t height;
1922 const TGPicture *pic;
1924
1925 y = fMargin - pos.fY;
1926 item = fFirst;
1927 finditem = 0;
1928 while (item && !finditem) {
1929 // Select the pixmap to use
1930 pic = item->GetPicture();
1931
1932 // Compute the height of this line
1933 height = FontHeight();
1934 if (pic && (pic->GetHeight() > height))
1935 height = pic->GetHeight();
1936
1937 if ((findy >= y) && (findy <= y + (Int_t)height))
1938 return item;
1939
1940 y += (Int_t)height + fVspacing;
1941 if ((item->fFirstchild) && (item->IsOpen())) {
1942 y = SearchChildren(item->fFirstchild, y, findy, &finditem);
1943 //if (finditem) return finditem;
1944 }
1945 item = item->fNextsibling;
1946 }
1947
1948 return finditem;
1949}
1950
1951//----- Public Functions
1952
1953////////////////////////////////////////////////////////////////////////////////
1954/// Add given item to list tree.
1955
1957{
1958 InsertChild(parent, item);
1959
1960 if ((parent == 0) || (parent && parent->IsOpen()))
1961 ClearViewPort();
1962}
1963
1964////////////////////////////////////////////////////////////////////////////////
1965/// Add item to list tree. Returns new item.
1966
1968 const TGPicture *open, const TGPicture *closed,
1970{
1972
1973 item = new TGListTreeItemStd(fClient, string, open, closed, checkbox);
1974 InsertChild(parent, item);
1975
1976 if ((parent == 0) || (parent && parent->IsOpen()))
1977 ClearViewPort();
1978 return item;
1979}
1980
1981////////////////////////////////////////////////////////////////////////////////
1982/// Add item to list tree. If item with same userData already exists
1983/// don't add it. Returns new item.
1984
1986 void *userData, const TGPicture *open,
1987 const TGPicture *closed,
1989{
1991 if (!item) {
1992 item = AddItem(parent, string, open, closed, checkbox);
1993 if (item) item->SetUserData(userData);
1994 }
1995
1996 return item;
1997}
1998
1999////////////////////////////////////////////////////////////////////////////////
2000/// Rename item in list tree.
2001
2003{
2004 if (item) {
2005 item->Rename(string);
2006 }
2007
2008 DoRedraw();
2009}
2010
2011////////////////////////////////////////////////////////////////////////////////
2012/// Delete item from list tree.
2013
2015{
2016 if (!fUserControlled)
2017 fCurrent = fBelowMouse = 0;
2018
2022
2023 fClient->NeedRedraw(this);
2024
2025 return 1;
2026}
2027
2028////////////////////////////////////////////////////////////////////////////////
2029/// Open item in list tree (i.e. show child items).
2030
2032{
2033 if (item) {
2034 item->SetOpen(kTRUE);
2035 DoRedraw(); // force layout
2037 }
2038}
2039
2040////////////////////////////////////////////////////////////////////////////////
2041/// Close item in list tree (i.e. hide child items).
2042
2044{
2045 if (item) {
2046 item->SetOpen(kFALSE);
2047 DoRedraw(); // force layout
2049 }
2050}
2051
2052////////////////////////////////////////////////////////////////////////////////
2053/// Delete item with fUserData == ptr. Search tree downwards starting
2054/// at item.
2055
2057{
2058 if (item && ptr) {
2059 if (item->GetUserData() == ptr) {
2061 } else {
2062 if (item->IsOpen() && item->fFirstchild) {
2063 RecursiveDeleteItem(item->fFirstchild, ptr);
2064 }
2065 RecursiveDeleteItem(item->fNextsibling, ptr);
2066 }
2067 }
2068 return 1;
2069}
2070
2071////////////////////////////////////////////////////////////////////////////////
2072/// Set tooltip text for this item. By default an item for which the
2073/// userData is a pointer to an TObject the TObject::GetTitle() will
2074/// be used to get the tip text.
2075
2077{
2078 if (item) {
2079 item->SetTipText(string);
2080 }
2081}
2082
2083////////////////////////////////////////////////////////////////////////////////
2084/// Delete children of item from list.
2085
2087{
2088 if (!fUserControlled)
2089 fCurrent = fBelowMouse = 0;
2090
2092
2093 DoRedraw();
2094
2095 return 1;
2096}
2097
2098////////////////////////////////////////////////////////////////////////////////
2099/// Make newparent the new parent of item.
2100
2102{
2103 // Remove the item from its old location.
2105
2106 // The item is now unattached. Reparent it.
2108
2109 DoRedraw();
2110
2111 return 1;
2112}
2113
2114////////////////////////////////////////////////////////////////////////////////
2115/// Make newparent the new parent of the children of item.
2116
2119{
2120 TGListTreeItem *first;
2121
2122 if (item->fFirstchild) {
2123 first = item->fFirstchild;
2124 item->fFirstchild = 0;
2125
2126 InsertChildren(newparent, first);
2127
2128 DoRedraw();
2129 return 1;
2130 }
2131 return 0;
2132}
2133
2134////////////////////////////////////////////////////////////////////////////////
2135
2136extern "C"
2137Int_t Compare(const void *item1, const void *item2)
2138{
2139 return strcmp((*((TGListTreeItem **) item1))->GetText(),
2140 (*((TGListTreeItem **) item2))->GetText());
2141}
2142
2143////////////////////////////////////////////////////////////////////////////////
2144/// Sort items starting with item.
2145
2147{
2148 TGListTreeItem *first, *parent, **list;
2149 size_t i, count;
2150
2151 // Get first child in list;
2152 while (item->fPrevsibling) item = item->fPrevsibling;
2153
2154 first = item;
2155 parent = first->fParent;
2156
2157 // Count the children
2158 count = 1;
2159 while (item->fNextsibling) item = item->fNextsibling, count++;
2160 if (count <= 1) return 1;
2161
2162 list = new TGListTreeItem* [count];
2163 list[0] = first;
2164 count = 1;
2165 while (first->fNextsibling) {
2166 list[count] = first->fNextsibling;
2167 count++;
2168 first = first->fNextsibling;
2169 }
2170
2171 ::qsort(list, count, sizeof(TGListTreeItem*), ::Compare);
2172
2173 list[0]->fPrevsibling = 0;
2174 for (i = 0; i < count; i++) {
2175 if (i < count - 1)
2176 list[i]->fNextsibling = list[i + 1];
2177 if (i > 0)
2178 list[i]->fPrevsibling = list[i - 1];
2179 }
2180 list[count - 1]->fNextsibling = 0;
2181 if (parent) {
2182 parent->fFirstchild = list[0];
2183 parent->fLastchild = list[count-1];
2184 }
2185 else {
2186 fFirst = list[0];
2187 fLast = list[count-1];
2188 }
2189
2190 delete [] list;
2191
2192 DoRedraw();
2193
2194 return 1;
2195}
2196
2197////////////////////////////////////////////////////////////////////////////////
2198/// Sort siblings of item.
2199
2204
2205////////////////////////////////////////////////////////////////////////////////
2206/// Sort children of item.
2207
2209{
2210 TGListTreeItem *first;
2211
2212 if (item) {
2213 first = item->fFirstchild;
2214 if (first) {
2215 SortSiblings(first);
2216 }
2217 } else {
2218 if (fFirst) {
2219 first = fFirst->fFirstchild;
2220 if (first) {
2221 SortSiblings(first);
2222 }
2223 }
2224 }
2225 DoRedraw();
2226 return 1;
2227}
2228
2229////////////////////////////////////////////////////////////////////////////////
2230/// Find sibling of item by name.
2231
2233{
2234 // Get first child in list
2235 if (item) {
2236 while (item->fPrevsibling) {
2237 item = item->fPrevsibling;
2238 }
2239
2240 while (item) {
2241 if (strcmp(item->GetText(), name) == 0) {
2242 return item;
2243 }
2244 item = item->fNextsibling;
2245 }
2246 return item;
2247 }
2248 return 0;
2249}
2250
2251////////////////////////////////////////////////////////////////////////////////
2252/// Find sibling of item by userData.
2253
2255{
2256 // Get first child in list
2257 if (item) {
2258 while (item->fPrevsibling) {
2259 item = item->fPrevsibling;
2260 }
2261
2262 while (item) {
2263 if (item->GetUserData() == userData) {
2264 return item;
2265 }
2266 item = item->fNextsibling;
2267 }
2268 return item;
2269 }
2270 return 0;
2271}
2272
2273////////////////////////////////////////////////////////////////////////////////
2274/// Find child of item by name.
2275
2277{
2278 // Get first child in list
2279 if (item && item->fFirstchild) {
2280 item = item->fFirstchild;
2281 } else if (!item && fFirst) {
2282 item = fFirst;
2283 } else {
2284 item = 0;
2285 }
2286
2287 while (item) {
2288 if (strcmp(item->GetText(), name) == 0) {
2289 return item;
2290 }
2291 item = item->fNextsibling;
2292 }
2293 return 0;
2294}
2295
2296////////////////////////////////////////////////////////////////////////////////
2297/// Find child of item by userData.
2298
2300{
2301 // Get first child in list
2302 if (item && item->fFirstchild) {
2303 item = item->fFirstchild;
2304 } else if (!item && fFirst) {
2305 item = fFirst;
2306 } else {
2307 item = 0;
2308 }
2309
2310 while (item) {
2311 if (item->GetUserData() == userData) {
2312 return item;
2313 }
2314 item = item->fNextsibling;
2315 }
2316 return 0;
2317}
2318
2319////////////////////////////////////////////////////////////////////////////////
2320/// Find item by pathname. Pathname is in the form of /xx/yy/zz. If zz
2321/// in path /xx/yy is found it returns item, 0 otherwise.
2322
2324{
2325 if (!path || !*path) return 0;
2326
2327 const char *p = path, *s;
2328 char dirname[1024];
2329 TGListTreeItem *item = 0;
2330 item = FindChildByName(item, "/");
2331 if (!gVirtualX->InheritsFrom("TGX11")) {
2332 // on Windows, use the current drive instead of root (/)
2333 TList *curvol = gSystem->GetVolumes("cur");
2334 if (curvol) {
2335 TNamed *drive = (TNamed *)curvol->At(0);
2336 item = FindChildByName(0, TString::Format("%s\\", drive->GetName()));
2337 delete curvol;
2338 }
2339 }
2342
2343 while (1) {
2344 while (*p && *p == '/') p++;
2345 if (!*p) break;
2346
2347 s = strchr(p, '/');
2348
2349 if (!s) {
2350 strlcpy(dirname, p, 1024);
2351 } else {
2352 strlcpy(dirname, p, (s-p)+1);
2353 }
2354
2356
2357 if (!diritem && dirname[0]) {
2358 fulldir += "/";
2359 fulldir += dirname;
2360
2361 if ((diritem=FindChildByName(0, fulldir.Data()))) {
2362 if (!s || !s[0]) return diritem;
2363 p = ++s;
2364 item = diritem;
2365 continue;
2366 }
2367 }
2368
2369 if (!s || !s[0]) return item;
2370 p = ++s;
2371 }
2372 return 0;
2373}
2374
2375////////////////////////////////////////////////////////////////////////////////
2376/// Highlight item.
2377
2384
2385////////////////////////////////////////////////////////////////////////////////
2386/// Un highlight items.
2387
2392
2393////////////////////////////////////////////////////////////////////////////////
2394/// Get pathname from item. Use depth to limit path name to last
2395/// depth levels. By default depth is not limited.
2396
2398{
2399 char tmppath[1024];
2400
2401 *path = '\0';
2402 while (item) {
2403 snprintf(tmppath, 1023, "/%s%s", item->GetText(), path);
2404 strlcpy(path, tmppath, 1024);
2405 item = item->fParent;
2406 if (--depth == 0 && item) {
2407 snprintf(tmppath, 1023, "...%s", path);
2408 strlcpy(path, tmppath, 1024);
2409 return;
2410 }
2411 }
2412}
2413
2414////////////////////////////////////////////////////////////////////////////////
2415/// Return gray draw color in use.
2416
2418{
2419 static Bool_t init = kFALSE;
2420 if (!init) {
2421 if (!gClient->GetColorByName("#808080", fgGrayPixel))
2423 init = kTRUE;
2424 }
2425 return fgGrayPixel;
2426}
2427
2428////////////////////////////////////////////////////////////////////////////////
2429/// Return default font structure in use.
2430
2432{
2433 if (!fgDefaultFont)
2434 fgDefaultFont = gClient->GetResourcePool()->GetIconFont();
2435 return fgDefaultFont->GetFontStruct();
2436}
2437
2438////////////////////////////////////////////////////////////////////////////////
2439/// Return default graphics context in use.
2440
2442{
2443 if (!fgActiveGC) {
2445
2448 gcv.fLineStyle = kLineSolid;
2449 gcv.fLineWidth = 0;
2450 gcv.fFillStyle = kFillSolid;
2451 gcv.fFont = fgDefaultFont->GetFontHandle();
2452 gcv.fBackground = fgDefaultSelectedBackground;
2453 const TGGC *selgc = gClient->GetResourcePool()->GetSelectedGC();
2454 if (selgc)
2455 gcv.fForeground = selgc->GetForeground();
2456 else
2457 gcv.fForeground = fgWhitePixel;
2458 fgActiveGC = gClient->GetGC(&gcv, kTRUE);
2459 }
2460 return *fgActiveGC;
2461}
2462
2463////////////////////////////////////////////////////////////////////////////////
2464/// Return default graphics context in use.
2465
2467{
2468 if (!fgDrawGC) {
2470
2473 gcv.fLineStyle = kLineSolid;
2474 gcv.fLineWidth = 0;
2475 gcv.fFillStyle = kFillSolid;
2476 gcv.fFont = fgDefaultFont->GetFontHandle();
2477 gcv.fBackground = fgWhitePixel;
2478 gcv.fForeground = fgBlackPixel;
2479
2480 fgDrawGC = gClient->GetGC(&gcv, kTRUE);
2481 }
2482 return *fgDrawGC;
2483}
2484
2485////////////////////////////////////////////////////////////////////////////////
2486/// Return graphics context in use for line drawing.
2487
2489{
2490 if (!fgLineGC) {
2492
2495 gcv.fLineStyle = kLineOnOffDash;
2496 gcv.fLineWidth = 0;
2497 gcv.fFillStyle = kFillSolid;
2498 gcv.fFont = fgDefaultFont->GetFontHandle();
2499 gcv.fBackground = fgWhitePixel;
2500 gcv.fForeground = GetGrayPixel();
2501
2502 fgLineGC = gClient->GetGC(&gcv, kTRUE);
2503 fgLineGC->SetDashOffset(0);
2504 fgLineGC->SetDashList("\x1\x1", 2);
2505 }
2506 return *fgLineGC;
2507}
2508
2509////////////////////////////////////////////////////////////////////////////////
2510/// Return graphics context for highlighted frame background.
2511
2513{
2514 if (!fgHighlightGC) {
2516
2519 gcv.fLineStyle = kLineSolid;
2520 gcv.fLineWidth = 0;
2521 gcv.fFillStyle = kFillSolid;
2522 gcv.fFont = fgDefaultFont->GetFontHandle();
2523 gcv.fBackground = fgDefaultSelectedBackground;
2524 gcv.fForeground = fgWhitePixel;
2525
2526 fgHighlightGC = gClient->GetGC(&gcv, kTRUE);
2527 }
2528 return *fgHighlightGC;
2529}
2530
2531////////////////////////////////////////////////////////////////////////////////
2532/// Return graphics context for highlighted frame background.
2533
2535{
2536 if (!fgColorGC) {
2538
2541 gcv.fLineStyle = kLineSolid;
2542 gcv.fLineWidth = 1;
2543 gcv.fFillStyle = kFillSolid;
2544 gcv.fBackground = fgDefaultSelectedBackground;
2545 gcv.fForeground = fgWhitePixel;
2546
2547 fgColorGC = gClient->GetGC(&gcv, kTRUE);
2548 }
2549 return *fgColorGC;
2550}
2551
2552////////////////////////////////////////////////////////////////////////////////
2553/// Returns the icon used by items in open state.
2554
2556{
2557 if (!fgOpenPic)
2558 fgOpenPic = gClient->GetPictureOrEmpty("ofolder_t.xpm");
2559 ((TGPicture *)fgOpenPic)->AddReference();
2560 return fgOpenPic;
2561}
2562
2563////////////////////////////////////////////////////////////////////////////////
2564/// Returns the icon used by items in closed state.
2565
2567{
2568 if (!fgClosedPic)
2569 fgClosedPic = gClient->GetPictureOrEmpty("folder_t.xpm");
2570 ((TGPicture *)fgClosedPic)->AddReference();
2571 return fgClosedPic;
2572}
2573
2574////////////////////////////////////////////////////////////////////////////////
2575/// Returns the icon used for checked checkbox.
2576
2578{
2579 if (!fgCheckedPic)
2580 fgCheckedPic = gClient->GetPictureOrEmpty("checked_t.xpm");
2581 ((TGPicture *)fgCheckedPic)->AddReference();
2582 return fgCheckedPic;
2583}
2584
2585////////////////////////////////////////////////////////////////////////////////
2586/// Returns the icon used for unchecked checkbox.
2587
2589{
2590 if (!fgUncheckedPic)
2591 fgUncheckedPic = gClient->GetPictureOrEmpty("unchecked_t.xpm");
2592 ((TGPicture *)fgUncheckedPic)->AddReference();
2593 return fgUncheckedPic;
2594}
2595
2596////////////////////////////////////////////////////////////////////////////////
2597/// Save a list tree widget as a C++ statements on output stream out.
2598
2599void TGListTree::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2600{
2601 // store options and color if differ from defaults
2603
2604 out << "\n // list tree\n";
2605 out << " TGListTree *" << GetName() << " = new TGListTree(";
2606
2607 if ((fParent->GetParent())->InheritsFrom(TGCanvas::Class()))
2608 out << GetCanvas()->GetName();
2609 else
2610 out << fParent->GetName() << "," << GetWidth() << "," << GetHeight();
2611 out << extra_args << ");\n";
2612
2613 if (option && strstr(option, "keep_names"))
2614 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
2615
2616 TGListTreeItem *current = GetFirstItem();
2617
2618 out << " \n";
2619
2620 while (current) {
2621 TString var_name = current->SaveTreeItem(out, GetName(), "nullptr");
2622 if (current->IsOpen())
2623 out << " " << GetName() << "->OpenItem(" << var_name << ");\n";
2624 else
2625 out << " " << GetName() << "->CloseItem(" << var_name << ");\n";
2626
2627 if (current == fSelected)
2628 out << " " << GetName() << "->SetSelected(" << var_name << ");\n";
2629
2630 if (current->fFirstchild)
2631 SaveChildren(out, var_name, current->fFirstchild);
2632
2633 current = current->fNextsibling;
2634 }
2635
2636 out << " \n";
2637}
2638
2639////////////////////////////////////////////////////////////////////////////////
2640/// Save child items as a C++ statements on output stream out.
2641
2642void TGListTree::SaveChildren(std::ostream &out, const char *parent_var_name, TGListTreeItem *item)
2643{
2644 while (item) {
2645 TString var_name = item->SaveTreeItem(out, GetName(), parent_var_name);
2646
2647 if (item == fSelected)
2648 out << " " << GetName() << "->SetSelected(" << var_name << ");\n";
2649
2650 if (item->fFirstchild)
2651 SaveChildren(out, var_name, item->fFirstchild);
2652
2653 item = item->fNextsibling;
2654 }
2655}
2656
2657////////////////////////////////////////////////////////////////////////////////
2658/// Save a list tree item attributes as a C++ statements on output stream.
2659
2660TString TGListTreeItemStd::SaveTreeItem(std::ostream &out, const char *tree_var_name, const char *parent_var_name)
2661{
2662 static const TGPicture *oldopen = nullptr, *oldclose = nullptr, *oldcheck = nullptr, *olduncheck = nullptr;
2663 static int item_cnt = 0;
2664
2665 if (!gROOT->ClassSaved(Class())) {
2666 oldopen = oldclose = oldcheck = olduncheck = nullptr;
2667 item_cnt = 0;
2668 out << " const TGPicture *pic_litem_open = nullptr, *pic_litem_close = nullptr, *pic_litem_check = nullptr, "
2669 "*pic_litem_uncheck = nullptr;\n";
2670 }
2671
2672 TString var_name = TString::Format("list_tree_item%d", item_cnt++);
2673
2674 if (fOpenPic && (oldopen != fOpenPic)) {
2675 oldopen = fOpenPic;
2678 out << " pic_litem_open = gClient->GetPicture(\"" << picname.ReplaceSpecialCppChars() << "\");\n";
2679 }
2680 if (fClosedPic && (oldclose != fClosedPic)) {
2684 out << " pic_litem_close = gClient->GetPicture(\"" << picname.ReplaceSpecialCppChars() << "\");\n";
2685 }
2686
2687 out << " TGListTreeItem *" << var_name << " = " << tree_var_name << "->AddItem(" << parent_var_name << ", \""
2688 << TString(GetText()).ReplaceSpecialCppChars() << "\", " << (fOpenPic ? "pic_litem_open" : "nullptr") << ", "
2689 << (fClosedPic ? "pic_litem_close" : "nullptr");
2690 if (HasCheckBox())
2691 out << ", kTRUE";
2692 out << ");\n";
2693
2694 if (HasCheckBox()) {
2695 out << " " << var_name << "->CheckItem();\n";
2696 if (fCheckedPic && oldcheck != fCheckedPic) {
2700 out << " pic_litem_check = gClient->GetPicture(\"" << picname.ReplaceSpecialCppChars() << "\");\n";
2701 }
2706 out << " pic_litem_uncheck = gClient->GetPicture(\"" << picname.ReplaceSpecialCppChars() << "\");\n";
2707 }
2708 out << " " << var_name << "->SetCheckBoxPictures(" << (fCheckedPic ? "pic_litem_check" : "nullptr") << ", "
2709 << (fUncheckedPic ? "pic_litem_uncheck" : "nullptr") << ");\n";
2710 }
2711 if (fHasColor)
2712 out << " " << var_name << "->SetColor(" << fColor << ");\n";
2713
2714 if (fTipText.Length() > 0)
2715 out << " " << var_name << "->SetTipText(\"" << TString(GetTipText()).ReplaceSpecialCppChars() << "\");\n";
2716
2717 return var_name;
2718}
2719
2720////////////////////////////////////////////////////////////////////////////////
2721/// Set check button state for the node 'item'.
2722
2724{
2725 item->CheckItem(check);
2726}
2727
2728////////////////////////////////////////////////////////////////////////////////
2729/// Set check button state for the node 'item'.
2730
2732{
2733 item->SetCheckBox(on);
2734}
2735
2736////////////////////////////////////////////////////////////////////////////////
2737/// Toggle check button state of the node 'item'.
2738
2740{
2741 item->Toggle();
2742}
2743
2744////////////////////////////////////////////////////////////////////////////////
2745/// Update the state of the node 'item' according to the children states.
2746
2748{
2749 if (fAutoCheckBoxPic == kFALSE) return;
2750
2751 const TGPicture *pic1 = nullptr, *pic2 = nullptr;
2752 TGListTreeItem *parent;
2753 TGListTreeItem *current;
2754 current = item->GetFirstChild();
2755 parent = current ? current : item;
2756 // recursively check parent/children status
2757 while (parent && parent->HasCheckBox()) {
2758 if ((!parent->IsChecked() && parent->HasCheckedChild(kTRUE)) ||
2759 (parent->IsChecked() && parent->HasUnCheckedChild(kTRUE))) {
2760 pic1 = fClient->GetPicture("checked_dis_t.xpm");
2761 pic2 = fClient->GetPicture("unchecked_dis_t.xpm");
2762 }
2763 else {
2764 pic1 = fClient->GetPicture("checked_t.xpm");
2765 pic2 = fClient->GetPicture("unchecked_t.xpm");
2766 }
2767 parent->SetCheckBoxPictures(pic1, pic2);
2770 parent = parent->GetParent();
2771 if (parent && fCheckMode == kRecursive) {
2772 pic1 = fClient->GetPicture("checked_t.xpm");
2773 pic2 = fClient->GetPicture("unchecked_t.xpm");
2774 if (!parent->IsChecked() && parent->GetFirstChild() &&
2775 !parent->GetFirstChild()->HasUnCheckedChild()) {
2776 parent->SetCheckBoxPictures(pic1, pic2);
2777 parent->CheckItem(kTRUE);
2778 }
2779 else if (parent->IsChecked() && parent->GetFirstChild() &&
2780 !parent->GetFirstChild()->HasCheckedChild()) {
2781 parent->SetCheckBoxPictures(pic1, pic2);
2782 parent->CheckItem(kFALSE);
2783 }
2786 }
2787 }
2788 if (redraw) {
2789 ClearViewPort();
2790 }
2791}
2792
2793////////////////////////////////////////////////////////////////////////////////
2794/// Find item with fUserData == ptr. Search tree downwards starting
2795/// at item.
2796
2798{
2800 if (item && ptr) {
2801 if (item->GetUserData() == ptr)
2802 return item;
2803 else {
2804 if (item->fFirstchild) {
2805 fitem = FindItemByObj(item->fFirstchild, ptr);
2806 if (fitem) return fitem;
2807 }
2808 return FindItemByObj(item->fNextsibling, ptr);
2809 }
2810 }
2811 return 0;
2812}
2813
2814////////////////////////////////////////////////////////////////////////////////
2815/// Add all checked list tree items of this list tree into
2816/// the list 'checked'. This list is not adopted and must
2817/// be deleted by the user later.
2818
2820{
2821 if (!checked || !fFirst) return;
2822 TGListTreeItem *current = fFirst;
2823 if (current->IsChecked()) {
2824 checked->Add(new TObjString(current->GetText()));
2825 }
2826 while(current) {
2827 if (current->GetFirstChild())
2828 GetCheckedChildren(checked, current->GetFirstChild());
2829 current = current->GetNextSibling();
2830 }
2831}
2832
2833////////////////////////////////////////////////////////////////////////////////
2834/// Add all child items of 'item' into the list 'checked'.
2835
2837{
2838 if (!checked || !item) return;
2839
2840 while (item) {
2841 if (item->IsChecked()) {
2842 checked->Add(new TObjString(item->GetText()));
2843 }
2844 if (item->GetFirstChild()) {
2845 GetCheckedChildren(checked, item->GetFirstChild());
2846 }
2847 item = item->GetNextSibling();
2848 }
2849}
2850
2851////////////////////////////////////////////////////////////////////////////////
2852/// Check all child items of 'item' and 'item' itself according
2853/// to the state value: kTRUE means check all, kFALSE - uncheck all.
2854
2856{
2857 if (item)
2858 item->CheckAllChildren(state);
2859}
2860
Handle_t Atom_t
WM token.
Definition GuiTypes.h:38
@ kGKeyPress
Definition GuiTypes.h:61
@ kButtonRelease
Definition GuiTypes.h:61
@ kButtonPress
Definition GuiTypes.h:61
@ kLeaveNotify
Definition GuiTypes.h:62
const Mask_t kGCBackground
Definition GuiTypes.h:290
const Mask_t kGCForeground
Definition GuiTypes.h:289
const Mask_t kGCLineStyle
Definition GuiTypes.h:292
const Mask_t kGCLineWidth
Definition GuiTypes.h:291
@ kHand
Definition GuiTypes.h:375
@ kPointer
Definition GuiTypes.h:376
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:31
const Mask_t kButtonPressMask
Definition GuiTypes.h:162
const Mask_t kGCFillStyle
Definition GuiTypes.h:295
const Mask_t kAnyModifier
Definition GuiTypes.h:211
const Mask_t kKeyPressMask
Definition GuiTypes.h:160
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:39
const Mask_t kGCFont
Definition GuiTypes.h:301
const Mask_t kPointerMotionMask
Definition GuiTypes.h:164
const Mask_t kKeyShiftMask
Definition GuiTypes.h:196
@ kSunkenFrame
Definition GuiTypes.h:384
const Handle_t kNone
Definition GuiTypes.h:89
const Mask_t kKeyControlMask
Definition GuiTypes.h:198
const Mask_t kLeaveWindowMask
Definition GuiTypes.h:169
@ kFillSolid
Definition GuiTypes.h:52
@ kLineSolid
Definition GuiTypes.h:49
@ kLineOnOffDash
Definition GuiTypes.h:49
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:163
const Mask_t kGCGraphicsExposures
Definition GuiTypes.h:303
const Mask_t kEnterWindowMask
Definition GuiTypes.h:168
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
@ kButton4
Definition GuiTypes.h:216
@ kButton5
Definition GuiTypes.h:216
@ kButton1
Definition GuiTypes.h:215
@ kAnyButton
Definition GuiTypes.h:215
ULongptr_t Handle_t
Generic resource handle.
Definition GuiTypes.h:26
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:40
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:148
#define gROOT
Definition TROOT.h:417
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2563
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
#define gVirtualX
Definition TVirtualX.h:375
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:250
GContext_t fColorGC
drawing context for main item color
Definition TGListTree.h:254
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:222
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:232
static const TGPicture * GetUncheckedPic()
Returns the icon used for unchecked checkbox.
void Clicked(TGFrame *, Int_t) override
Emit Clicked() signal.
Definition TGListTree.h:306
void RemoveReference(TGListTreeItem *item)
This function removes the specified item from the linked list.
UInt_t fDefw
default list width
Definition TGListTree.h:235
static Pixel_t fgGrayPixel
Definition TGListTree.h:256
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:253
static const TGPicture * GetClosedPic()
Returns the icon used by items in closed state.
static TGGC * fgLineGC
Definition TGListTree.h:260
void UnselectAll(Bool_t draw)
Unselect all items.
Bool_t fDisableOpen
disable branch opening on double-clicks
Definition TGListTree.h:247
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:231
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:258
GContext_t fHighlightGC
highlighted icon drawing context
Definition TGListTree.h:233
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:310
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:224
Int_t FontHeight()
Returns height of currently used font.
void ReturnPressed(TGFrame *) override
Signal emitted when Return/Enter key pressed.
Definition TGListTree.h:305
TGListTreeItem * fLast
pointer to last item in list
Definition TGListTree.h:221
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:238
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:261
static const TGPicture * GetCheckedPic()
Returns the icon used for checked checkbox.
TDNDData fDNDData
Drag and Drop data.
Definition TGListTree.h:242
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:300
virtual void DrawActive(Handle_t id, TGListTreeItem *item)
Draw active item with its active color.
Pixel_t fGrayPixel
gray draw color
Definition TGListTree.h:229
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:262
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:244
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:240
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:225
static const TGPicture * fgClosedPic
icon for closed item
Definition TGListTree.h:264
Int_t DeleteItem(TGListTreeItem *item)
Delete item from list tree.
static const TGPicture * fgUncheckedPic
icon for unchecked item
Definition TGListTree.h:266
Int_t fMargin
number of pixels margin from left side
Definition TGListTree.h:228
static const TGGC & GetHighlightGC()
Return graphics context for highlighted frame background.
UInt_t fDefh
default list height
Definition TGListTree.h:236
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:308
static const TGPicture * fgCheckedPic
icon for checked item
Definition TGListTree.h:265
void End(Bool_t select=kFALSE) override
Move content to the bottom.
TGListTreeItem * GetFirstItem() const
Definition TGListTree.h:391
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:249
TGListTree(const TGListTree &)=delete
Int_t SortChildren(TGListTreeItem *item)
Sort children of item.
static const TGPicture * fgOpenPic
icon for open item
Definition TGListTree.h:263
EColorMarkupMode fColorMode
if/how to render item's main color
Definition TGListTree.h:252
Atom_t * fDNDTypeList
handles DND types
Definition TGListTree.h:243
static TGGC * fgDrawGC
Definition TGListTree.h:259
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:246
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:220
void AdjustPosition() override
Move content to position of highlighted/activated frame.
Definition TGListTree.h:365
TBufferFile * fBuf
buffer used for Drag and Drop
Definition TGListTree.h:241
Bool_t HandleDNDDrop(TDNDData *data) override
Handle drop events.
TGToolTip * fTip
tooltip shown when moving over list items
Definition TGListTree.h:239
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:248
TGListTreeItem * fCurrent
pointer to current item in list
Definition TGListTree.h:223
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:237
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:226
FontStruct_t fFont
font used to draw item text
Definition TGListTree.h:234
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:227
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:245
TGListTreeItem * FindSiblingByData(TGListTreeItem *item, void *userData)
Find sibling of item by userData.
static const TGFont * fgDefaultFont
Definition TGListTree.h:257
GContext_t fActiveGC
activated (selected) drawing context
Definition TGListTree.h:230
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:42
virtual const char * GetTitle() const
Returns title of object.
Definition TObject.cxx:504
virtual TClass * IsA() const
Definition TObject.h:248
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:1289
virtual TList * GetVolumes(Option_t *) const
Definition TSystem.h:475
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1077
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:885
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Event structure.
Definition GuiTypes.h:175
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:176
Int_t fY
pointer x, y coordinates in event window
Definition GuiTypes.h:179
Int_t fXRoot
Definition GuiTypes.h:180
UInt_t fState
key or button mask
Definition GuiTypes.h:182
Int_t fYRoot
coordinates relative to root
Definition GuiTypes.h:180
Int_t fX
Definition GuiTypes.h:179
Time_t fTime
time event event occurred in ms
Definition GuiTypes.h:178
UInt_t fCode
key or button code
Definition GuiTypes.h:181
Graphics context structure.
Definition GuiTypes.h:225
th1 Draw()
TMarker m
Definition textangle.C:8