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