Logo ROOT   6.18/05
Reference Guide
TGListTree.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id: 2897f2e70909348e1e18681c5c7b0aee8c027744 $
2// Author: Fons Rademakers 25/02/98
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11/**************************************************************************
12
13 This source is based on Xclass95, a Win95-looking GUI toolkit.
14 Copyright (C) 1996, 1997 David Barth, Ricky Ralston, Hector Peraza.
15
16 Xclass95 is free software; you can redistribute it and/or
17 modify it under the terms of the GNU Library General Public
18 License as published by the Free Software Foundation; either
19 version 2 of the License, or (at your option) any later version.
20
21**************************************************************************/
22
23//////////////////////////////////////////////////////////////////////////
24// //
25// TGListTree and TGListTreeItem //
26// //
27// A list tree is a widget that can contain a number of items //
28// arranged in a tree structure. The items are represented by small //
29// folder icons that can be either open or closed. //
30// //
31// The TGListTree is user callable. The TGListTreeItem is a service //
32// class of the list tree. //
33// //
34// A list tree can generate the following events: //
35// kC_LISTTREE, kCT_ITEMCLICK, which button, location (y<<16|x). //
36// kC_LISTTREE, kCT_ITEMDBLCLICK, which button, location (y<<16|x). //
37// //
38//////////////////////////////////////////////////////////////////////////
39
40#include <stdlib.h>
41
42#include "TROOT.h"
43#include "TClass.h"
44#include "TGListTree.h"
45#include "TGPicture.h"
46#include "TGCanvas.h"
47#include "TGScrollBar.h"
48#include "TGToolTip.h"
49#include "KeySymbols.h"
50#include "TGTextEditDialogs.h"
51#include "TGResourcePool.h"
52#include "TGMsgBox.h"
53#include "TError.h"
54#include "TColor.h"
55#include "TSystem.h"
56#include "TString.h"
57#include "TObjString.h"
58#include "TGDNDManager.h"
59#include "TBufferFile.h"
60#include "Riostream.h"
61#include "RConfigure.h"
62
74
75
79
80/******************************************************************************/
81/******************************************************************************/
82// TGListTreeItem
83/******************************************************************************/
84
85////////////////////////////////////////////////////////////////////////////////
86/// Constructor.
87
89 fClient(client),
90 fParent (0), fFirstchild(0), fLastchild (0), fPrevsibling(0),
91 fNextsibling(0),fOpen (kFALSE), fDNDState (0),
92 fY (0), fXtext (0), fYtext(0), fHeight(0)
93{
94}
95
96////////////////////////////////////////////////////////////////////////////////
97/// Return width of item's icon.
98
100{
101 const TGPicture *pic = GetPicture();
102 return (pic) ? pic->GetWidth() : 0;
103}
104
105/******************************************************************************/
106/******************************************************************************/
107// TGListTreeItemStd
108/******************************************************************************/
109
110////////////////////////////////////////////////////////////////////////////////
111/// Create list tree item.
112
114 const TGPicture *opened,
115 const TGPicture *closed,
116 Bool_t checkbox) :
117 TGListTreeItem(client)
118{
119 fText = name;
120 fCheckBox = checkbox;
121 fChecked = kTRUE;
122
123 if (!opened)
124 opened = TGListTree::GetOpenPic();
125 else
126 ((TGPicture *)opened)->AddReference();
127
128 if (!closed)
129 closed = TGListTree::GetClosedPic();
130 else
131 ((TGPicture *)closed)->AddReference();
132
133 fOpenPic = opened;
134 fClosedPic = closed;
135
138
139 fActive = kFALSE;
140
142 fUserData = 0;
143
145 fColor = 0;
146 fDNDState = 0;
147}
148
149////////////////////////////////////////////////////////////////////////////////
150/// Delete list tree item.
151
153{
154 if (fOwnsData && fUserData) {
155 TObject *obj = static_cast<TObject *>(fUserData);
156 delete dynamic_cast<TObject *>(obj);
157 }
162}
163
164////////////////////////////////////////////////////////////////////////////////
165/// Return color for marking items that are active or selected.
166
168{
170}
171
172////////////////////////////////////////////////////////////////////////////////
173/// Add all child items of 'item' into the list 'checked'.
174
176{
177 TGListTreeItem *item = this;
178
179 while (item) {
180 if (item->IsChecked()) {
181 return kTRUE;
182 }
183 if (item->GetFirstChild()) {
184 if (item->GetFirstChild()->HasCheckedChild())
185 return kTRUE;
186 }
187 if (!first)
188 item = item->GetNextSibling();
189 else
190 break;
191 }
192 return kFALSE;
193}
194
195////////////////////////////////////////////////////////////////////////////////
196/// Add all child items of 'item' into the list 'checked'.
197
199{
200 TGListTreeItem *item = this;
201
202 while (item) {
203 if (!item->IsChecked()) {
204 return kTRUE;
205 }
206 if (item->GetFirstChild()) {
207 if (item->GetFirstChild()->HasUnCheckedChild())
208 return kTRUE;
209 }
210 if (!first)
211 item = item->GetNextSibling();
212 else
213 break;
214 }
215 return kFALSE;
216}
217
218////////////////////////////////////////////////////////////////////////////////
219/// Update the state of the node 'item' according to the children states.
220
222{
223 if ((!fChecked && HasCheckedChild(kTRUE)) ||
225 SetCheckBoxPictures(gClient->GetPicture("checked_dis_t.xpm"),
226 gClient->GetPicture("unchecked_dis_t.xpm"));
227 }
228 else {
229 SetCheckBoxPictures(gClient->GetPicture("checked_t.xpm"),
230 gClient->GetPicture("unchecked_t.xpm"));
231 }
232}
233
234////////////////////////////////////////////////////////////////////////////////
235/// Set all child items of this one checked if state=kTRUE,
236/// unchecked if state=kFALSE.
237
239{
240 if (state) {
241 if (!IsChecked())
242 CheckItem();
243 } else {
244 if (IsChecked())
245 Toggle();
246 }
248 UpdateState();
249}
250
251////////////////////////////////////////////////////////////////////////////////
252/// Set all child items of 'item' checked if state=kTRUE;
253/// unchecked if state=kFALSE.
254
256{
257 if (!item) return;
258
259 while (item) {
260 if (state){
261 if (!item->IsChecked())
262 item->CheckItem();
263 } else {
264 if (item->IsChecked())
265 item->Toggle();
266 }
267 if (item->GetFirstChild()) {
268 CheckChildren(item->GetFirstChild(), state);
269 }
270 item->UpdateState();
271 item = item->GetNextSibling();
272 }
273}
274
275////////////////////////////////////////////////////////////////////////////////
276/// Set a check box on the tree node.
277
279{
280 fCheckBox = on;
281}
282
283////////////////////////////////////////////////////////////////////////////////
284/// Change list tree check item icons.
285
287 const TGPicture *unchecked)
288{
291
292 if (!checked) {
293 ::Warning("TGListTreeItem::SetCheckBoxPictures", "checked picture not specified, defaulting to checked_t");
294 checked = fClient->GetPicture("checked_t.xpm");
295 } else
296 ((TGPicture *)checked)->AddReference();
297
298 if (!unchecked) {
299 ::Warning("TGListTreeItem::SetCheckBoxPictures", "unchecked picture not specified, defaulting to unchecked_t");
300 unchecked = fClient->GetPicture("unchecked_t.xpm");
301 } else
302 ((TGPicture *)unchecked)->AddReference();
303
304 fCheckedPic = checked;
305 fUncheckedPic = unchecked;
306}
307
308////////////////////////////////////////////////////////////////////////////////
309/// Change list tree item icons.
310
311void TGListTreeItemStd::SetPictures(const TGPicture *opened, const TGPicture *closed)
312{
315
316 if (!opened) {
317 ::Warning("TGListTreeItem::SetPictures", "opened picture not specified, defaulting to ofolder_t");
318 opened = fClient->GetPicture("ofolder_t.xpm");
319 } else
320 ((TGPicture *)opened)->AddReference();
321
322 if (!closed) {
323 ::Warning("TGListTreeItem::SetPictures", "closed picture not specified, defaulting to folder_t");
324 closed = fClient->GetPicture("folder_t.xpm");
325 } else
326 ((TGPicture *)closed)->AddReference();
327
328 fOpenPic = opened;
329 fClosedPic = closed;
330}
331
332
333/******************************************************************************/
334/******************************************************************************/
335// TGListTree
336/******************************************************************************/
337
338////////////////////////////////////////////////////////////////////////////////
339/// Create a list tree widget.
340
342 ULong_t back) :
343 TGContainer(p, w, h, options, back)
344{
345 fMsgWindow = p;
346 fCanvas = 0;
347 fTip = 0;
348 fTipItem = 0;
352 fBdown = kFALSE;
356 fDropItem = 0;
357 fLastEventState = 0;
358
361
363 fDrawGC = GetDrawGC()();
364 fLineGC = GetLineGC()();
366 fColorGC = GetColorGC()();
367
369 fDefw = fDefh = 1;
370
371 fHspacing = 2;
372 fVspacing = 2; // 0;
373 fIndent = 3; // 0;
374 fMargin = 2;
375
376 fXDND = fYDND = 0;
377 fDNDData.fData = 0;
380 fBuf = 0;
381
385
386 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
388 kNone, kNone);
389
393
394 fDNDTypeList = new Atom_t[3];
395 fDNDTypeList[0] = gVirtualX->InternAtom("application/root", kFALSE);
396 fDNDTypeList[1] = gVirtualX->InternAtom("text/uri-list", kFALSE);
397 fDNDTypeList[2] = 0;
398 gVirtualX->SetDNDAware(fId, fDNDTypeList);
401}
402
403////////////////////////////////////////////////////////////////////////////////
404/// Create a list tree widget.
405
407 TGContainer(p, options, back)
408{
409 fMsgWindow = p;
410 fTip = 0;
411 fTipItem = 0;
415 fBdown = kFALSE;
419 fDropItem = 0;
420 fLastEventState = 0;
421
424
426 fDrawGC = GetDrawGC()();
427 fLineGC = GetLineGC()();
429 fColorGC = GetColorGC()();
430
432 fDefw = fDefh = 1;
433
434 fHspacing = 2;
435 fVspacing = 2; // 0;
436 fIndent = 3; // 0;
437 fMargin = 2;
438
439 fXDND = fYDND = 0;
440 fDNDData.fData = 0;
443 fBuf = 0;
444
448
449 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
451 kNone, kNone);
452
456
457 fDNDTypeList = new Atom_t[3];
458 fDNDTypeList[0] = gVirtualX->InternAtom("application/root", kFALSE);
459 fDNDTypeList[1] = gVirtualX->InternAtom("text/uri-list", kFALSE);
460 fDNDTypeList[2] = 0;
461 gVirtualX->SetDNDAware(fId, fDNDTypeList);
464}
465
466////////////////////////////////////////////////////////////////////////////////
467/// Delete list tree widget.
468
470{
471 TGListTreeItem *item, *sibling;
472
473 delete [] fDNDTypeList;
474 delete fTip;
475
476 item = fFirst;
477 while (item) {
478 PDeleteChildren(item);
479 sibling = item->fNextsibling;
480 delete item;
481 item = sibling;
482 }
483}
484
485//--- text utility functions
486
487////////////////////////////////////////////////////////////////////////////////
488/// Returns height of currently used font.
489
491{
492 if (!fgDefaultFont)
493 fgDefaultFont = gClient->GetResourcePool()->GetIconFont();
494 return fgDefaultFont->TextHeight();
495}
496
497////////////////////////////////////////////////////////////////////////////////
498/// Returns ascent of currently used font.
499
501{
503 if (!fgDefaultFont)
504 fgDefaultFont = gClient->GetResourcePool()->GetIconFont();
506 return m.fAscent;
507}
508
509////////////////////////////////////////////////////////////////////////////////
510/// Returns text width relative to currently used font.
511
513{
514 if (!fgDefaultFont)
515 fgDefaultFont = gClient->GetResourcePool()->GetIconFont();
516 return fgDefaultFont->TextWidth(c);
517}
518
519//---- highlighting utilities
520
521////////////////////////////////////////////////////////////////////////////////
522/// Highlight tree item.
523
525{
526 if (item) {
527 if ((item == fSelected) && !state) {
528 fSelected = 0;
529 if (draw) DrawItemName(fId, item);
530 } else if (state != item->IsActive()) { // !!!! leave active alone ...
531 item->SetActive(state);
532 if (draw) DrawItemName(fId, item);
533 }
534 }
535}
536
537////////////////////////////////////////////////////////////////////////////////
538/// Higlight item children.
539
541{
542 while (item) {
543 HighlightItem(item, state, draw);
544 if (item->fFirstchild)
545 HighlightChildren(item->fFirstchild, state, (item->IsOpen()) ? draw : kFALSE);
546 item = item->fNextsibling;
547 }
548}
549
550////////////////////////////////////////////////////////////////////////////////
551/// Unselect all items.
552
554{
557}
558
559////////////////////////////////////////////////////////////////////////////////
560/// Handle button events in the list tree.
561
563{
564 TGListTreeItem *item;
565
566 if (fTip) fTip->Hide();
567
568 Int_t page = 0;
569 if (event->fCode == kButton4 || event->fCode == kButton5) {
570 if (!fCanvas) return kTRUE;
571 if (fCanvas->GetContainer()->GetHeight()) {
572// page = Int_t(Float_t(fCanvas->GetViewPort()->GetHeight() *
573// fCanvas->GetViewPort()->GetHeight()) /
574// fCanvas->GetContainer()->GetHeight());
575 // choose page size either 1/5 of viewport or 5 lines (90)
576 Int_t r = fCanvas->GetViewPort()->GetHeight() / 5;
577 page = TMath::Min(r, 90);
578 }
579 }
580
581 if (event->fCode == kButton4) {
582 //scroll up
583 Int_t newpos = fCanvas->GetVsbPosition() - page;
584 if (newpos < 0) newpos = 0;
585 fCanvas->SetVsbPosition(newpos);
586 return kTRUE;
587 }
588 if (event->fCode == kButton5) {
589 // scroll down
590 Int_t newpos = fCanvas->GetVsbPosition() + page;
591 fCanvas->SetVsbPosition(newpos);
592 return kTRUE;
593 }
594
595 if (event->fType == kButtonPress) {
596 if ((item = FindItem(event->fY)) != 0) {
597 if (event->fCode == kButton1) {
598 Int_t minx, maxx;
599 Int_t minxchk = 0, maxxchk = 0;
600 if (item->HasCheckBox() && item->GetCheckBoxPicture()) {
601 minxchk = (item->fXtext - item->GetCheckBoxPicture()->GetWidth());
602 maxxchk = (item->fXtext - 4);
603 maxx = maxxchk - Int_t(item->GetPicWidth()) - 8;
604 minx = minxchk - Int_t(item->GetPicWidth()) - 16;
605 }
606 else {
607 maxx = (item->fXtext - Int_t(item->GetPicWidth())) - 8;
608 minx = (item->fXtext - Int_t(item->GetPicWidth())) - 16;
609 }
610 if ((item->HasCheckBox()) && (event->fX < maxxchk) &&
611 (event->fX > minxchk))
612 {
613 ToggleItem(item);
614 if (fCheckMode == kRecursive) {
615 CheckAllChildren(item, item->IsChecked());
616 }
617 UpdateChecked(item, kTRUE);
618 Checked((TObject *)item->GetUserData(), item->IsChecked());
619 return kTRUE;
620 }
621 if ((event->fX < maxx) && (event->fX > minx)) {
622 item->SetOpen(!item->IsOpen());
624 return kTRUE;
625 }
626 }
627 // DND specific
628 if (event->fCode == kButton1) {
629 fXDND = event->fX;
630 fYDND = event->fY;
631 fBdown = kTRUE;
632 }
633 if (!fUserControlled) {
636 //item->fActive = kTRUE; // this is done below w/redraw
637 fCurrent = fSelected = item;
638 HighlightItem(item, kTRUE, kTRUE);
640 event->fCode, (event->fYRoot << 16) | event->fXRoot);
641 }
642 else {
643 fCurrent = fSelected = item;
645 }
646 Clicked(item, event->fCode);
647 Clicked(item, event->fCode, event->fXRoot, event->fYRoot);
648 Clicked(item, event->fCode, event->fState, event->fXRoot, event->fYRoot);
649 }
650 }
651 if (event->fType == kButtonRelease) {
652 fBdown = kFALSE;
653 }
654 return kTRUE;
655}
656
657////////////////////////////////////////////////////////////////////////////////
658/// Handle double click event in the list tree (only for kButton1).
659
661{
662 TGListTreeItem *item = 0;
663
664 if (event->fCode == kButton4 || event->fCode == kButton5) {
665 return kFALSE;
666 }
667 // If fDisableOpen is set, only send message and emit signals.
668 // It allows user to customize handling of double click events.
669 if (fDisableOpen && event->fCode == kButton1 && (item = FindItem(event->fY)) != 0) {
671 event->fCode, (event->fYRoot << 16) | event->fXRoot);
672 DoubleClicked(item, event->fCode);
673 DoubleClicked(item, event->fCode, event->fXRoot, event->fYRoot);
674 return kTRUE;
675 }
676 item = FindItem(event->fY);
677
678 // Otherwise, just use default behaviour (open item).
679 if (event->fCode == kButton1 && item) {
681 item->SetOpen(!item->IsOpen());
682 if (!fUserControlled) {
683 if (item != fSelected) { // huh?!
684 if (fSelected) fSelected->SetActive(kFALSE); // !!!!
686 HighlightItem(item, kTRUE, kTRUE);
687 }
688 }
690 event->fCode, (event->fYRoot << 16) | event->fXRoot);
691 DoubleClicked(item, event->fCode);
692 DoubleClicked(item, event->fCode, event->fXRoot, event->fYRoot);
693 }
694 if (!fUserControlled)
695 fSelected = item;
696 return kTRUE;
697}
698
699////////////////////////////////////////////////////////////////////////////////
700/// Handle mouse crossing event.
701
703{
704 if (event->fType == kLeaveNotify) {
705 if (fTip) {
706 fTip->Hide();
707 fTipItem = 0;
708 }
709 if (!fUserControlled) {
710 if (fCurrent)
711 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
712 if (fBelowMouse)
713 DrawOutline(fId, fBelowMouse, 0xffffff, kTRUE);
714 fCurrent = 0;
715 }
716 if (fBelowMouse) {
717 fBelowMouse = 0;
718 MouseOver(0);
719 MouseOver(0, event->fState);
720 }
721 }
723 return kTRUE;
724}
725
726////////////////////////////////////////////////////////////////////////////////
727/// Handle dragging position events.
728
730 Int_t /*xroot*/, Int_t /*yroot*/)
731{
732 static TGListTreeItem *olditem = 0;
733 TGListTreeItem *item;
734 if ((item = FindItem(y)) != 0) {
735 if (item->IsDNDTarget()) {
736 fDropItem = item;
737 if (olditem)
738 HighlightItem(olditem, kFALSE, kTRUE);
739 HighlightItem(item, kTRUE, kTRUE);
740 olditem = item;
741 return action;
742 }
743 }
744 fDropItem = 0;
745 if (olditem) {
746 HighlightItem(olditem, kFALSE, kTRUE);
747 olditem = 0;
748 }
749 return kNone;
750}
751
752////////////////////////////////////////////////////////////////////////////////
753/// Handle drag enter events.
754
756{
757 Atom_t ret = kNone;
758 for (int i = 0; typelist[i] != kNone; ++i) {
759 if (typelist[i] == fDNDTypeList[0])
760 ret = fDNDTypeList[0];
761 if (typelist[i] == fDNDTypeList[1])
762 ret = fDNDTypeList[1];
763 }
764 return ret;
765}
766
767////////////////////////////////////////////////////////////////////////////////
768/// Handle drag leave events.
769
771{
772 return kTRUE;
773}
774
775////////////////////////////////////////////////////////////////////////////////
776/// Handle drop events.
777
779{
780 DataDropped(fDropItem, data);
782 //ClearHighlighted();
783 return kTRUE;
784}
785
786////////////////////////////////////////////////////////////////////////////////
787/// Emit DataDropped() signal.
788
790{
791 Long_t args[2];
792
793 args[0] = (Long_t)item;
794 args[1] = (Long_t)data;
795
796 Emit("DataDropped(TGListTreeItem*,TDNDData*)", args);
797}
798
799////////////////////////////////////////////////////////////////////////////////
800/// Handle mouse motion event. Used to set tool tip, to emit
801/// MouseOver() signal and for DND handling.
802
804{
805 TGListTreeItem *item;
807
808 if (gDNDManager->IsDragging()) {
809 gDNDManager->Drag(event->fXRoot, event->fYRoot,
811 } else if ((item = FindItem(event->fY)) != 0) {
812 if (!fUserControlled) {
813 if (fCurrent)
814 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
815 if (fBelowMouse)
816 DrawOutline(fId, fBelowMouse, 0xffffff, kTRUE);
817 DrawOutline(fId, item);
818 fCurrent = item;
819 }
820 if (item != fBelowMouse) {
821 fBelowMouse = item;
824 }
825
826 if (item->HasCheckBox() && item->GetCheckBoxPicture()) {
827 if ((event->fX < (item->fXtext - 4) &&
828 (event->fX > (item->fXtext - (Int_t)item->GetCheckBoxPicture()->GetWidth()))))
829 {
830 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kPointer));
831 return kTRUE;
832 }
833 else {
834 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kHand));
835 }
836 }
837 if (!gDNDManager->IsDragging()) {
838 if (fBdown && ((abs(event->fX - fXDND) > 2) || (abs(event->fY - fYDND) > 2))) {
839 if (gDNDManager && item->IsDNDSource()) {
841 fBuf->Reset();
842 // !!!!! Here check virtual Bool_t HandlesDragAndDrop()
843 // and let the item handle this.
844 if (item->GetUserData()) {
845 TObject *obj = static_cast<TObject *>(item->GetUserData());
846 if (dynamic_cast<TObject *>(obj)) {
847 TObjString *ostr = dynamic_cast<TObjString *>(obj);
848 if (ostr) {
849 TString& str = ostr->String();
850 if (str.BeginsWith("file://")) {
852 fDNDData.fData = (void *)strdup(str.Data());
853 fDNDData.fDataLength = str.Length()+1;
854 }
855 }
856 else {
858 fBuf->WriteObject((TObject *)item->GetUserData());
861 }
862 }
863 }
864 else {
866 TString str = TString::Format("file://%s/%s\r\n",
868 item->GetText());
869 fDNDData.fData = (void *)strdup(str.Data());
870 fDNDData.fDataLength = str.Length()+1;
871 }
872 if (item->GetPicture()) {
873 TString xmpname = item->GetPicture()->GetName();
874 if (xmpname.EndsWith("_t.xpm"))
875 xmpname.ReplaceAll("_t.xpm", "_s.xpm");
876 if (xmpname.EndsWith("_t.xpm__16x16"))
877 xmpname.ReplaceAll("_t.xpm__16x16", "_s.xpm");
878 const TGPicture *pic = fClient->GetPicture(xmpname.Data());
879 if (!pic) pic = item->GetPicture();
880 if (pic) SetDragPixmap(pic);
881 }
882 gDNDManager->StartDrag(this, event->fXRoot, event->fYRoot);
883 }
884 }
885 }
886 if (gDNDManager->IsDragging()) {
887 gDNDManager->Drag(event->fXRoot, event->fYRoot,
889 } else {
890 if (fTipItem == item) return kTRUE;
891 if (!fUserControlled) { // !!!! what is this? It was called above once?
892 MouseOver(item);
893 MouseOver(item, event->fState);
894 }
895 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kHand));
896 }
897
898 if (fTip)
899 fTip->Hide();
900
901 if (item->GetTipTextLength() > 0) {
902
903 SetToolTipText(item->GetTipText(), item->fXtext,
904 item->fY - pos.fY + item->fHeight, 1000);
905
906 } else if (fAutoTips && item->GetUserData()) {
907 // must derive from TObject (in principle user can put pointer
908 // to anything in user data field). Add check.
909 TObject *obj = (TObject *)item->GetUserData();
910 if (obj && obj->IsA()->IsTObject()) {
911 SetToolTipText(obj->GetTitle(), item->fXtext,
912 item->fY - pos.fY + item->fHeight, 1000);
913 }
914 }
915 fTipItem = item;
916 } else {
917 if (fBelowMouse) {
918 fBelowMouse = 0;
921 }
922 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kPointer));
923 }
924 return kTRUE;
925}
926
927////////////////////////////////////////////////////////////////////////////////
928/// The key press event handler converts a key press to some line editor
929/// action.
930
932{
933 char input[10];
934 UInt_t keysym;
935 TGListTreeItem *item = 0;
936
937 fLastEventState = event->fState;
938 if (fTip) fTip->Hide();
939
940 if (event->fType == kGKeyPress) {
941 gVirtualX->LookupString(event, input, sizeof(input), keysym);
942
943 if (!event->fState && (EKeySym)keysym == kKey_Escape) {
945 }
946
947 item = fCurrent;
948 if (!item) return kFALSE;
949
951 KeyPressed(item, keysym, event->fState);
952
954 return kTRUE;
955
956 switch ((EKeySym)keysym) {
957 case kKey_Enter:
958 case kKey_Return:
959 event->fType = kButtonPress;
960 event->fCode = kButton1;
961
962 if (fSelected == item) {
963 // treat 'Enter' and 'Return' as a double click
965 item->SetOpen(!item->IsOpen());
966 DoubleClicked(item, 1);
967 } else {
968 // treat 'Enter' and 'Return' as a click
972 fSelected = item;
974 HighlightItem(item, kTRUE, kTRUE);
975 Clicked(item, 1);
976 Clicked(item, 1, event->fXRoot, event->fYRoot);
977 Clicked(item, 1, event->fState, event->fXRoot, event->fYRoot);
978 }
979 break;
980 case kKey_Space:
981 if (item->HasCheckBox()) {
982 ToggleItem(item);
983 if (fCheckMode == kRecursive) {
984 CheckAllChildren(item, item->IsChecked());
985 }
986 UpdateChecked(item, kTRUE);
987 Checked((TObject *)item->GetUserData(), item->IsChecked());
988 }
989 break;
990 case kKey_F3:
991 Search(kFALSE);
992 break;
993 case kKey_F5:
994 Layout();
995 break;
996 case kKey_F7:
997 Search();
998 break;
999 case kKey_Left:
1000 ClearViewPort();
1001 item->SetOpen(kFALSE);
1002 break;
1003 case kKey_Right:
1004 ClearViewPort();
1005 item->SetOpen(kTRUE);
1006 break;
1007 case kKey_Up:
1008 LineUp(event->fState & kKeyShiftMask);
1009 break;
1010 case kKey_Down:
1011 LineDown(event->fState & kKeyShiftMask);
1012 break;
1013 case kKey_PageUp:
1014 PageUp(event->fState & kKeyShiftMask);
1015 break;
1016 case kKey_PageDown:
1017 PageDown(event->fState & kKeyShiftMask);
1018 break;
1019 case kKey_Home:
1020 Home(event->fState & kKeyShiftMask);
1021 break;
1022 case kKey_End:
1023 End(event->fState & kKeyShiftMask);
1024 break;
1025 default:
1026 break;
1027 }
1028 if (event->fState & kKeyControlMask) { // Ctrl key modifier pressed
1029 switch((EKeySym)keysym & ~0x20) { // treat upper and lower the same
1030 case kKey_F:
1031 Search();
1032 break;
1033 case kKey_G:
1034 Search(kFALSE);
1035 break;
1036 default:
1037 return kTRUE;
1038 }
1039 }
1040
1041 }
1042 return kTRUE;
1043}
1044
1045////////////////////////////////////////////////////////////////////////////////
1046/// Signal emitted when pointer is over entry.
1047
1049{
1050 Emit("MouseOver(TGListTreeItem*)", (Long_t)entry);
1051}
1052
1053////////////////////////////////////////////////////////////////////////////////
1054/// Signal emitted when pointer is over entry.
1055
1057{
1058 Long_t args[2];
1059 args[0] = (Long_t)entry;
1060 args[1] = mask;
1061 Emit("MouseOver(TGListTreeItem*,UInt_t)", args);
1062}
1063
1064////////////////////////////////////////////////////////////////////////////////
1065/// Signal emitted when keyboard key pressed
1066///
1067/// entry - selected item
1068/// keysym - defined in "KeySymbols.h"
1069/// mask - modifier key mask, defined in "GuiTypes.h"
1070///
1071/// const Mask_t kKeyShiftMask = BIT(0);
1072/// const Mask_t kKeyLockMask = BIT(1);
1073/// const Mask_t kKeyControlMask = BIT(2);
1074/// const Mask_t kKeyMod1Mask = BIT(3); // typically the Alt key
1075/// const Mask_t kButton1Mask = BIT(8);
1076/// const Mask_t kButton2Mask = BIT(9);
1077/// const Mask_t kButton3Mask = BIT(10);
1078/// const Mask_t kButton4Mask = BIT(11);
1079/// const Mask_t kButton5Mask = BIT(12);
1080/// const Mask_t kAnyModifier = BIT(15);
1081
1083{
1084 Long_t args[3];
1085 args[0] = (Long_t)entry;
1086 args[1] = (Long_t)keysym;
1087 args[2] = (Long_t)mask;
1088 Emit("KeyPressed(TGListTreeItem*,ULong_t,ULong_t)", args);
1090}
1091
1092////////////////////////////////////////////////////////////////////////////////
1093/// Emit ReturnPressed() signal.
1094
1096{
1097 Emit("ReturnPressed(TGListTreeItem*)", (Long_t)entry);
1098}
1099
1100////////////////////////////////////////////////////////////////////////////////
1101/// Emit Checked() signal.
1102
1104{
1105 Long_t args[2];
1106
1107 args[0] = (Long_t)entry;
1108 args[1] = on;
1109
1110 Emit("Checked(TObject*,Bool_t)", args);
1111}
1112
1113////////////////////////////////////////////////////////////////////////////////
1114/// Emit Clicked() signal.
1115
1117{
1118 Long_t args[2];
1119
1120 args[0] = (Long_t)entry;
1121 args[1] = btn;
1122
1123 Emit("Clicked(TGListTreeItem*,Int_t)", args);
1124}
1125
1126////////////////////////////////////////////////////////////////////////////////
1127/// Emit Clicked() signal.
1128
1130{
1131 Long_t args[4];
1132
1133 args[0] = (Long_t)entry;
1134 args[1] = btn;
1135 args[2] = x;
1136 args[3] = y;
1137
1138 Emit("Clicked(TGListTreeItem*,Int_t,Int_t,Int_t)", args);
1139}
1140
1141////////////////////////////////////////////////////////////////////////////////
1142/// Emit Clicked() signal.
1143
1145{
1146 Long_t args[5];
1147
1148 args[0] = (Long_t)entry;
1149 args[1] = btn;
1150 args[2] = mask;
1151 args[3] = x;
1152 args[4] = y;
1153
1154 Emit("Clicked(TGListTreeItem*,Int_t,UInt_t,Int_t,Int_t)", args);
1155}
1156
1157////////////////////////////////////////////////////////////////////////////////
1158/// Emit DoubleClicked() signal.
1159
1161{
1162 Long_t args[2];
1163
1164 args[0] = (Long_t)entry;
1165 args[1] = btn;
1166
1167 Emit("DoubleClicked(TGListTreeItem*,Int_t)", args);
1168}
1169
1170////////////////////////////////////////////////////////////////////////////////
1171/// Emit DoubleClicked() signal.
1172
1174{
1175 Long_t args[4];
1176
1177 args[0] = (Long_t)entry;
1178 args[1] = btn;
1179 args[2] = x;
1180 args[3] = y;
1181
1182 Emit("DoubleClicked(TGListTreeItem*,Int_t,Int_t,Int_t)", args);
1183}
1184
1185////////////////////////////////////////////////////////////////////////////////
1186/// Move content to the top.
1187
1188void TGListTree::Home(Bool_t /*select*/)
1189{
1191}
1192
1193////////////////////////////////////////////////////////////////////////////////
1194/// Move content to the bottom.
1195
1196void TGListTree::End(Bool_t /*select*/)
1197{
1199}
1200
1201////////////////////////////////////////////////////////////////////////////////
1202/// Move content one page up.
1203
1205{
1206 if (!fCanvas) return;
1207
1209
1210 Int_t newpos = fCanvas->GetVsbPosition() - dim.fHeight;
1211 if (newpos<0) newpos = 0;
1212
1213 fCanvas->SetVsbPosition(newpos);
1214}
1215
1216////////////////////////////////////////////////////////////////////////////////
1217/// Move content one page down.
1218
1220{
1221 if (!fCanvas) return;
1222
1224
1225 Int_t newpos = fCanvas->GetVsbPosition() + dim.fHeight;
1226
1227 fCanvas->SetVsbPosition(newpos);
1228}
1229
1230////////////////////////////////////////////////////////////////////////////////
1231/// Move content one item-size up.
1232
1234{
1235 Int_t height = 0;
1236 if (!fCurrent) return;
1237
1239 const TGPicture *pic1 = fCurrent->GetPicture();
1240 if (pic1) height = pic1->GetHeight() + fVspacing;
1241 else height = fVspacing + 16;
1242 Int_t findy = (fCurrent->fY - height) + (fMargin - pos.fY);
1243 TGListTreeItem *next = FindItem(findy);
1244 if (next && (next != fCurrent)) {
1245 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
1246 if (findy <= 2*height) {
1247 Int_t newpos = fCanvas->GetVsbPosition() - height;
1248 if (newpos<0) newpos = 0;
1249 fCanvas->SetVsbPosition(newpos);
1250 }
1251 DrawOutline(fId, next);
1252 fCurrent = next;
1253 }
1254}
1255
1256////////////////////////////////////////////////////////////////////////////////
1257/// Move content one item-size down.
1258
1260{
1261 Int_t height;
1262 if (!fCurrent) return;
1263
1266 const TGPicture *pic1 = fCurrent->GetPicture();
1267 if (pic1) height = pic1->GetHeight() + fVspacing;
1268 else height = fVspacing + 16;
1269 Int_t findy = (fCurrent->fY + height) + (fMargin - pos.fY);
1270 TGListTreeItem *next = FindItem(findy);
1271 if (next && (next != fCurrent)) {
1272 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
1273 if (findy >= ((Int_t)dim.fHeight - 2*height)) {
1274 Int_t newpos = fCanvas->GetVsbPosition() + height;
1275 if (newpos<0) newpos = 0;
1276 fCanvas->SetVsbPosition(newpos);
1277 }
1278 DrawOutline(fId, next);
1279 fCurrent = next;
1280 }
1281}
1282
1283////////////////////////////////////////////////////////////////////////////////
1284/// Move content to position of item. If item is 0, move to position
1285/// of currently selected item.
1286
1288{
1289 TGListTreeItem *it = item;
1290
1291 if (!it) it = fSelected;
1292 if (!it) {
1293 HighlightItem(fFirst); // recursive call of this function
1294 return;
1295 }
1296
1297 Int_t y = 0;
1298 Int_t yparent = 0;
1299 Int_t vh = 0;
1300 Int_t v = 0;
1301
1302 if (it) {
1303 y = it->fY;
1304 if (it->GetParent()) yparent = it->GetParent()->fY;
1305 }
1306
1307 if (y==0) y = yparent; // item->fY not initiated yet
1308
1309 if (fCanvas->GetVScrollbar()->IsMapped()) {
1311
1312 if (y<fCanvas->GetVScrollbar()->GetPosition()) {
1315 } else if (y+(Int_t)it->fHeight>vh) {
1317 y+(Int_t)it->fHeight-(Int_t)fViewPort->GetHeight()/2);
1318 if (v<0) v = 0;
1320 }
1321 }
1322}
1323
1324////////////////////////////////////////////////////////////////////////////////
1325/// Invokes search dialog. Looks for item with the entered name.
1326
1328{
1329 Int_t ret = 0;
1330 char msg[256];
1331 static TString buf;
1332
1333 TGSearchType *srch = new TGSearchType;
1334 srch->fBuffer = (char *)StrDup(buf.Data());
1335
1336 TGListTreeItem *item;
1337 if (close || buf.IsNull())
1338 new TGSearchDialog(fClient->GetDefaultRoot(), fCanvas, 400, 150, srch, &ret);
1339 else if (!buf.IsNull()) ret = 1;
1340
1341 if (ret) {
1342 item = FindItemByPathname(srch->fBuffer);
1343 if (!item) {
1344 snprintf(msg, 255, "Couldn't find \"%s\"", srch->fBuffer);
1345 gVirtualX->Bell(20);
1346 new TGMsgBox(fClient->GetDefaultRoot(), fCanvas, "Container", msg,
1348 } else {
1350 HighlightItem(item);
1351 }
1352 }
1353 buf = srch->fBuffer;
1354 delete srch;
1355}
1356
1357//---- drawing functions
1358
1359////////////////////////////////////////////////////////////////////////////////
1360/// Redraw list tree.
1361
1363{
1364 static GContext_t gcBg = 0;
1365
1366 // sanity checks
1367 if (y > (Int_t)fViewPort->GetHeight()) {
1368 return;
1369 }
1370
1371 y = y < 0 ? 0 : y;
1372 UInt_t w = fViewPort->GetWidth();
1373
1374 // more sanity checks
1375 if (((Int_t)w < 1) || (w > 32768) || ((Int_t)h < 1)) {
1376 return;
1377 }
1378
1379 Pixmap_t pixmap = gVirtualX->CreatePixmap(fId, w, fViewPort->GetHeight());
1380
1381 if (!gcBg) {
1382 GCValues_t gcValues;
1383 gcValues.fForeground = fBackground;
1384 gcValues.fForeground = fBackground;
1385 gcValues.fGraphicsExposures = kTRUE;
1387 gcBg = gVirtualX->CreateGC(fId, &gcValues);
1388 }
1389
1390 gVirtualX->SetForeground(gcBg, fBackground);
1391 gVirtualX->FillRectangle(pixmap, gcBg, 0, 0, w, fViewPort->GetHeight());
1392
1393 Draw(pixmap, 0, fViewPort->GetHeight());
1394
1395 gVirtualX->CopyArea(pixmap, fId, gcBg, 0, y, w, fViewPort->GetHeight(), 0, y);
1396
1397 gVirtualX->DeletePixmap(pixmap);
1398 gVirtualX->Update(kFALSE);
1399}
1400
1401////////////////////////////////////////////////////////////////////////////////
1402/// Draw list tree widget.
1403
1404void TGListTree::Draw(Handle_t id, Int_t yevent, Int_t hevent)
1405{
1406 TGListTreeItem *item;
1407 Int_t x, y, xbranch;
1408 UInt_t width, height, old_width, old_height;
1409
1410 // Overestimate the expose region to be sure to draw an item that gets
1411 // cut by the region
1412 fExposeTop = yevent - FontHeight();
1413 fExposeBottom = yevent + hevent + FontHeight();
1414 old_width = fDefw;
1415 old_height = fDefh;
1416 fDefw = fDefh = 1;
1417
1419 x = 2-pos.fX;
1420 y = fMargin;
1421 item = fFirst;
1422
1423 while (item) {
1424 xbranch = -1;
1425
1426 DrawItem(id, item, x, y, &xbranch, &width, &height);
1427
1428 width += pos.fX + x + fHspacing + fMargin;
1429
1430 if (width > fDefw) fDefw = width;
1431
1432 y += height + fVspacing;
1433 if (item->fFirstchild && item->IsOpen()) {
1434 y = DrawChildren(id, item->fFirstchild, x, y, xbranch);
1435 }
1436
1437 item = item->fNextsibling;
1438 }
1439
1440 fDefh = y + fMargin;
1441
1442 if ((old_width != fDefw) || (old_height != fDefh)) {
1443 fCanvas->Layout();
1444 }
1445}
1446
1447////////////////////////////////////////////////////////////////////////////////
1448/// Draw children of item in list tree.
1449
1451 Int_t x, Int_t y, Int_t xroot)
1452{
1453 UInt_t width, height;
1454 Int_t xbranch;
1456
1457 x += fIndent + (Int_t)item->fParent->GetPicWidth();
1458 while (item) {
1459 xbranch = xroot;
1460
1461 DrawItem(id, item, x, y, &xbranch, &width, &height);
1462
1463 width += pos.fX + x + fHspacing + fMargin;
1464 if (width > fDefw) fDefw = width;
1465
1466 y += height + fVspacing;
1467 if ((item->fFirstchild) && (item->IsOpen())) {
1468 y = DrawChildren(id, item->fFirstchild, x, y, xbranch);
1469 }
1470
1471 item = item->fNextsibling;
1472 }
1473 return y;
1474}
1475
1476////////////////////////////////////////////////////////////////////////////////
1477/// Draw list tree item.
1478
1480 Int_t *xroot, UInt_t *retwidth, UInt_t *retheight)
1481{
1482 Int_t xpic1, ypic1, xbranch, ybranch, xtext, ytext = 0, xline, yline, xc;
1483 Int_t xpic2 = 0;
1484 UInt_t height;
1485 const TGPicture *pic1 = item->GetPicture();
1486 const TGPicture *pic2 = item->GetCheckBoxPicture();
1487
1488 // Compute the height of this line
1489 height = FontHeight();
1490
1491 xline = 0;
1492 xpic1 = x;
1493 xtext = x + fHspacing + (Int_t)item->GetPicWidth();
1494 if (pic2) {
1495 if (pic2->GetHeight() > height) {
1496 ytext = y + (Int_t)((pic2->GetHeight() - height) >> 1);
1497 height = pic2->GetHeight();
1498 } else {
1499 ytext = y;
1500 }
1501 if (pic1) xpic2 = xpic1 + pic1->GetWidth() + 1;
1502 else xpic2 = xpic1 + 1;
1503 xtext += pic2->GetWidth();
1504 } else {
1505 ypic1 = y;
1506 xline = 0;
1507 }
1508 if (pic1) {
1509 if (pic1->GetHeight() > height) {
1510 ytext = y + (Int_t)((pic1->GetHeight() - height) >> 1);
1511 height = pic1->GetHeight();
1512 ypic1 = y;
1513 } else {
1514#ifdef R__HAS_COCOA
1515 if (!pic2)//DO NOT MODIFY ytext, it WAS ADJUSTED already!
1516#endif
1517 ytext = y;
1518 ypic1 = y + (Int_t)((height - pic1->GetHeight()) >> 1);
1519 }
1520 xbranch = xpic1 + (Int_t)(pic1->GetWidth() >> 1);
1521 ybranch = ypic1 + (Int_t)pic1->GetHeight();
1522 yline = ypic1 + (Int_t)(pic1->GetHeight() >> 1);
1523 if (xline == 0) xline = xpic1;
1524 } else {
1525 if (xline == 0) xline = xpic1;
1526 ypic1 = ytext = y;
1527 xbranch = xpic1 + (Int_t)(item->GetPicWidth() >> 1);
1528 yline = ybranch = ypic1 + (Int_t)(height >> 1);
1529 yline = ypic1 + (Int_t)(height >> 1);
1530 }
1531
1532 // height must be even, otherwise our dashed line wont appear properly
1533 //++height; height &= ~1;
1534
1535 // Save the basic graphics info for use by other functions
1536 item->fY = y;
1537 item->fXtext = xtext;
1538 item->fYtext = ytext;
1539 item->fHeight = height;
1540
1541 // projected coordinates
1544 Int_t yp = y - pos.fY;
1545 Int_t ylinep = yline - pos.fY;
1546 Int_t ybranchp = ybranch - pos.fY;
1547 Int_t ypicp = ypic1 - pos.fY;
1548
1549 if ((yp >= fExposeTop) && (yp <= (Int_t)dim.fHeight))
1550 {
1551 DrawItemName(id, item);
1552 if (*xroot >= 0) {
1553 xc = *xroot;
1554
1555 if (item->fNextsibling) {
1556 gVirtualX->DrawLine(id, fLineGC, xc, yp, xc, yp+height);
1557 } else {
1558 gVirtualX->DrawLine(id, fLineGC, xc, yp, xc, ylinep);
1559 }
1560
1561 TGListTreeItem *p = item->fParent;
1562 while (p) {
1563 xc -= (fIndent + (Int_t)item->GetPicWidth());
1564 if (p->fNextsibling) {
1565 gVirtualX->DrawLine(id, fLineGC, xc, yp, xc, yp+height);
1566 }
1567 p = p->fParent;
1568 }
1569 gVirtualX->DrawLine(id, fLineGC, *xroot, ylinep, xpic1, ylinep);
1570 DrawNode(id, item, *xroot, yline);
1571 }
1572 if (item->IsOpen() && item->fFirstchild) {
1573 gVirtualX->DrawLine(id, fLineGC, xbranch, ybranchp, xbranch,
1574 yp+height);
1575 }
1576 if (pic1)
1577 pic1->Draw(id, fDrawGC, xpic1, ypicp);
1578 if (pic2)
1579 pic2->Draw(id, fDrawGC, xpic2, ypicp);
1580 }
1581
1582 *xroot = xbranch;
1583 *retwidth = TextWidth(item->GetText()) + item->GetPicWidth();
1584 *retheight = height;
1585}
1586
1587////////////////////////////////////////////////////////////////////////////////
1588/// Draw a outline of color 'col' around an item.
1589
1591 Bool_t clear)
1592{
1595
1596 if (clear) {
1597 gVirtualX->SetForeground(fDrawGC, fCanvas->GetContainer()->GetBackground());
1598 //ClearViewPort(); // time consuming!!!
1599 }
1600 else
1601 gVirtualX->SetForeground(fDrawGC, col);
1602
1603#ifdef R__HAS_COCOA
1604 gVirtualX->DrawRectangle(id, fDrawGC, 1, item->fY - pos.fY, dim.fWidth-2, item->fHeight + 1);
1605#else
1606 gVirtualX->DrawRectangle(id, fDrawGC, 1, item->fYtext-pos.fY-2,
1607 dim.fWidth-3, FontHeight()+4);
1608#endif
1609 gVirtualX->SetForeground(fDrawGC, fgBlackPixel);
1610}
1611
1612////////////////////////////////////////////////////////////////////////////////
1613/// Draw active item with its active color.
1614
1616{
1617 UInt_t width;
1620
1621 width = dim.fWidth-2;
1622 gVirtualX->SetForeground(fDrawGC, item->GetActiveColor());
1623
1624#ifdef R__HAS_COCOA
1625 gVirtualX->FillRectangle(id, fDrawGC, 1, item->fY - pos.fY, width, item->fHeight + 1);
1626#else
1627 gVirtualX->FillRectangle(id, fDrawGC, 1, item->fYtext-pos.fY-1, width,
1628 FontHeight()+3);
1629#endif
1630 gVirtualX->SetForeground(fDrawGC, fgBlackPixel);
1631 gVirtualX->DrawString(id, fActiveGC, item->fXtext,
1632 item->fYtext - pos.fY + FontAscent(),
1633 item->GetText(), item->GetTextLength());
1634}
1635
1636////////////////////////////////////////////////////////////////////////////////
1637/// Draw name of list tree item.
1638
1640{
1643
1644 if (item->IsActive()) {
1645 DrawActive(id, item);
1646 }
1647 else { // if (!item->IsActive() && (item != fSelected)) {
1648 gVirtualX->FillRectangle(id, fHighlightGC, item->fXtext,
1649 item->fYtext-pos.fY, dim.fWidth-item->fXtext-2,
1650 FontHeight()+1);
1651 gVirtualX->DrawString(id, fDrawGC,
1652 item->fXtext, item->fYtext-pos.fY + FontAscent(),
1653 item->GetText(), item->GetTextLength());
1654 }
1655 if (item == fCurrent) {
1656 DrawOutline(id, item);
1657 }
1658
1659 if (fColorMode != 0 && item->HasColor()) {
1660 UInt_t width = TextWidth(item->GetText());
1661 gVirtualX->SetForeground(fColorGC, TColor::Number2Pixel(item->GetColor()));
1663 Int_t y = item->fYtext-pos.fY + FontAscent() + 2;
1664 gVirtualX->DrawLine(id, fColorGC, item->fXtext, y,
1665 item->fXtext + width, y);
1666 }
1667 if (fColorMode & kColorBox) {
1668 Int_t x = item->fXtext + width + 4;
1669 Int_t y = item->fYtext - pos.fY + 3;
1670 Int_t h = FontAscent() - 4;
1671 gVirtualX->FillRectangle(id, fColorGC, x, y, h, h);
1672 gVirtualX->DrawRectangle(id, fDrawGC, x, y, h, h);
1673 }
1674 }
1675}
1676
1677////////////////////////////////////////////////////////////////////////////////
1678/// Draw node (little + in box).
1679
1681{
1683 Int_t yp = y - pos.fY;
1684
1685 if (item->fFirstchild) {
1686 gVirtualX->DrawLine(id, fHighlightGC, x, yp-2, x, yp+2);
1687 gVirtualX->SetForeground(fHighlightGC, fgBlackPixel);
1688 gVirtualX->DrawLine(id, fHighlightGC, x-2, yp, x+2, yp);
1689 if (!item->IsOpen())
1690 gVirtualX->DrawLine(id, fHighlightGC, x, yp-2, x, yp+2);
1691 gVirtualX->SetForeground(fHighlightGC, fGrayPixel);
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->DrawLine(id, fHighlightGC, x-4, yp-4, x-4, yp+4);
1696 gVirtualX->SetForeground(fHighlightGC, fgWhitePixel);
1697 }
1698}
1699
1700////////////////////////////////////////////////////////////////////////////////
1701/// Set tool tip text associated with this item. The delay is in
1702/// milliseconds (minimum 250). To remove tool tip call method with
1703/// delayms = 0. To change delayms you first have to call this method
1704/// with delayms=0.
1705
1707{
1708 if (delayms == 0) {
1709 delete fTip;
1710 fTip = 0;
1711 return;
1712 }
1713
1714 if (text && strlen(text)) {
1715 if (!fTip)
1716 fTip = new TGToolTip(fClient->GetDefaultRoot(), this, text, delayms);
1717 else
1718 fTip->SetText(text);
1719 fTip->SetPosition(x, y);
1720 fTip->Reset();
1721 }
1722}
1723
1724////////////////////////////////////////////////////////////////////////////////
1725/// This function removes the specified item from the linked list.
1726/// It does not do anything with the data contained in the item, though.
1727
1729{
1730 ClearViewPort();
1731
1732 // Disentangle from front (previous-sibling, parent's first child)
1733 if (item->fPrevsibling) {
1734 item->fPrevsibling->fNextsibling = item->fNextsibling;
1735 } else {
1736 if (item->fParent)
1737 item->fParent->fFirstchild = item->fNextsibling;
1738 else
1739 fFirst = item->fNextsibling;
1740 }
1741 // Disentangle from end (next-sibling, parent's last child)
1742 if (item->fNextsibling) {
1743 item->fNextsibling->fPrevsibling = item->fPrevsibling;
1744 } else {
1745 if (item->fParent)
1746 item->fParent->fLastchild = item->fPrevsibling;
1747 else
1748 fLast = item->fPrevsibling;
1749 }
1750}
1751
1752////////////////////////////////////////////////////////////////////////////////
1753/// Delete given item. Takes care of list-tree state members
1754/// fSelected, fCurrent and fBelowMouse.
1755
1757{
1758 if (fSelected == item) {
1759 fSelected = 0;
1760 }
1761 if (fCurrent == item) {
1762 DrawOutline(fId, fCurrent, 0xffffff, kTRUE);
1763 fCurrent = item->GetPrevSibling();
1764 if (! fCurrent) {
1765 fCurrent = item->GetNextSibling();
1766 if (! fCurrent)
1767 fCurrent = item->GetParent();
1768 }
1769 }
1770 if (fBelowMouse == item) {
1771 DrawOutline(fId, fBelowMouse, 0xffffff, kTRUE);
1772 fBelowMouse = 0;
1773 MouseOver(0);
1775 }
1776
1777 delete item;
1778}
1779
1780////////////////////////////////////////////////////////////////////////////////
1781/// Recursively delete all children of an item.
1782
1784{
1785 TGListTreeItem *child = item->fFirstchild;
1786
1787 while (child) {
1788 TGListTreeItem *next = child->fNextsibling;
1789 PDeleteChildren(child);
1790 PDeleteItem(child);
1791 child = next;
1792 }
1793
1794 item->fFirstchild = item->fLastchild = 0;
1795}
1796
1797////////////////////////////////////////////////////////////////////////////////
1798/// Insert child in list.
1799
1801{
1802 TGListTreeItem *i;
1803
1804 item->fParent = parent;
1805 item->fNextsibling = item->fPrevsibling = 0;
1806
1807 if (parent) {
1808
1809 if (parent->fFirstchild) {
1810 if (parent->fLastchild) {
1811 i = parent->fLastchild;
1812 }
1813 else {
1814 i = parent->fFirstchild;
1815 while (i->fNextsibling) i = i->fNextsibling;
1816 }
1817 i->fNextsibling = item;
1818 item->fPrevsibling = i;
1819 } else {
1820 parent->fFirstchild = item;
1821 }
1822 parent->fLastchild = item;
1823
1824 } else { // if parent == 0, this is a top level entry
1825
1826 if (fFirst) {
1827 if (fLast) {
1828 i = fLast;
1829 }
1830 else {
1831 i = fFirst;
1832 while (i->fNextsibling) i = i->fNextsibling;
1833 }
1834 i->fNextsibling = item;
1835 item->fPrevsibling = i;
1836 } else {
1837 fFirst = item;
1838 }
1839 fLast = item;
1840 }
1841 if (item->HasCheckBox())
1842 UpdateChecked(item);
1843}
1844
1845////////////////////////////////////////////////////////////////////////////////
1846/// Insert a list of ALREADY LINKED children into another list
1847
1849{
1850 TGListTreeItem *next, *newnext;
1851
1852 //while (item) {
1853 // next = item->fNextsibling;
1854 // InsertChild(parent, item);
1855 // item = next;
1856 //}
1857 //return;
1858
1859 // Save the reference for the next item in the new list
1860 next = item->fNextsibling;
1861
1862 // Insert the first item in the new list into the existing list
1863 InsertChild(parent, item);
1864
1865 // The first item is inserted, with its prev and next siblings updated
1866 // to fit into the existing list. So, save the existing list reference
1867 newnext = item->fNextsibling;
1868
1869 // Now, mark the first item's next sibling to point back to the new list
1870 item->fNextsibling = next;
1871
1872 // Mark the parents of the new list to the new parent. The order of the
1873 // rest of the new list should be OK, and the second item should still
1874 // point to the first, even though the first was reparented.
1875 while (item->fNextsibling) {
1876 item->fParent = parent;
1877 item = item->fNextsibling;
1878 }
1879
1880 // Fit the end of the new list back into the existing list
1881 item->fNextsibling = newnext;
1882 if (newnext)
1883 newnext->fPrevsibling = item;
1884}
1885
1886////////////////////////////////////////////////////////////////////////////////
1887/// Search child item.
1888
1890 TGListTreeItem **finditem)
1891{
1892 UInt_t height;
1893 const TGPicture *pic;
1894
1895 while (item) {
1896 // Select the pixmap to use
1897 pic = item->GetPicture();
1898
1899 // Compute the height of this line
1900 height = FontHeight();
1901 if (pic && pic->GetHeight() > height)
1902 height = pic->GetHeight();
1903
1904 if ((findy >= y) && (findy <= y + (Int_t)height)) {
1905 *finditem = item;
1906 return -1;
1907 }
1908
1909 y += (Int_t)height + fVspacing;
1910 if (item->fFirstchild && item->IsOpen()) {
1911 y = SearchChildren(item->fFirstchild, y, findy, finditem);
1912 if (*finditem) return -1;
1913 }
1914
1915 item = item->fNextsibling;
1916 }
1917
1918 return y;
1919}
1920
1921////////////////////////////////////////////////////////////////////////////////
1922/// Find item at postion findy.
1923
1925{
1926 Int_t y;
1927 UInt_t height;
1928 TGListTreeItem *item, *finditem;
1929 const TGPicture *pic;
1931
1932 y = fMargin - pos.fY;
1933 item = fFirst;
1934 finditem = 0;
1935 while (item && !finditem) {
1936 // Select the pixmap to use
1937 pic = item->GetPicture();
1938
1939 // Compute the height of this line
1940 height = FontHeight();
1941 if (pic && (pic->GetHeight() > height))
1942 height = pic->GetHeight();
1943
1944 if ((findy >= y) && (findy <= y + (Int_t)height))
1945 return item;
1946
1947 y += (Int_t)height + fVspacing;
1948 if ((item->fFirstchild) && (item->IsOpen())) {
1949 y = SearchChildren(item->fFirstchild, y, findy, &finditem);
1950 //if (finditem) return finditem;
1951 }
1952 item = item->fNextsibling;
1953 }
1954
1955 return finditem;
1956}
1957
1958//----- Public Functions
1959
1960////////////////////////////////////////////////////////////////////////////////
1961/// Add given item to list tree.
1962
1964{
1965 InsertChild(parent, item);
1966
1967 if ((parent == 0) || (parent && parent->IsOpen()))
1968 ClearViewPort();
1969}
1970
1971////////////////////////////////////////////////////////////////////////////////
1972/// Add item to list tree. Returns new item.
1973
1975 const TGPicture *open, const TGPicture *closed,
1976 Bool_t checkbox)
1977{
1978 TGListTreeItem *item;
1979
1980 item = new TGListTreeItemStd(fClient, string, open, closed, checkbox);
1981 InsertChild(parent, item);
1982
1983 if ((parent == 0) || (parent && parent->IsOpen()))
1984 ClearViewPort();
1985 return item;
1986}
1987
1988////////////////////////////////////////////////////////////////////////////////
1989/// Add item to list tree. If item with same userData already exists
1990/// don't add it. Returns new item.
1991
1993 void *userData, const TGPicture *open,
1994 const TGPicture *closed,
1995 Bool_t checkbox)
1996{
1997 TGListTreeItem *item = FindChildByData(parent, userData);
1998 if (!item) {
1999 item = AddItem(parent, string, open, closed, checkbox);
2000 if (item) item->SetUserData(userData);
2001 }
2002
2003 return item;
2004}
2005
2006////////////////////////////////////////////////////////////////////////////////
2007/// Rename item in list tree.
2008
2009void TGListTree::RenameItem(TGListTreeItem *item, const char *string)
2010{
2011 if (item) {
2012 item->Rename(string);
2013 }
2014
2015 DoRedraw();
2016}
2017
2018////////////////////////////////////////////////////////////////////////////////
2019/// Delete item from list tree.
2020
2022{
2023 if (!fUserControlled)
2024 fCurrent = fBelowMouse = 0;
2025
2026 PDeleteChildren(item);
2027 RemoveReference(item);
2028 PDeleteItem(item);
2029
2030 fClient->NeedRedraw(this);
2031
2032 return 1;
2033}
2034
2035////////////////////////////////////////////////////////////////////////////////
2036/// Open item in list tree (i.e. show child items).
2037
2039{
2040 if (item) {
2041 item->SetOpen(kTRUE);
2042 DoRedraw(); // force layout
2043 AdjustPosition(item);
2044 }
2045}
2046
2047////////////////////////////////////////////////////////////////////////////////
2048/// Close item in list tree (i.e. hide child items).
2049
2051{
2052 if (item) {
2053 item->SetOpen(kFALSE);
2054 DoRedraw(); // force layout
2055 AdjustPosition(item);
2056 }
2057}
2058
2059////////////////////////////////////////////////////////////////////////////////
2060/// Delete item with fUserData == ptr. Search tree downwards starting
2061/// at item.
2062
2064{
2065 if (item && ptr) {
2066 if (item->GetUserData() == ptr) {
2067 DeleteItem(item);
2068 } else {
2069 if (item->IsOpen() && item->fFirstchild) {
2070 RecursiveDeleteItem(item->fFirstchild, ptr);
2071 }
2073 }
2074 }
2075 return 1;
2076}
2077
2078////////////////////////////////////////////////////////////////////////////////
2079/// Set tooltip text for this item. By default an item for which the
2080/// userData is a pointer to an TObject the TObject::GetTitle() will
2081/// be used to get the tip text.
2082
2083void TGListTree::SetToolTipItem(TGListTreeItem *item, const char *string)
2084{
2085 if (item) {
2086 item->SetTipText(string);
2087 }
2088}
2089
2090////////////////////////////////////////////////////////////////////////////////
2091/// Delete children of item from list.
2092
2094{
2095 if (!fUserControlled)
2096 fCurrent = fBelowMouse = 0;
2097
2098 PDeleteChildren(item);
2099
2100 DoRedraw();
2101
2102 return 1;
2103}
2104
2105////////////////////////////////////////////////////////////////////////////////
2106/// Make newparent the new parent of item.
2107
2109{
2110 // Remove the item from its old location.
2111 RemoveReference(item);
2112
2113 // The item is now unattached. Reparent it.
2114 InsertChild(newparent, item);
2115
2116 DoRedraw();
2117
2118 return 1;
2119}
2120
2121////////////////////////////////////////////////////////////////////////////////
2122/// Make newparent the new parent of the children of item.
2123
2125 TGListTreeItem *newparent)
2126{
2128
2129 if (item->fFirstchild) {
2130 first = item->fFirstchild;
2131 item->fFirstchild = 0;
2132
2133 InsertChildren(newparent, first);
2134
2135 DoRedraw();
2136 return 1;
2137 }
2138 return 0;
2139}
2140
2141////////////////////////////////////////////////////////////////////////////////
2142
2143extern "C"
2144Int_t Compare(const void *item1, const void *item2)
2145{
2146 return strcmp((*((TGListTreeItem **) item1))->GetText(),
2147 (*((TGListTreeItem **) item2))->GetText());
2148}
2149
2150////////////////////////////////////////////////////////////////////////////////
2151/// Sort items starting with item.
2152
2154{
2155 TGListTreeItem *first, *parent, **list;
2156 size_t i, count;
2157
2158 // Get first child in list;
2159 while (item->fPrevsibling) item = item->fPrevsibling;
2160
2161 first = item;
2162 parent = first->fParent;
2163
2164 // Count the children
2165 count = 1;
2166 while (item->fNextsibling) item = item->fNextsibling, count++;
2167 if (count <= 1) return 1;
2168
2169 list = new TGListTreeItem* [count];
2170 list[0] = first;
2171 count = 1;
2172 while (first->fNextsibling) {
2173 list[count] = first->fNextsibling;
2174 count++;
2175 first = first->fNextsibling;
2176 }
2177
2178 ::qsort(list, count, sizeof(TGListTreeItem*), ::Compare);
2179
2180 list[0]->fPrevsibling = 0;
2181 for (i = 0; i < count; i++) {
2182 if (i < count - 1)
2183 list[i]->fNextsibling = list[i + 1];
2184 if (i > 0)
2185 list[i]->fPrevsibling = list[i - 1];
2186 }
2187 list[count - 1]->fNextsibling = 0;
2188 if (parent) {
2189 parent->fFirstchild = list[0];
2190 parent->fLastchild = list[count-1];
2191 }
2192 else {
2193 fFirst = list[0];
2194 fLast = list[count-1];
2195 }
2196
2197 delete [] list;
2198
2199 DoRedraw();
2200
2201 return 1;
2202}
2203
2204////////////////////////////////////////////////////////////////////////////////
2205/// Sort siblings of item.
2206
2208{
2209 return Sort(item);
2210}
2211
2212////////////////////////////////////////////////////////////////////////////////
2213/// Sort children of item.
2214
2216{
2218
2219 if (item) {
2220 first = item->fFirstchild;
2221 if (first) {
2223 }
2224 } else {
2225 if (fFirst) {
2227 if (first) {
2229 }
2230 }
2231 }
2232 DoRedraw();
2233 return 1;
2234}
2235
2236////////////////////////////////////////////////////////////////////////////////
2237/// Find sibling of item by name.
2238
2240{
2241 // Get first child in list
2242 if (item) {
2243 while (item->fPrevsibling) {
2244 item = item->fPrevsibling;
2245 }
2246
2247 while (item) {
2248 if (strcmp(item->GetText(), name) == 0) {
2249 return item;
2250 }
2251 item = item->fNextsibling;
2252 }
2253 return item;
2254 }
2255 return 0;
2256}
2257
2258////////////////////////////////////////////////////////////////////////////////
2259/// Find sibling of item by userData.
2260
2262{
2263 // Get first child in list
2264 if (item) {
2265 while (item->fPrevsibling) {
2266 item = item->fPrevsibling;
2267 }
2268
2269 while (item) {
2270 if (item->GetUserData() == userData) {
2271 return item;
2272 }
2273 item = item->fNextsibling;
2274 }
2275 return item;
2276 }
2277 return 0;
2278}
2279
2280////////////////////////////////////////////////////////////////////////////////
2281/// Find child of item by name.
2282
2284{
2285 // Get first child in list
2286 if (item && item->fFirstchild) {
2287 item = item->fFirstchild;
2288 } else if (!item && fFirst) {
2289 item = fFirst;
2290 } else {
2291 item = 0;
2292 }
2293
2294 while (item) {
2295 if (strcmp(item->GetText(), name) == 0) {
2296 return item;
2297 }
2298 item = item->fNextsibling;
2299 }
2300 return 0;
2301}
2302
2303////////////////////////////////////////////////////////////////////////////////
2304/// Find child of item by userData.
2305
2307{
2308 // Get first child in list
2309 if (item && item->fFirstchild) {
2310 item = item->fFirstchild;
2311 } else if (!item && fFirst) {
2312 item = fFirst;
2313 } else {
2314 item = 0;
2315 }
2316
2317 while (item) {
2318 if (item->GetUserData() == userData) {
2319 return item;
2320 }
2321 item = item->fNextsibling;
2322 }
2323 return 0;
2324}
2325
2326////////////////////////////////////////////////////////////////////////////////
2327/// Find item by pathname. Pathname is in the form of /xx/yy/zz. If zz
2328/// in path /xx/yy is found it returns item, 0 otherwise.
2329
2331{
2332 if (!path || !*path) return 0;
2333
2334 const char *p = path, *s;
2335 char dirname[1024];
2336 TGListTreeItem *item = 0;
2337 item = FindChildByName(item, "/");
2338 if (!gVirtualX->InheritsFrom("TGX11")) {
2339 // on Windows, use the current drive instead of root (/)
2340 TList *curvol = gSystem->GetVolumes("cur");
2341 if (curvol) {
2342 TNamed *drive = (TNamed *)curvol->At(0);
2343 item = FindChildByName(0, TString::Format("%s\\", drive->GetName()));
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=0;
2686 static const TGPicture *oldclose=0;
2687 static const TGPicture *oldcheck=0;
2688 static const TGPicture *olduncheck=0;
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;
2708 out << " popen = gClient->GetPicture(" << quote
2710 << quote << ");" << std::endl;
2711 }
2712 if (oldclose != fClosedPic) {
2713 oldclose = fClosedPic;
2714 out << " pclose = gClient->GetPicture(" << quote
2716 << 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;
2731 out << " pcheck = gClient->GetPicture(" << quote
2733 << quote << ");" << std::endl;
2734 }
2735 if (fUncheckedPic && olduncheck != fUncheckedPic) {
2736 olduncheck = fUncheckedPic;
2737 out << " puncheck = gClient->GetPicture(" << quote
2739 << 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
void Class()
Definition: Class.C:29
SVector< double, 2 > v
Definition: Dict.h:5
@ kGKeyPress
Definition: GuiTypes.h:59
@ kButtonRelease
Definition: GuiTypes.h:59
@ kButtonPress
Definition: GuiTypes.h:59
@ kLeaveNotify
Definition: GuiTypes.h:60
const Mask_t kGCBackground
Definition: GuiTypes.h:288
const Mask_t kGCForeground
Definition: GuiTypes.h:287
const Mask_t kGCLineStyle
Definition: GuiTypes.h:290
const Mask_t kGCLineWidth
Definition: GuiTypes.h:289
ULong_t Handle_t
Definition: GuiTypes.h:25
const Mask_t kButtonPressMask
Definition: GuiTypes.h:160
const Mask_t kGCFillStyle
Definition: GuiTypes.h:293
const Mask_t kAnyModifier
Definition: GuiTypes.h:209
Handle_t Pixmap_t
Definition: GuiTypes.h:29
const Mask_t kKeyPressMask
Definition: GuiTypes.h:158
const Mask_t kGCFont
Definition: GuiTypes.h:299
const Mask_t kPointerMotionMask
Definition: GuiTypes.h:162
const Mask_t kKeyShiftMask
Definition: GuiTypes.h:194
Handle_t Atom_t
Definition: GuiTypes.h:36
const Handle_t kNone
Definition: GuiTypes.h:87
const Mask_t kKeyControlMask
Definition: GuiTypes.h:196
const Mask_t kLeaveWindowMask
Definition: GuiTypes.h:167
@ kFillSolid
Definition: GuiTypes.h:50
@ kLineSolid
Definition: GuiTypes.h:47
@ kLineOnOffDash
Definition: GuiTypes.h:47
Handle_t GContext_t
Definition: GuiTypes.h:37
const Mask_t kButtonReleaseMask
Definition: GuiTypes.h:161
const Mask_t kGCGraphicsExposures
Definition: GuiTypes.h:301
const Mask_t kEnterWindowMask
Definition: GuiTypes.h:166
Handle_t FontStruct_t
Definition: GuiTypes.h:38
ULong_t Pixel_t
Definition: GuiTypes.h:39
@ kButton4
Definition: GuiTypes.h:214
@ kButton5
Definition: GuiTypes.h:214
@ kButton1
Definition: GuiTypes.h:213
@ kAnyButton
Definition: GuiTypes.h:213
EKeySym
Definition: KeySymbols.h:25
@ kKey_Right
Definition: KeySymbols.h:42
@ kKey_Down
Definition: KeySymbols.h:43
@ kKey_G
Definition: KeySymbols.h:132
@ kKey_Space
Definition: KeySymbols.h:93
@ kKey_PageDown
Definition: KeySymbols.h:47
@ kKey_F
Definition: KeySymbols.h:131
@ kKey_F5
Definition: KeySymbols.h:61
@ kKey_Up
Definition: KeySymbols.h:41
@ kKey_Return
Definition: KeySymbols.h:30
@ kKey_F3
Definition: KeySymbols.h:59
@ kKey_Left
Definition: KeySymbols.h:40
@ kKey_Escape
Definition: KeySymbols.h:26
@ kKey_Home
Definition: KeySymbols.h:38
@ kKey_Enter
Definition: KeySymbols.h:31
@ kKey_End
Definition: KeySymbols.h:39
@ kKey_PageUp
Definition: KeySymbols.h:45
@ kKey_F7
Definition: KeySymbols.h:63
ROOT::R::TRInterface & r
Definition: Object.C:4
#define c(i)
Definition: RSha256.hxx:101
#define h(i)
Definition: RSha256.hxx:106
static Int_t init()
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
unsigned long ULong_t
Definition: RtypesCore.h:51
long Long_t
Definition: RtypesCore.h:50
bool Bool_t
Definition: RtypesCore.h:59
short Color_t
Definition: RtypesCore.h:79
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:365
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
void Warning(const char *location, const char *msgfmt,...)
#define gClient
Definition: TGClient.h:166
R__EXTERN TGDNDManager * gDNDManager
Definition: TGDNDManager.h:203
@ kSunkenFrame
Definition: TGFrame.h:61
Int_t Compare(const void *item1, const void *item2)
@ kMBOk
Definition: TGMsgBox.h:44
@ kMBIconExclamation
Definition: TGMsgBox.h:35
char name[80]
Definition: TGX11.cxx:109
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2490
R__EXTERN TSystem * gSystem
Definition: TSystem.h:560
#define gVirtualX
Definition: TVirtualX.h:345
@ kHand
Definition: TVirtualX.h:46
@ kPointer
Definition: TVirtualX.h:47
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
@ kCT_ITEMCLICK
@ kCT_KEY
@ kC_LISTTREE
@ kCT_ITEMDBLCLICK
#define snprintf
Definition: civetweb.c:1540
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition: TBufferFile.h:46
virtual void WriteObject(const TObject *obj, Bool_t cacheReuse=kTRUE)
Write object to I/O buffer.
Definition: TBufferIO.cxx:530
virtual void Reset()
Reset buffer object. Resets map and buffer offset.
Definition: TBufferIO.cxx:305
@ kWrite
Definition: TBuffer.h:72
Int_t Length() const
Definition: TBuffer.h:99
char * Buffer() const
Definition: TBuffer.h:95
static ULong_t Number2Pixel(Int_t ci)
Static method that given a color index number, returns the corresponding pixel value.
Definition: TColor.cxx:2003
Atom_t fDataType
Definition: TGDNDManager.h:75
Int_t fDataLength
Definition: TGDNDManager.h:78
void * fData
Definition: TGDNDManager.h:77
TGFrame * GetContainer() const
Definition: TGCanvas.h:226
virtual void SetVsbPosition(Int_t newPos)
Set position of vertical scrollbar.
Definition: TGCanvas.cxx:2403
virtual Int_t GetVsbPosition() const
Get position of vertical scrollbar.
Definition: TGCanvas.cxx:2379
TGVScrollBar * GetVScrollbar() const
Definition: TGCanvas.h:229
TGViewPort * GetViewPort() const
Definition: TGCanvas.h:227
virtual void Layout()
Create layout for canvas.
Definition: TGCanvas.cxx:2224
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition: TGClient.cxx:234
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition: TGClient.cxx:289
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:372
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition: TGClient.cxx:308
TGCanvas * fCanvas
Definition: TGCanvas.h:51
virtual void ClearViewPort()
Clear view port and redraw full content.
Definition: TGCanvas.cxx:886
const TGWindow * fMsgWindow
Definition: TGCanvas.h:52
virtual void SetDragPixmap(const TGPicture *pic)
Set drag window pixmaps and hotpoint.
Definition: TGCanvas.cxx:1075
Int_t fXDND
Definition: TGCanvas.h:70
TGCanvas * GetCanvas() const
Definition: TGCanvas.h:109
Bool_t fBdown
Definition: TGCanvas.h:71
virtual void DoRedraw()
Redraw content of container in the viewport region.
Definition: TGCanvas.cxx:795
virtual TGDimension GetPageDimension() const
Returns page dimension.
Definition: TGCanvas.cxx:746
TGViewPort * fViewPort
Definition: TGCanvas.h:50
virtual TGVScrollBar * GetVScrollbar() const
returns pointer to vert. scroll bar
Definition: TGCanvas.cxx:1748
Int_t fYDND
Definition: TGCanvas.h:70
virtual TGPosition GetPagePosition() const
Returns page position.
Definition: TGCanvas.cxx:732
Bool_t IsDragging() const
Definition: TGDNDManager.h:175
Bool_t StartDrag(TGFrame *src, Int_t x_root, Int_t y_root, Window_t grabWin=kNone)
Start dragging.
Bool_t Drag(Int_t x_root, Int_t y_root, Atom_t action, Time_t timestamp)
Process drag event.
static Atom_t GetDNDActionCopy()
Bool_t EndDrag()
End dragging.
UInt_t fHeight
Definition: TGDimension.h:30
UInt_t fWidth
Definition: TGDimension.h:29
Definition: TGFont.h:149
void GetFontMetrics(FontMetrics_t *m) const
Get font metrics.
Definition: TGFont.cxx:274
Int_t TextHeight() const
Definition: TGFont.h:201
FontStruct_t GetFontStruct() const
Definition: TGFont.h:193
Int_t TextWidth(const char *string, Int_t numChars=-1) const
A wrapper function for the more complicated interface of MeasureChars.
Definition: TGFont.cxx:563
FontH_t GetFontHandle() const
Definition: TGFont.h:192
static Pixel_t GetDefaultSelectedBackground()
Get default selected frame background.
Definition: TGFrame.cxx:678
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition: TGFrame.cxx:321
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
UInt_t fHeight
Definition: TGFrame.h:135
static Pixel_t fgDefaultSelectedBackground
Definition: TGFrame.h:149
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
Definition: TGFrame.cxx:627
virtual UInt_t GetOptions() const
Definition: TGFrame.h:244
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition: TGFrame.cxx:2460
UInt_t GetHeight() const
Definition: TGFrame.h:272
virtual Pixel_t GetBackground() const
Definition: TGFrame.h:239
void SetDNDTarget(Bool_t onoff)
Definition: TGFrame.h:317
static Pixel_t fgWhitePixel
Definition: TGFrame.h:150
UInt_t GetWidth() const
Definition: TGFrame.h:271
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition: TGFrame.cxx:2433
Pixel_t fBackground
Definition: TGFrame.h:142
static Pixel_t fgBlackPixel
Definition: TGFrame.h:151
Definition: TGGC.h:31
Pixel_t GetForeground() const
Definition: TGGC.h:82
void SetDashOffset(Int_t v)
Patterned/dashed line offset.
Definition: TGGC.cxx:475
void SetDashList(const char v[], Int_t len)
Set dash pattern. First use SetDashOffset() if not 0.
Definition: TGGC.cxx:486
virtual void Toggle()
Definition: TGListTree.h:190
virtual const char * GetTipText() const
Definition: TGListTree.h:174
virtual Bool_t IsChecked() const
Definition: TGListTree.h:191
virtual Bool_t HasCheckedChild(Bool_t first=kFALSE)
Add all child items of 'item' into the list 'checked'.
Definition: TGListTree.cxx:175
virtual void SetPictures(const TGPicture *opened, const TGPicture *closed)
Change list tree item icons.
Definition: TGListTree.cxx:311
const TGPicture * fCheckedPic
Definition: TGListTree.h:152
virtual Bool_t HasUnCheckedChild(Bool_t first=kFALSE)
Add all child items of 'item' into the list 'checked'.
Definition: TGListTree.cxx:198
const TGPicture * fClosedPic
Definition: TGListTree.h:151
virtual void SavePrimitive(std::ostream &out, Option_t *option, Int_t n)
Save a list tree item attributes as a C++ statements on output stream.
virtual Pixel_t GetActiveColor() const
Return color for marking items that are active or selected.
Definition: TGListTree.cxx:167
virtual void SetCheckBox(Bool_t on=kTRUE)
Set a check box on the tree node.
Definition: TGListTree.cxx:278
virtual void CheckChildren(TGListTreeItem *item, Bool_t state)
Set all child items of 'item' checked if state=kTRUE; unchecked if state=kFALSE.
Definition: TGListTree.cxx:255
const TGPicture * fUncheckedPic
Definition: TGListTree.h:153
virtual void UpdateState()
Update the state of the node 'item' according to the children states.
Definition: TGListTree.cxx:221
TGListTreeItemStd(const TGListTreeItemStd &)
virtual void SetCheckBoxPictures(const TGPicture *checked, const TGPicture *unchecked)
Change list tree check item icons.
Definition: TGListTree.cxx:286
virtual Bool_t HasCheckBox() const
Definition: TGListTree.h:188
virtual void CheckItem(Bool_t checked=kTRUE)
Definition: TGListTree.h:189
const TGPicture * fOpenPic
Definition: TGListTree.h:150
virtual const char * GetText() const
Definition: TGListTree.h:172
virtual void CheckAllChildren(Bool_t state=kTRUE)
Set all child items of this one checked if state=kTRUE, unchecked if state=kFALSE.
Definition: TGListTree.cxx:238
virtual ~TGListTreeItemStd()
Delete list tree item.
Definition: TGListTree.cxx:152
TGListTreeItem * GetFirstChild() const
Definition: TGListTree.h:74
void Rename(const char *new_name)
Definition: TGListTree.h:86
virtual void SetCheckBoxPictures(const TGPicture *, const TGPicture *)
Definition: TGListTree.h:100
virtual Bool_t IsActive() const =0
virtual const char * GetText() const =0
virtual void CheckAllChildren(Bool_t=kTRUE)
Definition: TGListTree.h:110
TGListTreeItem * fLastchild
Definition: TGListTree.h:55
TGListTreeItem * fFirstchild
Definition: TGListTree.h:54
UInt_t fHeight
Definition: TGListTree.h:67
TGListTreeItem * GetNextSibling() const
Definition: TGListTree.h:77
virtual void CheckItem(Bool_t=kTRUE)=0
TGListTreeItem * fParent
Definition: TGListTree.h:53
TGListTreeItem(const TGListTreeItem &)
TGListTreeItem * fPrevsibling
Definition: TGListTree.h:56
Bool_t IsDNDTarget() const
Definition: TGListTree.h:128
Bool_t IsDNDSource() const
Definition: TGListTree.h:127
virtual Bool_t HasCheckedChild(Bool_t=kFALSE)
Definition: TGListTree.h:112
TGClient * fClient
Definition: TGListTree.h:52
TGListTreeItem * GetParent() const
Definition: TGListTree.h:73
virtual void SavePrimitive(std::ostream &, Option_t *, Int_t)
Definition: TGListTree.h:135
virtual Bool_t HasUnCheckedChild(Bool_t=kFALSE)
Definition: TGListTree.h:113
virtual void SetTipText(const char *)
Definition: TGListTree.h:92
virtual void SetActive(Bool_t)
Definition: TGListTree.h:84
virtual Int_t GetTextLength() const =0
virtual const TGPicture * GetCheckBoxPicture() const =0
Int_t fDNDState
Definition: TGListTree.h:61
virtual Bool_t IsOpen() const
Definition: TGListTree.h:79
TGListTreeItem * GetPrevSibling() const
Definition: TGListTree.h:76
virtual Color_t GetColor() const =0
virtual UInt_t GetPicWidth() const
Return width of item's icon.
Definition: TGListTree.cxx:99
virtual Bool_t IsChecked() const =0
virtual const TGPicture * GetPicture() const =0
virtual void SetOpen(Bool_t o)
Definition: TGListTree.h:80
virtual Pixel_t GetActiveColor() const =0
virtual void SetCheckBox(Bool_t=kTRUE)
Definition: TGListTree.h:103
virtual void Toggle()
Definition: TGListTree.h:106
virtual Bool_t HasCheckBox() const =0
virtual void UpdateState()
Definition: TGListTree.h:114
virtual Bool_t HasColor() const =0
virtual void * GetUserData() const =0
virtual void SetUserData(void *, Bool_t=kFALSE)
Definition: TGListTree.h:94
virtual const char * GetTipText() const =0
TGListTreeItem * fNextsibling
Definition: TGListTree.h:57
virtual Int_t GetTipTextLength() const =0
static const TGPicture * GetOpenPic()
Returns the icon used by items in open state.
UInt_t fLastEventState
Definition: TGListTree.h:255
void Clicked(TGFrame *, Int_t)
Emit Clicked() signal.
Definition: TGListTree.h:311
GContext_t fColorGC
Definition: TGListTree.h:259
void PageUp(Bool_t select=kFALSE)
Move content one page up.
TGListTreeItem * FindItemByObj(TGListTreeItem *item, void *ptr)
Find item with fUserData == ptr.
TGListTreeItem * fSelected
Definition: TGListTree.h:227
Int_t SortSiblings(TGListTreeItem *item)
Sort siblings of item.
GContext_t fLineGC
Definition: TGListTree.h:237
static const TGPicture * GetUncheckedPic()
Returns the icon used for unchecked checkbox.
void RemoveReference(TGListTreeItem *item)
This function removes the specified item from the linked list.
UInt_t fDefw
Definition: TGListTree.h:240
void LineUp(Bool_t select=kFALSE)
Move content one item-size up.
static Pixel_t fgGrayPixel
Definition: TGListTree.h:261
void ClearHighlighted()
Un highlight items.
void PDeleteChildren(TGListTreeItem *item)
Recursively delete all children of an item.
void InsertChildren(TGListTreeItem *parent, TGListTreeItem *item)
Insert a list of ALREADY LINKED children into another list.
Atom_t HandleDNDEnter(Atom_t *typelist)
Handle drag enter events.
Definition: TGListTree.cxx:755
ECheckMode fCheckMode
Definition: TGListTree.h:258
static const TGPicture * GetClosedPic()
Returns the icon used by items in closed state.
static TGGC * fgLineGC
Definition: TGListTree.h:265
virtual Bool_t HandleButton(Event_t *event)
Handle button events in the list tree.
Definition: TGListTree.cxx:562
void Home(Bool_t select=kFALSE)
Move content to the top.
void UnselectAll(Bool_t draw)
Unselect all items.
Definition: TGListTree.cxx:553
Bool_t fDisableOpen
Definition: TGListTree.h:252
TGListTree(const TGListTree &)
virtual void Layout()
Layout container entries.
Definition: TGListTree.h:305
void InsertChild(TGListTreeItem *parent, TGListTreeItem *item)
Insert child in list.
void ToggleItem(TGListTreeItem *item)
Toggle check button state of the node 'item'.
GContext_t fDrawGC
Definition: TGListTree.h:236
virtual ~TGListTree()
Delete list tree widget.
Definition: TGListTree.cxx:469
void RenameItem(TGListTreeItem *item, const char *string)
Rename item in list tree.
static TGGC * fgActiveGC
Definition: TGListTree.h:263
GContext_t fHighlightGC
Definition: TGListTree.h:238
void LineDown(Bool_t select=kFALSE)
Move content one item-size down.
void AddItem(TGListTreeItem *parent, TGListTreeItem *item)
Add given item to list tree.
Int_t DeleteChildren(TGListTreeItem *item)
Delete children of item from list.
TGListTreeItem * FindItem(Int_t findy)
Find item at postion findy.
TGListTreeItem * fBelowMouse
Definition: TGListTree.h:229
Int_t FontHeight()
Returns height of currently used font.
Definition: TGListTree.cxx:490
TGListTreeItem * fLast
Definition: TGListTree.h:226
Int_t ReparentChildren(TGListTreeItem *item, TGListTreeItem *newparent)
Make newparent the new parent of the children of item.
void CheckItem(TGListTreeItem *item, Bool_t check=kTRUE)
Set check button state for the node 'item'.
Int_t DrawChildren(Handle_t id, TGListTreeItem *item, Int_t x, Int_t y, Int_t xroot)
Draw children of item in list tree.
Int_t fExposeBottom
Definition: TGListTree.h:243
static const TGGC & GetLineGC()
Return graphics context in use for line drawing.
void CheckAllChildren(TGListTreeItem *item, Bool_t state)
Check all child items of 'item' and 'item' itself according to the state value: kTRUE means check all...
static TGGC * fgHighlightGC
Definition: TGListTree.h:266
static const TGPicture * GetCheckedPic()
Returns the icon used for checked checkbox.
TDNDData fDNDData
Definition: TGListTree.h:247
Atom_t HandleDNDPosition(Int_t x, Int_t y, Atom_t action, Int_t xroot, Int_t yroot)
Handle dragging position events.
Definition: TGListTree.cxx:729
void SetCheckBox(TGListTreeItem *item, Bool_t on=kTRUE)
Set check button state for the node 'item'.
void OpenItem(TGListTreeItem *item)
Open item in list tree (i.e. show child items).
virtual void DrawActive(Handle_t id, TGListTreeItem *item)
Draw active item with its active color.
Pixel_t fGrayPixel
Definition: TGListTree.h:234
Int_t Reparent(TGListTreeItem *item, TGListTreeItem *newparent)
Make newparent the new parent of item.
void GetChecked(TList *checked)
Add all checked list tree items of this list tree into the list 'checked'.
static TGGC * fgColorGC
Definition: TGListTree.h:267
Int_t RecursiveDeleteItem(TGListTreeItem *item, void *userData)
Delete item with fUserData == ptr.
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
Definition: TGListTree.cxx:702
Int_t TextWidth(const char *c)
Returns text width relative to currently used font.
Definition: TGListTree.cxx:512
void DrawItem(Handle_t id, TGListTreeItem *item, Int_t x, Int_t y, Int_t *xroot, UInt_t *retwidth, UInt_t *retheight)
Draw list tree item.
TGListTreeItem * fDropItem
Definition: TGListTree.h:249
void SetToolTipText(const char *text, Int_t x, Int_t y, Long_t delayms)
Set tool tip text associated with this item.
TGListTreeItem * fTipItem
Definition: TGListTree.h:245
Int_t FontAscent()
Returns ascent of currently used font.
Definition: TGListTree.cxx:500
void End(Bool_t select=kFALSE)
Move content to the bottom.
static const TGGC & GetColorGC()
Return graphics context for highlighted frame background.
virtual void Checked(TObject *obj, Bool_t check)
Emit Checked() signal.
static const TGGC & GetDrawGC()
Return default graphics context in use.
void HighlightChildren(TGListTreeItem *item, Bool_t state, Bool_t draw)
Higlight item children.
Definition: TGListTree.cxx:540
virtual void DataDropped(TGListTreeItem *item, TDNDData *data)
Emit DataDropped() signal.
Definition: TGListTree.cxx:789
Int_t fHspacing
Definition: TGListTree.h:230
static const TGPicture * fgClosedPic
Definition: TGListTree.h:269
Int_t DeleteItem(TGListTreeItem *item)
Delete item from list tree.
static const TGPicture * fgUncheckedPic
Definition: TGListTree.h:271
Int_t fMargin
Definition: TGListTree.h:233
static const TGGC & GetHighlightGC()
Return graphics context for highlighted frame background.
UInt_t fDefh
Definition: TGListTree.h:241
void GetCheckedChildren(TList *checked, TGListTreeItem *item)
Add all child items of 'item' into the list 'checked'.
static const TGPicture * fgCheckedPic
Definition: TGListTree.h:270
TGListTreeItem * GetFirstItem() const
Definition: TGListTree.h:396
Bool_t HandleDNDLeave()
Handle drag leave events.
Definition: TGListTree.cxx:770
TGListTreeItem * FindChildByName(TGListTreeItem *item, const char *name)
Find child of item by name.
void SaveChildren(std::ostream &out, TGListTreeItem *item, Int_t &n)
Save child items as a C++ statements on output stream out.
static const TGGC & GetActiveGC()
Return default graphics context in use.
Bool_t fEventHandled
Definition: TGListTree.h:254
Int_t SortChildren(TGListTreeItem *item)
Sort children of item.
static const TGPicture * fgOpenPic
Definition: TGListTree.h:268
EColorMarkupMode fColorMode
Definition: TGListTree.h:257
Atom_t * fDNDTypeList
Definition: TGListTree.h:248
static TGGC * fgDrawGC
Definition: TGListTree.h:264
Int_t Sort(TGListTreeItem *item)
Sort items starting with item.
void KeyPressed(TGFrame *, UInt_t, UInt_t)
Signal emitted when keyboard key pressed.
Definition: TGListTree.h:315
Bool_t fAutoCheckBoxPic
Definition: TGListTree.h:251
void DrawNode(Handle_t id, TGListTreeItem *item, Int_t x, Int_t y)
Draw node (little + in box).
TGListTreeItem * fFirst
Definition: TGListTree.h:225
void Search(Bool_t close=kTRUE)
Invokes search dialog. Looks for item with the entered name.
TBufferFile * fBuf
Definition: TGListTree.h:246
TGToolTip * fTip
Definition: TGListTree.h:244
virtual Bool_t HandleKey(Event_t *event)
The key press event handler converts a key press to some line editor action.
Definition: TGListTree.cxx:931
void DrawItemName(Handle_t id, TGListTreeItem *item)
Draw name of list tree item.
Bool_t fUserControlled
Definition: TGListTree.h:253
TGListTreeItem * fCurrent
Definition: TGListTree.h:228
virtual void UpdateChecked(TGListTreeItem *item, Bool_t redraw=kFALSE)
Update the state of the node 'item' according to the children states.
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event.
Definition: TGListTree.cxx:803
Int_t SearchChildren(TGListTreeItem *item, Int_t y, Int_t findy, TGListTreeItem **finditem)
Search child item.
virtual void MouseOver(TGListTreeItem *entry)
Signal emitted when pointer is over entry.
void HighlightItem(TGListTreeItem *item)
Highlight item.
Int_t fExposeTop
Definition: TGListTree.h:242
TGListTreeItem * FindSiblingByName(TGListTreeItem *item, const char *name)
Find sibling of item by name.
TGListTreeItem * FindItemByPathname(const char *path)
Find item by pathname.
void ReturnPressed(TGFrame *)
Signal emitted when Return/Enter key pressed.
Definition: TGListTree.h:310
void AdjustPosition()
Move content to position of highlighted/activated frame.
Definition: TGListTree.h:370
@ kColorUnderline
Definition: TGListTree.h:216
Int_t fVspacing
Definition: TGListTree.h:231
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a list tree widget as a C++ statements on output stream out.
FontStruct_t fFont
Definition: TGListTree.h:239
TGListTreeItem * FindChildByData(TGListTreeItem *item, void *userData)
Find child of item by userData.
void CloseItem(TGListTreeItem *item)
Close item in list tree (i.e. hide child items).
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use.
virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
Redraw list tree.
void PDeleteItem(TGListTreeItem *item)
Delete given item.
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle double click event in the list tree (only for kButton1).
Definition: TGListTree.cxx:660
void SetToolTipItem(TGListTreeItem *item, const char *string)
Set tooltip text for this item.
Bool_t HandleDNDDrop(TDNDData *data)
Handle drop events.
Definition: TGListTree.cxx:778
void DoubleClicked(TGFrame *, Int_t)
Emit DoubleClicked() signal.
Definition: TGListTree.h:313
Int_t fIndent
Definition: TGListTree.h:232
virtual void DrawOutline(Handle_t id, TGListTreeItem *item, Pixel_t col=0xbbbbbb, Bool_t clear=kFALSE)
Draw a outline of color 'col' around an item.
Bool_t fAutoTips
Definition: TGListTree.h:250
TGListTreeItem * FindSiblingByData(TGListTreeItem *item, void *userData)
Find sibling of item by userData.
static const TGFont * fgDefaultFont
Definition: TGListTree.h:262
GContext_t fActiveGC
Definition: TGListTree.h:235
void PageDown(Bool_t select=kFALSE)
Move content one page down.
static Pixel_t GetGrayPixel()
Return gray draw color in use.
void GetPathnameFromItem(TGListTreeItem *item, char *path, Int_t depth=0)
Get pathname from item.
void Draw(Handle_t id, Int_t yevent, Int_t hevent)
Draw list tree widget.
TGClient * fClient
Definition: TGObject.h:37
Handle_t fId
Definition: TGObject.h:36
const char * GetName() const
Returns name of object.
Definition: TGPicture.h:62
UInt_t GetHeight() const
Definition: TGPicture.h:64
void Draw(Option_t *="")
Default Draw method for all objects.
Definition: TGPicture.h:57
UInt_t GetWidth() const
Definition: TGPicture.h:63
Int_t fY
Definition: TGDimension.h:48
Int_t fX
Definition: TGDimension.h:47
virtual Int_t GetPosition() const
Definition: TGScrollBar.h:132
virtual void SetSmallIncrement(Int_t increment)
Definition: TGScrollBar.h:153
void Hide()
Hide tool tip window.
Definition: TGToolTip.cxx:246
void SetPosition(Int_t x, Int_t y)
Set popup position within specified frame (as specified in the ctor).
Definition: TGToolTip.cxx:405
void SetText(const char *new_text)
Set new tool tip text.
Definition: TGToolTip.cxx:386
void Reset()
Reset tool tip popup delay timer.
Definition: TGToolTip.cxx:259
virtual void SetWindowName(const char *name=0)
Set window name.
Definition: TGWindow.cxx:118
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:221
const TGWindow * fParent
Definition: TGWindow.h:37
@ kEditDisableBtnEnable
Definition: TGWindow.h:66
@ kEditDisableGrab
Definition: TGWindow.h:61
@ kEditDisable
Definition: TGWindow.h:59
const TGWindow * GetParent() const
Definition: TGWindow.h:85
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition: TGWindow.cxx:180
UInt_t fEditDisabled
Definition: TGWindow.h:41
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:354
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Collectable string class.
Definition: TObjString.h:28
TString & String()
Definition: TObjString.h:48
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:401
virtual Int_t Compare(const TObject *obj) const
Compare abstract method.
Definition: TObject.cxx:159
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
void AddReference()
Definition: TRefCnt.h:40
Basic string class.
Definition: TString.h:131
Ssiz_t Length() const
Definition: TString.h:405
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2177
const char * Data() const
Definition: TString.h:364
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:687
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:610
Bool_t IsNull() const
Definition: TString.h:402
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition: TString.cxx:2311
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition: TSystem.cxx:1264
virtual TList * GetVolumes(Option_t *) const
Definition: TSystem.h:455
virtual const char * UnixPathName(const char *unixpathname)
Convert from a Unix pathname to a local pathname.
Definition: TSystem.cxx:1053
virtual const char * WorkingDirectory()
Return working directory.
Definition: TSystem.cxx:878
TText * text
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
const Int_t n
Definition: legend1.C:16
static constexpr double s
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180
Definition: first.py:1
EGEventType fType
Definition: GuiTypes.h:174
Int_t fY
Definition: GuiTypes.h:177
Int_t fXRoot
Definition: GuiTypes.h:178
UInt_t fState
Definition: GuiTypes.h:180
Int_t fYRoot
Definition: GuiTypes.h:178
Int_t fX
Definition: GuiTypes.h:177
Time_t fTime
Definition: GuiTypes.h:176
UInt_t fCode
Definition: GuiTypes.h:179
ULong_t fBackground
Definition: GuiTypes.h:227
Int_t fLineWidth
Definition: GuiTypes.h:228
Mask_t fMask
Definition: GuiTypes.h:250
Int_t fLineStyle
Definition: GuiTypes.h:229
Bool_t fGraphicsExposures
Definition: GuiTypes.h:243
ULong_t fForeground
Definition: GuiTypes.h:226
Int_t fFillStyle
Definition: GuiTypes.h:233
FontH_t fFont
Definition: GuiTypes.h:241
auto * m
Definition: textangle.C:8