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