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 "TApplication.h"
47#include "KeySymbols.h"
48#include "RConfigure.h"
49#include "strlcpy.h"
50
51#include <cstdio>
52
54 kToggleStart = 1000, // first id of toggle menu items
55 kToggleListStart = 2000, // first id of toggle list menu items
56 kUserFunctionStart = 3000 // first id of user added functions/methods, etc...
57};
58
59
60
61////////////////////////////////////////////////////////////////////////////////
62/// Create context menu.
63
65 : TGPopupMenu(gClient->GetDefaultRoot()), TContextMenuImp(c)
66{
67 fDialog = 0;
68 fTrash = new TList;
69
71 gROOT->GetListOfCleanups()->Add(this);
72 // Context menu handles its own messages
73 Associate(this);
74}
75
76////////////////////////////////////////////////////////////////////////////////
77/// Delete a context menu.
78
80{
81 gROOT->GetListOfCleanups()->Remove(this);
82 delete fDialog;
83 if (fTrash) fTrash->Delete();
84 delete fTrash;
85}
86
87thread_local TRootContextMenu *gBuildingContextMenu = nullptr;
88
89
91{
92 if (gBuildingContextMenu != this) {
94 } else if (w != fWidth || h != fHeight) {
95 // Mirror TGFrame::Resize's bookkeeping and layout, omitting only the
96 // native window resize. Entries still see the correct intermediate size.
97 const auto size = GetDefaultSize();
98 fWidth = w ? w : size.fWidth;
99 fHeight = h ? h : size.fHeight;
100 Layout();
101 }
102}
103
104
105////////////////////////////////////////////////////////////////////////////////
106/// Display context popup menu for currently selected object.
107
109{
110 if (fClient->IsEditable()) return;
111
112 // delete menu items releated to previous object and reset menu size
114 fCurrent = 0;
115 if (fTrash) fTrash->Delete();
116 fMenuHeight = 6;
117 fMenuWidth = 8;
118
119 // delete previous dialog
120 if (fDialog) {
121 delete fDialog;
122 fDialog = 0;
123 }
124
126 // add menu items to popup menu
127#ifdef R__MACOSX
128 use_mac_x11_workaroud = gVirtualX->InheritsFrom("TGX11");
129#endif
131 // special workaround for X11 on MacOS
134 gBuildingContextMenu = nullptr;
135
136 // Include the help column before mapping; submit only the final size.
137 fMenuWidth += 5;
138 fWidth = GetDefaultWidth() + 5;
141 Layout();
142 } else {
144 }
145
146 int xx, yy, topx = 0, topy = 0;
147 UInt_t w, h;
148
150 gVirtualX->GetGeometry(fContextMenu->GetSelectedCanvas()->GetCanvasID(),
151 topx, topy, w, h);
152
153 xx = topx + x + 1;
154 yy = topy + y + 1;
155
156#ifdef R__HAS_COCOA
157 //Context menu must be transient for a canvas, otherwise it's possible
158 //to break the z-order (for example, using alt-tab to switch between
159 //different aplications). This hint works ONLY for canvas though
160 //(otherwise selected canvas is null).
161 TGWindow *parent = 0;
163 parent = dynamic_cast<TGWindow *>(pad->GetCanvasImp());
164 else if ((pad = fContextMenu->GetSelectedPad()) && pad->GetCanvasImp())
165 parent = dynamic_cast<TGWindow *>(pad->GetCanvasImp());
166 else if (TBrowser * const browser = fContextMenu->GetBrowser())
167 parent = dynamic_cast<TGWindow *>(browser->GetBrowserImp());
168
169 if (parent)
170 gVirtualX->SetWMTransientHint(GetId(), parent->GetId());
171#endif
172
174 // add some space for the right-side '?' (help)
175 fMenuWidth += 5;
177}
178
179////////////////////////////////////////////////////////////////////////////////
180/// Decodes the Hierarchy="Level0/Level1/Level2/..." statement from the comment field
181/// and returns the - if needed - created sub menu "Level0/Level1"
182/// Returns the last component in last_component.
183
185{
190
191 // search for arguments to the MENU statement
192 // strcpy(cmd,commentstring);
194 if ((opt_ptr=cmd.Index("*MENU={")) != kNPOS ||
195 (opt_ptr=cmd.Index("*SUBMENU={"))!= kNPOS ||
196 (opt_ptr=cmd.Index("*TOGGLE={")) != kNPOS ) {
197
198 Ssiz_t start = cmd.Index("{",opt_ptr) + 1;
199 Ssiz_t end = cmd.Index("}",start);
200 option = cmd(start,end - start);
201
202 // Look for Hierarchy token
203 TObjArray * array = option.Tokenize(";");
204 TIter iter(array);
205 TObject *obj;
206 while((obj = iter())) {
207 TString token(obj->GetName());
208 if (token.Index("Hierarchy=\"") != kNPOS) {
209 Ssiz_t tstart = token.Index("\"") + 1;
210 Ssiz_t tend = token.Index("\"",tstart+1);
211 if (tend == kNPOS) continue;
213 }
214 }
215 delete array;
216 }
217
218 // Build Hierarchy
219 currentMenu = this;
220 TObjArray * array = hierarchy.Tokenize("/");
221 TIter iter(array);
222 TObject *obj = iter();
223 while(obj) {
224 last_component = obj->GetName();
225 obj = iter();
226 if (obj) {
227 TGMenuEntry *ptr;
228 TIter next(currentMenu->GetListOfEntries());
229 // Search for popup with corresponding name
230 while ((ptr = (TGMenuEntry *) next()) &&
231 (ptr->GetType() != kMenuPopup ||
232 last_component.CompareTo(ptr->GetName()))) { }
233 if (ptr)
234 currentMenu = ptr->GetPopup();
235 else {
236 TGPopupMenu *r = new TGPopupMenu(gClient->GetDefaultRoot());
237 // Alphabetical ordering
239 TIter next2(currentMenu->GetListOfEntries());
240 // Search for popup with corresponding name
241 while ((ptr2 = (TGMenuEntry *) next2()) &&
242 (ptr2->GetType() != kMenuPopup ||
243 last_component.CompareTo(ptr2->GetName()) > 0 )) { }
244
245 currentMenu->AddPopup(last_component, r,ptr2);
246 currentMenu = r;
247 fTrash->Add(r);
248 last_component = obj->GetName();
249 }
250 }
251 }
252
253 delete array;
254 return currentMenu;
255}
256
257////////////////////////////////////////////////////////////////////////////////
258/// Add a entry to current menu with alphabetical ordering.
259
261 const TGPicture *p , Bool_t sorted)
262{
263 TGMenuEntry *ptr2 = 0;
264 if (sorted) {
265 TIter next(currentMenu->GetListOfEntries());
266 // Search for popup with corresponding name
267 while ((ptr2 = (TGMenuEntry *) next()) &&
268 (ptr2->GetType() != kMenuEntry ||
269 strcmp(ptr2->GetName(), s)<0 )) { }
270 }
271 currentMenu->AddEntry(s,id,ud,p,ptr2);
272}
273
274////////////////////////////////////////////////////////////////////////////////
275/// Create the context menu depending on the selected object.
276
278{
279 if (!object || fClient->IsEditable()) return;
280
283
284 // Add a title
286 AddSeparator();
287
288 // Get list of menu items from the selected object's class
289 TList *menuItemList = object->IsA()->GetMenuList();
290
293
294 while ((menuItem = (TClassMenuItem*) nextItem())) {
295 switch (menuItem->GetType()) {
297 {
298 TGMenuEntry *last = (TGMenuEntry *)GetListOfEntries()->Last();
299 if (last && last->GetType() != kMenuSeparator)
300 AddSeparator();
301 break;
302 }
304 {
305 // Standard list of class methods. Rebuild from scratch.
306 // Get linked list of objects menu items (i.e. member functions
307 // with the token *MENU in their comment fields.
308 TList *methodList = new TList;
309 object->IsA()->GetMenuItems(methodList);
310
312 TClass *classPtr = 0;
313 TIter next(methodList);
315
316 while ((method = (TMethod*) next())) {
317 if (classPtr != method->GetClass()) {
318 needSep = kTRUE;
319 classPtr = method->GetClass();
320 }
321
322 TDataMember *m;
323 EMenuItemKind menuKind = method->IsMenuItem();
326
327 switch (menuKind) {
328 case kMenuDialog:
329 // search for arguments to the MENU statement
330 currentMenu = FindHierarchy(method->GetCommentString(),last_component);
331 if (needSep && currentMenu == this) {
332 AddSeparator();
333 needSep = kFALSE;
334 }
335 AddEntrySorted(currentMenu,last_component.Length() ? last_component.Data() : method->GetName(), entry++, method,0,currentMenu != this);
336 break;
337 case kMenuSubMenu:
338 if ((m = method->FindDataMember())) {
339
340 // search for arguments to the MENU statement
341 currentMenu = FindHierarchy(method->GetCommentString(),last_component);
342
343 if (m->GetterMethod()) {
344 TGPopupMenu *r = new TGPopupMenu(gClient->GetDefaultRoot());
345 if (needSep && currentMenu == this) {
346 AddSeparator();
347 needSep = kFALSE;
348 }
349 if (last_component.Length()) {
350 currentMenu->AddPopup(last_component, r);
351 } else {
352 currentMenu->AddPopup(method->GetName(), r);
353 }
354 fTrash->Add(r);
355 TIter nxt(m->GetOptions());
356 TOptionListItem *it;
357 while ((it = (TOptionListItem*) nxt())) {
358 const char *name = it->fOptName;
359 Long_t val = it->fValue;
360
361 TToggle *t = new TToggle;
362 t->SetToggledObject(object, method);
363 t->SetOnValue(val);
364 fTrash->Add(t);
365
366 r->AddEntry(name, togglelist++, t);
367 if (t->GetState())
368 r->CheckEntry(togglelist-1);
369 }
370 } else {
371 if (needSep && currentMenu == this) {
372 AddSeparator();
373 needSep = kFALSE;
374 }
375 AddEntrySorted(currentMenu,last_component.Length() ? last_component.Data() : method->GetName(), entry++, method,0,currentMenu != this);
376 }
377 }
378 break;
379
380 case kMenuToggle:
381 {
382 TToggle *t = new TToggle;
383 t->SetToggledObject(object, method);
384 t->SetOnValue(1);
385 fTrash->Add(t);
386 // search for arguments to the MENU statement
387 currentMenu = FindHierarchy(method->GetCommentString(),last_component);
388 if (needSep && currentMenu == this) {
389 AddSeparator();
390 needSep = kFALSE;
391 }
392 AddEntrySorted(currentMenu,last_component.Length() ? last_component.Data() : method->GetName(), toggle++, t,0,currentMenu != this);
393 if (t->GetState()) currentMenu->CheckEntry(toggle-1);
394 }
395 break;
396
397 default:
398 break;
399 }
400 }
401 delete methodList;
402 }
403 break;
405 {
406 const char* menuItemTitle = menuItem->GetTitle();
407 if (menuItem->IsToggle()) {
408 TMethod* method =
409 object->IsA()->GetMethodWithPrototype(menuItem->GetFunctionName(),menuItem->GetArgs());
410 if (method) {
411 TToggle *t = new TToggle;
412 t->SetToggledObject(object, method);
413 t->SetOnValue(1);
414 fTrash->Add(t);
415
416 if (strlen(menuItemTitle)==0) menuItemTitle = method->GetName();
418 if (t->GetState()) CheckEntry(toggle-1);
419 }
420 } else {
421 if (strlen(menuItemTitle)==0) menuItemTitle = menuItem->GetFunctionName();
423 }
424 }
425 break;
426 default:
427 break;
428 }
429 }
430}
431
432////////////////////////////////////////////////////////////////////////////////
433/// Create dialog object with OK and Cancel buttons. This dialog
434/// prompts for the arguments of "method".
435
437{
438 Dialog(object,(TFunction*)method);
439}
440
441////////////////////////////////////////////////////////////////////////////////
442/// Create dialog object with OK and Cancel buttons. This dialog
443/// prompts for the arguments of "function".
444/// function may be a global function or a method
445
447{
449
450 if (!function) return;
451
452 // Position, if it exists, of the argument that correspond to the object itself
454 selfobjpos = fContextMenu->GetSelectedMenuItem()->GetSelfObjectPos();
455 else selfobjpos = -1;
456
457 const TGWindow *w;
460 // Embedded canvas has no canvasimp that is a TGFrame
461 // coverity[returned_null]
462 // coverity[dereference]
463 if (c->GetCanvasImp()->IsA()->InheritsFrom(TGFrame::Class())) {
464 w = fClient->GetWindowById(gVirtualX->GetWindowID(c->GetCanvasID()));
465 if (!w) w = (TRootCanvas *) c->GetCanvasImp();
466 } else {
467 w = gClient->GetDefaultRoot();
468 }
469 } else if (fContextMenu->GetBrowser()) {
471 w = (TRootBrowser *) b->GetBrowserImp();
472 } else {
473 w = gClient->GetDefaultRoot();
474 }
475 fDialog = new TRootDialog(this, w, fContextMenu->CreateDialogTitle(object, function));
476
477 // iterate through all arguments and create apropriate input-data objects:
478 // inputlines, option menus...
479 TMethodArg *argument = 0;
480
481 TIter next(function->GetListOfMethodArgs());
482 Int_t argpos = 0;
483
484 while ((argument = (TMethodArg *) next())) {
485 // Do not input argument for self object
486 if (selfobjpos != argpos) {
488 const char *type = argument->GetTypeName();
489 TDataType *datatype = gROOT->GetType(type);
490 const char *charstar = "char*";
491 char basictype[32];
492
493 if (datatype) {
494 strlcpy(basictype, datatype->GetTypeName(), 32);
495 } else {
497 if (strncmp(type, "enum", 4) && (cl && !(cl->Property() & kIsEnum)))
498 Warning("Dialog", "data type is not basic type, assuming (int)");
499 strlcpy(basictype, "int", 32);
500 }
501
502 if (strchr(argname, '*')) {
503 strlcat(basictype, "*",32);
504 if (!strncmp(type, "char", 4) || !strncmp(type, "Option_t", 8))
505 type = charstar;
506 else if (strstr(argname, "[default:")) {
507 // skip arguments that are pointers (but not char *)
508 // and have a default value
509 argpos++;
510 continue;
511 }
512 }
513
514 TDataMember *m = argument->GetDataMember();
515 if (m && object && m->GetterMethod(object->IsA())) {
516
517 // Get the current value and form it as a text:
518
519 char val[256];
520
521 if (!strncmp(basictype, "char*", 5)) {
522 char *tdefval;
523 m->GetterMethod()->Execute(object, "", &tdefval);
524 strlcpy(val, tdefval, sizeof(val));
525 } else if (!strncmp(basictype, "float", 5) ||
526 !strncmp(basictype, "double", 6)) {
528 m->GetterMethod()->Execute(object, "", ddefval);
529 snprintf(val,256, "%g", ddefval);
530 } else if (!strncmp(basictype, "char", 4) ||
531 !strncmp(basictype, "bool", 4) ||
532 !strncmp(basictype, "int", 3) ||
533 !strncmp(basictype, "long", 4) ||
534 !strncmp(basictype, "short", 5)) {
536 m->GetterMethod()->Execute(object, "", ldefval);
537 snprintf(val, 256, "%zi", (size_t)ldefval);
538 }
539
540 // Find out whether we have options ...
541 if (m->GetOptions()) {
542 Warning("Dialog", "option menu not yet implemented");
543 } else {
544 // we haven't got options - textfield ...
545 fDialog->Add(argname, val, type);
546 }
547 } else { // if m not found ...
548
549 char val[256] = "";
550 const char *tval = argument->GetDefault();
551 if (tval && strlen(tval)) {
552 // Remove leading and trailing quotes
553 strlcpy(val, tval + (tval[0] == '"' ? 1 : 0), sizeof(val));
554 if (val[strlen(val)-1] == '"')
555 val[strlen(val)-1]= 0;
556 }
557 fDialog->Add(argname, val, type);
558 }
559 }
560 argpos++;
561 }
562
563 fDialog->Popup();
564}
565
566////////////////////////////////////////////////////////////////////////////////
567/// Draw context menu entry.
568
570{
571 int ty, offset;
572 static int max_ascent = 0, max_descent = 0;
573
575 // draw the ? (help) in the right side when highlighting a menu entry
576 if (entry->GetType() == kMenuEntry && (entry->GetStatus() & kMenuActiveMask)) {
577 if (max_ascent == 0) {
578 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
579 }
580 offset = (entry->GetEh() - (max_ascent + max_descent)) / 2;
581 ty = entry->GetEy() + max_ascent + offset - 1;
582 TGHotString s("&?");
583 s.Draw(fId, fSelGC, fMenuWidth-12, ty);
584 }
585}
586
587////////////////////////////////////////////////////////////////////////////////
588/// Handle button event in the context menu.
589
591{
592 int id;
593 void *ud = 0;
594
595 if ((event->fType == kButtonRelease) && (event->fX >= (Int_t)(fMenuWidth-15)) &&
596 (event->fX <= (Int_t)fMenuWidth)) {
597 id = EndMenu(ud);
598 if (fHasGrab) gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab
599 if (ud) {
600 // retrieve the highlighted function
601 TFunction *function = 0;
602 if (id < kToggleStart) {
603 TMethod *m = (TMethod *)ud;
604 function = (TFunction *)m;
605 } else if (id >= kToggleStart && id < kUserFunctionStart) {
606 TToggle *t = (TToggle *)ud;
608 function = (TFunction *)mc->GetMethod();
609 } else {
611 function = gROOT->GetGlobalFunctionWithPrototype(mi->GetFunctionName());
612 }
613 if (function)
614 fContextMenu->SetMethod(function);
615 }
616 OnlineHelp();
617 return kTRUE;
618 }
620}
621
622////////////////////////////////////////////////////////////////////////////////
623/// Handle pointer crossing event in context menu.
624
626{
627 if (event->fType == kLeaveNotify) {
628 // just to reset the mouse pointer...
630 }
632}
633
634////////////////////////////////////////////////////////////////////////////////
635/// Handle pointer motion event in context menu.
636
638{
639 static int toggle = 0;
640 static Cursor_t handCur = kNone, rightCur = kNone;
642
643 if (handCur == kNone)
644 handCur = gVirtualX->CreateCursor(kHand);
645 if (rightCur == kNone)
646 rightCur = gVirtualX->CreateCursor(kArrowRight);
647
648 if (event->fType == kLeaveNotify) {
649 gVirtualX->ChangeActivePointerGrab(fId, mask, rightCur);
650 toggle = 0;
651 return kTRUE;
652 }
653 // change the cursot to a small hand when over the ? (help)
654 if ((event->fX >= (Int_t)(fMenuWidth-15)) && (event->fX <= (Int_t)fMenuWidth) &&
655 fCurrent && (fCurrent->GetType() == kMenuEntry)) {
656 if (toggle == 0) {
657 gVirtualX->ChangeActivePointerGrab(fId, mask, handCur);
658 toggle = 1;
659 }
660 }
661 else {
662 if (toggle == 1) {
663 gVirtualX->ChangeActivePointerGrab(fId, mask, rightCur);
664 toggle = 0;
665 }
666 }
668}
669
670////////////////////////////////////////////////////////////////////////////////
671/// Open the online help matching the actual class/method.
672
674{
677 if (obj) {
678 clname = obj->ClassName();
681 TMethod *method = obj->IsA()->GetMethodAllAny(smeth.Data());
682 if (method)
683 clname = method->GetClass()->GetName();
684 clname += "::" + smeth;
685 }
687 }
688}
689
690////////////////////////////////////////////////////////////////////////////////
691/// Handle context menu messages.
692
694{
696 if (GetContextMenu()->GetSelectedPad()) {
697 savedPad.SetObject(gPad);
698 gPad = GetContextMenu()->GetSelectedPad();
699 }
700
701 switch (GET_MSG(msg)) {
702
703 case kC_COMMAND:
704
705 switch (GET_SUBMSG(msg)) {
706
707 case kCM_MENU:
708
709 if (parm1 < kToggleStart) {
710 TMethod *m = (TMethod *) parm2;
711 GetContextMenu()->Action(m);
712 } else if (parm1 >= kToggleStart && parm1 < kToggleListStart) {
713 TToggle *t = (TToggle *) parm2;
714 GetContextMenu()->Action(t);
716 TToggle *t = (TToggle *) parm2;
717 if (t->GetState() == 0)
718 t->SetState(1);
719 } else {
721 GetContextMenu()->Action(mi);
722 }
723 break;
724
725 case kCM_BUTTON:
726 if (parm1 == 1) {
727 const char *args = fDialog->GetParameters();
728 GetContextMenu()->Execute((char *)args);
729 delete fDialog;
730 fDialog = nullptr;
731 }
732 if (parm1 == 2) {
733 const char *args = fDialog->GetParameters();
734 GetContextMenu()->Execute((char *)args);
735 }
736 if (parm1 == 3) {
737 delete fDialog;
738 fDialog = nullptr;
739 }
740 if (parm1 == 4) {
741 OnlineHelp();
742 }
743 break;
744
745 default:
746 break;
747 }
748 break;
749
750 case kC_TEXTENTRY:
751
752 switch (GET_SUBMSG(msg)) {
753
754 case kTE_ENTER:
755 {
756 const char *args = fDialog->GetParameters();
757 GetContextMenu()->Execute((char *)args);
758 delete fDialog;
759 fDialog = nullptr;
760 }
761 break;
762
763 default:
764 break;
765 }
766 break;
767
768 default:
769 break;
770 }
771
772 if (savedPad.GetObject()) gPad = (TVirtualPad*) savedPad.GetObject();
773
774 return kTRUE;
775}
776
777////////////////////////////////////////////////////////////////////////////////
778/// Close the context menu if the object is deleted in the
779/// RecursiveRemove() operation.
780
782{
783 void *ud;
784 if (obj == fContextMenu->GetSelectedCanvas())
786 if (obj == fContextMenu->GetSelectedPad())
788 if (obj == fContextMenu->GetSelectedObject()) {
789 // if the object being deleted is the one selected,
790 // ungrab the mouse pointer and terminate (close) the menu
792 if (fHasGrab)
793 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
794 EndMenu(ud);
795 }
796}
797
@ kButtonRelease
Definition GuiTypes.h:61
@ kLeaveNotify
Definition GuiTypes.h:62
@ kArrowRight
Definition GuiTypes.h:376
@ kHand
Definition GuiTypes.h:375
const Mask_t kButtonPressMask
Definition GuiTypes.h:162
const Mask_t kPointerMotionMask
Definition GuiTypes.h:164
Handle_t Cursor_t
Cursor handle.
Definition GuiTypes.h:35
const Handle_t kNone
Definition GuiTypes.h:89
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:163
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
cudaEvent_t event
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:90
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:69
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:132
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
R__EXTERN TApplication * gApplication
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ kIsEnum
Definition TDictionary.h:68
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:142
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:417
thread_local TRootContextMenu * gBuildingContextMenu
@ kToggleStart
@ kToggleListStart
@ kUserFunctionStart
#define gPad
#define gVirtualX
Definition TVirtualX.h:379
Int_t GET_MSG(Long_t val)
@ kCM_MENU
@ kTE_ENTER
@ kC_COMMAND
@ kCM_BUTTON
@ kC_TEXTENTRY
Int_t GET_SUBMSG(Long_t val)
void OpenReferenceGuideFor(const TString &strippedClass)
It opens the online reference guide, generated with Doxygen, for the chosen scope (class/namespace/st...
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:6254
void GetMenuItems(TList *listitems)
Returns list of methods accessible by context menu.
Definition TClass.cxx:3937
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:2999
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
Global functions class (global functions are obtained from CINT).
Definition TFunction.h:30
TList * GetListOfMethodArgs()
Return list containing the TMethodArgs of a TFunction.
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
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.cxx:577
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:332
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:598
UInt_t fHeight
frame height
Definition TGFrame.h:88
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:192
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:193
UInt_t fWidth
frame width
Definition TGFrame.h:87
virtual void Layout()
Definition TGFrame.h:201
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:1364
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:1092
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:1779
virtual void DrawEntry(TGMenuEntry *entry)
Draw popup menu entry.
Definition TGMenu.cxx:1503
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:1286
virtual void AddSeparator(TGMenuEntry *before=nullptr)
Add a menu separator to the menu.
Definition TGMenu.cxx:1057
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:987
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:1238
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:1391
Bool_t HandleButton(Event_t *event) override
Handle button event in the popup menu.
Definition TGMenu.cxx:1335
Bool_t fHasGrab
true if menu has grabbed pointer
Definition TGMenu.h:120
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual void Resize(UInt_t w, UInt_t h)
Resize the window.
Definition TGWindow.cxx:277
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:600
TClass * IsA() const override
Definition TList.h:115
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:42
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:461
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:248
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 Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
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:137
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:175
TMarker m
Definition textangle.C:8