Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TTVLVContainer.cxx
Go to the documentation of this file.
1// @(#)root/treeviewer:$Id$
2//Author : Andrei Gheata 16/08/00
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#include "TTVLVContainer.h"
13#include "TTreeViewer.h"
14#include "TGPicture.h"
15#include "TGLabel.h"
16#include "TGButton.h"
17#include "TGTextEntry.h"
18#include "TGToolTip.h"
19#include "TList.h"
20#include "TVirtualX.h"
21#include "snprintf.h"
22
23
24
25/** \class TGItemContext
26Empty object used as context menu support for TGLVTreeEntries.
27*/
28
29////////////////////////////////////////////////////////////////////////////////
30/// Constructor
31
33{
34 fItem = nullptr;
35}
36
37////////////////////////////////////////////////////////////////////////////////
38/// Draw item
39
41{
42 fItem->GetContainer()->GetViewer()->ProcessMessage(MK_MSG(kC_CONTAINER, kCT_ITEMDBLCLICK), kButton1, 0);
43}
44
45////////////////////////////////////////////////////////////////////////////////
46/// Edit expression
47
49{
50 fItem->GetContainer()->GetViewer()->EditExpression();
51}
52
53////////////////////////////////////////////////////////////////////////////////
54/// Empty item
55
57{
58 fItem->Empty();
59}
60
61////////////////////////////////////////////////////////////////////////////////
62/// Remove item
63
65{
66 fItem->GetContainer()->GetViewer()->RemoveItem();
67}
68
69////////////////////////////////////////////////////////////////////////////////
70/// Scan item
71
73{
74 fItem->GetContainer()->GetViewer()->SetScanMode();
75 fItem->GetContainer()->GetViewer()->ProcessMessage(MK_MSG(kC_CONTAINER, kCT_ITEMDBLCLICK), kButton1, 0);
76}
77
78////////////////////////////////////////////////////////////////////////////////
79/// Set item expression
80
81void TGItemContext::SetExpression(const char *name, const char *alias, bool cut)
82{
83 fItem->SetExpression(name, alias, cut);
84}
85
86
87/** \class TTVLVEntry
88This class represent entries that goes into the TreeViewer listview container.
89It subclasses TGLVEntry and adds two data members: the item true name and the alias.
90*/
91
92////////////////////////////////////////////////////////////////////////////////
93/// TTVLVEntry constructor.
94
96 const TGPicture *bigpic, const TGPicture *smallpic,
97 TGString *name, TGString **subnames,
98 EListViewMode ViewMode)
99 :TGLVEntry(p, bigpic, smallpic, name, subnames, ViewMode)
100{
101 // both alias and true name are initialized to name
103
104 fTip = nullptr;
105 fIsCut = false;
106 fTrueName = name->GetString();
107 fContext = new TGItemContext();
108 fContext->Associate(this);
109
111}
112
113////////////////////////////////////////////////////////////////////////////////
114/// TTVLVEntry destructor
115
117{
118 if (fTip) delete fTip;
119 delete fContext;
120}
121
122////////////////////////////////////////////////////////////////////////////////
123/// Convert all aliases into true names
124
126{
130 TIter next(list);
131 TTVLVEntry* item;
132 while (!FullConverted()) {
133 next.Reset();
135 while ((item=(TTVLVEntry*)next())) {
136 if (item != this)
137 fConvName.ReplaceAll(item->GetAlias(), item->GetTrueName());
138 }
139 if (fConvName == start) {
140 //the following line is deadcode reported by coverity because item=0
141 //if (item) Warning(item->GetAlias(), "Cannot convert aliases for this expression.");
142 return(fConvName.Data());
143 }
144 }
145 return(fConvName.Data());
146}
147
148////////////////////////////////////////////////////////////////////////////////
149/// Return true if converted name is alias free
150
152{
154 TIter next(list);
155 TTVLVEntry* item;
156 while ((item=(TTVLVEntry*)next())) {
157 if (item != this) {
158 if (fConvName.Contains(item->GetAlias())) return false;
159 }
160 }
161 return true;
162}
163
164////////////////////////////////////////////////////////////////////////////////
165/// Copy this item's name and alias to an other.
166
168{
169 if (!dest) return;
170 dest->SetExpression(fTrueName.Data(), fAlias.Data(), fIsCut);
171 TString alias = dest->GetAlias();
172 if (!alias.BeginsWith("~") && !alias.Contains("empty")) dest->PrependTilde();
173}
174
175////////////////////////////////////////////////////////////////////////////////
176/// Handle mouse crossing event.
177
179{
180 if (fTip) {
181 if (event->fType == kEnterNotify)
182 fTip->Reset();
183 else
184 fTip->Hide();
185 }
186 return true;
187}
188
189////////////////////////////////////////////////////////////////////////////////
190/// Check if alias name is not empty.
191
193{
194 if (fAlias.Length()) return true;
195 return false;
196}
197
198////////////////////////////////////////////////////////////////////////////////
199/// Prepend a ~ to item alias
200
202{
203 fAlias = "~" + fAlias;
204 SetItemName(fAlias.Data());
205}
206
207////////////////////////////////////////////////////////////////////////////////
208/// Redraw this entry with new name
209
211{
212 if (fItemName) delete fItemName;
213 fItemName = new TGString(name);
214 Int_t max_ascent, max_descent;
215 fTWidth = gVirtualX->TextWidth(fFontStruct, fItemName->GetString(), fItemName->GetLength());
216 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
217 fTHeight = max_ascent + max_descent;
218 gVirtualX->ClearWindow(fId);
220 fClient->NeedRedraw(this);
221}
222
223////////////////////////////////////////////////////////////////////////////////
224/// Set cut type
225
227{
228 if (fIsCut && type) return;
229 if (!fIsCut && !type) return;
230 if (type) {
231 SetSmallPic(fClient->GetPicture("selection_t.xpm"));
232 SetToolTipText("Selection expression. Drag to scissors to activate");
233 } else
234 SetSmallPic(fClient->GetPicture("expression_t.xpm"));
235 fIsCut = type;
236}
237
238////////////////////////////////////////////////////////////////////////////////
239/// Set the true name, alias and type of the expression, then refresh it
240
241void TTVLVEntry::SetExpression(const char* name, const char* alias, bool cutType)
242{
243 SetItemName(alias);
244 SetAlias(alias);
246 ULong_t *itemType = (ULong_t *) GetUserData();
247 if (*itemType & TTreeViewer::kLTPackType) {
248 if (strlen(name))
249 SetSmallPic(fClient->GetPicture("pack_t.xpm"));
250 else
251 SetSmallPic(fClient->GetPicture("pack-empty_t.xpm"));
252 }
253 if ((*itemType & TTreeViewer::kLTDragType) && strlen(name) && !fIsCut)
254 SetToolTipText("Double-click to draw. Drag and drop. Use Edit/Expression or context menu to edit.");
255 if (*itemType & TTreeViewer::kLTDragType) SetCutType(cutType);
256}
257
258////////////////////////////////////////////////////////////////////////////////
259/// Clear all names and alias
260
262{
263 SetExpression("","-empty-");
264 ULong_t *itemType = (ULong_t *) GetUserData();
265 if (itemType && (*itemType & TTreeViewer::kLTDragType))
266 SetToolTipText("User-defined expression/cut. Double-click to edit");
267}
268
269////////////////////////////////////////////////////////////////////////////////
270/// Set tool tip text associated with this item. The delay is in
271/// milliseconds (minimum 250). To remove tool tip call method with text = 0
272
273void TTVLVEntry::SetToolTipText(const char *text, Long_t delayms)
274{
275 if (fTip) {
276 delete fTip;
277 fTip = nullptr;
278 }
279
280 if (text && strlen(text))
281 fTip = new TGToolTip(fClient->GetRoot(), this, text, delayms);
282}
283////////////////////////////////////////////////////////////////////////////////
284/// Set small picture
285
287{
288 const TGPicture *cspic = fSmallPic;
289 fSmallPic = spic;
291 if (fSelPic) delete fSelPic;
292 fSelPic = nullptr;
293 if (fActive) {
295 }
296 DoRedraw();
297 fClient->FreePicture(cspic);
298}
299
300
301/** \class TTVLVContainer
302This class represent the list view container for the TreeView class.
303It is a TGLVContainer with item dragging capabilities for the TTVLVEntry objects inside.
304*/
305
306////////////////////////////////////////////////////////////////////////////////
307/// TGLVContainer constructor
308
310 :TGLVContainer(p, w, h,options | kSunkenFrame)
311{
312 fListView = nullptr;
313 fViewer = nullptr;
315 fCursor = gVirtualX->CreateCursor(kMove);
316 fDefaultCursor = gVirtualX->CreateCursor(kPointer);
317 fMapSubwindows = true;
318}
319
320////////////////////////////////////////////////////////////////////////////////
321/// TGLVContainer destructor
322
327
328////////////////////////////////////////////////////////////////////////////////
329/// Return the cut entry
330
332{
333 TGFrameElement *el = (TGFrameElement *) fList->At(3);
334 if (el) {
335 TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
336 if (f) return f->ConvertAliases();
337 return nullptr;
338 }
339 return nullptr;
340}
341
342////////////////////////////////////////////////////////////////////////////////
343/// Return the expression item at specific position
344
346{
347 TGFrameElement *el = (TGFrameElement *) fList->At(index);
348 if (el) {
349 TTVLVEntry *item = (TTVLVEntry *) el->fFrame;
350 return item;
351 }
352 return nullptr;
353}
354
355////////////////////////////////////////////////////////////////////////////////
356/// Return the list of user-defined expressions
357
359{
360 fExpressionList->Clear();
361 TIter next(fList);
362 TGFrameElement *el;
363 while ((el = (TGFrameElement*)next())) {
364 TTVLVEntry *item = (TTVLVEntry *)el->fFrame;
365 if (item) {
366 ULong_t *itemType = (ULong_t *) item->GetUserData();
367 if ((*itemType & TTreeViewer::kLTExpressionType) &&
368 (*itemType & TTreeViewer::kLTDragType)) fExpressionList->Add(item);
369 }
370 }
371 return fExpressionList;
372}
373
374////////////////////////////////////////////////////////////////////////////////
375/// Return the expression on X
376
378{
379 TGFrameElement *el = (TGFrameElement *) fList->At(0);
380 if (el) {
381 TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
382 if (f) return f->ConvertAliases();
383 return nullptr;
384 }
385 return nullptr;
386}
387
388////////////////////////////////////////////////////////////////////////////////
389/// Return the expression on Y
390
392{
393 TGFrameElement *el = (TGFrameElement *) fList->At(1);
394 if (el) {
395 TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
396 if (f) return f->ConvertAliases();
397 return nullptr;
398 }
399 return nullptr;
400}
401
402////////////////////////////////////////////////////////////////////////////////
403/// Return the expression on Z
404
406{
407 TGFrameElement *el = (TGFrameElement *) fList->At(2);
408 if (el) {
409 TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
410 if (f) return f->ConvertAliases();
411 return nullptr;
412 }
413 return nullptr;
414}
415
416////////////////////////////////////////////////////////////////////////////////
417/// Return the cut entry
418
420{
421 TGFrameElement *el = (TGFrameElement *) fList->At(4);
422 if (el) {
423 TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
424 if (f) return f->GetTrueName();
425 return nullptr;
426 }
427 return nullptr;
428}
429
430////////////////////////////////////////////////////////////////////////////////
431/// Handle mouse button event in container.
432
434{
435 int total, selected;
436
437 if (event->fType == kButtonPress) {
438 fXp = event->fX;
439 fYp = event->fY;
440 if (fLastActive) {
441 fLastActive->Activate(false);
442 fLastActive = nullptr;
443 }
444 total = selected = 0;
445
446 TGFrameElement *el;
447 TIter next(fList);
448 while ((el = (TGFrameElement *) next())) {
449 TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
450 ++total;
451 if (f->GetId() == (Window_t)event->fUser[0]) { // fUser[0] = subwindow
452 f->Activate(true);
453 if (f->GetTip()) (f->GetTip())->Hide();
454 fX0 = f->GetX();
455 fY0 = f->GetY();
456 ++selected;
457 fLastActive = f;
458 } else {
459 f->Activate(false);
460 }
461 }
462
463 if (fTotal != total || fSelected != selected) {
464 fTotal = total;
465 fSelected = selected;
468 }
469
470 if (selected == 1 && event->fCode == 1) {
471 ULong_t *itemType = (ULong_t *) fLastActive->GetUserData();
472 if (*itemType & TTreeViewer::kLTDragType) {
473 fDragging = true;
474 gVirtualX->SetCursor(fId,fCursor);
475 fXp = event->fX;
476 fYp = event->fY;
477 }
478 }
479 }
480
481 if (event->fType == kButtonRelease) {
482 if (fDragging) {
483 fDragging = false;
484 gVirtualX->SetCursor(fId,fDefaultCursor);
485 fLastActive->Move(fX0,fY0);
486 TGFrameElement *el;
487 TIter next(fList);
488 while ((el = (TGFrameElement *) next())) {
489 TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
490 if ((f == fLastActive) || !f->IsActive()) continue;
491 ULong_t *itemType = (ULong_t *) f->GetUserData();
492 fLastActive->Activate(false);
493 if (!(*itemType & TTreeViewer::kLTPackType)) {
494 // dragging items to expressions
495 ((TTVLVEntry *) fLastActive)->CopyItem(f);
496 if (*itemType & TTreeViewer::kLTDragType)
497 f->SetToolTipText("Double-click to draw. Drag and drop. Use Edit/Expression or context menu to edit.");
498 } else {
499 if (strlen(((TTVLVEntry *) fLastActive)->GetTrueName())) {
500 // dragging to scan box
501 if (!strlen(f->GetTrueName())) {
502 f->SetTrueName(((TTVLVEntry *)fLastActive)->GetTrueName());
503 f->SetSmallPic(fClient->GetPicture("pack_t.xpm"));
504 } else {
505 TString name(2000);
506 TString dragged = ((TTVLVEntry *)fLastActive)->ConvertAliases();
507 name = f->GetTrueName();
508 if ((name.Length()+dragged.Length()) < 228) {
509 name += ":";
510 name += dragged;
511 f->SetTrueName(name.Data());
512 } else {
513 Warning("HandleButton",
514 "Name too long. Can not add any more items to scan box.");
515 }
516 }
517 }
518 }
519 fLastActive = f;
520 if (fViewer) {
521 char msg[2000];
522 msg[0] = 0;
523 snprintf(msg,2000, "Content : %s", f->GetTrueName());
524 fViewer->Message(msg);
525 }
526 }
527 if ((std::abs(event->fX - fXp) < 2) && (std::abs(event->fY - fYp) < 2)) {
529 event->fCode, (event->fYRoot << 16) | event->fXRoot);
530 }
531 } else {
533 event->fCode, (event->fYRoot << 16) | event->fXRoot);
534 }
535 }
536 return true;
537}
538
539////////////////////////////////////////////////////////////////////////////////
540/// Handle mouse motion events.
541
543{
544 Int_t xf0, xff, yf0, yff;
545 Int_t xpos = event->fX - (fXp-fX0);
546 Int_t ypos = event->fY - (fYp-fY0);
547
548 if (fDragging) {
549 TGFrameElement *el;
550 ULong_t *itemType;
551 TIter next(fList);
552 while ((el = (TGFrameElement *) next())) {
553 TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
554 if (f == fLastActive) {
555 if (f->GetTip()) (f->GetTip())->Hide();
556 continue;
557 }
558 xf0 = f->GetX();
559 yf0 = f->GetY();
560 xff = f->GetX() + f->GetWidth();
561 yff = f->GetY() + f->GetHeight();
562 itemType = (ULong_t *) f->GetUserData();
563 if (*itemType & TTreeViewer::kLTExpressionType) {
564 if (xpos>xf0 && xpos<xff && ypos>yf0 && ypos<yff) {
565 f->Activate(true);
566 } else {
567 f->Activate(false);
568 }
569 }
570 }
571 if ((fXp - event->fX) > 10) {
572 fListView->SetHsbPosition(0);
573 fListView->SetVsbPosition(0);
574 }
575 fLastActive->Move(xpos, ypos);
576 gVirtualX->RaiseWindow(fLastActive->GetId());
578 }
579 return true;
580}
581
582////////////////////////////////////////////////////////////////////////////////
583/// Clear all names and aliases for expression type items
584
586{
587 TGFrameElement *el;
588 TIter next(fList);
589 while ((el = (TGFrameElement *) next())) {
590 TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
591 UInt_t *userData = (UInt_t *) f->GetUserData();
592 if (*userData & TTreeViewer::kLTExpressionType) {
593 if (*userData & TTreeViewer::kLTPackType) {
594 f->SetSmallPic(fClient->GetPicture("pack-empty_t.xpm"));
595 f->SetTrueName("");
596 } else {
597 f->Empty();
598 }
599 }
600 }
601}
602
603////////////////////////////////////////////////////////////////////////////////
604/// Remove all non-static items from the list view, except expressions
605
607{
608 TGFrameElement *el;
609 TIter next(fList);
610 while ((el = (TGFrameElement *) next())) {
611 TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
612 UInt_t *userData = (UInt_t *) f->GetUserData();
613 if (!((*userData) & TTreeViewer::kLTExpressionType)) {
614 RemoveItem(f);
615 }
616 }
617 fLastActive = nullptr;
618}
619
620////////////////////////////////////////////////////////////////////////////////
621/// Select an item
622
624{
625 if (fLastActive) {
626 fLastActive->Activate(false);
627 fLastActive = nullptr;
628 }
629 TGFrameElement *el;
630 fSelected = 0;
631 TIter next(fList);
632 while ((el = (TGFrameElement *) next())) {
633 TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
634 if (!strcmp(f->GetItemName()->GetString(),name)) {
635 f->Activate(true);
636 fLastActive = (TGLVEntry *) f;
637 fSelected++;
638 } else {
639 f->Activate(false);
640 }
641 }
642}
643
644
645/** \class TGSelectBox
646This class represent a specialized expression editor for TTVLVEntry 'true name' and 'alias' data members.
647It is a singleton in order to be able to use it for several expressions.
648*/
649
654
656
657////////////////////////////////////////////////////////////////////////////////
658/// TGSelectBox constructor
659
661 UInt_t w, UInt_t h)
662 :TGTransientFrame(p, main, w, h)
663{
664 if (!fgInstance) {
665 fgInstance = this;
667 if (!fViewer) Error("TGSelectBox", "Must be started from viewer");
668 fEntry = nullptr;
670 fBLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 2, 2, 2);
672
673 fLabel = new TGLabel(this, "");
675
676 fTe = new TGTextEntry(this, new TGTextBuffer(2000));
677 fTe->SetToolTipText("Type an expression using C++ syntax. Click other expression/leaves to paste them here.");
679
680 fLabelAlias = new TGLabel(this, "Alias");
682
683 fTeAlias = new TGTextEntry(this, new TGTextBuffer(100));
684 fTeAlias->SetToolTipText("Define an alias for this expression. Do NOT use leading strings of other aliases.");
686
687 fBf = new TGHorizontalFrame(this, 10, 10);
688
689 fCANCEL = new TGTextButton(fBf, "&Cancel", kTFCancel);
690 fCANCEL->Associate(this);
691 fBf->AddFrame(fCANCEL, fBLayout);
692
693 fDONE = new TGTextButton(fBf, "&Done", kTFDone);
694 fDONE->Associate(this);
695 fBf->AddFrame(fDONE, fBLayout1);
696
698
701
702// SetBackgroundColor(color);
703 Window_t wdum;
704 Int_t ax, ay;
705 gVirtualX->TranslateCoordinates(main->GetId(), GetParent()->GetId(), 25,
706 (Int_t)(((TGFrame *) main)->GetHeight() - fHeight) >> 1,
707 ax, ay, wdum);
708 MoveResize(ax, ay, w, GetDefaultHeight());
709 MapWindow();
710 }
711}
712
713////////////////////////////////////////////////////////////////////////////////
714/// TGSelectBox destructor
715
717{
718 fgInstance = nullptr;
719 delete fLabel;
720 delete fTe;
721 delete fLabelAlias;
722 delete fTeAlias;
723 delete fDONE;
724 delete fCANCEL;
725 delete fBf;
726 delete fLayout;
727 delete fBLayout;
728 delete fBLayout1;
729}
730
731////////////////////////////////////////////////////////////////////////////////
732/// Close the select box
733
735{
736 gVirtualX->UnmapWindow(GetId());
737 delete this;
738}
739
740////////////////////////////////////////////////////////////////////////////////
741/// Return the pointer to the instantiated singleton
742
747
748////////////////////////////////////////////////////////////////////////////////
749/// Just focus the cursor inside
750
752{
753 Event_t event;
754 event.fType = kButtonPress;
755 event.fCode = kButton1;
756 event.fX = event.fY = 1;
757 Int_t position = fTe->GetCursorPosition();
758 fTe->HandleButton(&event);
759 fTe->SetCursorPosition(position);
760}
761
762////////////////////////////////////////////////////////////////////////////////
763/// Set label of selection box
764
765void TGSelectBox::SetLabel(const char* title)
766{
767 fLabel->SetText(new TGString(title));
768}
769
770////////////////////////////////////////////////////////////////////////////////
771/// Save the edited entry true name and alias
772
774{
775 if (fEntry) {
776
777 bool cutType;
778 TString name(fTe->GetText());
779 if (name.Length())
780 fEntry->SetToolTipText("Double-click to draw. Drag and drop. Use Edit/Expression or context menu to edit.");
781 else
782 fEntry->SetToolTipText("User-defined expression/cut. Double-click to edit");
783 // Set type of item to "cut" if containing boolean operators
784 cutType = name.Contains("<") || name.Contains(">") || name.Contains("=") ||
785 name.Contains("!") || name.Contains("&") || name.Contains("|");
786 TString alias(fTeAlias->GetText());
787 if (!alias.BeginsWith("~") && !alias.Contains("empty")) fTeAlias->InsertText("~", 0);
788 fEntry->SetExpression(fTe->GetText(), fTeAlias->GetText(), cutType);
789
790 if (fOldAlias.Contains("empty")) {
791 fOldAlias = fTeAlias->GetText();
792 return;
793 }
794 TList *list = fViewer->ExpressionList();
795 TIter next(list);
796 TTVLVEntry* item;
797 while ((item=(TTVLVEntry*)next())) {
798 if (item != fEntry) {
799 name = item->GetTrueName();
800 name.ReplaceAll(fOldAlias.Data(), fTeAlias->GetText());
801 item->SetTrueName(name.Data());
802 }
803 }
804 }
805}
806
807////////////////////////////////////////////////////////////////////////////////
808/// Connect one entry
809
811{
812 fEntry = entry;
813 fTe->SetText(entry->GetTrueName());
814 fTeAlias->SetText(entry->GetAlias());
815 fOldAlias = entry->GetAlias();
816}
817
818////////////////////////////////////////////////////////////////////////////////
819/// Insert text in text entry
820
822{
823 Int_t start = fTe->GetCursorPosition();
824 fTe->InsertText(text, fTe->GetCursorPosition());
825 fTe->SetCursorPosition(start+strlen(text));
826}
827
828////////////////////////////////////////////////////////////////////////////////
829/// Message interpreter
830
832{
833 switch (GET_MSG(msg)) {
834 case kC_TEXTENTRY:
835 switch (GET_SUBMSG(msg)) {
836 case kTE_ENTER:
837 if (ValidateAlias()) SaveText();
838 break;
839 default:
840 break;
841 }
842 break;
843 case kC_COMMAND:
844 switch (GET_SUBMSG(msg)) {
845 case kCM_BUTTON:
846 switch (parm1) {
847 case kTFDone:
848 if (!ValidateAlias()) break;
849 SaveText();
850 CloseWindow();
851 break;
852 case kTFCancel:
853 CloseWindow();
854 break;
855 default:
856 break;
857 }
858 break;
859 default:
860 break;
861 }
862 break;
863 default:
864 if (parm2) break; // just to avoid warning on CC compiler
865 break;
866 }
867 return true;
868}
869
870////////////////////////////////////////////////////////////////////////////////
871/// Return true if edited alias is not a leading string of other expression aliases
872
874{
875 if (!strcmp(fTeAlias->GetText(), "-empty-") || !strlen(fTeAlias->GetText())) {
876 fViewer->Warning("ValidateAlias", "You should define the alias first.");
877 return false;
878 }
879 TList *list = fViewer->ExpressionList();
880 TIter next(list);
881 TTVLVEntry* item;
882 while ((item=(TTVLVEntry*)next())) {
883 if (item != fEntry) {
884 TString itemalias(item->GetAlias());
885 if (itemalias.Contains(fTeAlias->GetText())) {
886 fViewer->Warning("ValidAlias", "Alias can not be the leading string of other alias.");
887 return false;
888 }
889 }
890 }
891 return true;
892}
@ kButtonRelease
Definition GuiTypes.h:61
@ kButtonPress
Definition GuiTypes.h:61
@ kEnterNotify
Definition GuiTypes.h:62
@ kSunkenFrame
Definition GuiTypes.h:384
const Mask_t kLeaveWindowMask
Definition GuiTypes.h:169
@ kMove
Definition GuiTypes.h:375
@ kPointer
Definition GuiTypes.h:376
const Mask_t kEnterWindowMask
Definition GuiTypes.h:168
@ kButton1
Definition GuiTypes.h:215
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
#define f(i)
Definition RSha256.hxx:104
#define h(i)
Definition RSha256.hxx:106
start
Definition Rotated.cxx:223
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
long Longptr_t
Integer large enough to hold a pointer (platform-dependent).
Definition RtypesCore.h:89
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
EListViewMode
Definition TGListView.h:21
static unsigned int total
char name[80]
Definition TGX11.cxx:148
ETransientFrameCommands
@ kTFCancel
@ kTFDone
#define gVirtualX
Definition TVirtualX.h:375
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
Int_t GET_MSG(Long_t val)
EWidgetMessageTypes
WidgetMessageTypes.
@ kCT_SELCHANGED
@ kTE_ENTER
@ kCT_ITEMCLICK
@ kC_COMMAND
@ kCM_BUTTON
@ kC_TEXTENTRY
@ kCT_ITEMDBLCLICK
@ kC_CONTAINER
Int_t GET_SUBMSG(Long_t val)
#define snprintf
Definition civetweb.c:1579
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:318
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1156
UInt_t GetDefaultHeight() const override
Definition TGFrame.h:316
Bool_t fMapSubwindows
kTRUE - map subwindows
Definition TGFrame.h:297
TList * fList
container of frame elements
Definition TGFrame.h:294
virtual void RemoveItem(TGFrame *item)
Remove item from container.
Definition TGCanvas.cxx:657
const TGWindow * fMsgWindow
window handling container messages
Definition TGCanvas.h:42
Int_t fYp
previous pointer position
Definition TGCanvas.h:44
Int_t fY0
corner of rubber band box
Definition TGCanvas.h:45
Int_t fSelected
number of selected items
Definition TGCanvas.h:49
Int_t fX0
Definition TGCanvas.h:45
Int_t fXp
Definition TGCanvas.h:44
Bool_t fDragging
true if in dragging mode
Definition TGCanvas.h:47
Int_t fTotal
total items
Definition TGCanvas.h:48
TGFrame * fFrame
Definition TGLayout.h:112
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:331
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and/or resize the frame.
Definition TGFrame.cxx:621
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
UInt_t fHeight
frame height
Definition TGFrame.h:88
void MapWindow() override
map window
Definition TGFrame.h:206
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:637
UInt_t GetHeight() const
Definition TGFrame.h:227
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:387
Empty object used as context menu support for TGLVTreeEntries.
void EditExpression()
Edit expression.
void SetExpression(const char *name="", const char *alias="-empty-", bool cut=false)
Set item expression.
void Empty()
Empty item.
void Draw(Option_t *option="") override
Draw item.
TGItemContext()
Constructor.
void RemoveItem()
Remove item.
TTVLVEntry * fItem
void Scan()
Scan item.
TGLVEntry * fLastActive
last active item
Definition TGListView.h:191
TGLVContainer(const TGLVContainer &)=delete
const TGPicture * fCurrent
current icon
Definition TGListView.h:55
UInt_t fTHeight
height of name
Definition TGListView.h:49
void DoRedraw() override
Redraw list view item.
UInt_t fTWidth
width of name
Definition TGListView.h:48
TGDimension GetDefaultSize() const override
Get default size of list item.
Bool_t fActive
true if item is active
Definition TGListView.h:50
FontStruct_t fFontStruct
text font
Definition TGListView.h:59
TGString * fItemName
name of item
Definition TGListView.h:43
void * GetUserData() const
Definition TGListView.h:95
TGLVEntry(const TGLVEntry &)=delete
TGSelectedPicture * fSelPic
selected icon
Definition TGListView.h:57
const TGPicture * fSmallPic
small icon
Definition TGListView.h:54
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t GetId() const
Definition TGObject.h:41
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
This class represent a specialized expression editor for TTVLVEntry 'true name' and 'alias' data memb...
bool ValidateAlias()
Return true if edited alias is not a leading string of other expression aliases.
TGHorizontalFrame * fBf
Buttons frame.
TGSelectBox(const TGWindow *p, const TGWindow *main, UInt_t w=10, UInt_t h=10)
TGSelectBox constructor.
bool ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Message interpreter.
TGLayoutHints * fBLayout1
Layout for close button.
TGTextEntry * fTeAlias
Alias text entry.
void CloseWindow() override
Close the select box.
void InsertText(const char *text)
Insert text in text entry.
TGLayoutHints * fBLayout
Layout for cancel button.
TGLabel * fLabelAlias
Alias label.
TGLayoutHints * fLayout
Layout hints for widgets inside.
TGTextButton * fCANCEL
Cancel button.
void GrabPointer()
Just focus the cursor inside.
~TGSelectBox() override
TGSelectBox destructor.
void SetLabel(const char *title)
Set label of selection box.
void SetEntry(TTVLVEntry *entry)
Connect one entry.
static TGSelectBox * fgInstance
TTVLVEntry * fEntry
Edited expression entry.
static TGSelectBox * GetInstance()
Return the pointer to the instantiated singleton.
TGLabel * fLabel
Label.
TString fOldAlias
Old alias for edited entry.
TGTextEntry * fTe
Text entry box.
TTreeViewer * fViewer
Pointer to tree viewer.
TGTextButton * fDONE
Close button.
void SaveText()
Save the edited entry true name and alias.
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition TGString.h:20
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
Yield an action as soon as it is clicked.
Definition TGButton.h:142
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
A tooltip can be a one or multiple lines help text that is displayed in a window when the mouse curso...
Definition TGToolTip.h:24
TGTransientFrame(const TGTransientFrame &)=delete
const TGWindow * fMain
Definition TGFrame.h:503
ROOT GUI Window base class.
Definition TGWindow.h:23
TGWindow(Window_t id)
Definition TGWindow.h:34
const TGWindow * GetParent() const
Definition TGWindow.h:83
void Reset()
A doubly linked list.
Definition TList.h:38
Basic string class.
Definition TString.h:138
Ssiz_t Length() const
Definition TString.h:425
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:632
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:641
This class represent the list view container for the TreeView class.
Cursor_t fDefaultCursor
Default cursor.
void SelectItem(const char *name)
Select an item.
TList * fExpressionList
List of user defined expression widgets.
TList * ExpressionList()
Return the list of user-defined expressions.
const char * Cut()
Return the cut entry.
TTreeViewer * GetViewer()
const char * Ez()
Return the expression on Z.
TGListView * fListView
Associated list view.
const char * Ey()
Return the expression on Y.
const char * ScanList()
Return the cut entry.
TTreeViewer * fViewer
Pointer to tree viewer.
Cursor_t fCursor
Current cursor.
~TTVLVContainer() override
TGLVContainer destructor.
TTVLVEntry * ExpressionItem(Int_t index)
Return the expression item at specific position.
bool HandleMotion(Event_t *event) override
Handle mouse motion events.
const char * Ex()
Return the expression on X.
TTVLVContainer(const TGWindow *p, UInt_t w, UInt_t h, UInt_t options=kSunkenFrame)
TGLVContainer constructor.
bool HandleButton(Event_t *event) override
Handle mouse button event in container.
void EmptyAll()
Clear all names and aliases for expression type items.
void RemoveNonStatic()
Remove all non-static items from the list view, except expressions.
This class represent entries that goes into the TreeViewer listview container.
void SetSmallPic(const TGPicture *spic)
Set small picture.
~TTVLVEntry() override
TTVLVEntry destructor.
bool HasAlias()
Check if alias name is not empty.
TTVLVContainer * GetContainer()
TTVLVContainer * fContainer
Container to whom this item belongs.
TGToolTip * fTip
Tool tip associated with item.
bool fIsCut
Flag for cut type items.
void SetCutType(bool type=false)
Set cut type.
void SetAlias(const char *alias)
void SetExpression(const char *name, const char *alias, bool cutType=false)
Set the true name, alias and type of the expression, then refresh it.
void SetToolTipText(const char *text, Long_t delayms=1000)
Set tool tip text associated with this item.
void SetTrueName(const char *name)
TGItemContext * fContext
Associated context menu.
bool HandleCrossing(Event_t *event) override
Handle mouse crossing event.
const char * ConvertAliases()
Convert all aliases into true names.
void CopyItem(TTVLVEntry *dest)
Copy this item's name and alias to an other.
const char * GetAlias()
TString fConvName
Name converted into true expressions.
TString fTrueName
Name for this entry.
TString fAlias
Alias for this entry.
void Empty()
Clear all names and alias.
bool FullConverted()
Return true if converted name is alias free.
void SetItemName(const char *name)
Redraw this entry with new name.
const char * GetTrueName()
TTVLVEntry(const TGWindow *p, const TGPicture *bigpic, const TGPicture *smallpic, TGString *name, TGString **subnames, EListViewMode ViewMode)
TTVLVEntry constructor.
void PrependTilde()
Prepend a ~ to item alias.
A graphic user interface designed to handle ROOT trees and to take advantage of TTree class features.
Definition TTreeViewer.h:54
TList * ExpressionList()
TText * text
int main(int argc, char **argv)
Definition hadd.cxx:631
Event structure.
Definition GuiTypes.h:175
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:176
Int_t fY
pointer x, y coordinates in event window
Definition GuiTypes.h:179
Int_t fXRoot
Definition GuiTypes.h:180
Int_t fYRoot
coordinates relative to root
Definition GuiTypes.h:180
Int_t fX
Definition GuiTypes.h:179
UInt_t fCode
key or button code
Definition GuiTypes.h:181
Longptr_t fUser[5]
5 longs can be used by client message events NOTE: only [0], [1] and [2] may be used.
Definition GuiTypes.h:188