Logo ROOT   6.14/05
Reference Guide
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 
21 
23 
24 /** \class TGItemContext
25 empty object used as context menu support for TGLVTreeEntries.
26 */
27 
28 ////////////////////////////////////////////////////////////////////////////////
29 /// Constructor
30 
32 {
33  fItem = 0;
34 }
35 
36 ////////////////////////////////////////////////////////////////////////////////
37 /// Draw item
38 
40 {
42 }
43 
44 ////////////////////////////////////////////////////////////////////////////////
45 /// Edit expression
46 
48 {
50 }
51 
52 ////////////////////////////////////////////////////////////////////////////////
53 /// Empty item
54 
56 {
57  fItem->Empty();
58 }
59 
60 ////////////////////////////////////////////////////////////////////////////////
61 /// Remove item
62 
64 {
66 }
67 
68 ////////////////////////////////////////////////////////////////////////////////
69 /// Scan item
70 
72 {
75 }
76 
77 ////////////////////////////////////////////////////////////////////////////////
78 /// Set item expression
79 
80 void TGItemContext::SetExpression(const char *name, const char *alias, Bool_t cut)
81 {
82  fItem->SetExpression(name, alias, cut);
83 }
84 
86 
87 /** \class TTVLVEntry
88 This class represent entries that goes into the TreeViewer
89 listview container. It subclasses TGLVEntry and adds 2
90 data members: the item true name and the alias.
91 */
92 
93 ////////////////////////////////////////////////////////////////////////////////
94 /// TTVLVEntry constructor.
95 
97  const TGPicture *bigpic, const TGPicture *smallpic,
98  TGString *name, TGString **subnames,
99  EListViewMode ViewMode)
100  :TGLVEntry(p, bigpic, smallpic, name, subnames, ViewMode)
101 {
102  // both alias and true name are initialized to name
103  fContainer = (TTVLVContainer *) p;
104 
105  fTip = 0;
106  fIsCut = kFALSE;
107  fTrueName = name->GetString();
108  fContext = new TGItemContext();
109  fContext->Associate(this);
110 
112 }
113 
114 ////////////////////////////////////////////////////////////////////////////////
115 /// TTVLVEntry destructor
116 
118 {
119  if (fTip) delete fTip;
120  delete fContext;
121 }
122 
123 ////////////////////////////////////////////////////////////////////////////////
124 /// Convert all aliases into true names
125 
127 {
128  TList *list = GetContainer()->GetViewer()->ExpressionList();
130  TString start(fConvName);
131  TIter next(list);
132  TTVLVEntry* item;
133  while (!FullConverted()) {
134  next.Reset();
135  start = fConvName;
136  while ((item=(TTVLVEntry*)next())) {
137  if (item != this)
138  fConvName.ReplaceAll(item->GetAlias(), item->GetTrueName());
139  }
140  if (fConvName == start) {
141  //the following line is deadcode reported by coverity because item=0
142  //if (item) Warning(item->GetAlias(), "Cannot convert aliases for this expression.");
143  return(fConvName.Data());
144  }
145  }
146  return(fConvName.Data());
147 }
148 
149 ////////////////////////////////////////////////////////////////////////////////
150 /// Return true if converted name is alias free
151 
153 {
154  TList *list = GetContainer()->GetViewer()->ExpressionList();
155  TIter next(list);
156  TTVLVEntry* item;
157  while ((item=(TTVLVEntry*)next())) {
158  if (item != this) {
159  if (fConvName.Contains(item->GetAlias())) return kFALSE;
160  }
161  }
162  return kTRUE;
163 }
164 
165 ////////////////////////////////////////////////////////////////////////////////
166 /// Copy this item's name and alias to an other.
167 
169 {
170  if (!dest) return;
172  TString alias = dest->GetAlias();
173  if (!alias.BeginsWith("~") && !alias.Contains("empty")) dest->PrependTilde();
174 }
175 
176 ////////////////////////////////////////////////////////////////////////////////
177 /// Handle mouse crossing event.
178 
180 {
181  if (fTip) {
182  if (event->fType == kEnterNotify)
183  fTip->Reset();
184  else
185  fTip->Hide();
186  }
187  return kTRUE;
188 }
189 
190 ////////////////////////////////////////////////////////////////////////////////
191 /// Check if alias name is not empty.
192 
194 {
195  if (fAlias.Length()) return kTRUE;
196  return kFALSE;
197 }
198 
199 ////////////////////////////////////////////////////////////////////////////////
200 /// Prepend a ~ to item alias
201 
203 {
204  fAlias = "~" + fAlias;
206 }
207 
208 ////////////////////////////////////////////////////////////////////////////////
209 /// Redraw this entry with new name
210 
211 void TTVLVEntry::SetItemName(const char* name)
212 {
213  if (fItemName) delete fItemName;
214  fItemName = new TGString(name);
215  Int_t max_ascent, max_descent;
217  gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
218  fTHeight = max_ascent + max_descent;
219  gVirtualX->ClearWindow(fId);
221  fClient->NeedRedraw(this);
222 }
223 
224 ////////////////////////////////////////////////////////////////////////////////
225 /// Set cut type
226 
228 {
229  if (fIsCut && type) return;
230  if (!fIsCut && !type) return;
231  if (type) {
232  SetSmallPic(fClient->GetPicture("selection_t.xpm"));
233  SetToolTipText("Selection expression. Drag to scissors to activate");
234  } else
235  SetSmallPic(fClient->GetPicture("expression_t.xpm"));
236  fIsCut = type;
237 }
238 
239 ////////////////////////////////////////////////////////////////////////////////
240 /// Set the true name, alias and type of the expression, then refresh it
241 
242 void TTVLVEntry::SetExpression(const char* name, const char* alias, Bool_t cutType)
243 {
244  SetItemName(alias);
245  SetAlias(alias);
246  SetTrueName(name);
247  ULong_t *itemType = (ULong_t *) GetUserData();
248  if (*itemType & TTreeViewer::kLTPackType) {
249  if (strlen(name))
250  SetSmallPic(fClient->GetPicture("pack_t.xpm"));
251  else
252  SetSmallPic(fClient->GetPicture("pack-empty_t.xpm"));
253  }
254  if ((*itemType & TTreeViewer::kLTDragType) && strlen(name) && !fIsCut)
255  SetToolTipText("Double-click to draw. Drag and drop. Use Edit/Expression or context menu to edit.");
256  if (*itemType & TTreeViewer::kLTDragType) SetCutType(cutType);
257 }
258 
259 ////////////////////////////////////////////////////////////////////////////////
260 /// Clear all names and alias
261 
263 {
264  SetExpression("","-empty-");
265  ULong_t *itemType = (ULong_t *) GetUserData();
266  if (itemType && (*itemType & TTreeViewer::kLTDragType))
267  SetToolTipText("User-defined expression/cut. Double-click to edit");
268 }
269 
270 ////////////////////////////////////////////////////////////////////////////////
271 /// Set tool tip text associated with this item. The delay is in
272 /// milliseconds (minimum 250). To remove tool tip call method with text = 0
273 
274 void TTVLVEntry::SetToolTipText(const char *text, Long_t delayms)
275 {
276  if (fTip) {
277  delete fTip;
278  fTip = 0;
279  }
280 
281  if (text && strlen(text))
282  fTip = new TGToolTip(fClient->GetRoot(), this, text, delayms);
283 }
284 ////////////////////////////////////////////////////////////////////////////////
285 /// Set small picture
286 
288 {
289  const TGPicture *cspic = fSmallPic;
290  fSmallPic = spic;
292  if (fSelPic) delete fSelPic;
293  fSelPic = 0;
294  if (fActive) {
296  }
297  DoRedraw();
298  fClient->FreePicture(cspic);
299 }
300 
302 
303 /** \class TTVLVContainer
304 This class represent the list view container for the.
305 TreeView class. It is a TGLVContainer with item dragging
306 capabilities for the TTVLVEntry objects inside.
307 */
308 
309 ////////////////////////////////////////////////////////////////////////////////
310 /// TGLVContainer constructor
311 
313  :TGLVContainer(p, w, h,options | kSunkenFrame)
314 {
315  fListView = 0;
316  fViewer = 0;
317  fExpressionList = new TList;
318  fCursor = gVirtualX->CreateCursor(kMove);
319  fDefaultCursor = gVirtualX->CreateCursor(kPointer);
321 }
322 
323 ////////////////////////////////////////////////////////////////////////////////
324 /// TGLVContainer destructor
325 
327 {
328  delete fExpressionList;
329 }
330 
331 ////////////////////////////////////////////////////////////////////////////////
332 /// Return the cut entry
333 
334 const char* TTVLVContainer::Cut()
335 {
336  TGFrameElement *el = (TGFrameElement *) fList->At(3);
337  if (el) {
338  TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
339  if (f) return f->ConvertAliases();
340  return 0;
341  }
342  return 0;
343 }
344 
345 ////////////////////////////////////////////////////////////////////////////////
346 /// Return the expression item at specific position
347 
349 {
350  TGFrameElement *el = (TGFrameElement *) fList->At(index);
351  if (el) {
352  TTVLVEntry *item = (TTVLVEntry *) el->fFrame;
353  return item;
354  }
355  return 0;
356 }
357 
358 ////////////////////////////////////////////////////////////////////////////////
359 /// Return the list of user-defined expressions
360 
362 {
364  TIter next(fList);
365  TGFrameElement *el;
366  while ((el = (TGFrameElement*)next())) {
367  TTVLVEntry *item = (TTVLVEntry *)el->fFrame;
368  if (item) {
369  ULong_t *itemType = (ULong_t *) item->GetUserData();
370  if ((*itemType & TTreeViewer::kLTExpressionType) &&
371  (*itemType & TTreeViewer::kLTDragType)) fExpressionList->Add(item);
372  }
373  }
374  return fExpressionList;
375 }
376 
377 ////////////////////////////////////////////////////////////////////////////////
378 /// Return the expression on X
379 
380 const char* TTVLVContainer::Ex()
381 {
382  TGFrameElement *el = (TGFrameElement *) fList->At(0);
383  if (el) {
384  TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
385  if (f) return f->ConvertAliases();
386  return 0;
387  }
388  return 0;
389 }
390 
391 ////////////////////////////////////////////////////////////////////////////////
392 /// Return the expression on Y
393 
394 const char* TTVLVContainer::Ey()
395 {
396  TGFrameElement *el = (TGFrameElement *) fList->At(1);
397  if (el) {
398  TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
399  if (f) return f->ConvertAliases();
400  return 0;
401  }
402  return 0;
403 }
404 
405 ////////////////////////////////////////////////////////////////////////////////
406 /// Return the expression on Z
407 
408 const char* TTVLVContainer::Ez()
409 {
410  TGFrameElement *el = (TGFrameElement *) fList->At(2);
411  if (el) {
412  TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
413  if (f) return f->ConvertAliases();
414  return 0;
415  }
416  return 0;
417 }
418 
419 ////////////////////////////////////////////////////////////////////////////////
420 /// Return the cut entry
421 
423 {
424  TGFrameElement *el = (TGFrameElement *) fList->At(4);
425  if (el) {
426  TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
427  if (f) return f->GetTrueName();
428  return 0;
429  }
430  return 0;
431 }
432 
433 ////////////////////////////////////////////////////////////////////////////////
434 /// Handle mouse button event in container.
435 
437 {
438  int total, selected;
439 
440  if (event->fType == kButtonPress) {
441  fXp = event->fX;
442  fYp = event->fY;
443  if (fLastActive) {
445  fLastActive = 0;
446  }
447  total = selected = 0;
448 
449  TGFrameElement *el;
450  TIter next(fList);
451  while ((el = (TGFrameElement *) next())) {
452  TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
453  ++total;
454  if (f->GetId() == (Window_t)event->fUser[0]) { // fUser[0] = subwindow
455  f->Activate(kTRUE);
456  if (f->GetTip()) (f->GetTip())->Hide();
457  fX0 = f->GetX();
458  fY0 = f->GetY();
459  ++selected;
460  fLastActive = f;
461  } else {
462  f->Activate(kFALSE);
463  }
464  }
465 
466  if (fTotal != total || fSelected != selected) {
467  fTotal = total;
468  fSelected = selected;
470  fTotal, fSelected);
471  }
472 
473  if (selected == 1 && event->fCode == 1) {
474  ULong_t *itemType = (ULong_t *) fLastActive->GetUserData();
475  if (*itemType & TTreeViewer::kLTDragType) {
476  fDragging = kTRUE;
477  gVirtualX->SetCursor(fId,fCursor);
478  fXp = event->fX;
479  fYp = event->fY;
480  }
481  }
482  }
483 
484  if (event->fType == kButtonRelease) {
485  if (fDragging) {
486  fDragging = kFALSE;
487  gVirtualX->SetCursor(fId,fDefaultCursor);
489  TGFrameElement *el;
490  TIter next(fList);
491  while ((el = (TGFrameElement *) next())) {
492  TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
493  if ((f == fLastActive) || !f->IsActive()) continue;
494  ULong_t *itemType = (ULong_t *) f->GetUserData();
496  if (!(*itemType & TTreeViewer::kLTPackType)) {
497  // dragging items to expressions
498  ((TTVLVEntry *) fLastActive)->CopyItem(f);
499  if (*itemType & TTreeViewer::kLTDragType)
500  f->SetToolTipText("Double-click to draw. Drag and drop. Use Edit/Expression or context menu to edit.");
501  } else {
502  if (strlen(((TTVLVEntry *) fLastActive)->GetTrueName())) {
503  // dragging to scan box
504  if (!strlen(f->GetTrueName())) {
505  f->SetTrueName(((TTVLVEntry *)fLastActive)->GetTrueName());
506  f->SetSmallPic(fClient->GetPicture("pack_t.xpm"));
507  } else {
508  TString name(2000);
509  TString dragged = ((TTVLVEntry *)fLastActive)->ConvertAliases();
510  name = f->GetTrueName();
511  if ((name.Length()+dragged.Length()) < 228) {
512  name += ":";
513  name += dragged;
514  f->SetTrueName(name.Data());
515  } else {
516  Warning("HandleButton",
517  "Name too long. Can not add any more items to scan box.");
518  }
519  }
520  }
521  }
522  fLastActive = f;
523  if (fViewer) {
524  char msg[2000];
525  msg[0] = 0;
526  snprintf(msg,2000, "Content : %s", f->GetTrueName());
527  fViewer->Message(msg);
528  }
529  }
530  if ((TMath::Abs(event->fX - fXp) < 2) && (TMath::Abs(event->fY - fYp) < 2)) {
532  event->fCode, (event->fYRoot << 16) | event->fXRoot);
533  }
534  } else {
536  event->fCode, (event->fYRoot << 16) | event->fXRoot);
537  }
538  }
539  return kTRUE;
540 }
541 
542 ////////////////////////////////////////////////////////////////////////////////
543 /// Handle mouse motion events.
544 
546 {
547  Int_t xf0, xff, yf0, yff;
548  Int_t xpos = event->fX - (fXp-fX0);
549  Int_t ypos = event->fY - (fYp-fY0);
550 
551  if (fDragging) {
552  TGFrameElement *el;
553  ULong_t *itemType;
554  TIter next(fList);
555  while ((el = (TGFrameElement *) next())) {
556  TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
557  if (f == fLastActive) {
558  if (f->GetTip()) (f->GetTip())->Hide();
559  continue;
560  }
561  xf0 = f->GetX();
562  yf0 = f->GetY();
563  xff = f->GetX() + f->GetWidth();
564  yff = f->GetY() + f->GetHeight();
565  itemType = (ULong_t *) f->GetUserData();
566  if (*itemType & TTreeViewer::kLTExpressionType) {
567  if (xpos>xf0 && xpos<xff && ypos>yf0 && ypos<yff) {
568  f->Activate(kTRUE);
569  } else {
570  f->Activate(kFALSE);
571  }
572  }
573  }
574  if ((fXp - event->fX) > 10) {
577  }
578  fLastActive->Move(xpos, ypos);
579  gVirtualX->RaiseWindow(fLastActive->GetId());
581  }
582  return kTRUE;
583 }
584 
585 ////////////////////////////////////////////////////////////////////////////////
586 /// Clear all names and aliases for expression type items
587 
589 {
590  TGFrameElement *el;
591  TIter next(fList);
592  while ((el = (TGFrameElement *) next())) {
593  TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
594  UInt_t *userData = (UInt_t *) f->GetUserData();
595  if (*userData & TTreeViewer::kLTExpressionType) {
596  if (*userData & TTreeViewer::kLTPackType) {
597  f->SetSmallPic(fClient->GetPicture("pack-empty_t.xpm"));
598  f->SetTrueName("");
599  } else {
600  f->Empty();
601  }
602  }
603  }
604 }
605 
606 ////////////////////////////////////////////////////////////////////////////////
607 /// Remove all non-static items from the list view, except expressions
608 
610 {
611  TGFrameElement *el;
612  TIter next(fList);
613  while ((el = (TGFrameElement *) next())) {
614  TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
615  UInt_t *userData = (UInt_t *) f->GetUserData();
616  if (!((*userData) & TTreeViewer::kLTExpressionType)) {
617  RemoveItem(f);
618  }
619  }
620  fLastActive = 0;
621 }
622 
623 ////////////////////////////////////////////////////////////////////////////////
624 /// Select an item
625 
627 {
628  if (fLastActive) {
630  fLastActive = 0;
631  }
632  TGFrameElement *el;
633  fSelected = 0;
634  TIter next(fList);
635  while ((el = (TGFrameElement *) next())) {
636  TTVLVEntry *f = (TTVLVEntry *) el->fFrame;
637  if (!strcmp(f->GetItemName()->GetString(),name)) {
638  f->Activate(kTRUE);
639  fLastActive = (TGLVEntry *) f;
640  fSelected++;
641  } else {
642  f->Activate(kFALSE);
643  }
644  }
645 }
646 
648 
649 /** \class TGSelectBox
650 This class represent a specialized expression editor for
651 TTVLVEntry 'true name' and 'alias' data members.
652 It is a singleton in order to be able to use it for several
653 expressions.
654 */
655 
659 };
660 
662 
663 ////////////////////////////////////////////////////////////////////////////////
664 /// TGSelectBox constructor
665 
667  UInt_t w, UInt_t h)
668  :TGTransientFrame(p, main, w, h)
669 {
670  if (!fgInstance) {
671  fgInstance = this;
673  if (!fViewer) Error("TGSelectBox", "Must be started from viewer");
674  fEntry = 0;
676  fBLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 2, 2, 2);
677  fBLayout1= new TGLayoutHints(kLHintsTop | kLHintsRight, 2, 0, 2, 2);
678 
679  fLabel = new TGLabel(this, "");
681 
682  fTe = new TGTextEntry(this, new TGTextBuffer(2000));
683  fTe->SetToolTipText("Type an expression using C++ syntax. Click other expression/leaves to paste them here.");
684  AddFrame(fTe, fLayout);
685 
686  fLabelAlias = new TGLabel(this, "Alias");
688 
689  fTeAlias = new TGTextEntry(this, new TGTextBuffer(100));
690  fTeAlias->SetToolTipText("Define an alias for this expression. Do NOT use leading strings of other aliases.");
692 
693  fBf = new TGHorizontalFrame(this, 10, 10);
694 
695  fCANCEL = new TGTextButton(fBf, "&Cancel", kTFCancel);
696  fCANCEL->Associate(this);
698 
699  fDONE = new TGTextButton(fBf, "&Done", kTFDone);
700  fDONE->Associate(this);
702 
703  AddFrame(fBf, fLayout);
704 
705  MapSubwindows();
707 
708 // SetBackgroundColor(color);
709  Window_t wdum;
710  Int_t ax, ay;
711  gVirtualX->TranslateCoordinates(main->GetId(), GetParent()->GetId(), 25,
712  (Int_t)(((TGFrame *) main)->GetHeight() - fHeight) >> 1,
713  ax, ay, wdum);
714  MoveResize(ax, ay, w, GetDefaultHeight());
715  MapWindow();
716  }
717 }
718 
719 ////////////////////////////////////////////////////////////////////////////////
720 /// TGSelectBox destructor
721 
723 {
724  fgInstance = 0;
725  delete fLabel;
726  delete fTe;
727  delete fLabelAlias;
728  delete fTeAlias;
729  delete fDONE;
730  delete fCANCEL;
731  delete fBf;
732  delete fLayout;
733  delete fBLayout;
734  delete fBLayout1;
735 }
736 
737 ////////////////////////////////////////////////////////////////////////////////
738 /// Close the select box
739 
741 {
742  gVirtualX->UnmapWindow(GetId());
743  delete this;
744 }
745 
746 ////////////////////////////////////////////////////////////////////////////////
747 /// Return the pointer to the instantiated singleton
748 
750 {
751  return fgInstance;
752 }
753 
754 ////////////////////////////////////////////////////////////////////////////////
755 /// Just focus the cursor inside
756 
758 {
759  Event_t event;
760  event.fType = kButtonPress;
761  event.fCode = kButton1;
762  event.fX = event.fY = 1;
763  Int_t position = fTe->GetCursorPosition();
764  fTe->HandleButton(&event);
765  fTe->SetCursorPosition(position);
766 }
767 
768 ////////////////////////////////////////////////////////////////////////////////
769 /// Set label of selection box
770 
771 void TGSelectBox::SetLabel(const char* title)
772 {
773  fLabel->SetText(new TGString(title));
774 }
775 
776 ////////////////////////////////////////////////////////////////////////////////
777 /// Save the edited entry true name and alias
778 
780 {
781  if (fEntry) {
782 
783  Bool_t cutType;
784  TString name(fTe->GetText());
785  if (name.Length())
786  fEntry->SetToolTipText("Double-click to draw. Drag and drop. Use Edit/Expression or context menu to edit.");
787  else
788  fEntry->SetToolTipText("User-defined expression/cut. Double-click to edit");
789  // Set type of item to "cut" if containing boolean operators
790  cutType = name.Contains("<") || name.Contains(">") || name.Contains("=") ||
791  name.Contains("!") || name.Contains("&") || name.Contains("|");
792  TString alias(fTeAlias->GetText());
793  if (!alias.BeginsWith("~") && !alias.Contains("empty")) fTeAlias->InsertText("~", 0);
794  fEntry->SetExpression(fTe->GetText(), fTeAlias->GetText(), cutType);
795 
796  if (fOldAlias.Contains("empty")) {
798  return;
799  }
800  TList *list = fViewer->ExpressionList();
801  TIter next(list);
802  TTVLVEntry* item;
803  while ((item=(TTVLVEntry*)next())) {
804  if (item != fEntry) {
805  name = item->GetTrueName();
806  name.ReplaceAll(fOldAlias.Data(), fTeAlias->GetText());
807  item->SetTrueName(name.Data());
808  }
809  }
810  }
811 }
812 
813 ////////////////////////////////////////////////////////////////////////////////
814 /// Connect one entry
815 
817 {
818  fEntry = entry;
819  fTe->SetText(entry->GetTrueName());
820  fTeAlias->SetText(entry->GetAlias());
821  fOldAlias = entry->GetAlias();
822 }
823 
824 ////////////////////////////////////////////////////////////////////////////////
825 /// Insert text in text entry
826 
827 void TGSelectBox::InsertText(const char* text)
828 {
829  Int_t start = fTe->GetCursorPosition();
830  fTe->InsertText(text, fTe->GetCursorPosition());
831  fTe->SetCursorPosition(start+strlen(text));
832 }
833 
834 ////////////////////////////////////////////////////////////////////////////////
835 /// Message interpreter
836 
838 {
839  switch (GET_MSG(msg)) {
840  case kC_TEXTENTRY:
841  switch (GET_SUBMSG(msg)) {
842  case kTE_ENTER:
843  if (ValidateAlias()) SaveText();
844  break;
845  default:
846  break;
847  }
848  break;
849  case kC_COMMAND:
850  switch (GET_SUBMSG(msg)) {
851  case kCM_BUTTON:
852  switch (parm1) {
853  case kTFDone:
854  if (!ValidateAlias()) break;
855  SaveText();
856  CloseWindow();
857  break;
858  case kTFCancel:
859  CloseWindow();
860  break;
861  default:
862  break;
863  }
864  break;
865  default:
866  break;
867  }
868  break;
869  default:
870  if (parm2) break; // just to avoid warning on CC compiler
871  break;
872  }
873  return kTRUE;
874 }
875 
876 ////////////////////////////////////////////////////////////////////////////////
877 /// Return true if edited alias is not a leading string of other expression aliases
878 
880 {
881  if (!strcmp(fTeAlias->GetText(), "-empty-") || !strlen(fTeAlias->GetText())) {
882  fViewer->Warning("ValidateAlias", "You should define the alias first.");
883  return kFALSE;
884  }
885  TList *list = fViewer->ExpressionList();
886  TIter next(list);
887  TTVLVEntry* item;
888  while ((item=(TTVLVEntry*)next())) {
889  if (item != fEntry) {
890  TString itemalias(item->GetAlias());
891  if (itemalias.Contains(fTeAlias->GetText())) {
892  fViewer->Warning("ValidAlias", "Alias can not be the leading string of other alias.");
893  return kFALSE;
894  }
895  }
896  }
897  return kTRUE;
898 }
void InsertText(const char *text)
Insert text in text entry.
const char * Ey()
Return the expression on Y.
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
const char * GetTrueName()
Int_t GetCursorPosition() const
Definition: TGTextEntry.h:128
void Empty()
Empty item.
void Empty()
Clear all names and alias.
Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Handle menu and other commands generated.
TTVLVEntry(const TGWindow *p, const TGPicture *bigpic, const TGPicture *smallpic, TGString *name, TGString **subnames, EListViewMode ViewMode)
TTVLVEntry constructor.
const char * GetAlias()
TGLayoutHints * fBLayout1
Int_t fSelected
Definition: TGCanvas.h:59
virtual void Activate(Bool_t a)
Make list view item active.
Definition: TGListView.cxx:254
const char * ScanList()
Return the cut entry.
virtual void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0)
Move and/or resize the frame.
Definition: TGFrame.cxx:611
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion events.
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition: TGFrame.cxx:321
const char Option_t
Definition: RtypesCore.h:62
Cursor_t fDefaultCursor
virtual void SetVsbPosition(Int_t newPos)
Set position of vertical scrollbar.
Definition: TGCanvas.cxx:2405
void Scan()
Scan item.
Int_t GetY() const
Definition: TGFrame.h:279
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition: TGClient.cxx:222
void Reset()
Reset tool tip popup delay timer.
Definition: TGToolTip.cxx:259
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:687
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
UInt_t fTWidth
Definition: TGListView.h:66
UInt_t GetHeight() const
Definition: TGFrame.h:272
FontStruct_t fFontStruct
Definition: TGListView.h:77
const Mask_t kLeaveWindowMask
Definition: GuiTypes.h:167
void SetItemName(const char *name)
Redraw this entry with new name.
TGListView * fListView
EListViewMode
Definition: TGListView.h:39
Int_t fY
Definition: GuiTypes.h:177
TString fConvName
Basic string class.
Definition: TString.h:131
void SetTrueName(const char *name)
void SetScanMode(Bool_t mode=kTRUE)
Definition: TTreeViewer.h:221
#define f(i)
Definition: RSha256.hxx:104
TList * fExpressionList
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
TTVLVContainer * GetContainer()
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:373
void Hide()
Hide tool tip window.
Definition: TGToolTip.cxx:246
void SelectItem(const char *name)
Select an item.
virtual ~TTVLVEntry()
TTVLVEntry destructor.
UInt_t GetWidth() const
Definition: TGFrame.h:271
const TGWindow * fMsgWindow
Definition: TGCanvas.h:52
void EditExpression()
Start the expression editor.
void GrabPointer()
Just focus the cursor inside.
void Message(const char *msg)
Send a message on the status bar.
virtual ~TGSelectBox()
TGSelectBox destructor.
Short_t Abs(Short_t d)
Definition: TMathBase.h:108
Handle_t GetId() const
Definition: TGObject.h:47
TGToolTip * fTip
void Reset()
Definition: TCollection.h:252
Int_t fY0
Definition: TGCanvas.h:55
TGLabel * fLabel
const char * ConvertAliases()
Convert all aliases into true names.
TString fOldAlias
TGHorizontalFrame * fBf
void RemoveItem()
Remove item.
static TGSelectBox * fgInstance
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
static TGSelectBox * GetInstance()
Return the pointer to the instantiated singleton.
virtual void SetText(TGString *newText)
Set new text in label.
Definition: TGLabel.cxx:177
empty object used as context menu support for TGLVTreeEntries.
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition: TGClient.cxx:306
TGLabel * fLabelAlias
Int_t fXRoot
Definition: GuiTypes.h:178
A graphic user interface designed to handle ROOT trees and to take advantage of TTree class features...
Definition: TTreeViewer.h:56
TGToolTip * GetTip()
TGString * fItemName
Definition: TGListView.h:61
int main(int argc, char **argv)
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
Definition: TGFrame.cxx:627
TTVLVContainer(const TGWindow *p, UInt_t w, UInt_t h, UInt_t options=kSunkenFrame)
TGLVContainer constructor.
void EmptyAll()
Clear all names and aliases for expression type items.
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in text entry widget.
TGLayoutHints * fBLayout
Bool_t fActive
Definition: TGListView.h:68
TList * ExpressionList()
Get the list of expression items.
void RemoveNonStatic()
Remove all non-static items from the list view, except expressions.
void SetExpression(const char *name="", const char *alias="-empty-", Bool_t cut=kFALSE)
Set item expression.
ETransientFrameCommands
virtual void RemoveItem(TGFrame *item)
Remove item from container.
Definition: TGCanvas.cxx:657
Bool_t fMapSubwindows
Definition: TGFrame.h:354
TGSelectBox(const TGWindow *p, const TGWindow *main, UInt_t w=10, UInt_t h=10)
TGSelectBox constructor.
TGItemContext()
Constructor.
A doubly linked list.
Definition: TList.h:44
void SetLabel(const char *title)
Set label of selection box.
Bool_t fIsCut
UInt_t fTHeight
Definition: TGListView.h:67
TGTextButton * fCANCEL
virtual void InsertText(const char *text, Int_t pos)
Inserts text at position pos, clears the selection and moves the cursor to the end of the line...
Int_t GetX() const
Definition: TGFrame.h:278
void SetExpression(const char *name, const char *alias, Bool_t cutType=kFALSE)
Set the true name, alias and type of the expression, then refresh it.
const TGPicture * fSmallPic
Definition: TGListView.h:72
TList * fList
Definition: TGFrame.h:351
Int_t fYp
Definition: TGCanvas.h:54
Bool_t IsActive() const
Definition: TGListView.h:105
TGTextEntry * fTe
EGEventType fType
Definition: GuiTypes.h:174
void * GetUserData() const
Definition: TGListView.h:113
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGFrame.h:375
Int_t GET_SUBMSG(Long_t val)
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:84
Bool_t ValidateAlias()
Return true if edited alias is not a leading string of other expression aliases.
void Associate(TTVLVEntry *item)
This class represent entries that goes into the TreeViewer listview container.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:610
Int_t fX0
Definition: TGCanvas.h:55
unsigned int UInt_t
Definition: RtypesCore.h:42
TList * ExpressionList()
Return the list of user-defined expressions.
const char * Cut()
Return the cut entry.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
Ssiz_t Length() const
Definition: TString.h:405
TGFrame * fFrame
Definition: TGLayout.h:119
void CopyItem(TTVLVEntry *dest)
Copy this item&#39;s name and alias to an other.
Int_t fYRoot
Definition: GuiTypes.h:178
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
void SetToolTipText(const char *text, Long_t delayms=1000)
Set tool tip text associated with this item.
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Message interpreter.
virtual TGDimension GetDefaultSize() const
Get default size of list item.
Definition: TGListView.cxx:463
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in container.
#define gVirtualX
Definition: TVirtualX.h:350
void RemoveItem()
Remove the selected item from the list.
#define h(i)
Definition: RSha256.hxx:106
virtual void Move(Int_t x, Int_t y)
Move frame.
Definition: TGFrame.cxx:575
Int_t GET_MSG(Long_t val)
const char * GetString() const
Definition: TGString.h:40
const Bool_t kFALSE
Definition: RtypesCore.h:88
EWidgetMessageTypes
void SetAlias(const char *alias)
static unsigned int total
const char * GetText() const
Definition: TGTextEntry.h:134
long Long_t
Definition: RtypesCore.h:50
const Mask_t kEnterWindowMask
Definition: GuiTypes.h:166
Int_t fXp
Definition: TGCanvas.h:54
const TGWindow * fMain
Definition: TGFrame.h:578
#define ClassImp(name)
Definition: Rtypes.h:359
TTreeViewer * fViewer
virtual void SetCursorPosition(Int_t pos)
Set the cursor position to newPos.
TText * text
UInt_t fCode
Definition: GuiTypes.h:179
virtual void CloseWindow()
Close the select box.
virtual ~TTVLVContainer()
TGLVContainer destructor.
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition: TGClient.cxx:287
void SetSmallPic(const TGPicture *spic)
Set small picture.
int type
Definition: TGX11.cxx:120
unsigned long ULong_t
Definition: RtypesCore.h:51
This class represent a specialized expression editor for TTVLVEntry &#39;true name&#39; and &#39;alias&#39; data memb...
TGTextEntry * fTeAlias
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:619
UInt_t fHeight
Definition: TGFrame.h:135
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
virtual void Clear(Option_t *option="")
Remove all objects from the list.
Definition: TList.cxx:399
TTreeViewer * fViewer
const TGWindow * GetParent() const
Definition: TGWindow.h:85
Long_t fUser[5]
Definition: GuiTypes.h:186
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1146
TTVLVContainer * fContainer
TGLayoutHints * fLayout
Handle_t fId
Definition: TGObject.h:36
TString fAlias
TTVLVEntry * fItem
TGSelectedPicture * fSelPic
Definition: TGListView.h:75
const TGPicture * fCurrent
Definition: TGListView.h:73
Handle_t Window_t
Definition: GuiTypes.h:28
TGLVEntry * fLastActive
Definition: TGListView.h:209
virtual void Add(TObject *obj)
Definition: TList.h:87
TTVLVEntry * ExpressionItem(Int_t index)
Return the expression item at specific position.
virtual void MapWindow()
Definition: TGFrame.h:251
TGClient * fClient
Definition: TGObject.h:37
#define dest(otri, vertexptr)
Definition: triangle.c:1040
const char * Ez()
Return the expression on Z.
Int_t fTotal
Definition: TGCanvas.h:58
#define snprintf
Definition: civetweb.c:1351
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:370
void Draw(Option_t *option="")
Draw item.
virtual void DoRedraw()
Redraw list view item.
Definition: TGListView.cxx:314
virtual void SetHsbPosition(Int_t newPos)
Set position of horizontal scrollbar.
Definition: TGCanvas.cxx:2391
TTreeViewer * GetViewer()
Bool_t HasAlias()
Check if alias name is not empty.
const char * Ex()
Return the expression on X.
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line...
void PrependTilde()
Prepend a ~ to item alias.
TGString * GetItemName() const
Definition: TGListView.h:106
TGTextButton * fDONE
const Bool_t kTRUE
Definition: RtypesCore.h:87
Int_t GetLength() const
Definition: TGString.h:39
TString fTrueName
Int_t fX
Definition: GuiTypes.h:177
void SaveText()
Save the edited entry true name and alias.
char name[80]
Definition: TGX11.cxx:109
Bool_t FullConverted()
Return true if converted name is alias free.
void SetEntry(TTVLVEntry *entry)
Connect one entry.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:866
void SetCutType(Bool_t type=kFALSE)
Set cut type.
Bool_t fDragging
Definition: TGCanvas.h:57
TTVLVEntry * fEntry
This class represent the list view container for the.
void EditExpression()
Edit expression.
const char * Data() const
Definition: TString.h:364
TGItemContext * fContext