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
58
59////////////////////////////////////////////////////////////////////////////////
60/// Create context menu.
61
63 : TGPopupMenu(gClient->GetDefaultRoot()), TContextMenuImp(c)
64{
65 fDialog = 0;
66 fTrash = new TList;
67
69 gROOT->GetListOfCleanups()->Add(this);
70 // Context menu handles its own messages
71 Associate(this);
72}
73
74////////////////////////////////////////////////////////////////////////////////
75/// Delete a context menu.
76
78{
79 gROOT->GetListOfCleanups()->Remove(this);
80 delete fDialog;
81 if (fTrash) fTrash->Delete();
82 delete fTrash;
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// Display context popup menu for currently selected object.
87
89{
90 if (fClient->IsEditable()) return;
91
92 // delete menu items releated to previous object and reset menu size
94 fCurrent = 0;
95 if (fTrash) fTrash->Delete();
96 fMenuHeight = 6;
97 fMenuWidth = 8;
98
99 // delete previous dialog
100 if (fDialog) {
101 delete fDialog;
102 fDialog = 0;
103 }
104
105 // add menu items to popup menu
107
108 int xx, yy, topx = 0, topy = 0;
109 UInt_t w, h;
110
112 gVirtualX->GetGeometry(fContextMenu->GetSelectedCanvas()->GetCanvasID(),
113 topx, topy, w, h);
114
115 xx = topx + x + 1;
116 yy = topy + y + 1;
117
118#ifdef R__HAS_COCOA
119 //Context menu must be transient for a canvas, otherwise it's possible
120 //to break the z-order (for example, using alt-tab to switch between
121 //different aplications). This hint works ONLY for canvas though
122 //(otherwise selected canvas is null).
123 TGWindow *parent = 0;
125 parent = dynamic_cast<TGWindow *>(pad->GetCanvasImp());
126 else if ((pad = fContextMenu->GetSelectedPad()) && pad->GetCanvasImp())
127 parent = dynamic_cast<TGWindow *>(pad->GetCanvasImp());
128 else if (TBrowser * const browser = fContextMenu->GetBrowser())
129 parent = dynamic_cast<TGWindow *>(browser->GetBrowserImp());
130
131 if (parent)
132 gVirtualX->SetWMTransientHint(GetId(), parent->GetId());
133#endif
134
136 // add some space for the right-side '?' (help)
137 fMenuWidth += 5;
139}
140
141////////////////////////////////////////////////////////////////////////////////
142/// Decodes the Hierarchy="Level0/Level1/Level2/..." statement from the comment field
143/// and returns the - if needed - created sub menu "Level0/Level1"
144/// Returns the last component in last_component.
145
147{
152
153 // search for arguments to the MENU statement
154 // strcpy(cmd,commentstring);
156 if ((opt_ptr=cmd.Index("*MENU={")) != kNPOS ||
157 (opt_ptr=cmd.Index("*SUBMENU={"))!= kNPOS ||
158 (opt_ptr=cmd.Index("*TOGGLE={")) != kNPOS ) {
159
160 Ssiz_t start = cmd.Index("{",opt_ptr) + 1;
161 Ssiz_t end = cmd.Index("}",start);
162 option = cmd(start,end - start);
163
164 // Look for Hierarchy token
165 TObjArray * array = option.Tokenize(";");
166 TIter iter(array);
167 TObject *obj;
168 while((obj = iter())) {
169 TString token(obj->GetName());
170 if (token.Index("Hierarchy=\"") != kNPOS) {
171 Ssiz_t tstart = token.Index("\"") + 1;
172 Ssiz_t tend = token.Index("\"",tstart+1);
173 if (tend == kNPOS) continue;
174 hierarchy = token(tstart,tend - tstart);
175 }
176 }
177 delete array;
178 }
179
180 // Build Hierarchy
181 currentMenu = this;
182 TObjArray * array = hierarchy.Tokenize("/");
183 TIter iter(array);
184 TObject *obj = iter();
185 while(obj) {
186 last_component = obj->GetName();
187 obj = iter();
188 if (obj) {
189 TGMenuEntry *ptr;
190 TIter next(currentMenu->GetListOfEntries());
191 // Search for popup with corresponding name
192 while ((ptr = (TGMenuEntry *) next()) &&
193 (ptr->GetType() != kMenuPopup ||
194 last_component.CompareTo(ptr->GetName()))) { }
195 if (ptr)
196 currentMenu = ptr->GetPopup();
197 else {
198 TGPopupMenu *r = new TGPopupMenu(gClient->GetDefaultRoot());
199 // Alphabetical ordering
201 TIter next2(currentMenu->GetListOfEntries());
202 // Search for popup with corresponding name
203 while ((ptr2 = (TGMenuEntry *) next2()) &&
204 (ptr2->GetType() != kMenuPopup ||
205 last_component.CompareTo(ptr2->GetName()) > 0 )) { }
206
207 currentMenu->AddPopup(last_component, r,ptr2);
208 currentMenu = r;
209 fTrash->Add(r);
210 last_component = obj->GetName();
211 }
212 }
213 }
214
215 delete array;
216 return currentMenu;
217}
218
219////////////////////////////////////////////////////////////////////////////////
220/// Add a entry to current menu with alphabetical ordering.
221
223 const TGPicture *p , Bool_t sorted)
224{
225 TGMenuEntry *ptr2 = 0;
226 if (sorted) {
227 TIter next(currentMenu->GetListOfEntries());
228 // Search for popup with corresponding name
229 while ((ptr2 = (TGMenuEntry *) next()) &&
230 (ptr2->GetType() != kMenuEntry ||
231 strcmp(ptr2->GetName(), s)<0 )) { }
232 }
233 currentMenu->AddEntry(s,id,ud,p,ptr2);
234}
235
236////////////////////////////////////////////////////////////////////////////////
237/// Create the context menu depending on the selected object.
238
240{
241 if (!object || fClient->IsEditable()) return;
242
245
246 // Add a title
248 AddSeparator();
249
250 // Get list of menu items from the selected object's class
251 TList *menuItemList = object->IsA()->GetMenuList();
252
255
256 while ((menuItem = (TClassMenuItem*) nextItem())) {
257 switch (menuItem->GetType()) {
259 {
260 TGMenuEntry *last = (TGMenuEntry *)GetListOfEntries()->Last();
261 if (last && last->GetType() != kMenuSeparator)
262 AddSeparator();
263 break;
264 }
266 {
267 // Standard list of class methods. Rebuild from scratch.
268 // Get linked list of objects menu items (i.e. member functions
269 // with the token *MENU in their comment fields.
270 TList *methodList = new TList;
271 object->IsA()->GetMenuItems(methodList);
272
274 TClass *classPtr = 0;
275 TIter next(methodList);
277
278 while ((method = (TMethod*) next())) {
279 if (classPtr != method->GetClass()) {
280 needSep = kTRUE;
281 classPtr = method->GetClass();
282 }
283
284 TDataMember *m;
285 EMenuItemKind menuKind = method->IsMenuItem();
288
289 switch (menuKind) {
290 case kMenuDialog:
291 // search for arguments to the MENU statement
292 currentMenu = FindHierarchy(method->GetCommentString(),last_component);
293 if (needSep && currentMenu == this) {
294 AddSeparator();
295 needSep = kFALSE;
296 }
297 AddEntrySorted(currentMenu,last_component.Length() ? last_component.Data() : method->GetName(), entry++, method,0,currentMenu != this);
298 break;
299 case kMenuSubMenu:
300 if ((m = method->FindDataMember())) {
301
302 // search for arguments to the MENU statement
303 currentMenu = FindHierarchy(method->GetCommentString(),last_component);
304
305 if (m->GetterMethod()) {
306 TGPopupMenu *r = new TGPopupMenu(gClient->GetDefaultRoot());
307 if (needSep && currentMenu == this) {
308 AddSeparator();
309 needSep = kFALSE;
310 }
311 if (last_component.Length()) {
312 currentMenu->AddPopup(last_component, r);
313 } else {
314 currentMenu->AddPopup(method->GetName(), r);
315 }
316 fTrash->Add(r);
317 TIter nxt(m->GetOptions());
318 TOptionListItem *it;
319 while ((it = (TOptionListItem*) nxt())) {
320 const char *name = it->fOptName;
321 Long_t val = it->fValue;
322
323 TToggle *t = new TToggle;
324 t->SetToggledObject(object, method);
325 t->SetOnValue(val);
326 fTrash->Add(t);
327
328 r->AddEntry(name, togglelist++, t);
329 if (t->GetState())
330 r->CheckEntry(togglelist-1);
331 }
332 } else {
333 if (needSep && currentMenu == this) {
334 AddSeparator();
335 needSep = kFALSE;
336 }
337 AddEntrySorted(currentMenu,last_component.Length() ? last_component.Data() : method->GetName(), entry++, method,0,currentMenu != this);
338 }
339 }
340 break;
341
342 case kMenuToggle:
343 {
344 TToggle *t = new TToggle;
345 t->SetToggledObject(object, method);
346 t->SetOnValue(1);
347 fTrash->Add(t);
348 // search for arguments to the MENU statement
349 currentMenu = FindHierarchy(method->GetCommentString(),last_component);
350 if (needSep && currentMenu == this) {
351 AddSeparator();
352 needSep = kFALSE;
353 }
354 AddEntrySorted(currentMenu,last_component.Length() ? last_component.Data() : method->GetName(), toggle++, t,0,currentMenu != this);
355 if (t->GetState()) currentMenu->CheckEntry(toggle-1);
356 }
357 break;
358
359 default:
360 break;
361 }
362 }
363 delete methodList;
364 }
365 break;
367 {
368 const char* menuItemTitle = menuItem->GetTitle();
369 if (menuItem->IsToggle()) {
370 TMethod* method =
371 object->IsA()->GetMethodWithPrototype(menuItem->GetFunctionName(),menuItem->GetArgs());
372 if (method) {
373 TToggle *t = new TToggle;
374 t->SetToggledObject(object, method);
375 t->SetOnValue(1);
376 fTrash->Add(t);
377
378 if (strlen(menuItemTitle)==0) menuItemTitle = method->GetName();
380 if (t->GetState()) CheckEntry(toggle-1);
381 }
382 } else {
383 if (strlen(menuItemTitle)==0) menuItemTitle = menuItem->GetFunctionName();
385 }
386 }
387 break;
388 default:
389 break;
390 }
391 }
392}
393
394////////////////////////////////////////////////////////////////////////////////
395/// Create dialog object with OK and Cancel buttons. This dialog
396/// prompts for the arguments of "method".
397
399{
400 Dialog(object,(TFunction*)method);
401}
402
403////////////////////////////////////////////////////////////////////////////////
404/// Create dialog object with OK and Cancel buttons. This dialog
405/// prompts for the arguments of "function".
406/// function may be a global function or a method
407
409{
411
412 if (!function) return;
413
414 // Position, if it exists, of the argument that correspond to the object itself
416 selfobjpos = fContextMenu->GetSelectedMenuItem()->GetSelfObjectPos();
417 else selfobjpos = -1;
418
419 const TGWindow *w;
422 // Embedded canvas has no canvasimp that is a TGFrame
423 // coverity[returned_null]
424 // coverity[dereference]
425 if (c->GetCanvasImp()->IsA()->InheritsFrom(TGFrame::Class())) {
426 w = fClient->GetWindowById(gVirtualX->GetWindowID(c->GetCanvasID()));
427 if (!w) w = (TRootCanvas *) c->GetCanvasImp();
428 } else {
429 w = gClient->GetDefaultRoot();
430 }
431 } else if (fContextMenu->GetBrowser()) {
433 w = (TRootBrowser *) b->GetBrowserImp();
434 } else {
435 w = gClient->GetDefaultRoot();
436 }
437 fDialog = new TRootDialog(this, w, fContextMenu->CreateDialogTitle(object, function));
438
439 // iterate through all arguments and create apropriate input-data objects:
440 // inputlines, option menus...
441 TMethodArg *argument = 0;
442
443 TIter next(function->GetListOfMethodArgs());
444 Int_t argpos = 0;
445
446 while ((argument = (TMethodArg *) next())) {
447 // Do not input argument for self object
448 if (selfobjpos != argpos) {
450 const char *type = argument->GetTypeName();
451 TDataType *datatype = gROOT->GetType(type);
452 const char *charstar = "char*";
453 char basictype[32];
454
455 if (datatype) {
456 strlcpy(basictype, datatype->GetTypeName(), 32);
457 } else {
459 if (strncmp(type, "enum", 4) && (cl && !(cl->Property() & kIsEnum)))
460 Warning("Dialog", "data type is not basic type, assuming (int)");
461 strlcpy(basictype, "int", 32);
462 }
463
464 if (strchr(argname, '*')) {
465 strlcat(basictype, "*",32);
466 if (!strncmp(type, "char", 4) || !strncmp(type, "Option_t", 8))
467 type = charstar;
468 else if (strstr(argname, "[default:")) {
469 // skip arguments that are pointers (but not char *)
470 // and have a default value
471 argpos++;
472 continue;
473 }
474 }
475
476 TDataMember *m = argument->GetDataMember();
477 if (m && object && m->GetterMethod(object->IsA())) {
478
479 // Get the current value and form it as a text:
480
481 char val[256];
482
483 if (!strncmp(basictype, "char*", 5)) {
484 char *tdefval;
485 m->GetterMethod()->Execute(object, "", &tdefval);
486 strlcpy(val, tdefval, sizeof(val));
487 } else if (!strncmp(basictype, "float", 5) ||
488 !strncmp(basictype, "double", 6)) {
490 m->GetterMethod()->Execute(object, "", ddefval);
491 snprintf(val,256, "%g", ddefval);
492 } else if (!strncmp(basictype, "char", 4) ||
493 !strncmp(basictype, "bool", 4) ||
494 !strncmp(basictype, "int", 3) ||
495 !strncmp(basictype, "long", 4) ||
496 !strncmp(basictype, "short", 5)) {
498 m->GetterMethod()->Execute(object, "", ldefval);
499 snprintf(val, 256, "%zi", (size_t)ldefval);
500 }
501
502 // Find out whether we have options ...
503 if (m->GetOptions()) {
504 Warning("Dialog", "option menu not yet implemented");
505 } else {
506 // we haven't got options - textfield ...
507 fDialog->Add(argname, val, type);
508 }
509 } else { // if m not found ...
510
511 char val[256] = "";
512 const char *tval = argument->GetDefault();
513 if (tval && strlen(tval)) {
514 // Remove leading and trailing quotes
515 strlcpy(val, tval + (tval[0] == '"' ? 1 : 0), sizeof(val));
516 if (val[strlen(val)-1] == '"')
517 val[strlen(val)-1]= 0;
518 }
519 fDialog->Add(argname, val, type);
520 }
521 }
522 argpos++;
523 }
524
525 fDialog->Popup();
526}
527
528////////////////////////////////////////////////////////////////////////////////
529/// Draw context menu entry.
530
532{
533 int ty, offset;
534 static int max_ascent = 0, max_descent = 0;
535
537 // draw the ? (help) in the right side when highlighting a menu entry
538 if (entry->GetType() == kMenuEntry && (entry->GetStatus() & kMenuActiveMask)) {
539 if (max_ascent == 0) {
540 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
541 }
542 offset = (entry->GetEh() - (max_ascent + max_descent)) / 2;
543 ty = entry->GetEy() + max_ascent + offset - 1;
544 TGHotString s("&?");
545 s.Draw(fId, fSelGC, fMenuWidth-12, ty);
546 }
547}
548
549////////////////////////////////////////////////////////////////////////////////
550/// Handle button event in the context menu.
551
553{
554 int id;
555 void *ud = 0;
556
557 if ((event->fType == kButtonRelease) && (event->fX >= (Int_t)(fMenuWidth-15)) &&
558 (event->fX <= (Int_t)fMenuWidth)) {
559 id = EndMenu(ud);
560 if (fHasGrab) gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab
561 if (ud) {
562 // retrieve the highlighted function
563 TFunction *function = 0;
564 if (id < kToggleStart) {
565 TMethod *m = (TMethod *)ud;
566 function = (TFunction *)m;
567 } else if (id >= kToggleStart && id < kUserFunctionStart) {
568 TToggle *t = (TToggle *)ud;
570 function = (TFunction *)mc->GetMethod();
571 } else {
573 function = gROOT->GetGlobalFunctionWithPrototype(mi->GetFunctionName());
574 }
575 if (function)
576 fContextMenu->SetMethod(function);
577 }
578 OnlineHelp();
579 return kTRUE;
580 }
581 return TGPopupMenu::HandleButton(event);
582}
583
584////////////////////////////////////////////////////////////////////////////////
585/// Handle pointer crossing event in context menu.
586
588{
589 if (event->fType == kLeaveNotify) {
590 // just to reset the mouse pointer...
591 HandleMotion(event);
592 }
593 return TGPopupMenu::HandleCrossing(event);
594}
595
596////////////////////////////////////////////////////////////////////////////////
597/// Handle pointer motion event in context menu.
598
600{
601 static int toggle = 0;
602 static Cursor_t handCur = kNone, rightCur = kNone;
604
605 if (handCur == kNone)
606 handCur = gVirtualX->CreateCursor(kHand);
607 if (rightCur == kNone)
608 rightCur = gVirtualX->CreateCursor(kArrowRight);
609
610 if (event->fType == kLeaveNotify) {
611 gVirtualX->ChangeActivePointerGrab(fId, mask, rightCur);
612 toggle = 0;
613 return kTRUE;
614 }
615 // change the cursot to a small hand when over the ? (help)
616 if ((event->fX >= (Int_t)(fMenuWidth-15)) && (event->fX <= (Int_t)fMenuWidth) &&
617 fCurrent && (fCurrent->GetType() == kMenuEntry)) {
618 if (toggle == 0) {
619 gVirtualX->ChangeActivePointerGrab(fId, mask, handCur);
620 toggle = 1;
621 }
622 }
623 else {
624 if (toggle == 1) {
625 gVirtualX->ChangeActivePointerGrab(fId, mask, rightCur);
626 toggle = 0;
627 }
628 }
629 return TGPopupMenu::HandleMotion(event);
630}
631
632////////////////////////////////////////////////////////////////////////////////
633/// Open the online help matching the actual class/method.
634
636{
638 TString cmd;
639 TString url = gEnv->GetValue("Browser.StartUrl", "https://root.cern.ch/doc/master");
640 if (url.EndsWith(".html", TString::kIgnoreCase)) {
641 if (url.Last('/') != kNPOS)
642 url.Remove(url.Last('/'));
643 }
644 if (!url.EndsWith("/")) {
645 url += '/';
646 }
648 if (obj) {
649 clname = obj->ClassName();
652 TMethod *method = obj->IsA()->GetMethodAllAny(smeth.Data());
653 if (method) clname = method->GetClass()->GetName();
654 url += clname;
655 url += ".html";
656 url += "#";
657 url += clname;
658 url += ":";
659 url += smeth.Data();
660 }
661 else {
662 url += clname;
663 url += ".html";
664 }
665 if (fDialog) delete fDialog;
666 fDialog = 0;
667 cmd = TString::Format("new TGHtmlBrowser(\"%s\", 0, 900, 300);", url.Data());
668 gROOT->ProcessLine(cmd.Data());
669 }
670}
671
672////////////////////////////////////////////////////////////////////////////////
673/// Handle context menu messages.
674
676{
678 if (GetContextMenu()->GetSelectedPad()) {
679 savedPad.SetObject(gPad);
680 gPad = GetContextMenu()->GetSelectedPad();
681 }
682
683 switch (GET_MSG(msg)) {
684
685 case kC_COMMAND:
686
687 switch (GET_SUBMSG(msg)) {
688
689 case kCM_MENU:
690
691 if (parm1 < kToggleStart) {
692 TMethod *m = (TMethod *) parm2;
693 GetContextMenu()->Action(m);
694 } else if (parm1 >= kToggleStart && parm1 < kToggleListStart) {
695 TToggle *t = (TToggle *) parm2;
696 GetContextMenu()->Action(t);
698 TToggle *t = (TToggle *) parm2;
699 if (t->GetState() == 0)
700 t->SetState(1);
701 } else {
703 GetContextMenu()->Action(mi);
704 }
705 break;
706
707 case kCM_BUTTON:
708 if (parm1 == 1) {
709 const char *args = fDialog->GetParameters();
710 GetContextMenu()->Execute((char *)args);
711 delete fDialog;
712 fDialog = nullptr;
713 }
714 if (parm1 == 2) {
715 const char *args = fDialog->GetParameters();
716 GetContextMenu()->Execute((char *)args);
717 }
718 if (parm1 == 3) {
719 delete fDialog;
720 fDialog = nullptr;
721 }
722 if (parm1 == 4) {
723 OnlineHelp();
724 }
725 break;
726
727 default:
728 break;
729 }
730 break;
731
732 case kC_TEXTENTRY:
733
734 switch (GET_SUBMSG(msg)) {
735
736 case kTE_ENTER:
737 {
738 const char *args = fDialog->GetParameters();
739 GetContextMenu()->Execute((char *)args);
740 delete fDialog;
741 fDialog = nullptr;
742 }
743 break;
744
745 default:
746 break;
747 }
748 break;
749
750 default:
751 break;
752 }
753
754 if (savedPad.GetObject()) gPad = (TVirtualPad*) savedPad.GetObject();
755
756 return kTRUE;
757}
758
759////////////////////////////////////////////////////////////////////////////////
760/// Close the context menu if the object is deleted in the
761/// RecursiveRemove() operation.
762
764{
765 void *ud;
766 if (obj == fContextMenu->GetSelectedCanvas())
768 if (obj == fContextMenu->GetSelectedPad())
770 if (obj == fContextMenu->GetSelectedObject()) {
771 // if the object being deleted is the one selected,
772 // ungrab the mouse pointer and terminate (close) the menu
774 if (fHasGrab)
775 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
776 EndMenu(ud);
777 }
778}
779
@ 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
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:6128
void GetMenuItems(TList *listitems)
Returns list of methods accessible by context menu.
Definition TClass.cxx:3901
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:2973
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:490
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:602
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:331
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
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:173
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:1363
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:1091
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:1778
virtual void DrawEntry(TGMenuEntry *entry)
Draw popup menu entry.
Definition TGMenu.cxx:1502
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:1285
virtual void AddSeparator(TGMenuEntry *before=nullptr)
Add a menu separator to the menu.
Definition TGMenu.cxx:1056
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:986
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:1237
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:1390
Bool_t HandleButton(Event_t *event) override
Handle button event in the popup menu.
Definition TGMenu.cxx:1334
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:467
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:457
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
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:377
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
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:2384
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:134
virtual void SetState(Bool_t state)
Sets the value of toggle to fOnValue or fOffValue according to passed argument.
Definition TToggle.cxx:79
virtual Bool_t GetState()
Returns the state of Toggle according to its current value and fOnValue, returns true if they match.
Definition TToggle.cxx:68
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