Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TRootContextMenu.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 12/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/** \class TRootContextMenu
14 \ingroup guiwidgets
15
16This class provides an interface to context sensitive popup menus.
17These menus pop up when the user hits the right mouse button, and
18are destroyed when the menu pops downs.
19The picture below shows a canvas with a pop-up menu.
20
21*/
22
23
24#include "TRootContextMenu.h"
25#include "TROOT.h"
26#include "TGClient.h"
27#include "TEnv.h"
28#include "TList.h"
29#include "TObjArray.h"
30#include "TContextMenu.h"
31#include "TMethod.h"
32#include "TMethodArg.h"
33#include "TMethodCall.h"
34#include "TClass.h"
35#include "TVirtualX.h"
36#include "TCanvas.h"
37#include "TDataMember.h"
38#include "TToggle.h"
39#include "TRootDialog.h"
40#include "TDataType.h"
41#include "TBrowser.h"
42#include "TRootCanvas.h"
43#include "TRootBrowser.h"
44#include "TClassMenuItem.h"
45#include "TObjectSpy.h"
46#include "KeySymbols.h"
47#include "RConfigure.h"
48#include "strlcpy.h"
49#include "snprintf.h"
50
52 kToggleStart = 1000, // first id of toggle menu items
53 kToggleListStart = 2000, // first id of toggle list menu items
54 kUserFunctionStart = 3000 // first id of user added functions/methods, etc...
55};
56
57
59
60////////////////////////////////////////////////////////////////////////////////
61/// Create context menu.
62
64 : TGPopupMenu(gClient->GetDefaultRoot()), TContextMenuImp(c)
65{
66 fDialog = 0;
67 fTrash = new TList;
68
70 gROOT->GetListOfCleanups()->Add(this);
71 // Context menu handles its own messages
72 Associate(this);
73}
74
75////////////////////////////////////////////////////////////////////////////////
76/// Delete a context menu.
77
79{
80 gROOT->GetListOfCleanups()->Remove(this);
81 delete fDialog;
82 if (fTrash) fTrash->Delete();
83 delete fTrash;
84}
85
86////////////////////////////////////////////////////////////////////////////////
87/// Display context popup menu for currently selected object.
88
90{
91 if (fClient->IsEditable()) return;
92
93 // delete menu items releated to previous object and reset menu size
95 fCurrent = 0;
96 if (fTrash) fTrash->Delete();
97 fMenuHeight = 6;
98 fMenuWidth = 8;
99
100 // delete previous dialog
101 if (fDialog) {
102 delete fDialog;
103 fDialog = 0;
104 }
105
106 // add menu items to popup menu
108
109 int xx, yy, topx = 0, topy = 0;
110 UInt_t w, h;
111
113 gVirtualX->GetGeometry(fContextMenu->GetSelectedCanvas()->GetCanvasID(),
114 topx, topy, w, h);
115
116 xx = topx + x + 1;
117 yy = topy + y + 1;
118
119#ifdef R__HAS_COCOA
120 //Context menu must be transient for a canvas, otherwise it's possible
121 //to break the z-order (for example, using alt-tab to switch between
122 //different aplications). This hint works ONLY for canvas though
123 //(otherwise selected canvas is null).
124 TGWindow *parent = 0;
126 parent = dynamic_cast<TGWindow *>(pad->GetCanvasImp());
127 else if ((pad = fContextMenu->GetSelectedPad()) && pad->GetCanvasImp())
128 parent = dynamic_cast<TGWindow *>(pad->GetCanvasImp());
129 else if (TBrowser * const browser = fContextMenu->GetBrowser())
130 parent = dynamic_cast<TGWindow *>(browser->GetBrowserImp());
131
132 if (parent)
133 gVirtualX->SetWMTransientHint(GetId(), parent->GetId());
134#endif
135
137 // add some space for the right-side '?' (help)
138 fMenuWidth += 5;
140}
141
142////////////////////////////////////////////////////////////////////////////////
143/// Decodes the Hierarchy="Level0/Level1/Level2/..." statement from the comment field
144/// and returns the - if needed - created sub menu "Level0/Level1"
145/// Returns the last component in last_component.
146
148{
153
154 // search for arguments to the MENU statement
155 // strcpy(cmd,commentstring);
157 if ((opt_ptr=cmd.Index("*MENU={")) != kNPOS ||
158 (opt_ptr=cmd.Index("*SUBMENU={"))!= kNPOS ||
159 (opt_ptr=cmd.Index("*TOGGLE={")) != kNPOS ) {
160
161 Ssiz_t start = cmd.Index("{",opt_ptr) + 1;
162 Ssiz_t end = cmd.Index("}",start);
163 option = cmd(start,end - start);
164
165 // Look for Hierarchy token
166 TObjArray * array = option.Tokenize(";");
167 TIter iter(array);
168 TObject *obj;
169 while((obj = iter())) {
170 TString token(obj->GetName());
171 if (token.Index("Hierarchy=\"") != kNPOS) {
172 Ssiz_t tstart = token.Index("\"") + 1;
173 Ssiz_t tend = token.Index("\"",tstart+1);
174 if (tend == kNPOS) continue;
175 hierarchy = token(tstart,tend - tstart);
176 }
177 }
178 delete array;
179 }
180
181 // Build Hierarchy
182 currentMenu = this;
183 TObjArray * array = hierarchy.Tokenize("/");
184 TIter iter(array);
185 TObject *obj = iter();
186 while(obj) {
187 last_component = obj->GetName();
188 obj = iter();
189 if (obj) {
190 TGMenuEntry *ptr;
191 TIter next(currentMenu->GetListOfEntries());
192 // Search for popup with corresponding name
193 while ((ptr = (TGMenuEntry *) next()) &&
194 (ptr->GetType() != kMenuPopup ||
195 last_component.CompareTo(ptr->GetName()))) { }
196 if (ptr)
197 currentMenu = ptr->GetPopup();
198 else {
199 TGPopupMenu *r = new TGPopupMenu(gClient->GetDefaultRoot());
200 // Alphabetical ordering
202 TIter next2(currentMenu->GetListOfEntries());
203 // Search for popup with corresponding name
204 while ((ptr2 = (TGMenuEntry *) next2()) &&
205 (ptr2->GetType() != kMenuPopup ||
206 last_component.CompareTo(ptr2->GetName()) > 0 )) { }
207
208 currentMenu->AddPopup(last_component, r,ptr2);
209 currentMenu = r;
210 fTrash->Add(r);
211 last_component = obj->GetName();
212 }
213 }
214 }
215
216 delete array;
217 return currentMenu;
218}
219
220////////////////////////////////////////////////////////////////////////////////
221/// Add a entry to current menu with alphabetical ordering.
222
224 const TGPicture *p , Bool_t sorted)
225{
226 TGMenuEntry *ptr2 = 0;
227 if (sorted) {
228 TIter next(currentMenu->GetListOfEntries());
229 // Search for popup with corresponding name
230 while ((ptr2 = (TGMenuEntry *) next()) &&
231 (ptr2->GetType() != kMenuEntry ||
232 strcmp(ptr2->GetName(), s)<0 )) { }
233 }
234 currentMenu->AddEntry(s,id,ud,p,ptr2);
235}
236
237////////////////////////////////////////////////////////////////////////////////
238/// Create the context menu depending on the selected object.
239
241{
242 if (!object || fClient->IsEditable()) return;
243
246
247 // Add a title
249 AddSeparator();
250
251 // Get list of menu items from the selected object's class
252 TList *menuItemList = object->IsA()->GetMenuList();
253
256
257 while ((menuItem = (TClassMenuItem*) nextItem())) {
258 switch (menuItem->GetType()) {
260 {
261 TGMenuEntry *last = (TGMenuEntry *)GetListOfEntries()->Last();
262 if (last && last->GetType() != kMenuSeparator)
263 AddSeparator();
264 break;
265 }
267 {
268 // Standard list of class methods. Rebuild from scratch.
269 // Get linked list of objects menu items (i.e. member functions
270 // with the token *MENU in their comment fields.
271 TList *methodList = new TList;
272 object->IsA()->GetMenuItems(methodList);
273
275 TClass *classPtr = 0;
276 TIter next(methodList);
278
279 while ((method = (TMethod*) next())) {
280 if (classPtr != method->GetClass()) {
281 needSep = kTRUE;
282 classPtr = method->GetClass();
283 }
284
285 TDataMember *m;
286 EMenuItemKind menuKind = method->IsMenuItem();
289
290 switch (menuKind) {
291 case kMenuDialog:
292 // search for arguments to the MENU statement
293 currentMenu = FindHierarchy(method->GetCommentString(),last_component);
294 if (needSep && currentMenu == this) {
295 AddSeparator();
296 needSep = kFALSE;
297 }
298 AddEntrySorted(currentMenu,last_component.Length() ? last_component.Data() : method->GetName(), entry++, method,0,currentMenu != this);
299 break;
300 case kMenuSubMenu:
301 if ((m = method->FindDataMember())) {
302
303 // search for arguments to the MENU statement
304 currentMenu = FindHierarchy(method->GetCommentString(),last_component);
305
306 if (m->GetterMethod()) {
307 TGPopupMenu *r = new TGPopupMenu(gClient->GetDefaultRoot());
308 if (needSep && currentMenu == this) {
309 AddSeparator();
310 needSep = kFALSE;
311 }
312 if (last_component.Length()) {
313 currentMenu->AddPopup(last_component, r);
314 } else {
315 currentMenu->AddPopup(method->GetName(), r);
316 }
317 fTrash->Add(r);
318 TIter nxt(m->GetOptions());
319 TOptionListItem *it;
320 while ((it = (TOptionListItem*) nxt())) {
321 const char *name = it->fOptName;
322 Long_t val = it->fValue;
323
324 TToggle *t = new TToggle;
325 t->SetToggledObject(object, method);
326 t->SetOnValue(val);
327 fTrash->Add(t);
328
329 r->AddEntry(name, togglelist++, t);
330 if (t->GetState())
331 r->CheckEntry(togglelist-1);
332 }
333 } else {
334 if (needSep && currentMenu == this) {
335 AddSeparator();
336 needSep = kFALSE;
337 }
338 AddEntrySorted(currentMenu,last_component.Length() ? last_component.Data() : method->GetName(), entry++, method,0,currentMenu != this);
339 }
340 }
341 break;
342
343 case kMenuToggle:
344 {
345 TToggle *t = new TToggle;
346 t->SetToggledObject(object, method);
347 t->SetOnValue(1);
348 fTrash->Add(t);
349 // search for arguments to the MENU statement
350 currentMenu = FindHierarchy(method->GetCommentString(),last_component);
351 if (needSep && currentMenu == this) {
352 AddSeparator();
353 needSep = kFALSE;
354 }
355 AddEntrySorted(currentMenu,last_component.Length() ? last_component.Data() : method->GetName(), toggle++, t,0,currentMenu != this);
356 if (t->GetState()) currentMenu->CheckEntry(toggle-1);
357 }
358 break;
359
360 default:
361 break;
362 }
363 }
364 delete methodList;
365 }
366 break;
368 {
369 const char* menuItemTitle = menuItem->GetTitle();
370 if (menuItem->IsToggle()) {
371 TMethod* method =
372 object->IsA()->GetMethodWithPrototype(menuItem->GetFunctionName(),menuItem->GetArgs());
373 if (method) {
374 TToggle *t = new TToggle;
375 t->SetToggledObject(object, method);
376 t->SetOnValue(1);
377 fTrash->Add(t);
378
379 if (strlen(menuItemTitle)==0) menuItemTitle = method->GetName();
381 if (t->GetState()) CheckEntry(toggle-1);
382 }
383 } else {
384 if (strlen(menuItemTitle)==0) menuItemTitle = menuItem->GetFunctionName();
386 }
387 }
388 break;
389 default:
390 break;
391 }
392 }
393}
394
395////////////////////////////////////////////////////////////////////////////////
396/// Create dialog object with OK and Cancel buttons. This dialog
397/// prompts for the arguments of "method".
398
400{
401 Dialog(object,(TFunction*)method);
402}
403
404////////////////////////////////////////////////////////////////////////////////
405/// Create dialog object with OK and Cancel buttons. This dialog
406/// prompts for the arguments of "function".
407/// function may be a global function or a method
408
410{
412
413 if (!function) return;
414
415 // Position, if it exists, of the argument that correspond to the object itself
417 selfobjpos = fContextMenu->GetSelectedMenuItem()->GetSelfObjectPos();
418 else selfobjpos = -1;
419
420 const TGWindow *w;
423 // Embedded canvas has no canvasimp that is a TGFrame
424 // coverity[returned_null]
425 // coverity[dereference]
426 if (c->GetCanvasImp()->IsA()->InheritsFrom(TGFrame::Class())) {
427 w = fClient->GetWindowById(gVirtualX->GetWindowID(c->GetCanvasID()));
428 if (!w) w = (TRootCanvas *) c->GetCanvasImp();
429 } else {
430 w = gClient->GetDefaultRoot();
431 }
432 } else if (fContextMenu->GetBrowser()) {
434 w = (TRootBrowser *) b->GetBrowserImp();
435 } else {
436 w = gClient->GetDefaultRoot();
437 }
438 fDialog = new TRootDialog(this, w, fContextMenu->CreateDialogTitle(object, function));
439
440 // iterate through all arguments and create apropriate input-data objects:
441 // inputlines, option menus...
442 TMethodArg *argument = 0;
443
444 TIter next(function->GetListOfMethodArgs());
445 Int_t argpos = 0;
446
447 while ((argument = (TMethodArg *) next())) {
448 // Do not input argument for self object
449 if (selfobjpos != argpos) {
451 const char *type = argument->GetTypeName();
452 TDataType *datatype = gROOT->GetType(type);
453 const char *charstar = "char*";
454 char basictype[32];
455
456 if (datatype) {
457 strlcpy(basictype, datatype->GetTypeName(), 32);
458 } else {
460 if (strncmp(type, "enum", 4) && (cl && !(cl->Property() & kIsEnum)))
461 Warning("Dialog", "data type is not basic type, assuming (int)");
462 strlcpy(basictype, "int", 32);
463 }
464
465 if (strchr(argname, '*')) {
466 strlcat(basictype, "*",32);
467 if (!strncmp(type, "char", 4) || !strncmp(type, "Option_t", 8))
468 type = charstar;
469 else if (strstr(argname, "[default:")) {
470 // skip arguments that are pointers (but not char *)
471 // and have a default value
472 argpos++;
473 continue;
474 }
475 }
476
477 TDataMember *m = argument->GetDataMember();
478 if (m && object && m->GetterMethod(object->IsA())) {
479
480 // Get the current value and form it as a text:
481
482 char val[256];
483
484 if (!strncmp(basictype, "char*", 5)) {
485 char *tdefval;
486 m->GetterMethod()->Execute(object, "", &tdefval);
487 strlcpy(val, tdefval, sizeof(val));
488 } else if (!strncmp(basictype, "float", 5) ||
489 !strncmp(basictype, "double", 6)) {
491 m->GetterMethod()->Execute(object, "", ddefval);
492 snprintf(val,256, "%g", ddefval);
493 } else if (!strncmp(basictype, "char", 4) ||
494 !strncmp(basictype, "bool", 4) ||
495 !strncmp(basictype, "int", 3) ||
496 !strncmp(basictype, "long", 4) ||
497 !strncmp(basictype, "short", 5)) {
499 m->GetterMethod()->Execute(object, "", ldefval);
500 snprintf(val, 256, "%zi", (size_t)ldefval);
501 }
502
503 // Find out whether we have options ...
504 if (m->GetOptions()) {
505 Warning("Dialog", "option menu not yet implemented");
506 } else {
507 // we haven't got options - textfield ...
508 fDialog->Add(argname, val, type);
509 }
510 } else { // if m not found ...
511
512 char val[256] = "";
513 const char *tval = argument->GetDefault();
514 if (tval && strlen(tval)) {
515 // Remove leading and trailing quotes
516 strlcpy(val, tval + (tval[0] == '"' ? 1 : 0), sizeof(val));
517 if (val[strlen(val)-1] == '"')
518 val[strlen(val)-1]= 0;
519 }
520 fDialog->Add(argname, val, type);
521 }
522 }
523 argpos++;
524 }
525
526 fDialog->Popup();
527}
528
529////////////////////////////////////////////////////////////////////////////////
530/// Draw context menu entry.
531
533{
534 int ty, offset;
535 static int max_ascent = 0, max_descent = 0;
536
538 // draw the ? (help) in the right side when highlighting a menu entry
539 if (entry->GetType() == kMenuEntry && (entry->GetStatus() & kMenuActiveMask)) {
540 if (max_ascent == 0) {
541 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
542 }
543 offset = (entry->GetEh() - (max_ascent + max_descent)) / 2;
544 ty = entry->GetEy() + max_ascent + offset - 1;
545 TGHotString s("&?");
546 s.Draw(fId, fSelGC, fMenuWidth-12, ty);
547 }
548}
549
550////////////////////////////////////////////////////////////////////////////////
551/// Handle button event in the context menu.
552
554{
555 int id;
556 void *ud = 0;
557
558 if ((event->fType == kButtonRelease) && (event->fX >= (Int_t)(fMenuWidth-15)) &&
559 (event->fX <= (Int_t)fMenuWidth)) {
560 id = EndMenu(ud);
561 if (fHasGrab) gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab
562 if (ud) {
563 // retrieve the highlighted function
564 TFunction *function = 0;
565 if (id < kToggleStart) {
566 TMethod *m = (TMethod *)ud;
567 function = (TFunction *)m;
568 } else if (id >= kToggleStart && id < kUserFunctionStart) {
569 TToggle *t = (TToggle *)ud;
571 function = (TFunction *)mc->GetMethod();
572 } else {
574 function = gROOT->GetGlobalFunctionWithPrototype(mi->GetFunctionName());
575 }
576 if (function)
577 fContextMenu->SetMethod(function);
578 }
579 OnlineHelp();
580 return kTRUE;
581 }
582 return TGPopupMenu::HandleButton(event);
583}
584
585////////////////////////////////////////////////////////////////////////////////
586/// Handle pointer crossing event in context menu.
587
589{
590 if (event->fType == kLeaveNotify) {
591 // just to reset the mouse pointer...
592 HandleMotion(event);
593 }
594 return TGPopupMenu::HandleCrossing(event);
595}
596
597////////////////////////////////////////////////////////////////////////////////
598/// Handle pointer motion event in context menu.
599
601{
602 static int toggle = 0;
603 static Cursor_t handCur = kNone, rightCur = kNone;
605
606 if (handCur == kNone)
607 handCur = gVirtualX->CreateCursor(kHand);
608 if (rightCur == kNone)
609 rightCur = gVirtualX->CreateCursor(kArrowRight);
610
611 if (event->fType == kLeaveNotify) {
612 gVirtualX->ChangeActivePointerGrab(fId, mask, rightCur);
613 toggle = 0;
614 return kTRUE;
615 }
616 // change the cursot to a small hand when over the ? (help)
617 if ((event->fX >= (Int_t)(fMenuWidth-15)) && (event->fX <= (Int_t)fMenuWidth) &&
618 fCurrent && (fCurrent->GetType() == kMenuEntry)) {
619 if (toggle == 0) {
620 gVirtualX->ChangeActivePointerGrab(fId, mask, handCur);
621 toggle = 1;
622 }
623 }
624 else {
625 if (toggle == 1) {
626 gVirtualX->ChangeActivePointerGrab(fId, mask, rightCur);
627 toggle = 0;
628 }
629 }
630 return TGPopupMenu::HandleMotion(event);
631}
632
633////////////////////////////////////////////////////////////////////////////////
634/// Open the online help matching the actual class/method.
635
637{
639 TString cmd;
640 TString url = gEnv->GetValue("Browser.StartUrl", "https://root.cern.ch/doc/master");
641 if (url.EndsWith(".html", TString::kIgnoreCase)) {
642 if (url.Last('/') != kNPOS)
643 url.Remove(url.Last('/'));
644 }
645 if (!url.EndsWith("/")) {
646 url += '/';
647 }
649 if (obj) {
650 clname = obj->ClassName();
653 TMethod *method = obj->IsA()->GetMethodAllAny(smeth.Data());
654 if (method) clname = method->GetClass()->GetName();
655 url += clname;
656 url += ".html";
657 url += "#";
658 url += clname;
659 url += ":";
660 url += smeth.Data();
661 }
662 else {
663 url += clname;
664 url += ".html";
665 }
666 if (fDialog) delete fDialog;
667 fDialog = 0;
668 cmd = TString::Format("new TGHtmlBrowser(\"%s\", 0, 900, 300);", url.Data());
669 gROOT->ProcessLine(cmd.Data());
670 }
671}
672
673////////////////////////////////////////////////////////////////////////////////
674/// Handle context menu messages.
675
677{
679 if (GetContextMenu()->GetSelectedPad()) {
680 savedPad.SetObject(gPad);
681 gPad = GetContextMenu()->GetSelectedPad();
682 }
683
684 switch (GET_MSG(msg)) {
685
686 case kC_COMMAND:
687
688 switch (GET_SUBMSG(msg)) {
689
690 case kCM_MENU:
691
692 if (parm1 < kToggleStart) {
693 TMethod *m = (TMethod *) parm2;
694 GetContextMenu()->Action(m);
695 } else if (parm1 >= kToggleStart && parm1 < kToggleListStart) {
696 TToggle *t = (TToggle *) parm2;
697 GetContextMenu()->Action(t);
699 TToggle *t = (TToggle *) parm2;
700 if (t->GetState() == 0)
701 t->SetState(1);
702 } else {
704 GetContextMenu()->Action(mi);
705 }
706 break;
707
708 case kCM_BUTTON:
709 if (parm1 == 1) {
710 const char *args = fDialog->GetParameters();
711 GetContextMenu()->Execute((char *)args);
712 delete fDialog;
713 fDialog = nullptr;
714 }
715 if (parm1 == 2) {
716 const char *args = fDialog->GetParameters();
717 GetContextMenu()->Execute((char *)args);
718 }
719 if (parm1 == 3) {
720 delete fDialog;
721 fDialog = nullptr;
722 }
723 if (parm1 == 4) {
724 OnlineHelp();
725 }
726 break;
727
728 default:
729 break;
730 }
731 break;
732
733 case kC_TEXTENTRY:
734
735 switch (GET_SUBMSG(msg)) {
736
737 case kTE_ENTER:
738 {
739 const char *args = fDialog->GetParameters();
740 GetContextMenu()->Execute((char *)args);
741 delete fDialog;
742 fDialog = nullptr;
743 }
744 break;
745
746 default:
747 break;
748 }
749 break;
750
751 default:
752 break;
753 }
754
755 if (savedPad.GetObject()) gPad = (TVirtualPad*) savedPad.GetObject();
756
757 return kTRUE;
758}
759
760////////////////////////////////////////////////////////////////////////////////
761/// Close the context menu if the object is deleted in the
762/// RecursiveRemove() operation.
763
765{
766 void *ud;
767 if (obj == fContextMenu->GetSelectedCanvas())
769 if (obj == fContextMenu->GetSelectedPad())
771 if (obj == fContextMenu->GetSelectedObject()) {
772 // if the object being deleted is the one selected,
773 // ungrab the mouse pointer and terminate (close) the menu
775 if (fHasGrab)
776 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
777 EndMenu(ud);
778 }
779}
780
@ kButtonRelease
Definition GuiTypes.h:60
@ kLeaveNotify
Definition GuiTypes.h:61
@ kArrowRight
Definition GuiTypes.h:375
@ kHand
Definition GuiTypes.h:374
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
const Mask_t kPointerMotionMask
Definition GuiTypes.h:163
Handle_t Cursor_t
Cursor handle.
Definition GuiTypes.h:34
const Handle_t kNone
Definition GuiTypes.h:88
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:89
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:131
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
#define ClassImp(name)
Definition Rtypes.h:376
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ kIsEnum
Definition TDictionary.h:68
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
#define gClient
Definition TGClient.h:157
@ kMenuActiveMask
Definition TGMenu.h:24
@ kMenuEntry
Definition TGMenu.h:38
@ kMenuSeparator
Definition TGMenu.h:36
@ kMenuPopup
Definition TGMenu.h:39
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition TGX11.cxx:110
EMenuItemKind
Definition TMethod.h:31
@ kMenuSubMenu
Definition TMethod.h:35
@ kMenuDialog
Definition TMethod.h:33
@ kMenuToggle
Definition TMethod.h:34
#define gROOT
Definition TROOT.h:411
@ kToggleStart
@ kToggleListStart
@ kUserFunctionStart
#define gPad
#define gVirtualX
Definition TVirtualX.h:337
Int_t GET_MSG(Long_t val)
@ kCM_MENU
@ kTE_ENTER
@ kC_COMMAND
@ kCM_BUTTON
@ kC_TEXTENTRY
Int_t GET_SUBMSG(Long_t val)
#define snprintf
Definition civetweb.c:1579
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
The Canvas class.
Definition TCanvas.h:23
Describes one element of the context menu associated to a class The menu item may describe.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
Long_t Property() const override
Returns the properties of the TClass as a bit field stored as a Long_t value.
Definition TClass.cxx:6129
void GetMenuItems(TList *listitems)
Returns list of methods accessible by context menu.
Definition TClass.cxx:3902
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2974
This class provides an interface to GUI independent context sensitive popup menus.
TContextMenu * fContextMenu
virtual TContextMenu * GetContextMenu() const
This class provides an interface to context sensitive popup menus.
virtual void SetCanvas(TVirtualPad *c)
virtual TVirtualPad * GetSelectedCanvas()
virtual TFunction * GetSelectedMethod()
virtual TVirtualPad * GetSelectedPad()
virtual void SetPad(TVirtualPad *p)
virtual TClassMenuItem * GetSelectedMenuItem()
virtual void SetMethod(TFunction *m)
virtual void SetObject(TObject *o)
virtual TObject * GetSelectedObject()
virtual const char * CreateArgumentTitle(TMethodArg *argument)
Create string describing argument (for use in dialog box).
virtual TBrowser * GetBrowser()
virtual const char * CreateDialogTitle(TObject *object, TFunction *method)
Create title for dialog box retrieving argument values.
virtual const char * CreatePopupTitle(TObject *object)
Create title for popup menu.
All ROOT classes may have RTTI (run time type identification) support added.
Definition TDataMember.h:31
Basic data type descriptor (datatype information is obtained from CINT).
Definition TDataType.h:44
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:491
Global functions class (global functions are obtained from CINT).
Definition TFunction.h:30
Bool_t IsEditable() const
Definition TGClient.h:89
TGWindow * GetWindowById(Window_t sw) const
Find a TGWindow via its handle. If window is not found return 0.
Definition TGClient.cxx:603
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:339
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:192
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:193
static TClass * Class()
TGHotString is a string with a "hot" character underlined.
Definition TGString.h:42
void Draw(Drawable_t id, GContext_t gc, Int_t x, Int_t y) override
Draw a hot string and underline the hot character.
Definition TGString.cxx:175
This class contains all information about a menu entry.
Definition TGMenu.h:57
TGPopupMenu * GetPopup() const
Definition TGMenu.h:88
const char * GetName() const override
Returns name of object.
Definition TGMenu.h:84
EMenuEntryType GetType() const
Definition TGMenu.h:87
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 creates a popup menu object.
Definition TGMenu.h:110
Bool_t HandleCrossing(Event_t *event) override
Handle pointer crossing event in popup menu.
Definition TGMenu.cxx:1367
TList * fEntryList
list of menu entries
Definition TGMenu.h:117
TGPopupMenu(const TGPopupMenu &)=delete
virtual void AddLabel(TGHotString *s, const TGPicture *p=nullptr, TGMenuEntry *before=nullptr)
Add a menu label to the menu.
Definition TGMenu.cxx:1095
TGMenuEntry * fCurrent
currently selected menu entry
Definition TGMenu.h:118
UInt_t fMenuHeight
height of popup menu
Definition TGMenu.h:124
GContext_t fSelGC
graphics context for drawing selections
Definition TGMenu.h:127
virtual void CheckEntry(Int_t id)
Check a menu entry (i.e. add a check mark in front of it).
Definition TGMenu.cxx:1782
virtual void DrawEntry(TGMenuEntry *entry)
Draw popup menu entry.
Definition TGMenu.cxx:1506
FontStruct_t fFontStruct
font to draw menu entries
Definition TGMenu.h:129
virtual void Associate(const TGWindow *w)
Definition TGMenu.h:206
virtual Int_t EndMenu(void *&userData)
Close menu and return ID of selected menu item.
Definition TGMenu.cxx:1289
virtual void AddSeparator(TGMenuEntry *before=nullptr)
Add a menu separator to the menu.
Definition TGMenu.cxx:1060
virtual void AddEntry(TGHotString *s, Int_t id, void *ud=nullptr, const TGPicture *p=nullptr, TGMenuEntry *before=nullptr)
Add a menu entry.
Definition TGMenu.cxx:990
UInt_t fMenuWidth
width of popup menu
Definition TGMenu.h:123
virtual void PlaceMenu(Int_t x, Int_t y, Bool_t stick_mode, Bool_t grab_pointer)
Popup a popup menu.
Definition TGMenu.cxx:1241
const TList * GetListOfEntries() const
Definition TGMenu.h:200
Bool_t HandleMotion(Event_t *event) override
Handle pointer motion event in popup menu.
Definition TGMenu.cxx:1394
Bool_t HandleButton(Event_t *event) override
Handle button event in the popup menu.
Definition TGMenu.cxx:1338
Bool_t fHasGrab
true if menu has grabbed pointer
Definition TGMenu.h:120
ROOT GUI Window base class.
Definition TGWindow.h:23
A doubly linked list.
Definition TList.h:38
void Add(TObject *obj) override
Definition TList.h:81
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:468
TClass * IsA() const override
Definition TList.h:110
Each ROOT method (see TMethod) has a linked list of its arguments.
Definition TMethodArg.h:36
Method or function calling interface.
Definition TMethodCall.h:37
Each ROOT class (see TClass) has a linked list of methods.
Definition TMethod.h:38
An array of TObjects.
Definition TObjArray.h:31
Monitors objects for deletion and reflects the deletion by reverting the internal pointer to zero.
Definition TObjectSpy.h:30
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:458
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:227
virtual void Execute(const char *method, const char *params, Int_t *error=nullptr)
Execute method on this object with the given parameter string, e.g.
Definition TObject.cxx:378
virtual TClass * IsA() const
Definition TObject.h:246
Long_t fValue
Data member to which this option belongs.
This class creates a ROOT object browser, constituted by three main tabs.
This class creates a main window with menubar, scrollbars and a drawing area.
Definition TRootCanvas.h:34
This class provides an interface to context sensitive popup menus.
TGPopupMenu * FindHierarchy(const char *commentstring, TString &last_component)
Decodes the Hierarchy="Level0/Level1/Level2/..." statement from the comment field and returns the - i...
virtual void OnlineHelp()
Open the online help matching the actual class/method.
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Handle context menu messages.
void DisplayPopup(Int_t x, Int_t y) override
Display context popup menu for currently selected object.
Bool_t HandleButton(Event_t *event) override
Handle button event in the context menu.
Bool_t HandleMotion(Event_t *event) override
Handle pointer motion event in context menu.
void RecursiveRemove(TObject *obj) override
Close the context menu if the object is deleted in the RecursiveRemove() operation.
void CreateMenu(TObject *object)
Create the context menu depending on the selected object.
TRootContextMenu(const TRootContextMenu &)
void Dialog(TObject *object, TMethod *method) override
Create dialog object with OK and Cancel buttons.
TList * fTrash
list of objects to be deleted before refilling menu
TRootDialog * fDialog
dialog prompting for command line arguments
void DrawEntry(TGMenuEntry *entry) override
Draw context menu entry.
Bool_t HandleCrossing(Event_t *event) override
Handle pointer crossing event in context menu.
void AddEntrySorted(TGPopupMenu *current, const char *s, Int_t id, void *ud=nullptr, const TGPicture *p=nullptr, Bool_t sorted=kTRUE)
Add a entry to current menu with alphabetical ordering.
~TRootContextMenu() override
Delete a context menu.
A TRootDialog is used to prompt for the arguments of an object's member function.
Definition TRootDialog.h:21
virtual void Add(const char *argname, const char *value, const char *type)
Add a label and text input field.
virtual const char * GetParameters()
Get parameter string (called by contextmenu after OK or Apply has been selected).
virtual void Popup()
Popup dialog.
Basic string class.
Definition TString.h:138
@ kIgnoreCase
Definition TString.h:285
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:2385
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:659
This class defines toggling facility for both - object's method or variables.
Definition TToggle.h:47
virtual void SetOnValue(Long_t lon)
Definition TToggle.h:78
TMethodCall * GetSetter() const
Definition TToggle.h:87
virtual void SetToggledObject(TObject *obj, TMethod *anymethod)
Initializes it to toggle an object's datamember using this object's method.
Definition TToggle.cxx:135
virtual void SetState(Bool_t state)
Sets the value of toggle to fOnValue or fOffValue according to passed argument.
Definition TToggle.cxx:80
virtual Bool_t GetState()
Returns the state of Toggle according to its current value and fOnValue, returns true if they match.
Definition TToggle.cxx:69
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
Int_t fX
Definition GuiTypes.h:178
TMarker m
Definition textangle.C:8
static byte * ptr2
Definition gifdecode.c:17