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