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