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
125 Bool_t use_mac_x11_workaroud = kFALSE;
126 // add menu items to popup menu
127#ifdef R__MACOSX
128 use_mac_x11_workaroud = gVirtualX->InheritsFrom("TGX11");
129#endif
130 if (use_mac_x11_workaroud) {
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
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
173 PlaceMenu(xx, yy, kTRUE, kTRUE);
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
184TGPopupMenu * TRootContextMenu::FindHierarchy(const char *commentstring, TString & last_component)
185{
186 TString cmd(commentstring);
188 TString hierarchy;
189 TGPopupMenu *currentMenu = 0;
190
191 // search for arguments to the MENU statement
192 // strcpy(cmd,commentstring);
193 Ssiz_t opt_ptr;
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;
212 hierarchy = token(tstart,tend - tstart);
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
238 TGMenuEntry *ptr2;
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
260void TRootContextMenu::AddEntrySorted(TGPopupMenu *currentMenu, const char *s, Int_t id, void *ud,
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
281 int entry = 0, toggle = kToggleStart, togglelist = kToggleListStart;
282 int userfunction = kUserFunctionStart;
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
291 TClassMenuItem *menuItem;
292 TIter nextItem(menuItemList);
293
294 while ((menuItem = (TClassMenuItem*) nextItem())) {
295 switch (menuItem->GetType()) {
297 {
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
311 TClass *classPtr = nullptr;
312 TIter next(methodList);
313 Bool_t needSep = kFALSE;
314
315 while (auto method = (TMethod*) next()) {
316 if (classPtr != method->GetClass()) {
317 needSep = kTRUE;
318 classPtr = method->GetClass();
319 }
320
321 EMenuItemKind menuKind = method->IsMenuItem();
322 TGPopupMenu *currentMenu = nullptr;
323 TString last_component;
324
325 switch (menuKind) {
326 case kMenuDialog:
327 // search for arguments to the MENU statement
328 currentMenu = FindHierarchy(method->GetCommentString(),last_component);
329 if (needSep && currentMenu == this) {
330 AddSeparator();
331 needSep = kFALSE;
332 }
333 AddEntrySorted(currentMenu,last_component.Length() ? last_component.Data() : method->GetName(), entry++, method,0,currentMenu != this);
334 break;
335 case kMenuSubMenu:
336 if (auto member = method->FindDataMember()) {
337
338 // search for arguments to the MENU statement
339 currentMenu = FindHierarchy(method->GetCommentString(),last_component);
340
341 if (member->GetterMethod()) {
342 TGPopupMenu *r = new TGPopupMenu(gClient->GetDefaultRoot());
343 if (needSep && currentMenu == this) {
344 AddSeparator();
345 needSep = kFALSE;
346 }
347 if (last_component.Length()) {
348 currentMenu->AddPopup(last_component, r);
349 } else {
350 currentMenu->AddPopup(method->GetName(), r);
351 }
352 fTrash->Add(r);
353 TIter nxt(member->GetOptions());
354 while (auto it = (TOptionListItem*) nxt()) {
355 TToggle *t = new TToggle;
356 t->SetToggledObject(object, member);
357 t->SetOnValue(it->fValue);
358 fTrash->Add(t);
359
360 r->AddEntry(it->fOptName, togglelist++, t);
361 if (t->GetState())
362 r->CheckEntry(togglelist-1);
363 }
364 } else {
365 if (needSep && currentMenu == this) {
366 AddSeparator();
367 needSep = kFALSE;
368 }
369 AddEntrySorted(currentMenu,last_component.Length() ? last_component.Data() : method->GetName(), entry++, method,0,currentMenu != this);
370 }
371 }
372 break;
373
374 case kMenuToggle:
375 {
376 TToggle *t = new TToggle;
377 t->SetToggledObject(object, method);
378 t->SetOnValue(1);
379 fTrash->Add(t);
380 // search for arguments to the MENU statement
381 currentMenu = FindHierarchy(method->GetCommentString(),last_component);
382 if (needSep && currentMenu == this) {
383 AddSeparator();
384 needSep = kFALSE;
385 }
386 AddEntrySorted(currentMenu,last_component.Length() ? last_component.Data() : method->GetName(), toggle++, t,0,currentMenu != this);
387 if (t->GetState()) currentMenu->CheckEntry(toggle-1);
388 }
389 break;
390
391 default:
392 break;
393 }
394 }
395 delete methodList;
396 }
397 break;
399 {
400 const char* menuItemTitle = menuItem->GetTitle();
401 if (menuItem->IsToggle()) {
402 TMethod* method =
403 object->IsA()->GetMethodWithPrototype(menuItem->GetFunctionName(),menuItem->GetArgs());
404 if (method) {
405 TToggle *t = new TToggle;
406 t->SetToggledObject(object, method);
407 t->SetOnValue(1);
408 fTrash->Add(t);
409
410 if (strlen(menuItemTitle)==0) menuItemTitle = method->GetName();
411 AddEntry(menuItemTitle, toggle++, t);
412 if (t->GetState()) CheckEntry(toggle-1);
413 }
414 } else {
415 if (strlen(menuItemTitle)==0) menuItemTitle = menuItem->GetFunctionName();
416 AddEntry(menuItemTitle,userfunction++,menuItem);
417 }
418 }
419 break;
420 default:
421 break;
422 }
423 }
424}
425
426////////////////////////////////////////////////////////////////////////////////
427/// Create dialog object with OK and Cancel buttons. This dialog
428/// prompts for the arguments of "method".
429
431{
432 Dialog(object,(TFunction*)method);
433}
434
435////////////////////////////////////////////////////////////////////////////////
436/// Create dialog object with OK and Cancel buttons. This dialog
437/// prompts for the arguments of "function".
438/// function may be a global function or a method
439
441{
442 Int_t selfobjpos;
443
444 if (!function) return;
445
446 // Position, if it exists, of the argument that correspond to the object itself
449 else selfobjpos = -1;
450
451 const TGWindow *w;
454 // Embedded canvas has no canvasimp that is a TGFrame
455 // coverity[returned_null]
456 // coverity[dereference]
457 if (c->GetCanvasImp()->IsA()->InheritsFrom(TGFrame::Class())) {
458 w = fClient->GetWindowById(gVirtualX->GetWindowID(c->GetCanvasID()));
459 if (!w) w = (TRootCanvas *) c->GetCanvasImp();
460 } else {
461 w = gClient->GetDefaultRoot();
462 }
463 } else if (fContextMenu->GetBrowser()) {
465 w = (TRootBrowser *) b->GetBrowserImp();
466 } else {
467 w = gClient->GetDefaultRoot();
468 }
469 fDialog = new TRootDialog(this, w, fContextMenu->CreateDialogTitle(object, function));
470
471 // iterate through all arguments and create apropriate input-data objects:
472 // inputlines, option menus...
473 TMethodArg *argument = 0;
474
475 TIter next(function->GetListOfMethodArgs());
476 Int_t argpos = 0;
477
478 while ((argument = (TMethodArg *) next())) {
479 // Do not input argument for self object
480 if (selfobjpos != argpos) {
481 const char *argname = fContextMenu->CreateArgumentTitle(argument);
482 const char *type = argument->GetTypeName();
483 TDataType *datatype = gROOT->GetType(type);
484 const char *charstar = "char*";
485 char basictype[32];
486
487 if (datatype) {
488 strlcpy(basictype, datatype->GetTypeName(), 32);
489 } else {
491 if (strncmp(type, "enum", 4) && (cl && !(cl->Property() & kIsEnum)))
492 Warning("Dialog", "data type is not basic type, assuming (int)");
493 strlcpy(basictype, "int", 32);
494 }
495
496 if (strchr(argname, '*')) {
497 strlcat(basictype, "*",32);
498 if (!strncmp(type, "char", 4) || !strncmp(type, "Option_t", 8))
499 type = charstar;
500 else if (strstr(argname, "[default:")) {
501 // skip arguments that are pointers (but not char *)
502 // and have a default value
503 argpos++;
504 continue;
505 }
506 }
507
508 TDataMember *m = argument->GetDataMember();
509 if (m && object && m->GetterMethod(object->IsA())) {
510
511 // Get the current value and form it as a text:
512
513 char val[256];
514
515 if (!strncmp(basictype, "char*", 5)) {
516 char *tdefval;
517 m->GetterMethod()->Execute(object, "", &tdefval);
518 strlcpy(val, tdefval, sizeof(val));
519 } else if (!strncmp(basictype, "float", 5) ||
520 !strncmp(basictype, "double", 6)) {
521 Double_t ddefval;
522 m->GetterMethod()->Execute(object, "", ddefval);
523 snprintf(val,256, "%g", ddefval);
524 } else if (!strncmp(basictype, "char", 4) ||
525 !strncmp(basictype, "bool", 4) ||
526 !strncmp(basictype, "int", 3) ||
527 !strncmp(basictype, "long", 4) ||
528 !strncmp(basictype, "short", 5)) {
529 Longptr_t ldefval;
530 m->GetterMethod()->Execute(object, "", ldefval);
531 snprintf(val, 256, "%zi", (size_t)ldefval);
532 }
533
534 // Find out whether we have options ...
535 if (m->GetOptions()) {
536 Warning("Dialog", "option menu not yet implemented");
537 } else {
538 // we haven't got options - textfield ...
539 fDialog->Add(argname, val, type);
540 }
541 } else { // if m not found ...
542
543 char val[256] = "";
544 const char *tval = argument->GetDefault();
545 if (tval && strlen(tval)) {
546 // Remove leading and trailing quotes
547 strlcpy(val, tval + (tval[0] == '"' ? 1 : 0), sizeof(val));
548 if (val[strlen(val)-1] == '"')
549 val[strlen(val)-1]= 0;
550 }
551 fDialog->Add(argname, val, type);
552 }
553 }
554 argpos++;
555 }
556
557 fDialog->Popup();
558}
559
560////////////////////////////////////////////////////////////////////////////////
561/// Draw context menu entry.
562
564{
565 int ty, offset;
566 static int max_ascent = 0, max_descent = 0;
567
569 // draw the ? (help) in the right side when highlighting a menu entry
570 if (entry->GetType() == kMenuEntry && (entry->GetStatus() & kMenuActiveMask)) {
571 if (max_ascent == 0) {
572 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
573 }
574 offset = (entry->GetEh() - (max_ascent + max_descent)) / 2;
575 ty = entry->GetEy() + max_ascent + offset - 1;
576 TGHotString s("&?");
577 s.Draw(fId, fSelGC, fMenuWidth-12, ty);
578 }
579}
580
581////////////////////////////////////////////////////////////////////////////////
582/// Handle button event in the context menu.
583
585{
586 int id;
587 void *ud = 0;
588
589 if ((event->fType == kButtonRelease) && (event->fX >= (Int_t)(fMenuWidth-15)) &&
590 (event->fX <= (Int_t)fMenuWidth)) {
591 id = EndMenu(ud);
592 if (fHasGrab) gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab
593 if (ud) {
594 // retrieve the highlighted function
595 TFunction *function = 0;
596 if (id < kToggleStart) {
597 TMethod *m = (TMethod *)ud;
598 function = (TFunction *)m;
599 } else if (id >= kToggleStart && id < kUserFunctionStart) {
600 TToggle *t = (TToggle *)ud;
601 TMethodCall *mc = (TMethodCall *)t->GetSetter();
602 function = (TFunction *)mc->GetMethod();
603 } else {
604 TClassMenuItem *mi = (TClassMenuItem *)ud;
605 function = gROOT->GetGlobalFunctionWithPrototype(mi->GetFunctionName());
606 }
607 if (function)
608 fContextMenu->SetMethod(function);
609 }
610 OnlineHelp();
611 return kTRUE;
612 }
614}
615
616////////////////////////////////////////////////////////////////////////////////
617/// Handle pointer crossing event in context menu.
618
620{
621 if (event->fType == kLeaveNotify) {
622 // just to reset the mouse pointer...
624 }
626}
627
628////////////////////////////////////////////////////////////////////////////////
629/// Handle pointer motion event in context menu.
630
632{
633 static int toggle = 0;
634 static Cursor_t handCur = kNone, rightCur = kNone;
636
637 if (handCur == kNone)
638 handCur = gVirtualX->CreateCursor(kHand);
639 if (rightCur == kNone)
640 rightCur = gVirtualX->CreateCursor(kArrowRight);
641
642 if (event->fType == kLeaveNotify) {
643 gVirtualX->ChangeActivePointerGrab(fId, mask, rightCur);
644 toggle = 0;
645 return kTRUE;
646 }
647 // change the cursot to a small hand when over the ? (help)
648 if ((event->fX >= (Int_t)(fMenuWidth-15)) && (event->fX <= (Int_t)fMenuWidth) &&
649 fCurrent && (fCurrent->GetType() == kMenuEntry)) {
650 if (toggle == 0) {
651 gVirtualX->ChangeActivePointerGrab(fId, mask, handCur);
652 toggle = 1;
653 }
654 }
655 else {
656 if (toggle == 1) {
657 gVirtualX->ChangeActivePointerGrab(fId, mask, rightCur);
658 toggle = 0;
659 }
660 }
662}
663
664////////////////////////////////////////////////////////////////////////////////
665/// Open the online help matching the actual class/method.
666
668{
669 TString clname;
671 if (obj) {
672 clname = obj->ClassName();
675 TMethod *method = obj->IsA()->GetMethodAllAny(smeth.Data());
676 if (method)
677 clname = method->GetClass()->GetName();
678 clname += "::" + smeth;
679 }
681 }
682}
683
684////////////////////////////////////////////////////////////////////////////////
685/// Handle context menu messages.
686
688{
689 TObjectSpy savedPad;
690 if (GetContextMenu()->GetSelectedPad()) {
691 savedPad.SetObject(gPad);
693 }
694
695 switch (GET_MSG(msg)) {
696
697 case kC_COMMAND:
698
699 switch (GET_SUBMSG(msg)) {
700
701 case kCM_MENU:
702
703 if (parm1 < kToggleStart) {
704 TMethod *m = (TMethod *) parm2;
706 } else if (parm1 >= kToggleStart && parm1 < kToggleListStart) {
707 TToggle *t = (TToggle *) parm2;
709 } else if (parm1 >= kToggleListStart && parm1<kUserFunctionStart) {
710 TToggle *t = (TToggle *) parm2;
711 if (t->GetState() == 0)
712 t->SetState(1);
713 } else {
714 TClassMenuItem *mi = (TClassMenuItem*)parm2;
715 GetContextMenu()->Action(mi);
716 }
717 break;
718
719 case kCM_BUTTON:
720 if (parm1 == 1) {
721 const char *args = fDialog->GetParameters();
722 GetContextMenu()->Execute((char *)args);
723 delete fDialog;
724 fDialog = nullptr;
725 }
726 if (parm1 == 2) {
727 const char *args = fDialog->GetParameters();
728 GetContextMenu()->Execute((char *)args);
729 }
730 if (parm1 == 3) {
731 delete fDialog;
732 fDialog = nullptr;
733 }
734 if (parm1 == 4) {
735 OnlineHelp();
736 }
737 break;
738
739 default:
740 break;
741 }
742 break;
743
744 case kC_TEXTENTRY:
745
746 switch (GET_SUBMSG(msg)) {
747
748 case kTE_ENTER:
749 {
750 const char *args = fDialog->GetParameters();
751 GetContextMenu()->Execute((char *)args);
752 delete fDialog;
753 fDialog = nullptr;
754 }
755 break;
756
757 default:
758 break;
759 }
760 break;
761
762 default:
763 break;
764 }
765
766 if (savedPad.GetObject()) gPad = (TVirtualPad*) savedPad.GetObject();
767
768 return kTRUE;
769}
770
771////////////////////////////////////////////////////////////////////////////////
772/// Close the context menu if the object is deleted in the
773/// RecursiveRemove() operation.
774
776{
777 void *ud;
778 if (obj == fContextMenu->GetSelectedCanvas())
780 if (obj == fContextMenu->GetSelectedPad())
782 if (obj == fContextMenu->GetSelectedObject()) {
783 // if the object being deleted is the one selected,
784 // ungrab the mouse pointer and terminate (close) the menu
786 if (fHasGrab)
787 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
788 EndMenu(ud);
789 }
790}
791
@ 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
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
@ 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
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
TBrowserImp * GetBrowserImp() const
Definition TBrowser.h:94
The Canvas class.
Definition TCanvas.h:23
Describes one element of the context menu associated to a class The menu item may describe.
virtual const char * GetArgs() const
const char * GetTitle() const override
Returns title of object.
virtual const char * GetFunctionName() const
virtual Int_t GetType() const
virtual Bool_t IsToggle() const
virtual Int_t GetSelfObjectPos() const
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
TList * GetMenuList() const
Return the list of menu items associated with the class.
Definition TClass.cxx:4462
TMethod * GetMethodWithPrototype(const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Find the method with a given prototype.
Definition TClass.cxx:4577
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
TMethod * GetMethodAllAny(const char *method)
Return pointer to method without looking at parameters.
Definition TClass.cxx:4505
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 void Action(TObject *object, TMethod *method)
Action to be performed when this menu item is selected.
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.
void Execute(const char *method, const char *params, Int_t *error=nullptr) override
Execute method on this object with the given parameter string, e.g.
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
Int_t GetType() const
Definition TDataType.h:71
TString GetTypeName()
Get basic type of typedef, e,g.: "class TDirectory*" -> "TDirectory".
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:578
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:333
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:599
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
Int_t GetEy() const
Definition TGMenu.h:92
virtual Int_t GetStatus() const
Definition TGMenu.h:86
EMenuEntryType GetType() const
Definition TGMenu.h:87
UInt_t GetEh() const
Definition TGMenu.h:94
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 AddPopup(TGHotString *s, TGPopupMenu *popup, TGMenuEntry *before=nullptr, const TGPicture *p=nullptr)
Add a (cascading) popup menu to a popup menu.
Definition TGMenu.cxx:1149
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:280
A doubly linked list.
Definition TList.h:38
void Add(TObject *obj) override
Definition TList.h:81
TObject * Last() const override
Return the last object in the list. Returns 0 when list is empty.
Definition TList.cxx:823
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
const char * GetDefault() const
Get default value of method argument.
const char * GetTypeName() const
Get type of method argument, e.g.: "class TDirectory*" -> "TDirectory" Result needs to be used or cop...
TDataMember * GetDataMember() const
Returns TDataMember pointed by this methodarg.
Method or function calling interface.
Definition TMethodCall.h:37
TFunction * GetMethod()
Returns the TMethod describing the method to be executed.
Each ROOT class (see TClass) has a linked list of methods.
Definition TMethod.h:38
TClass * GetClass() const
Definition TMethod.h:55
TClass * IsA() const override
Definition TMethod.h:68
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
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
TObject * GetObject() const
Definition TObjectSpy.h:45
void SetObject(TObject *obj, Bool_t fixMustCleanupBit=kTRUE)
Set obj as the spy target.
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
Ssiz_t Length() const
Definition TString.h:426
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition TString.cxx:465
const char * Data() const
Definition TString.h:385
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition TString.cxx:2345
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:661
This class defines toggling facility for both - object's method or variables.
Definition TToggle.h:49
virtual void SetOnValue(Long_t lon)
Definition TToggle.h:82
TMethodCall * GetSetter() const
return setter method request new for the TDataMember while it can be recreated at any time
Definition TToggle.cxx:167
virtual void SetToggledObject(TObject *obj, TMethod *anymethod)
Initializes it to toggle an object's datamember using this object's method.
Definition TToggle.cxx:116
virtual void SetState(Bool_t state)
Sets the value of toggle to fOnValue or fOffValue according to passed argument.
Definition TToggle.cxx:73
virtual Bool_t GetState()
Returns the state of Toggle according to its current value and fOnValue, returns true if they match.
Definition TToggle.cxx:60
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:53
virtual Int_t GetCanvasID() const =0
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