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