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 
27 A list tree is a widget that can contain a number of items
28 arranged in a tree structure. The items are represented by small
29 folder icons that can be either open or closed.
30 
31 The TGListTree is user callable. The TGListTreeItem is a service
32 class of the list tree.
33 
34 A list tree can generate the following events:
35  - kC_LISTTREE, kCT_ITEMCLICK, which button, location (y<<16|x).
36  - kC_LISTTREE, kCT_ITEMDBLCLICK, which button, location (y<<16|x).
37 
38 */
39 
40 
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 
67 const TGFont *TGListTree::fgDefaultFont = nullptr;
68 TGGC *TGListTree::fgActiveGC = nullptr;
69 TGGC *TGListTree::fgDrawGC = nullptr;
70 TGGC *TGListTree::fgLineGC = nullptr;
72 TGGC *TGListTree::fgColorGC = nullptr;
73 const TGPicture *TGListTree::fgOpenPic = nullptr;
74 const TGPicture *TGListTree::fgClosedPic = nullptr;
75 const TGPicture *TGListTree::fgCheckedPic = nullptr;
76 const TGPicture *TGListTree::fgUncheckedPic = 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 
144  fOwnsData = kFALSE;
145  fUserData = 0;
146 
147  fHasColor = kFALSE;
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  }
250  CheckChildren(GetFirstChild(), state);
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 
314 void 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;
352  fAutoTips = kFALSE;
355  fBdown = kFALSE;
359  fDropItem = 0;
360  fLastEventState = 0;
361 
364 
365  fActiveGC = GetActiveGC()();
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;
381  fDNDData.fDataLength = 0;
382  fDNDData.fDataType = 0;
383  fBuf = 0;
384 
388 
389  gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
391  kNone, kNone);
392 
395  SetWindowName();
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;
415  fAutoTips = kFALSE;
418  fBdown = kFALSE;
422  fDropItem = 0;
423  fLastEventState = 0;
424 
427 
428  fActiveGC = GetActiveGC()();
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;
444  fDNDData.fDataLength = 0;
445  fDNDData.fDataType = 0;
446  fBuf = 0;
447 
451 
452  gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
454  kNone, kNone);
455 
458  SetWindowName();
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 {
558  ClearViewPort();
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());
626  ClearViewPort();
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;
647  ClearViewPort();
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) {
683  ClearViewPort();
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  }
725  ClearViewPort();
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;
809  TGPosition pos = GetPagePosition();
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()) {
843  if (!fBuf) fBuf = new TBufferFile(TBuffer::kWrite);
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());
862  fDNDData.fData = fBuf->Buffer();
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
967  ClearViewPort();
968  item->SetOpen(!item->IsOpen());
969  DoubleClicked(item, 1);
970  } else {
971  // treat 'Enter' and 'Return' as a click
974  ClearViewPort();
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);
1092  SendMessage(fMsgWindow, MK_MSG(kC_LISTTREE, kCT_KEY), keysym, mask);
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 
1191 void TGListTree::Home(Bool_t /*select*/)
1192 {
1193  if (fCanvas) fCanvas->SetVsbPosition(0);
1194 }
1195 
1196 ////////////////////////////////////////////////////////////////////////////////
1197 /// Move content to the bottom.
1198 
1199 void TGListTree::End(Bool_t /*select*/)
1200 {
1202 }
1203 
1204 ////////////////////////////////////////////////////////////////////////////////
1205 /// Move content one page up.
1206 
1207 void TGListTree::PageUp(Bool_t /*select*/)
1208 {
1209  if (!fCanvas) return;
1210 
1211  TGDimension dim = GetPageDimension();
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 
1226  TGDimension dim = GetPageDimension();
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 
1236 void TGListTree::LineUp(Bool_t /*select*/)
1237 {
1238  Int_t height = 0;
1239  if (!fCurrent) return;
1240 
1241  TGPosition pos = GetPagePosition();
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 
1267  TGDimension dim = GetPageDimension();
1268  TGPosition pos = GetPagePosition();
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()) {
1316  v = TMath::Max(0,y-(Int_t)fViewPort->GetHeight()/2);
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 {
1352  ClearHighlighted();
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 
1407 void 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 
1421  TGPosition pos = GetPagePosition();
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;
1458  TGPosition pos = GetPagePosition();
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
1536  TGPosition pos = GetPagePosition();
1537  TGDimension dim = GetPageDimension();
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 {
1587  TGPosition pos = GetPagePosition();
1588  TGDimension dim = GetPageDimension();
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;
1612  TGPosition pos = GetPagePosition();
1613  TGDimension dim = GetPageDimension();
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 {
1635  TGPosition pos = GetPagePosition();
1636  TGDimension dim = GetPageDimension();
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()));
1656  if (fColorMode & kColorUnderline) {
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 {
1676  TGPosition pos = GetPagePosition();
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 
1700 void TGListTree::SetToolTipText(const char *text, Int_t x, Int_t y, Long_t delayms)
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;
1924  TGPosition pos = GetPagePosition();
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 
2003 void 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  }
2066  RecursiveDeleteItem(item->fNextsibling, ptr);
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 
2077 void 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 
2137 extern "C"
2138 Int_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
2458  gcv.fForeground = fgWhitePixel;
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;
2478  gcv.fBackground = fgWhitePixel;
2479  gcv.fForeground = fgBlackPixel;
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 
2496  gcv.fLineStyle = kLineOnOffDash;
2497  gcv.fLineWidth = 0;
2498  gcv.fFillStyle = kFillSolid;
2500  gcv.fBackground = fgWhitePixel;
2501  gcv.fForeground = GetGrayPixel();
2502 
2503  fgLineGC = gClient->GetGC(&gcv, kTRUE);
2504  fgLineGC->SetDashOffset(0);
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;
2525  gcv.fForeground = fgWhitePixel;
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;
2546  gcv.fForeground = fgWhitePixel;
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 
2600 void 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 
2661 void 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 
2678 void 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;
2703  TString picname = gSystem->UnixPathName(fOpenPic->GetName());
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 
TGWindow::SetWindowName
virtual void SetWindowName(const char *name=0)
Set window name.
Definition: TGWindow.cxx:129
TGListTree::HighlightChildren
void HighlightChildren(TGListTreeItem *item, Bool_t state, Bool_t draw)
Highlight item children.
Definition: TGListTree.cxx:543
TGListTree::SortChildren
Int_t SortChildren(TGListTreeItem *item)
Sort children of item.
Definition: TGListTree.cxx:2209
kKey_Down
@ kKey_Down
Definition: KeySymbols.h:43
c
#define c(i)
Definition: RSha256.hxx:101
TGListTree::kSimple
@ kSimple
Definition: TGListTree.h:205
TGListTree::InsertChild
void InsertChild(TGListTreeItem *parent, TGListTreeItem *item)
Insert child in list.
Definition: TGListTree.cxx:1794
Event_t::fType
EGEventType fType
of event (see EGEventType)
Definition: GuiTypes.h:175
TGClient::GetDefaultRoot
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition: TGClient.cxx:236
m
auto * m
Definition: textangle.C:8
n
const Int_t n
Definition: legend1.C:16
TGListTree::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a list tree widget as a C++ statements on output stream out.
Definition: TGListTree.cxx:2600
Event_t::fState
UInt_t fState
key or button mask
Definition: GuiTypes.h:181
TGListTreeItemStd::fOpenPic
const TGPicture * fOpenPic
icon for open state
Definition: TGListTree.h:135
TGContainer::DoRedraw
virtual void DoRedraw()
Redraw content of container in the viewport region.
Definition: TGCanvas.cxx:800
TGFrame::GetHeight
UInt_t GetHeight() const
Definition: TGFrame.h:225
TGListTree::FindSiblingByData
TGListTreeItem * FindSiblingByData(TGListTreeItem *item, void *userData)
Find sibling of item by userData.
Definition: TGListTree.cxx:2255
TGListTreeItemStd::fUncheckedPic
const TGPicture * fUncheckedPic
icon for unchecked item
Definition: TGListTree.h:138
FontMetrics_t
Definition: TGFont.h:52
first
Definition: first.py:1
TGListTree::HandleKey
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
Event_t::fY
Int_t fY
pointer x, y coordinates in event window
Definition: GuiTypes.h:178
Event_t::fX
Int_t fX
Definition: GuiTypes.h:178
TGWindow
ROOT GUI Window base class.
Definition: TGWindow.h:23
TBufferIO::WriteObject
void WriteObject(const TObject *obj, Bool_t cacheReuse=kTRUE) override
Write object to I/O buffer.
Definition: TBufferIO.cxx:530
TGListTree::RemoveReference
void RemoveReference(TGListTreeItem *item)
This function removes the specified item from the linked list.
Definition: TGListTree.cxx:1722
TGListTree::FindChildByName
TGListTreeItem * FindChildByName(TGListTreeItem *item, const char *name)
Find child of item by name.
Definition: TGListTree.cxx:2277
TGPosition::fY
Int_t fY
y position
Definition: TGDimension.h:39
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
Pixmap_t
Handle_t Pixmap_t
Pixmap handle.
Definition: GuiTypes.h:30
TGListTreeItem::SetCheckBox
virtual void SetCheckBox(Bool_t=kTRUE)
Definition: TGListTree.h:88
TGListTree::fActiveGC
GContext_t fActiveGC
activated (selected) drawing context
Definition: TGListTree.h:220
TGListTreeItem::GetTipText
virtual const char * GetTipText() const =0
TGFrame::fgBlackPixel
static Pixel_t fgBlackPixel
Definition: TGFrame.h:104
TGListTree::fHighlightGC
GContext_t fHighlightGC
highlighted icon drawing context
Definition: TGListTree.h:223
TGListTree::kColorUnderline
@ kColorUnderline
Definition: TGListTree.h:201
snprintf
#define snprintf
Definition: civetweb.c:1540
TGListTree::InsertChildren
void InsertChildren(TGListTreeItem *parent, TGListTreeItem *item)
Insert a list of ALREADY LINKED children into another list.
Definition: TGListTree.cxx:1842
TDNDData::fDataLength
Int_t fDataLength
Length of data.
Definition: TGDNDManager.h:77
TGContainer::fCanvas
TGCanvas * fCanvas
pointer to canvas
Definition: TGCanvas.h:41
kC_LISTTREE
@ kC_LISTTREE
Definition: WidgetMessageTypes.h:65
TGListTree::~TGListTree
virtual ~TGListTree()
Delete list tree widget.
Definition: TGListTree.cxx:472
TGListTreeItemStd::HasCheckedChild
virtual Bool_t HasCheckedChild(Bool_t first=kFALSE)
Add all child items of 'item' into the list 'checked'.
Definition: TGListTree.cxx:178
TGListTree::fIndent
Int_t fIndent
number of pixels indentation
Definition: TGListTree.h:217
TGListTree::UpdateChecked
virtual void UpdateChecked(TGListTreeItem *item, Bool_t redraw=kFALSE)
Update the state of the node 'item' according to the children states.
Definition: TGListTree.cxx:2783
Warning
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition: TError.cxx:231
TGPicture
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition: TGPicture.h:25
TGListTreeItem::GetCheckBoxPicture
virtual const TGPicture * GetCheckBoxPicture() const =0
TGListTreeItem::GetPicture
virtual const TGPicture * GetPicture() const =0
kAnyModifier
const Mask_t kAnyModifier
Definition: GuiTypes.h:210
TGListTree::GetLineGC
static const TGGC & GetLineGC()
Return graphics context in use for line drawing.
Definition: TGListTree.cxx:2489
TGGC::GetForeground
Pixel_t GetForeground() const
Definition: TGGC.h:73
TGDimension
Definition: TGDimension.h:18
TGListTreeItem::fNextsibling
TGListTreeItem * fNextsibling
pointer to next sibling
Definition: TGListTree.h:40
TGListTree::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event.
Definition: TGListTree.cxx:806
TGListTreeItem::GetPicWidth
virtual UInt_t GetPicWidth() const
Return width of item's icon.
Definition: TGListTree.cxx:102
TGListTree::DrawItemName
void DrawItemName(Handle_t id, TGListTreeItem *item)
Draw name of list tree item.
Definition: TGListTree.cxx:1633
Option_t
const char Option_t
Definition: RtypesCore.h:66
TGListTreeItemStd::CheckAllChildren
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
TMath::Max
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
TGPicture::GetWidth
UInt_t GetWidth() const
Definition: TGPicture.h:52
kLeaveNotify
@ kLeaveNotify
Definition: GuiTypes.h:61
kPointerMotionMask
const Mask_t kPointerMotionMask
Definition: GuiTypes.h:163
Compare
Int_t Compare(const void *item1, const void *item2)
Definition: TGListTree.cxx:2138
kLineSolid
@ kLineSolid
Definition: GuiTypes.h:48
TGListTree::PDeleteChildren
void PDeleteChildren(TGListTreeItem *item)
Recursively delete all children of an item.
Definition: TGListTree.cxx:1777
kKey_F3
@ kKey_F3
Definition: KeySymbols.h:59
TGListTreeItemStd::fActive
Bool_t fActive
true if item is active
Definition: TGListTree.h:129
TObject::Compare
virtual Int_t Compare(const TObject *obj) const
Compare abstract method.
Definition: TObject.cxx:161
TGToolTip::SetPosition
void SetPosition(Int_t x, Int_t y)
Set popup position within specified frame (as specified in the ctor).
Definition: TGToolTip.cxx:409
gVirtualX
#define gVirtualX
Definition: TVirtualX.h:338
kAnyButton
@ kAnyButton
Definition: GuiTypes.h:214
TString::Data
const char * Data() const
Definition: TString.h:369
kKey_Up
@ kKey_Up
Definition: KeySymbols.h:41
TGListTree::GetActiveGC
static const TGGC & GetActiveGC()
Return default graphics context in use.
Definition: TGListTree.cxx:2442
Pixel_t
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
TGListTree::FontAscent
Int_t FontAscent()
Returns ascent of currently used font.
Definition: TGListTree.cxx:503
TGListTree::fLastEventState
UInt_t fLastEventState
modifier state of the last keyboard event
Definition: TGListTree.h:240
TGListTree::DrawOutline
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.
Definition: TGListTree.cxx:1584
TGListTreeItem::GetPrevSibling
TGListTreeItem * GetPrevSibling() const
Definition: TGListTree.h:61
TGListTree::SearchChildren
Int_t SearchChildren(TGListTreeItem *item, Int_t y, Int_t findy, TGListTreeItem **finditem)
Search child item.
Definition: TGListTree.cxx:1883
TGListTree::ClearHighlighted
void ClearHighlighted()
Un highlight items.
Definition: TGListTree.cxx:2389
TGListTree::fgActiveGC
static TGGC * fgActiveGC
Definition: TGListTree.h:248
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TGListTree::DrawChildren
Int_t DrawChildren(Handle_t id, TGListTreeItem *item, Int_t x, Int_t y, Int_t xroot)
Draw children of item in list tree.
Definition: TGListTree.cxx:1453
EKeySym
EKeySym
Definition: KeySymbols.h:25
TGTextEditDialogs.h
TGDNDManager::StartDrag
Bool_t StartDrag(TGFrame *src, Int_t x_root, Int_t y_root, Window_t grabWin=kNone)
Start dragging.
Definition: TGDNDManager.cxx:904
TGListTreeItemStd::SetPictures
virtual void SetPictures(const TGPicture *opened, const TGPicture *closed)
Change list tree item icons.
Definition: TGListTree.cxx:314
TObjString.h
TGPicture.h
TGListTree::fDrawGC
GContext_t fDrawGC
icon drawing context
Definition: TGListTree.h:221
TGListTree::Reparent
Int_t Reparent(TGListTreeItem *item, TGListTreeItem *newparent)
Make newparent the new parent of item.
Definition: TGListTree.cxx:2102
TGListTree::DrawItem
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.
Definition: TGListTree.cxx:1482
TGListTree::Sort
Int_t Sort(TGListTreeItem *item)
Sort items starting with item.
Definition: TGListTree.cxx:2147
TGCanvas::GetContainer
TGFrame * GetContainer() const
Definition: TGCanvas.h:216
TGMsgBox
Definition: TGMsgBox.h:52
TGListTree::fDefw
UInt_t fDefw
default list width
Definition: TGListTree.h:225
FontStruct_t
Handle_t FontStruct_t
Pointer to font structure.
Definition: GuiTypes.h:39
r
ROOT::R::TRInterface & r
Definition: Object.C:4
TGListTree::fColorGC
GContext_t fColorGC
drawing context for main item color
Definition: TGListTree.h:244
TGListTree::GetGrayPixel
static Pixel_t GetGrayPixel()
Return gray draw color in use.
Definition: TGListTree.cxx:2418
TGListTree::fDNDTypeList
Atom_t * fDNDTypeList
handles DND types
Definition: TGListTree.h:233
TGListTree::ReturnPressed
void ReturnPressed(TGFrame *)
Signal emitted when Return/Enter key pressed.
Definition: TGListTree.h:295
TGListTree::HighlightItem
void HighlightItem(TGListTreeItem *item)
Highlight item.
Definition: TGListTree.cxx:2379
TGListTree::FindChildByData
TGListTreeItem * FindChildByData(TGListTreeItem *item, void *userData)
Find child of item by userData.
Definition: TGListTree.cxx:2300
TGSearchType::fBuffer
char * fBuffer
Definition: TGTextEditDialogs.h:23
kButton4
@ kButton4
Definition: GuiTypes.h:215
GCValues_t
Graphics context structure.
Definition: GuiTypes.h:224
TGListTree::Home
void Home(Bool_t select=kFALSE)
Move content to the top.
Definition: TGListTree.cxx:1191
TGWindow::kEditDisable
@ kEditDisable
disable edit of this window
Definition: TGWindow.h:50
TGListTreeItem::GetText
virtual const char * GetText() const =0
TGListTree::fCheckMode
ECheckMode fCheckMode
how to propagate check properties through the tree
Definition: TGListTree.h:243
TGListTreeItemStd::fText
TString fText
item text
Definition: TGListTree.h:133
width
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
TGListTreeItemStd::fUserData
void * fUserData
pointer to user data structure
Definition: TGListTree.h:139
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:162
kKey_F
@ kKey_F
Definition: KeySymbols.h:131
kFillSolid
@ kFillSolid
Definition: GuiTypes.h:51
Int_t
int Int_t
Definition: RtypesCore.h:45
TGListTree::DeleteChildren
Int_t DeleteChildren(TGListTreeItem *item)
Delete children of item from list.
Definition: TGListTree.cxx:2087
GCValues_t::fFillStyle
Int_t fFillStyle
kFillSolid, kFillTiled, kFillStippled, kFillOpaeueStippled
Definition: GuiTypes.h:234
TGListTreeItem::SavePrimitive
virtual void SavePrimitive(std::ostream &, Option_t *, Int_t)
Definition: TGListTree.h:120
TGListTree::fEventHandled
Bool_t fEventHandled
flag used from user code to bypass standard event handling
Definition: TGListTree.h:239
TGListTreeItemStd::fColor
Color_t fColor
item's color
Definition: TGListTree.h:142
TGListTree::End
void End(Bool_t select=kFALSE)
Move content to the bottom.
Definition: TGListTree.cxx:1199
TGListTree::GetCheckedPic
static const TGPicture * GetCheckedPic()
Returns the icon used for checked checkbox.
Definition: TGListTree.cxx:2578
TGListTree
A list tree is a widget that can contain a number of items arranged in a tree structure.
Definition: TGListTree.h:195
TBuffer::Buffer
char * Buffer() const
Definition: TBuffer.h:96
TGListTree::SortSiblings
Int_t SortSiblings(TGListTreeItem *item)
Sort siblings of item.
Definition: TGListTree.cxx:2201
TString::EndsWith
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2199
TGContainer::GetPageDimension
virtual TGDimension GetPageDimension() const
Returns page dimension.
Definition: TGCanvas.cxx:751
TGListTree::kColorBox
@ kColorBox
Definition: TGListTree.h:202
TGPicture::Draw
void Draw(Option_t *="")
Default Draw method for all objects.
Definition: TGPicture.h:46
TGFont::TextWidth
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
x
Double_t x[n]
Definition: legend1.C:17
TGToolTip::SetText
void SetText(const char *new_text)
Set new tool tip text.
Definition: TGToolTip.cxx:390
TString::Length
Ssiz_t Length() const
Definition: TString.h:410
TGCanvas::Layout
virtual void Layout()
Create layout for canvas.
Definition: TGCanvas.cxx:2229
TGListTreeItem::HasCheckBox
virtual Bool_t HasCheckBox() const =0
TBufferIO::Reset
void Reset() override
Reset buffer object. Resets map and buffer offset.
Definition: TBufferIO.cxx:305
TClass.h
TGFrame::fgWhitePixel
static Pixel_t fgWhitePixel
Definition: TGFrame.h:103
TGToolTip
Definition: TGToolTip.h:24
kButton1
@ kButton1
Definition: GuiTypes.h:214
TGListTree::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle button events in the list tree.
Definition: TGListTree.cxx:565
TGListTree::FindItemByPathname
TGListTreeItem * FindItemByPathname(const char *path)
Find item by pathname.
Definition: TGListTree.cxx:2324
Handle_t
ULongptr_t Handle_t
Generic resource handle.
Definition: GuiTypes.h:26
TColor.h
TGListTree::fAutoTips
Bool_t fAutoTips
assume item->fUserData is TObject and use GetTitle() for tip text
Definition: TGListTree.h:235
TGCanvas::GetVScrollbar
TGVScrollBar * GetVScrollbar() const
Definition: TGCanvas.h:219
TVirtualX.h
TGListTree::fGrayPixel
Pixel_t fGrayPixel
gray draw color
Definition: TGListTree.h:219
TGClient::FreePicture
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition: TGClient.cxx:310
TColor::Number2Pixel
static ULong_t Number2Pixel(Int_t ci)
Static method that given a color index number, returns the corresponding pixel value.
Definition: TColor.cxx:2022
TGFrame::GetBackground
virtual Pixel_t GetBackground() const
Definition: TGFrame.h:192
TGListTree::fHspacing
Int_t fHspacing
horizontal spacing between items
Definition: TGListTree.h:215
TGListTree::fgColorGC
static TGGC * fgColorGC
Definition: TGListTree.h:252
TGListTree::FindItemByObj
TGListTreeItem * FindItemByObj(TGListTreeItem *item, void *ptr)
Find item with fUserData == ptr.
Definition: TGListTree.cxx:2827
TGListTree::AddItem
void AddItem(TGListTreeItem *parent, TGListTreeItem *item)
Add given item to list tree.
Definition: TGListTree.cxx:1957
TString::Format
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:2333
TObject::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:403
kKey_Home
@ kKey_Home
Definition: KeySymbols.h:38
TGListTree::DeleteItem
Int_t DeleteItem(TGListTreeItem *item)
Delete item from list tree.
Definition: TGListTree.cxx:2015
TGListTree::DrawNode
void DrawNode(Handle_t id, TGListTreeItem *item, Int_t x, Int_t y)
Draw node (little + in box).
Definition: TGListTree.cxx:1674
TGListTreeItem::CheckItem
virtual void CheckItem(Bool_t=kTRUE)=0
TGDNDManager.h
TGListTree::fLast
TGListTreeItem * fLast
pointer to last item in list
Definition: TGListTree.h:211
TGListTree::fgOpenPic
static const TGPicture * fgOpenPic
icon for open item
Definition: TGListTree.h:253
TString
Basic string class.
Definition: TString.h:136
TGGC::SetDashOffset
void SetDashOffset(Int_t v)
Patterned/dashed line offset.
Definition: TGGC.cxx:477
ROOT::Math::detail::open
@ open
Definition: GenVectorIO.h:35
TGListTree::fFirst
TGListTreeItem * fFirst
pointer to first item in list
Definition: TGListTree.h:210
kButtonPressMask
const Mask_t kButtonPressMask
Definition: GuiTypes.h:161
TGListTree::Layout
virtual void Layout()
Layout container entries.
Definition: TGListTree.h:290
TGListTree::fDNDData
TDNDData fDNDData
Drag and Drop data.
Definition: TGListTree.h:232
TGListTreeItemStd::HasUnCheckedChild
virtual Bool_t HasUnCheckedChild(Bool_t first=kFALSE)
Add all child items of 'item' into the list 'checked'.
Definition: TGListTree.cxx:201
TGCanvas::GetVsbPosition
virtual Int_t GetVsbPosition() const
Get position of vertical scrollbar.
Definition: TGCanvas.cxx:2384
TGListTreeItemStd::fCheckedPic
const TGPicture * fCheckedPic
icon for checked item
Definition: TGListTree.h:137
Color_t
short Color_t
Definition: RtypesCore.h:92
kCT_ITEMDBLCLICK
@ kCT_ITEMDBLCLICK
Definition: WidgetMessageTypes.h:55
v
@ v
Definition: rootcling_impl.cxx:3664
text
TText * text
Definition: entrylist_figure1.C:10
TString.h
TGListTree::GetChecked
void GetChecked(TList *checked)
Add all checked list tree items of this list tree into the list 'checked'.
Definition: TGListTree.cxx:2849
TGCanvas::SetVsbPosition
virtual void SetVsbPosition(Int_t newPos)
Set position of vertical scrollbar.
Definition: TGCanvas.cxx:2408
TGListTree::KeyPressed
void KeyPressed(TGFrame *, UInt_t, UInt_t)
Signal emitted when keyboard key pressed.
Definition: TGListTree.h:300
TGListTree::GetFirstItem
TGListTreeItem * GetFirstItem() const
Definition: TGListTree.h:381
bool
TSystem::WorkingDirectory
virtual const char * WorkingDirectory()
Return working directory.
Definition: TSystem.cxx:871
kLeaveWindowMask
const Mask_t kLeaveWindowMask
Definition: GuiTypes.h:168
kGCLineStyle
const Mask_t kGCLineStyle
Definition: GuiTypes.h:291
TString::ReplaceAll
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:692
TGFrame::GetWidth
UInt_t GetWidth() const
Definition: TGFrame.h:224
TGFont::GetFontMetrics
void GetFontMetrics(FontMetrics_t *m) const
Get font metrics.
Definition: TGFont.cxx:286
TGListTreeItemStd::GetText
virtual const char * GetText() const
Definition: TGListTree.h:157
kKey_G
@ kKey_G
Definition: KeySymbols.h:132
TGListTree::Search
void Search(Bool_t close=kTRUE)
Invokes search dialog. Looks for item with the entered name.
Definition: TGListTree.cxx:1330
TObjString::String
TString & String()
Definition: TObjString.h:48
TGWindow::kEditDisableBtnEnable
@ kEditDisableBtnEnable
window can handle mouse button events
Definition: TGWindow.h:57
kKey_Right
@ kKey_Right
Definition: KeySymbols.h:42
TGListTreeItem::fXtext
Int_t fXtext
Definition: TGListTree.h:49
TGFrame::GetOptionString
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition: TGFrame.cxx:2480
TGFrame::GetOptions
virtual UInt_t GetOptions() const
Definition: TGFrame.h:197
TGListTree::PageUp
void PageUp(Bool_t select=kFALSE)
Move content one page up.
Definition: TGListTree.cxx:1207
TGListTree::ReparentChildren
Int_t ReparentChildren(TGListTreeItem *item, TGListTreeItem *newparent)
Make newparent the new parent of the children of item.
Definition: TGListTree.cxx:2118
kCT_KEY
@ kCT_KEY
Definition: WidgetMessageTypes.h:57
TGListTreeItemStd::SavePrimitive
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.
Definition: TGListTree.cxx:2678
GContext_t
Handle_t GContext_t
Graphics context handle.
Definition: GuiTypes.h:38
TGListTreeItem::GetTipTextLength
virtual Int_t GetTipTextLength() const =0
TGListTree::CloseItem
void CloseItem(TGListTreeItem *item)
Close item in list tree (i.e. hide child items).
Definition: TGListTree.cxx:2044
TObjString
Collectable string class.
Definition: TObjString.h:28
TGContainer::fYDND
Int_t fYDND
Definition: TGCanvas.h:60
gClient
#define gClient
Definition: TGClient.h:157
TDNDData::fDataType
Atom_t fDataType
Data type description.
Definition: TGDNDManager.h:74
TGListTreeItem::IsActive
virtual Bool_t IsActive() const =0
TGContainer::fMsgWindow
const TGWindow * fMsgWindow
window handling container messages
Definition: TGCanvas.h:42
TGListTreeItemStd::HasCheckBox
virtual Bool_t HasCheckBox() const
Definition: TGListTree.h:173
TRefCnt::AddReference
void AddReference()
Definition: TRefCnt.h:40
TGListTree::fgLineGC
static TGGC * fgLineGC
Definition: TGListTree.h:250
TGFrame::AddInput
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition: TGFrame.cxx:339
TBuffer::Length
Int_t Length() const
Definition: TBuffer.h:100
kNone
const Handle_t kNone
Definition: GuiTypes.h:88
TList::At
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
TGListTree::GetDrawGC
static const TGGC & GetDrawGC()
Return default graphics context in use.
Definition: TGListTree.cxx:2467
TGContainer::GetVScrollbar
virtual TGVScrollBar * GetVScrollbar() const
returns pointer to vert. scroll bar
Definition: TGCanvas.cxx:1753
TGToolTip::Reset
void Reset()
Reset tool tip popup delay timer.
Definition: TGToolTip.cxx:263
TGScrollBar::GetPosition
virtual Int_t GetPosition() const
Definition: TGScrollBar.h:113
TGDNDManager::GetDNDActionCopy
static Atom_t GetDNDActionCopy()
Definition: TGDNDManager.cxx:283
TGContainer::GetPagePosition
virtual TGPosition GetPagePosition() const
Returns page position.
Definition: TGCanvas.cxx:737
TGListTreeItem::fPrevsibling
TGListTreeItem * fPrevsibling
pointer to previous sibling
Definition: TGListTree.h:39
TGListTree::fTip
TGToolTip * fTip
tooltip shown when moving over list items
Definition: TGListTree.h:229
kSunkenFrame
@ kSunkenFrame
Definition: GuiTypes.h:383
TGScrollBar::SetSmallIncrement
virtual void SetSmallIncrement(Int_t increment)
Definition: TGScrollBar.h:134
kLineOnOffDash
@ kLineOnOffDash
Definition: GuiTypes.h:48
TGListTree::UnselectAll
void UnselectAll(Bool_t draw)
Unselect all items.
Definition: TGListTree.cxx:556
TDNDData::fData
void * fData
Actual data.
Definition: TGDNDManager.h:76
TGListTreeItemStd::UpdateState
virtual void UpdateState()
Update the state of the node 'item' according to the children states.
Definition: TGListTree.cxx:224
TGWindow::kEditDisableGrab
@ kEditDisableGrab
window grab cannot be edited
Definition: TGWindow.h:52
TGListTreeItemStd
Definition: TGListTree.h:127
TGListTree::kDefault
@ kDefault
Definition: TGListTree.h:200
TSystem.h
TGPosition::fX
Int_t fX
x position
Definition: TGDimension.h:38
TGListTree::Clicked
void Clicked(TGFrame *, Int_t)
Emit Clicked() signal.
Definition: TGListTree.h:296
TGListTree::PDeleteItem
void PDeleteItem(TGListTreeItem *item)
Delete given item.
Definition: TGListTree.cxx:1750
TGListTree::GetDefaultFontStruct
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use.
Definition: TGListTree.cxx:2432
kGCFillStyle
const Mask_t kGCFillStyle
Definition: GuiTypes.h:294
TGDimension::fHeight
UInt_t fHeight
Definition: TGDimension.h:21
TGFont::TextHeight
Int_t TextHeight() const
Definition: TGFont.h:192
TGListTree::fFont
FontStruct_t fFont
font used to draw item text
Definition: TGListTree.h:224
h
#define h(i)
Definition: RSha256.hxx:106
kGKeyPress
@ kGKeyPress
Definition: GuiTypes.h:60
TGWindow::GetName
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:336
TGListTree::GetCheckedChildren
void GetCheckedChildren(TList *checked, TGListTreeItem *item)
Add all child items of 'item' into the list 'checked'.
Definition: TGListTree.cxx:2866
TGListTreeItem::fClient
TGClient * fClient
pointer to TGClient
Definition: TGListTree.h:35
TGListTreeItem::GetActiveColor
virtual Pixel_t GetActiveColor() const =0
TGListTree::GetColorGC
static const TGGC & GetColorGC()
Return graphics context for highlighted frame background.
Definition: TGListTree.cxx:2535
TGGC
Encapsulate a graphics context used in the low level graphics.
Definition: TGGC.h:22
TGListTreeItem::SetUserData
virtual void SetUserData(void *, Bool_t=kFALSE)
Definition: TGListTree.h:79
TGListTreeItem::Toggle
virtual void Toggle()
Definition: TGListTree.h:91
TGListTree::FindSiblingByName
TGListTreeItem * FindSiblingByName(TGListTreeItem *item, const char *name)
Find sibling of item by name.
Definition: TGListTree.cxx:2233
TGObject::fId
Handle_t fId
X11/Win32 Window identifier.
Definition: TGObject.h:26
TGContainer::fXDND
Int_t fXDND
Definition: TGCanvas.h:60
TGListTree::PageDown
void PageDown(Bool_t select=kFALSE)
Move content one page down.
Definition: TGListTree.cxx:1222
Atom_t
Handle_t Atom_t
WM token.
Definition: GuiTypes.h:37
TGListTree::CheckItem
void CheckItem(TGListTreeItem *item, Bool_t check=kTRUE)
Set check button state for the node 'item'.
Definition: TGListTree.cxx:2759
kMBIconExclamation
@ kMBIconExclamation
Definition: TGMsgBox.h:24
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
Event_t::fCode
UInt_t fCode
key or button code
Definition: GuiTypes.h:180
TGDNDManager::IsDragging
Bool_t IsDragging() const
Definition: TGDNDManager.h:173
TGFrame::SendMessage
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
Definition: TGFrame.cxx:645
TGListTree::fCurrent
TGListTreeItem * fCurrent
pointer to current item in list
Definition: TGListTree.h:213
TGListTreeItem::HasColor
virtual Bool_t HasColor() const =0
TGListTree::AdjustPosition
void AdjustPosition()
Move content to position of highlighted/activated frame.
Definition: TGListTree.h:355
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
kKey_PageUp
@ kKey_PageUp
Definition: KeySymbols.h:45
TGListTree::fExposeBottom
Int_t fExposeBottom
bottom y position of visible region
Definition: TGListTree.h:228
GCValues_t::fLineStyle
Int_t fLineStyle
kLineSolid, kLineOnOffDash, kLineDoubleDash
Definition: GuiTypes.h:230
kGCForeground
const Mask_t kGCForeground
Definition: GuiTypes.h:288
TGListTreeItem::fLastchild
TGListTreeItem * fLastchild
pointer to last child item
Definition: TGListTree.h:38
TGListTreeItemStd::Toggle
virtual void Toggle()
Definition: TGListTree.h:175
kButtonPress
@ kButtonPress
Definition: GuiTypes.h:60
Long_t
long Long_t
Definition: RtypesCore.h:54
kGCGraphicsExposures
const Mask_t kGCGraphicsExposures
Definition: GuiTypes.h:302
TGListTreeItemStd::SetCheckBox
virtual void SetCheckBox(Bool_t on=kTRUE)
Set a check box on the tree node.
Definition: TGListTree.cxx:281
TGListTree::FindItem
TGListTreeItem * FindItem(Int_t findy)
Find item at postion findy.
Definition: TGListTree.cxx:1918
TGListTreeItem::fY
Int_t fY
Definition: TGListTree.h:48
GCValues_t::fFont
FontH_t fFont
default text font for text operations
Definition: GuiTypes.h:242
kButtonReleaseMask
const Mask_t kButtonReleaseMask
Definition: GuiTypes.h:162
TGFont::GetFontHandle
FontH_t GetFontHandle() const
Definition: TGFont.h:183
TGDimension::fWidth
UInt_t fWidth
Definition: TGDimension.h:20
kButtonRelease
@ kButtonRelease
Definition: GuiTypes.h:60
TGListTree::fUserControlled
Bool_t fUserControlled
let user decides what is the behaviour on events
Definition: TGListTree.h:238
TGListTreeItem::SetCheckBoxPictures
virtual void SetCheckBoxPictures(const TGPicture *, const TGPicture *)
Definition: TGListTree.h:85
TGListTree::SetToolTipText
void SetToolTipText(const char *text, Int_t x, Int_t y, Long_t delayms)
Set tool tip text associated with this item.
Definition: TGListTree.cxx:1700
TGListTreeItem::IsOpen
virtual Bool_t IsOpen() const
Definition: TGListTree.h:64
TGFrame::SaveUserColor
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition: TGFrame.cxx:2453
StrDup
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2512
TGListTree::fgCheckedPic
static const TGPicture * fgCheckedPic
icon for checked item
Definition: TGListTree.h:255
kGCFont
const Mask_t kGCFont
Definition: GuiTypes.h:300
kKey_F7
@ kKey_F7
Definition: KeySymbols.h:63
TGClient::GetPicture
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition: TGClient.cxx:291
TGListTreeItem::IsDNDTarget
Bool_t IsDNDTarget() const
Definition: TGListTree.h:113
GCValues_t::fBackground
ULong_t fBackground
background pixel
Definition: GuiTypes.h:228
TGListTree::HandleCrossing
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
Definition: TGListTree.cxx:705
TGListTree::LineDown
void LineDown(Bool_t select=kFALSE)
Move content one item-size down.
Definition: TGListTree.cxx:1262
kGCLineWidth
const Mask_t kGCLineWidth
Definition: GuiTypes.h:290
TGListTree::HandleDNDLeave
Bool_t HandleDNDLeave()
Handle drag leave events.
Definition: TGListTree.cxx:773
TString::BeginsWith
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:615
TGContainer::ClearViewPort
virtual void ClearViewPort()
Clear view port and redraw full content.
Definition: TGCanvas.cxx:891
TGListTree::kRecursive
@ kRecursive
Definition: TGListTree.h:206
TGContainer::GetCanvas
TGCanvas * GetCanvas() const
Definition: TGCanvas.h:99
y
Double_t y[n]
Definition: legend1.C:17
TGListTree::HandleDNDPosition
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
TGListTreeItem::HasUnCheckedChild
virtual Bool_t HasUnCheckedChild(Bool_t=kFALSE)
Definition: TGListTree.h:98
TGListTree::fColorMode
EColorMarkupMode fColorMode
if/how to render item's main color
Definition: TGListTree.h:242
kKey_Escape
@ kKey_Escape
Definition: KeySymbols.h:26
ULong_t
unsigned long ULong_t
Definition: RtypesCore.h:55
TDNDData
Drag and drop data container.
Definition: TGDNDManager.h:64
TSystem::ExpandPathName
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition: TSystem.cxx:1273
TGGC::SetDashList
void SetDashList(const char v[], Int_t len)
Set dash pattern. First use SetDashOffset() if not 0.
Definition: TGGC.cxx:488
GCValues_t::fGraphicsExposures
Bool_t fGraphicsExposures
boolean, should exposures be generated
Definition: GuiTypes.h:244
KeySymbols.h
TGListTreeItemStd::GetTipText
virtual const char * GetTipText() const
Definition: TGListTree.h:159
Event_t::fXRoot
Int_t fXRoot
Definition: GuiTypes.h:179
TGListTree::fgDefaultFont
static const TGFont * fgDefaultFont
Definition: TGListTree.h:247
kGCBackground
const Mask_t kGCBackground
Definition: GuiTypes.h:289
TGListTreeItem::CheckAllChildren
virtual void CheckAllChildren(Bool_t=kTRUE)
Definition: TGListTree.h:95
TGListTreeItem::GetFirstChild
TGListTreeItem * GetFirstChild() const
Definition: TGListTree.h:59
kKey_F5
@ kKey_F5
Definition: KeySymbols.h:61
TGListTree::HandleDNDEnter
Atom_t HandleDNDEnter(Atom_t *typelist)
Handle drag enter events.
Definition: TGListTree.cxx:758
kPointer
@ kPointer
Definition: GuiTypes.h:375
kKeyPressMask
const Mask_t kKeyPressMask
Definition: GuiTypes.h:159
gDNDManager
R__EXTERN TGDNDManager * gDNDManager
Definition: TGDNDManager.h:201
Event_t::fYRoot
Int_t fYRoot
coordinates relative to root
Definition: GuiTypes.h:179
TGListTree::CheckAllChildren
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...
Definition: TGListTree.cxx:2885
TGListTreeItemStd::CheckItem
virtual void CheckItem(Bool_t checked=kTRUE)
Definition: TGListTree.h:174
TMath::Min
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180
TGListTreeItem::IsChecked
virtual Bool_t IsChecked() const =0
kHand
@ kHand
Definition: GuiTypes.h:374
TGListTreeItem::SetTipText
virtual void SetTipText(const char *)
Definition: TGListTree.h:77
TGListTreeItem::fParent
TGListTreeItem * fParent
pointer to parent
Definition: TGListTree.h:36
unsigned int
TGListTreeItem::GetTextLength
virtual Int_t GetTextLength() const =0
TGListTree::fgClosedPic
static const TGPicture * fgClosedPic
icon for closed item
Definition: TGListTree.h:254
kMBOk
@ kMBOk
Definition: TGMsgBox.h:33
TGListTree::TGListTree
TGListTree(const TGListTree &)=delete
kKey_Return
@ kKey_Return
Definition: KeySymbols.h:30
TGListTreeItemStd::fCheckBox
Bool_t fCheckBox
true if checkbox is visible
Definition: TGListTree.h:130
ROOT::Math::detail::close
@ close
Definition: GenVectorIO.h:35
gSystem
R__EXTERN TSystem * gSystem
Definition: TSystem.h:559
kKeyControlMask
const Mask_t kKeyControlMask
Definition: GuiTypes.h:197
TGListTree::GetPathnameFromItem
void GetPathnameFromItem(TGListTreeItem *item, char *path, Int_t depth=0)
Get pathname from item.
Definition: TGListTree.cxx:2398
TGListTreeItem::fHeight
UInt_t fHeight
Definition: TGListTree.h:51
kKey_Left
@ kKey_Left
Definition: KeySymbols.h:40
TGWindow::GetParent
const TGWindow * GetParent() const
Definition: TGWindow.h:76
kKey_Enter
@ kKey_Enter
Definition: KeySymbols.h:31
TGContainer::SetDragPixmap
virtual void SetDragPixmap(const TGPicture *pic)
Set drag window pixmaps and hotpoint.
Definition: TGCanvas.cxx:1080
TGListTree::fMargin
Int_t fMargin
number of pixels margin from left side
Definition: TGListTree.h:218
TGListTree::TextWidth
Int_t TextWidth(const char *c)
Returns text width relative to currently used font.
Definition: TGListTree.cxx:515
TGClient::NeedRedraw
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:374
TGListTree::Draw
void Draw(Handle_t id, Int_t yevent, Int_t hevent)
Draw list tree widget.
Definition: TGListTree.cxx:1407
TString::IsNull
Bool_t IsNull() const
Definition: TString.h:407
TGListTree::SetToolTipItem
void SetToolTipItem(TGListTreeItem *item, const char *string)
Set tooltip text for this item.
Definition: TGListTree.cxx:2077
TGListTree::fDisableOpen
Bool_t fDisableOpen
disable branch opening on double-clicks
Definition: TGListTree.h:237
TGContainer
Manages a content area.
Definition: TGCanvas.h:31
TGListTree::fTipItem
TGListTreeItem * fTipItem
item for which tooltip is set
Definition: TGListTree.h:230
TGListTreeItemStd::SetCheckBoxPictures
virtual void SetCheckBoxPictures(const TGPicture *checked, const TGPicture *unchecked)
Change list tree check item icons.
Definition: TGListTree.cxx:289
TGListTreeItemStd::GetActiveColor
virtual Pixel_t GetActiveColor() const
Return color for marking items that are active or selected.
Definition: TGListTree.cxx:170
TGListTreeItem::SetActive
virtual void SetActive(Bool_t)
Definition: TGListTree.h:69
TGListTree::fSelected
TGListTreeItem * fSelected
pointer to selected item in list
Definition: TGListTree.h:212
TSystem::UnixPathName
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition: TSystem.cxx:1062
TGListTree::SetCheckBox
void SetCheckBox(TGListTreeItem *item, Bool_t on=kTRUE)
Set check button state for the node 'item'.
Definition: TGListTree.cxx:2767
TGMsgBox.h
TGListTree::FontHeight
Int_t FontHeight()
Returns height of currently used font.
Definition: TGListTree.cxx:493
GCValues_t::fMask
Mask_t fMask
bit mask specifying which fields are valid
Definition: GuiTypes.h:251
TGObject::fClient
TGClient * fClient
Connection to display server.
Definition: TGObject.h:27
TGListTree::SaveChildren
void SaveChildren(std::ostream &out, TGListTreeItem *item, Int_t &n)
Save child items as a C++ statements on output stream out.
Definition: TGListTree.cxx:2661
TGListTreeItem::GetColor
virtual Color_t GetColor() const =0
TGListTree::ToggleItem
void ToggleItem(TGListTreeItem *item)
Toggle check button state of the node 'item'.
Definition: TGListTree.cxx:2775
TGListTreeItem::GetUserData
virtual void * GetUserData() const =0
TGListTree::fAutoCheckBoxPic
Bool_t fAutoCheckBoxPic
change check box picture if parent and children have diffrent state
Definition: TGListTree.h:236
TGListTree::HandleDNDDrop
Bool_t HandleDNDDrop(TDNDData *data)
Handle drop events.
Definition: TGListTree.cxx:781
TGListTreeItemStd::fOwnsData
Bool_t fOwnsData
true if user data has to be deleted
Definition: TGListTree.h:132
Event_t::fTime
Time_t fTime
time event event occurred in ms
Definition: GuiTypes.h:177
TGListTree::fgUncheckedPic
static const TGPicture * fgUncheckedPic
icon for unchecked item
Definition: TGListTree.h:256
TList::Add
virtual void Add(TObject *obj)
Definition: TList.h:87
TGListTree::fDefh
UInt_t fDefh
default list height
Definition: TGListTree.h:226
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TBufferFile.h
TGToolTip.h
kKey_Space
@ kKey_Space
Definition: KeySymbols.h:93
TGListTreeItem::SetOpen
virtual void SetOpen(Bool_t o)
Definition: TGListTree.h:65
TGListTree.h
TGDNDManager::EndDrag
Bool_t EndDrag()
End dragging.
Definition: TGDNDManager.cxx:971
TGFrame::SetDNDTarget
void SetDNDTarget(Bool_t onoff)
Definition: TGFrame.h:270
TGListTree::RenameItem
void RenameItem(TGListTreeItem *item, const char *string)
Rename item in list tree.
Definition: TGListTree.cxx:2003
Event_t
Event structure.
Definition: GuiTypes.h:174
TGListTree::DrawActive
virtual void DrawActive(Handle_t id, TGListTreeItem *item)
Draw active item with its active color.
Definition: TGListTree.cxx:1609
TGListTree::DataDropped
virtual void DataDropped(TGListTreeItem *item, TDNDData *data)
Emit DataDropped() signal.
Definition: TGListTree.cxx:792
name
char name[80]
Definition: TGX11.cxx:110
GCValues_t::fForeground
ULong_t fForeground
foreground pixel
Definition: GuiTypes.h:227
TGPicture::GetName
const char * GetName() const
Returns name of object.
Definition: TGPicture.h:51
kButton5
@ kButton5
Definition: GuiTypes.h:215
TGCanvas.h
TGListTreeItem::GetNextSibling
TGListTreeItem * GetNextSibling() const
Definition: TGListTree.h:62
TGFrame::GetWhitePixel
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:709
TGListTree::GetUncheckedPic
static const TGPicture * GetUncheckedPic()
Returns the icon used for unchecked checkbox.
Definition: TGListTree.cxx:2589
TGContainer::fViewPort
TGViewPort * fViewPort
container viewport
Definition: TGCanvas.h:40
TGListTree::DoubleClicked
void DoubleClicked(TGFrame *, Int_t)
Emit DoubleClicked() signal.
Definition: TGListTree.h:298
kKey_End
@ kKey_End
Definition: KeySymbols.h:39
TGListTree::fBelowMouse
TGListTreeItem * fBelowMouse
pointer to item below mouses cursor
Definition: TGListTree.h:214
TGListTreeItem::UpdateState
virtual void UpdateState()
Definition: TGListTree.h:99
TGListTree::fgHighlightGC
static TGGC * fgHighlightGC
Definition: TGListTree.h:251
TGFrame::GetDefaultSelectedBackground
static Pixel_t GetDefaultSelectedBackground()
Get default selected frame background.
Definition: TGFrame.cxx:696
kCT_ITEMCLICK
@ kCT_ITEMCLICK
Definition: WidgetMessageTypes.h:54
TGListTree::LineUp
void LineUp(Bool_t select=kFALSE)
Move content one item-size up.
Definition: TGListTree.cxx:1236
TGListTreeItemStd::fTipText
TString fTipText
tooltip text
Definition: TGListTree.h:134
TGResourcePool.h
TGFont::GetFontStruct
FontStruct_t GetFontStruct() const
Definition: TGFont.h:184
TGListTreeItemStd::TGListTreeItemStd
TGListTreeItemStd(const TGListTreeItemStd &)=delete
TGListTree::fVspacing
Int_t fVspacing
vertical spacing between items
Definition: TGListTree.h:216
TGListTree::Checked
virtual void Checked(TObject *obj, Bool_t check)
Emit Checked() signal.
Definition: TGListTree.cxx:1106
TGFrame::fHeight
UInt_t fHeight
frame height
Definition: TGFrame.h:88
TGListTree::fLineGC
GContext_t fLineGC
dashed line drawing context
Definition: TGListTree.h:222
TGListTreeItemStd::CheckChildren
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
TGListTreeItemStd::fClosedPic
const TGPicture * fClosedPic
icon for closed state
Definition: TGListTree.h:136
TGFrame::fBackground
Pixel_t fBackground
frame background color
Definition: TGFrame.h:95
TGListTreeItem::IsDNDSource
Bool_t IsDNDSource() const
Definition: TGListTree.h:112
TGListTree::fgDrawGC
static TGGC * fgDrawGC
Definition: TGListTree.h:249
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
kEnterWindowMask
const Mask_t kEnterWindowMask
Definition: GuiTypes.h:167
TGListTree::GetHighlightGC
static const TGGC & GetHighlightGC()
Return graphics context for highlighted frame background.
Definition: TGListTree.cxx:2513
TGFont
Encapsulate fonts used in the GUI system.
Definition: TGFont.h:140
TGWindow::fEditDisabled
UInt_t fEditDisabled
flags used for "guibuilding"
Definition: TGWindow.h:32
TGDNDManager::Drag
Bool_t Drag(Int_t x_root, Int_t y_root, Atom_t action, Time_t timestamp)
Process drag event.
Definition: TGDNDManager.cxx:993
TGSearchDialog
Definition: TGTextEditDialogs.h:38
TGCanvas::GetViewPort
TGViewPort * GetViewPort() const
Definition: TGCanvas.h:217
TGFrame::fgDefaultSelectedBackground
static Pixel_t fgDefaultSelectedBackground
Definition: TGFrame.h:102
Class
void Class()
Definition: Class.C:29
TGPosition
Definition: TGDimension.h:36
TGListTree::fDropItem
TGListTreeItem * fDropItem
item on which DND is over
Definition: TGListTree.h:234
TGListTree::fgGrayPixel
static Pixel_t fgGrayPixel
Definition: TGListTree.h:246
TGCanvas
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition: TGCanvas.h:192
TGListTreeItemStd::fHasColor
Bool_t fHasColor
true if item has assigned color
Definition: TGListTree.h:141
TGListTreeItem::fYtext
Int_t fYtext
Definition: TGListTree.h:50
TGPicture::GetHeight
UInt_t GetHeight() const
Definition: TGPicture.h:53
TGListTreeItem
Definition: TGListTree.h:27
TGToolTip::Hide
void Hide()
Hide tool tip window.
Definition: TGToolTip.cxx:250
TGListTree::HandleDoubleClick
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle double click event in the list tree (only for kButton1).
Definition: TGListTree.cxx:663
TGListTreeItem::TGListTreeItem
TGListTreeItem(const TGListTreeItem &)=delete
TGListTreeItemStd::IsChecked
virtual Bool_t IsChecked() const
Definition: TGListTree.h:176
TGListTreeItem::fFirstchild
TGListTreeItem * fFirstchild
pointer to first child item
Definition: TGListTree.h:37
TGListTree::RecursiveDeleteItem
Int_t RecursiveDeleteItem(TGListTreeItem *item, void *userData)
Delete item with fUserData == ptr.
Definition: TGListTree.cxx:2057
TGScrollBar.h
kKey_PageDown
@ kKey_PageDown
Definition: KeySymbols.h:47
TGListTreeItemStd::fChecked
Bool_t fChecked
true if item is checked
Definition: TGListTree.h:131
TBufferFile
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition: TBufferFile.h:47
TGClient
Window client.
Definition: TGClient.h:37
TGListTree::OpenItem
void OpenItem(TGListTreeItem *item)
Open item in list tree (i.e. show child items).
Definition: TGListTree.cxx:2032
TGListTree::DrawRegion
virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
Redraw list tree.
Definition: TGListTree.cxx:1365
MK_MSG
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
Definition: WidgetMessageTypes.h:108
TGListTreeItem::GetParent
TGListTreeItem * GetParent() const
Definition: TGListTree.h:58
TGListTreeItem::fDNDState
Int_t fDNDState
EDNDFlags.
Definition: TGListTree.h:44
TGListTreeItem::Rename
void Rename(const char *new_name)
Definition: TGListTree.h:71
TGWindow::fParent
const TGWindow * fParent
Parent window.
Definition: TGWindow.h:28
TGListTreeItemStd::~TGListTreeItemStd
virtual ~TGListTreeItemStd()
Delete list tree item.
Definition: TGListTree.cxx:155
kKeyShiftMask
const Mask_t kKeyShiftMask
Definition: GuiTypes.h:195
TGListTree::GetOpenPic
static const TGPicture * GetOpenPic()
Returns the icon used by items in open state.
Definition: TGListTree.cxx:2556
TList
A doubly linked list.
Definition: TList.h:44
TBuffer::kWrite
@ kWrite
Definition: TBuffer.h:73
TQObject::Emit
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
TGListTree::GetClosedPic
static const TGPicture * GetClosedPic()
Returns the icon used by items in closed state.
Definition: TGListTree.cxx:2567
TGListTreeItem::HasCheckedChild
virtual Bool_t HasCheckedChild(Bool_t=kFALSE)
Definition: TGListTree.h:97
TGSearchType
Definition: TGTextEditDialogs.h:19
GCValues_t::fLineWidth
Int_t fLineWidth
line width
Definition: GuiTypes.h:229
int
TGListTree::fBuf
TBufferFile * fBuf
buffer used for Drag and Drop
Definition: TGListTree.h:231
TGListTree::fExposeTop
Int_t fExposeTop
top y postion of visible region
Definition: TGListTree.h:227
TError.h
TGListTree::MouseOver
virtual void MouseOver(TGListTreeItem *entry)
Signal emitted when pointer is over entry.
Definition: TGListTree.cxx:1051
TGContainer::fBdown
Bool_t fBdown
Definition: TGCanvas.h:61
TSystem::GetVolumes
virtual TList * GetVolumes(Option_t *) const
Definition: TSystem.h:453
TGWindow::IsMapped
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition: TGWindow.cxx:295