Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGMenu.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 09/01/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 This source is based on Xclass95, a Win95-looking GUI toolkit.
14 Copyright (C) 1996, 1997 David Barth, Ricky Ralston, Hector Peraza.
15
16 Xclass95 is free software; you can redistribute it and/or
17 modify it under the terms of the GNU Library General Public
18 License as published by the Free Software Foundation; either
19 version 2 of the License, or (at your option) any later version.
20
21**************************************************************************/
22
23
24/** \class TGMenuBar
25 \ingroup guiwidgets
26
27The TGMenu.h header contains all different menu classes.
28
29The TGMenuBar class implements a menu bar widget. It is used to
30specify and provide access to common and frequently used application
31actions grouped under menu titles (TGMenuTitle class). The menu bar
32takes the highest-level of the menu system and it is a starting
33point for many interactions. It is always visible and allows using
34the keyboard equivalents. The geometry of the menu bar is
35automatically set to the parent widget, i.e. the menu bar
36automatically resizes itself so that it has the same width as its
37parent (typically TGMainFrame). A menu bar contains one or more
38popup menus and usually is placed along the top of the application
39window. Any popup menu is invisible until the user invokes it by
40using the mouse pointer or the keyboard.
41
42Popup menus implemented by TGPopupMenu class are unique in that,
43by convention, they are not placed with the other GUI components in
44the user interfaces. Instead, a popup menu usually appears either in
45a menu bar or as a context menu on the TOP of the GUI. For that
46reason it needs gClient->GetDefaultRoot() as a parent to get the
47pointer to the root (i.e. desktop) window. This way a popup menu
48will never be embedded.
49NOTE: Using gClient->GetRoot() as a parent of TGPopupMenu will not
50avoid the possibility of embedding the corresponding popup menu
51because the current window hierarchy can be changed by using
52gClient->SetRoot() method.
53
54As a context menus TGPopupMenu shows up after pressing the right
55mouse button, over a popup-enabled component. The popup menu then
56appears under the mouse pointer.
57
58Selecting a menu item will generate the event:
59kC_COMMAND, kCM_MENU, menu id, user data.
60
61*/
62
63
64#include "TGMenu.h"
65#include "TGResourcePool.h"
66#include "TTimer.h"
67#include "TMath.h"
68#include "TSystem.h"
69#include "TList.h"
70#include "KeySymbols.h"
71#include "TGButton.h"
72#include "TQConnection.h"
73#include "TParameter.h"
74#include "RConfigure.h"
75#include "TVirtualX.h"
76#include "snprintf.h"
77
78#include <iostream>
79
80const TGGC *TGPopupMenu::fgDefaultGC = nullptr;
83const TGFont *TGPopupMenu::fgDefaultFont = nullptr;
84const TGFont *TGPopupMenu::fgHilightFont = nullptr;
85
86const TGGC *TGMenuTitle::fgDefaultGC = nullptr;
88const TGFont *TGMenuTitle::fgDefaultFont = nullptr;
89
90
91
92////////////////////////////////////////////////////////////////////////////////
93
94class TPopupDelayTimer : public TTimer {
95private:
96 TGPopupMenu *fPopup; // popup menu
97public:
99 Bool_t Notify() override;
100};
101
102////////////////////////////////////////////////////////////////////////////////
103/// Notify when timer times out and reset the timer.
104
106{
108 Reset();
109 return kFALSE;
110}
111
112
113//////////////////////////////////////////////////////////////////////////
114// //
115// TGMenuBar member functions. //
116// //
117//////////////////////////////////////////////////////////////////////////
118
119////////////////////////////////////////////////////////////////////////////////
120/// Create a menu bar object.
121
123 : TGHorizontalFrame(p, w, h, options | kHorizontalFrame)
124{
125 fCurrent = 0;
126 fTitles = new TList;
127 fStick = kTRUE;
128 fDefaultCursor = fClient->GetResourcePool()->GetGrabCursor();
129 fTrash = new TList();
130
131 gVirtualX->GrabButton(fId, kButton1, kAnyModifier,
133 kNone, kNone);
134
136
137 fMenuMore = new TGPopupMenu(gClient->GetDefaultRoot());
138 fMenuMore->AddLabel("Hidden Menus");
141
143 fOutLayouts = new TList();
144 fNeededSpace = new TList();
145}
146
147////////////////////////////////////////////////////////////////////////////////
148/// Delete menu bar object. Removes also the hot keys from the main frame,
149/// so hitting them will not cause the menus to popup.
150
152{
154 TGMenuTitle *t;
156
157 if (!MustCleanup()) {
158 fTrash->Delete();
159 }
160 delete fTrash;
161
163
164 if (!MustCleanup()) {
165 TIter next(fList);
166 while ((el = (TGFrameElement *) next())) {
167 t = (TGMenuTitle *) el->fFrame;
168 if ((keycode = t->GetHotKeyCode()) != 0 && main) {
169 main->RemoveBind(this, keycode, kKeyMod1Mask);
170 }
171 }
172 }
173
174 // delete TGMenuTitles
175 if (fTitles && !MustCleanup()) fTitles->Delete();
176 delete fTitles;
177
178 delete fOutLayouts;
180 delete fNeededSpace;
181 delete fMenuMore;
182 delete fMenuBarMoreLayout;
183}
184
185////////////////////////////////////////////////////////////////////////////////
186/// Calculates whether the >> menu must be shown or not and
187/// which menu titles are hidden.
188
190{
191 if (GetDefaultWidth() > GetWidth()) {
192 while (!(GetDefaultWidth() < GetWidth() ||
193 GetList()->GetSize() <= 1)) {
195 if (!entry) break;
197 fNeededSpace->AddLast(new TParameter<Int_t>("", menuTitle->GetWidth() +
198 entry->fLayout->GetPadLeft() +
199 entry->fLayout->GetPadRight() ) );
200 fOutLayouts->AddLast( entry->fLayout );
201 fMenuMore->AddPopup( menuTitle->GetName(), menuTitle->GetMenu() );
202 menuTitle->GetMenu()->Connect("PoppedUp()", "TGMenuBar", this, "PopupConnection()");
203 RemovePopup( menuTitle->GetName() );
204 }
205 }
206
207 if (fNeededSpace->GetSize() > 0) {
209 Bool_t fit = kFALSE;
210 if (fNeededSpace->GetSize() > 1)
211 fit = GetDefaultWidth() + neededWidth + 5 < GetWidth();
212 else
213 fit = GetDefaultWidth() + neededWidth - 7 < GetWidth();
214 while (fit) {
217 ULong_t hints = (layout) ? layout->GetLayoutHints() : 0;
219 if (hints & kLHintsRight) {
221 if (entry) {
223 beforeMenu = beforeMenuTitle->GetMenu();
224 }
225 }
226 if (menu && menu->GetPopup()) {
227 menu->GetPopup()->Disconnect("PoppedUp()", this, "PopupConnection()");
228 AddPopup( menu->GetName(), menu->GetPopup(), layout, beforeMenu );
229 }
233
234 if (fNeededSpace->GetSize() > 0) {
236 if (fNeededSpace->GetSize() > 1)
237 fit = GetDefaultWidth() + neededWidth + 5 < GetWidth();
238 else
239 fit = GetDefaultWidth() + neededWidth - 7 < GetWidth();
240 } else
241 fit = kFALSE;
242 }
243 }
244
245 if (fNeededSpace->GetSize() > 0) {
246 if (!fWithExt) {
248 ((TGMenuTitle*)((TGFrameElement*)GetList()->First())->fFrame)->GetMenu());
249 fWithExt = kTRUE;
250 }
251 } else {
252 RemovePopup(">>");
254 }
255
258}
259
260////////////////////////////////////////////////////////////////////////////////
261/// Returns the last visible menu title on the left of the '>>'
262/// in the menu bar.
263
265{
266 TIter next(GetList());
267 while (TGFrameElement *entry = (TGFrameElement*) next()) {
268
271 ULong_t hints = tmpLayout->GetLayoutHints();
272
273 if (hints & kLHintsRight && menuTitle->GetMenu() != fMenuMore) {
274 return entry;
275 }
276 }
277
278 return ((TGFrameElement*)GetList()->Last());
279}
280
281////////////////////////////////////////////////////////////////////////////////
282/// Connects the corresponding cascaded menu to the proper slots,
283/// according to the highlighted menu entry in '>>' menu.
284
286{
287 // Disconnect all previous signals
289 TIter next (slots);
290 while (TList* connlist = (TList*) next()) {
291
292 const char* signal_name = connlist->GetName();
294 while (TQConnection* conn = (TQConnection*) next2()) {
295 const char* slot_name = conn->GetName();
296 void* receiver = conn->GetReceiver();
298 }
299 }
301
302 // Check whether the current entry is a menu or not (just in case)
304 if (currentEntry->GetType() != kMenuPopup) return;
305
306 // Connect the corresponding active signals to the >> menu
307 TGPopupMenu* currentMenu = currentEntry->GetPopup();
308
309 slots = currentMenu->GetListOfSignals();
310 TIter next3 (slots);
311 while (TList* connlist = (TList*) next3()) {
312
313 const char* signal_name = connlist->GetName();
314 if (strcmp(signal_name, "Activated(int)") == 0) {
316 while (TQConnection* conn = (TQConnection*) next2()) {
317
318 const char* slot_name = conn->GetName();
319 const char* class_name = conn->GetClassName();
320 void* receiver = conn->GetReceiver();
322 }
323 }
324 }
325
326 fMenuMore->fMsgWindow = currentMenu->fMsgWindow;
327}
328
329////////////////////////////////////////////////////////////////////////////////
330/// If on kTRUE bind arrow, popup menu hot keys, otherwise
331/// remove key bindings.
332
334{
335 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Left), kAnyModifier, on);
336 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Right), kAnyModifier, on);
337 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Up), kAnyModifier, on);
338 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Down), kAnyModifier, on);
339 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Enter), kAnyModifier, on);
340 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Return), kAnyModifier, on);
341 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Escape), kAnyModifier, on);
342
343 if (fCurrent && fCurrent->GetMenu()) {
345 }
346}
347
348////////////////////////////////////////////////////////////////////////////////
349/// If on kTRUE bind subMenu hot keys, otherwise remove key bindings.
350
352{
353 TGMenuEntry *e;
354 TIter next(subMenu->GetListOfEntries());
355
356 while ((e = (TGMenuEntry*)next())) {
357 Int_t hot = 0;
358 if ( e->GetType() == kMenuPopup )
359 BindMenu(e->GetPopup(), on);
360 if (e->GetLabel()) {
361 hot = e->GetLabel()->GetHotChar();
362 }
363 if (!hot) continue;
364 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), 0, on);
365 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask, on);
366 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyLockMask, on);
367 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyMod2Mask, on);
368 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask | kKeyLockMask, on);
369 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask | kKeyMod2Mask, on);
370 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyLockMask | kKeyMod2Mask, on);
371 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask | kKeyLockMask | kKeyMod2Mask, on);
372 }
373}
374
375
376////////////////////////////////////////////////////////////////////////////////
377/// If on kTRUE bind hot keys, otherwise remove key binding.
378
380{
382
383 if (!main || !main->InheritsFrom("TGMainFrame")) return;
384
385 if (on) {
386 // case insensitive bindings
387 main->BindKey(this, keycode, kKeyMod1Mask);
388 main->BindKey(this, keycode, kKeyMod1Mask | kKeyShiftMask);
389 main->BindKey(this, keycode, kKeyMod1Mask | kKeyLockMask);
391
392 main->BindKey(this, keycode, kKeyMod1Mask | kKeyMod2Mask);
396 } else {
397 main->RemoveBind(this, keycode, kKeyMod1Mask);
398 main->RemoveBind(this, keycode, kKeyMod1Mask | kKeyShiftMask);
399 main->RemoveBind(this, keycode, kKeyMod1Mask | kKeyLockMask);
400 main->RemoveBind(this, keycode, kKeyMod1Mask | kKeyShiftMask | kKeyLockMask);
401
402 main->RemoveBind(this, keycode, kKeyMod1Mask | kKeyMod2Mask);
403 main->RemoveBind(this, keycode, kKeyMod1Mask | kKeyShiftMask | kKeyMod2Mask);
404 main->RemoveBind(this, keycode, kKeyMod1Mask | kKeyMod2Mask | kKeyLockMask);
406 }
407}
408
409////////////////////////////////////////////////////////////////////////////////
410/// Add popup menu to menu bar. The hot string will be adopted by the
411/// menubar (actually the menu title) and deleted when possible.
412/// If before is not 0 the menu will be added before it.
413
416{
417 TGMenuTitle *t;
419
420 AddFrameBefore(t = new TGMenuTitle(this, s, menu), l, before);
421 fTitles->Add(t); // keep track of menu titles for later cleanup in dtor
422
423 if ((keycode = t->GetHotKeyCode()) != 0) {
425 }
426}
427
428////////////////////////////////////////////////////////////////////////////////
429/// Add popup via created before menu title.
430
432{
434
435 AddFrameBefore(title, l, before);
436 fTitles->Add(title); // keep track of menu titles for later cleanup in dtor
437
438 if ((keycode = title->GetHotKeyCode()) != 0) {
440 }
441}
442
443////////////////////////////////////////////////////////////////////////////////
444/// Add popup menu to menu bar. If before is not 0 the menu will be
445/// added before it.
446
449{
450 AddPopup(new TGHotString(s), menu, l, before);
451}
452
453////////////////////////////////////////////////////////////////////////////////
454/// Add popup menu to menu bar.
455///
456/// Comment:
457/// This method is valid only for horizontal menu bars.
458/// The most common case is menu bar containing equidistant titles padding left side.
459/// TGMenuBar *bar;
460/// bar->AddPopup("title1", 10);
461/// bar->AddPopup("title2", 10);
462/// ...
463///
464/// To add equidistant titles padding right side padleft must be 0.
465/// TGMenuBar *bar;
466/// bar->AddPopup("title1", 0, 10);
467/// bar->AddPopup("title2", 0, 10);
468/// ...
469///
470/// This method guarantee automatic cleanup when menu bar is destroyed.
471/// Do not delete returned popup-menu
472
475{
477
478 if (padleft) {
480 } else {
482 }
483
486 fTrash->Add(l);
487
489 AddPopup(new TGHotString(s), menu, l, 0);
490 fTrash->Add(menu);
491 return menu;
492}
493
494////////////////////////////////////////////////////////////////////////////////
495/// Private version of AddFrame for menubar, to make sure that we
496/// indeed only add TGMenuTitle objects to it. If before is not 0
497/// the menu will be added before it.
498
501{
502 if (!f->InheritsFrom("TGMenuTitle")) {
503 Error("AddFrameBefore", "may only add TGMenuTitle objects to a menu bar");
504 return;
505 }
506
507 if (!before) {
508 AddFrame(f, l);
509 return;
510 }
511
513
514 nw = new TGFrameElement;
515 nw->fFrame = f;
516 nw->fLayout = l ? l : fgDefaultHints;
517 nw->fState = 1;
518
520 TIter next(fList);
521 while ((el = (TGFrameElement *) next())) {
522 TGMenuTitle *t = (TGMenuTitle *) el->fFrame;
523 if (t->GetMenu() == before) {
524 fList->AddBefore(el, nw);
525 return;
526 }
527 }
528 fList->Add(nw);
529}
530
531////////////////////////////////////////////////////////////////////////////////
532/// Return popup menu with the specified name. Returns 0 if menu is
533/// not found. Returnes menu can be used as "before" in AddPopup().
534/// Don't use hot key (&) in name.
535
537{
538 if (!GetList()) return 0;
539
541 TIter next(GetList());
542 TString str = s;
543
544 while ((el = (TGFrameElement *) next())) {
545 TGMenuTitle *t = (TGMenuTitle *) el->fFrame;
546 if (str == t->GetName())
547 return t->GetMenu();
548 }
549 return 0;
550}
551
552////////////////////////////////////////////////////////////////////////////////
553/// Remove popup menu from menu bar. Returned menu has to be deleted by
554/// the user, or can be re-used in another AddPopup(). Returns 0 if
555/// menu is not found. Don't use hot key (&) in name.
556
558{
559 if (!GetList()) return 0;
560
562 TIter next(GetList());
563 TString str = s;
564
565 while ((el = (TGFrameElement *) next())) {
566 TGMenuTitle *t = (TGMenuTitle *) el->fFrame;
567 if (str == t->GetName()) {
569 if ((keycode = t->GetHotKeyCode())) {
570 BindHotKey(keycode, kFALSE); // remove bind
571 }
572 TGPopupMenu *m = t->GetMenu();
573 fTitles->Remove(t);
574 t->DestroyWindow();
575 RemoveFrame(t);
576 delete t;
577 return m;
578 }
579 }
580 return 0;
581}
582
583////////////////////////////////////////////////////////////////////////////////
584/// Handle a mouse motion event in a menu bar.
585
587{
588 if (fKeyNavigate) return kTRUE;
589
590 Int_t dummy;
592 TGMenuTitle *target = 0;
593
594 if (!(event->fState & kButton1Mask))
595 fStick = kFALSE; // use some threshold!
596
597 gVirtualX->TranslateCoordinates(fId, fId, event->fX, event->fY,
598 dummy, dummy, wtarget);
600
601 if (fCurrent && target && (target != fCurrent)) {
602 // deactivate all others
604 TIter next(fList);
605 while ((el = (TGFrameElement *) next()))
606 ((TGMenuTitle*)el->fFrame)->SetState(kFALSE);
607
608 fStick = kTRUE;
610 target->SetState(kTRUE);
611 }
612
613 return kTRUE;
614}
615
616////////////////////////////////////////////////////////////////////////////////
617/// Handle a mouse button event in a menubar.
618
620{
621 Int_t dummy;
624
625 // We don't need to check the button number as GrabButton will
626 // only allow button1 events
627
628 if (event->fType == kButtonPress) {
629
630 gVirtualX->TranslateCoordinates(fId, fId, event->fX, event->fY,
631 dummy, dummy, wtarget);
633
634 if (target != 0) {
635 fStick = kTRUE;
636
637 if (target != fCurrent) {
638 // deactivate all others
640 TIter next(fList);
641 while ((el = (TGFrameElement *) next()))
642 ((TGMenuTitle*)el->fFrame)->SetState(kFALSE);
643
644 fStick = kTRUE;
646 target->SetState(kTRUE);
647
650 }
651 }
652 }
653
654 if (event->fType == kButtonRelease) {
655 if (fStick) {
656 fStick = kFALSE;
657 return kTRUE;
658 }
659
661 TIter next(fList);
662 while ((el = (TGFrameElement *) next()))
663 ((TGMenuTitle*)el->fFrame)->SetState(kFALSE);
664
665 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
666
667 if (fCurrent != 0) {
668 target = fCurrent; // tricky, because WaitFor
669 fCurrent = 0;
670 if (!fKeyNavigate)
671 target->DoSendMessage();
672 }
674 }
675
676 return kTRUE;
677}
678
679////////////////////////////////////////////////////////////////////////////////
680/// Handle keyboard events in a menu bar.
681
683{
684 TGMenuTitle *target = 0;
686 void *dummy;
687 Int_t ax, ay;
689 TIter next(fList);
690
691 if (event->fType == kGKeyPress) {
693 char tmp[2];
694
695 gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
696
697 if (event->fState & kKeyMod1Mask) {
698 while ((el = (TGFrameElement *) next())) {
699 target = (TGMenuTitle *) el->fFrame;
700 if ((Int_t)event->fCode == target->GetHotKeyCode()) {
701 RequestFocus();
703 break;
704 }
705 }
706 if (el == 0) target = 0;
707 } else {
709
710 if (fCurrent) {
711 TGFrameElement *cur = 0;
712 TGPopupMenu *menu = 0;
713 next.Reset();
714 el = 0;
715 while ((el = (TGFrameElement *) next())) {
716 if (el->fFrame == fCurrent) {
717 cur = el;
718 menu = ((TGMenuTitle*)el->fFrame)->GetMenu();
719 break;
720 }
721 }
722
723 if (!menu || !menu->fPoppedUp) return kFALSE;
724
725 TGMenuEntry *ce = 0;
726
728 TGMenuEntry* currentEntry = currentMenu->GetCurrent();
729 while ( currentEntry ) {
730 if ( currentEntry->GetType() == kMenuPopup )
731 currentMenu = currentEntry->GetPopup();
732 if ( currentEntry != currentMenu->GetCurrent() )
733 currentEntry = currentMenu->GetCurrent();
734 else
735 currentEntry = 0;
736 }
737
738 TIter next2(currentMenu->GetListOfEntries());
739
740 while ((ce = (TGMenuEntry*)next2())) {
741 UInt_t hot = 0;
742 if (ce->GetLabel()) hot = ce->GetLabel()->GetHotChar();
743 if (!hot || (hot != keysym)) continue;
744
745 currentMenu->Activate(ce);
746 if (ce->GetType() != kMenuPopup) {
747 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
749 currentMenu->fStick = kFALSE;
750 Event_t ev;
751 ev.fType = kButtonRelease;
752 ev.fWindow = currentMenu->GetId();
753 fCurrent = 0;
754 return currentMenu->HandleButton(&ev);
755 }
756 else {
757 gVirtualX->TranslateCoordinates(currentMenu->fId,
758 (ce->fPopup->GetParent())->GetId(),
759 ce->fEx+currentMenu->fMenuWidth, ce->fEy,
760 ax, ay, wdummy);
761#ifdef R__HAS_COCOA
762 gVirtualX->SetWMTransientHint(ce->fPopup->GetId(), GetId());
763#endif
764 ce->fPopup->PlaceMenu(ax-5, ay-1, kFALSE, kFALSE);
765 }
766 }
767
768 ce = menu->GetCurrent();
769 TGPopupMenu *submenu = 0;
770
771 while (ce && (ce->GetType() == kMenuPopup)) {
772 submenu = ce->GetPopup();
773 if (!submenu->fPoppedUp) break;
774 ce = submenu->GetCurrent();
775 menu = submenu;
776 }
777 switch ((EKeySym)keysym) {
778 case kKey_Left:
779 if ((submenu) && (submenu->fPoppedUp)) {
780 submenu->EndMenu(dummy);
781 break;
782 }
784 if (!el) el = (TGFrameElement*)fList->Last();
785 break;
786 case kKey_Right:
787 if (submenu) {
788 if (submenu->fPoppedUp) {
789 if (!submenu->GetCurrent()) {
790 ce = (TGMenuEntry*)submenu->GetListOfEntries()->First();
791 } else {
792 submenu->EndMenu(dummy);
793 }
794 }
795 else {
796 gVirtualX->TranslateCoordinates(menu->fId,
797 (submenu->GetParent())->GetId(),
798 ce->fEx+menu->fMenuWidth, ce->fEy,
799 ax, ay, wdummy);
800#ifdef R__HAS_COCOA
801 gVirtualX->SetWMTransientHint(submenu->GetId(), GetId());
802#endif
803 submenu->PlaceMenu(ax-5, ay-1, kFALSE, kFALSE);
804 }
805 break;
806 }
808 if (!el) el = (TGFrameElement*)fList->First();
809 break;
810 case kKey_Up:
811 if (ce) ce = (TGMenuEntry*)menu->GetListOfEntries()->Before(ce);
812 while (ce && ((ce->GetType() == kMenuSeparator) ||
813 (ce->GetType() == kMenuLabel) ||
814 !(ce->GetStatus() & kMenuEnableMask))) {
815 ce = (TGMenuEntry*)menu->GetListOfEntries()->Before(ce);
816 }
817 if (!ce) ce = (TGMenuEntry*)menu->GetListOfEntries()->Last();
818 break;
819 case kKey_Down:
820 if (ce) ce = (TGMenuEntry*)menu->GetListOfEntries()->After(ce);
821 while (ce && ((ce->GetType() == kMenuSeparator) ||
822 (ce->GetType() == kMenuLabel) ||
823 !(ce->GetStatus() & kMenuEnableMask))) {
824 ce = (TGMenuEntry*)menu->GetListOfEntries()->After(ce);
825 }
826 if (!ce) ce = (TGMenuEntry*)menu->GetListOfEntries()->First();
827 break;
828 case kKey_Enter:
829 case kKey_Return: {
830 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
832 menu->fStick = kFALSE;
833 Event_t ev;
834 ev.fType = kButtonRelease;
835 ev.fWindow = menu->GetId();
836 fCurrent = 0;
837 return menu->HandleButton(&ev);
838 }
839 case kKey_Escape:
840 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
842 fStick = kFALSE;
843 fCurrent = 0;
844 return menu->EndMenu(dummy);
845 default:
846 break;
847 }
848 if (ce) menu->Activate(ce);
849
850 el = el ? el : cur;
851 if (el) target = (TGMenuTitle*)el->fFrame;
852 } else {
853 return kFALSE;
854 }
855 }
856
857 if (target != 0) {
858 fStick = kTRUE;
859
860 if (target != fCurrent) {
861 // deactivate all others
862 next.Reset();
863 while ((el = (TGFrameElement *) next()))
864 ((TGMenuTitle*)el->fFrame)->SetState(kFALSE);
865
867 target->SetState(kTRUE);
868 fStick = kTRUE;
869
872
873 TGMenuEntry *ptr;
874 TIter nexte(target->GetMenu()->GetListOfEntries());
875
876 while ((ptr = (TGMenuEntry *) nexte())) {
877 if ((ptr->GetStatus() & kMenuEnableMask) &&
878 !(ptr->GetStatus() & kMenuHideMask) &&
879 (ptr->GetType() != kMenuSeparator) &&
880 (ptr->GetType() != kMenuLabel)) break;
881 }
882 if (ptr)
883 target->GetMenu()->Activate(ptr);
884
885 return kTRUE;
886 }
887 } else {
888 return kFALSE;
889 }
890 }
891
892 if (event->fType == kKeyRelease) {
893 if (fStick) {
894 fStick = kFALSE;
895 return kTRUE;
896 }
897 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
898
899 next.Reset();
900 while ((el = (TGFrameElement *) next()))
901 ((TGMenuTitle*)el->fFrame)->SetState(kFALSE);
902
903 if (fCurrent != 0) {
904 target = fCurrent; // tricky, because WaitFor
905 fCurrent = 0;
906 target->DoSendMessage();
907 }
908 }
909
910 return kTRUE;
911}
912
913
914//////////////////////////////////////////////////////////////////////////
915// //
916// TGPopupMenu member functions. //
917// //
918//////////////////////////////////////////////////////////////////////////
919
920////////////////////////////////////////////////////////////////////////////////
921/// Create a popup menu.
922
924 : TGFrame(p, w, h, options | kOwnBackground)
925{
926 fNormGC = GetDefaultGC()();
931 fDefaultCursor = fClient->GetResourcePool()->GetGrabCursor();
932
933 // We need to change the default context to actually use the
934 // Menu Fonts. [Are we actually changing the global settings?]
936 gcval.fMask = kGCFont;
937 gcval.fFont = gVirtualX->GetFontHandle(fFontStruct);
938 gVirtualX->ChangeGC(fNormGC, &gcval);
939 gVirtualX->ChangeGC(fSelGC, &gcval);
940
941 fDelay = 0;
942 fEntryList = new TList;
943
944 // in case any of these magic values is changes, check also Reposition()
945 fBorderWidth = 3;
946 fMenuHeight = 6;
947 fMenuWidth = 8;
948 fXl = 16;
949 fMsgWindow = p;
950 fStick = kTRUE;
951 fCurrent = 0;
954 fMenuBar = 0;
955 fSplitButton = 0;
956 fEntrySep = 3;
957
960 wattr.fOverrideRedirect = kTRUE;
961 wattr.fSaveUnder = kTRUE;
962
963 gVirtualX->ChangeWindowAttributes(fId, &wattr);
964
966}
967
968////////////////////////////////////////////////////////////////////////////////
969/// Delete a popup menu.
970
972{
973 gClient->UnregisterPopup(this);
974
976 delete fEntryList;
977 delete fDelay;
978}
979
980////////////////////////////////////////////////////////////////////////////////
981/// Add a menu entry. The hotstring is adopted by the menu (actually by
982/// the TGMenuEntry) and deleted when possible. A possible picture is
983/// borrowed from the picture pool and therefore not adopted.
984/// If before is not 0, the entry will be added before it.
985
987 const TGPicture *p, TGMenuEntry *before)
988{
989 if (!s) return;
991 Ssiz_t tab = s->Index('\t');
992 if (tab > 0) {
993 TString ts(s->Data());
994 TString shortcut = ts(tab+1, s->Length());
995 nw->fShortcut = new TGString(shortcut.Data());
996 nw->fLabel = new TGHotString(*s);
997 nw->fLabel->Remove(tab);
998 }
999 else {
1000 nw->fLabel = s;
1001 }
1002 nw->fPic = p;
1003 nw->fType = kMenuEntry;
1004 nw->fEntryId = id;
1005 nw->fUserData = ud;
1006 nw->fPopup = 0;
1007 nw->fStatus = kMenuEnableMask;
1008 nw->fEx = 2;
1009 nw->fEy = fMenuHeight-2;
1010
1011 if (before)
1013 else
1014 fEntryList->Add(nw);
1015
1016 UInt_t tw, ph = 0, pw = 0;
1017 tw = gVirtualX->TextWidth(fHifontStruct, s->GetString(), s->GetLength());
1018 if (p) {
1019 ph = p->GetHeight();
1020 pw = p->GetWidth();
1021 if (pw+12 > fXl) { fMenuWidth += pw+12-fXl; fXl = pw+12; }
1022 }
1023 if (nw->fShortcut) {
1024 tw += 10;
1025 delete s;
1026 }
1027
1029 nw->fEw = tw + pw /*+8*/+18+12;
1031 gVirtualX->GetFontProperties(fHifontStruct, max_ascent, max_descent);
1033 if (nw->fEh < ph+fEntrySep) nw->fEh = ph+fEntrySep;
1034 fMenuHeight += nw->fEh;
1035
1036 if (before)
1037 Reposition();
1038 else
1040}
1041
1042////////////////////////////////////////////////////////////////////////////////
1043/// Add a menu entry. The string s in not adopted.
1044/// If before is not 0, the entry will be added before it.
1045
1046void TGPopupMenu::AddEntry(const char *s, Int_t id, void *ud,
1047 const TGPicture *p, TGMenuEntry *before)
1048{
1049 AddEntry(new TGHotString(s), id, ud, p, before);
1050}
1051
1052////////////////////////////////////////////////////////////////////////////////
1053/// Add a menu separator to the menu.
1054/// If before is not 0, the entry will be added before it.
1055
1057{
1058 TGMenuEntry *nw = new TGMenuEntry;
1059
1060 nw->fLabel = 0;
1061 nw->fPic = 0;
1062 nw->fType = kMenuSeparator;
1063 nw->fEntryId = -1;
1064 nw->fUserData = 0;
1065 nw->fPopup = 0;
1066 nw->fStatus = kMenuEnableMask;
1067 nw->fEx = 2;
1068 nw->fEy = fMenuHeight-2;
1069
1070 if (before)
1072 else
1073 fEntryList->Add(nw);
1074
1075 nw->fEw = 0;
1076 nw->fEh = 4;
1077 fMenuHeight += nw->fEh;
1078
1079 if (before)
1080 Reposition();
1081 else
1083}
1084
1085////////////////////////////////////////////////////////////////////////////////
1086/// Add a menu label to the menu. The hotstring is adopted by the menu
1087/// (actually by the TGMenuEntry) and deleted when possible. A possible
1088/// picture is borrowed from the picture pool and therefore not adopted.
1089/// If before is not 0, the entry will be added before it.
1090
1093{
1094 TGMenuEntry *nw = new TGMenuEntry;
1095
1096 nw->fLabel = s;
1097 nw->fPic = p;
1098 nw->fType = kMenuLabel;
1099 nw->fEntryId = -1;
1100 nw->fUserData = 0;
1101 nw->fPopup = 0;
1102 nw->fStatus = kMenuEnableMask | kMenuDefaultMask;
1103 nw->fEx = 2;
1104 nw->fEy = fMenuHeight-2;
1105
1106 if (before)
1108 else
1109 fEntryList->Add(nw);
1110
1111 UInt_t tw, ph = 0, pw = 0;
1112 tw = gVirtualX->TextWidth(fHifontStruct, s->GetString(), s->GetLength());
1113 if (p) {
1114 ph = p->GetHeight();
1115 pw = p->GetWidth();
1116 if (pw+12 > fXl) { fMenuWidth += pw+12-fXl; fXl = pw+12; }
1117 }
1118
1120 nw->fEw = tw + pw /*+8*/+18+12;
1122 gVirtualX->GetFontProperties(fHifontStruct, max_ascent, max_descent);
1124 if (nw->fEh < ph+fEntrySep) nw->fEh = ph+fEntrySep;
1125 fMenuHeight += nw->fEh;
1126
1127 if (before)
1128 Reposition();
1129 else
1131}
1132
1133////////////////////////////////////////////////////////////////////////////////
1134/// Add a menu label to the menu. The string s in not adopted.
1135/// If before is not 0, the entry will be added before it.
1136
1137void TGPopupMenu::AddLabel(const char *s, const TGPicture *p,
1139{
1140 AddLabel(new TGHotString(s), p, before);
1141}
1142
1143////////////////////////////////////////////////////////////////////////////////
1144/// Add a (cascading) popup menu to a popup menu. The hotstring is adopted
1145/// by the menu (actually by the TGMenuEntry) and deleted when possible.
1146/// If before is not 0, the entry will be added before it.
1147
1149 TGMenuEntry *before, const TGPicture *p)
1150{
1151 TGMenuEntry *nw = new TGMenuEntry;
1152
1153 nw->fLabel = s;
1154 nw->fPic = p;
1155 nw->fType = kMenuPopup;
1156 nw->fEntryId = -2;
1157 nw->fUserData = 0;
1158 nw->fPopup = popup;
1159 nw->fStatus = kMenuEnableMask;
1160 nw->fEx = 2;
1161 nw->fEy = fMenuHeight-2;
1162
1163 if (before)
1165 else
1166 fEntryList->Add(nw);
1167
1168 UInt_t tw = gVirtualX->TextWidth(fHifontStruct, s->GetString(),
1169 s->GetLength());
1170
1171 UInt_t ph = 0, pw = 8;
1172 if (p) {
1173 ph = p->GetHeight();
1174 pw = p->GetWidth();
1175 if (pw+12 > fXl) { fMenuWidth += pw+12-fXl; fXl = pw+12; }
1176 }
1178 nw->fEw = tw + pw+18+12;
1180 gVirtualX->GetFontProperties(fHifontStruct, max_ascent, max_descent);
1182 if (nw->fEh < ph+fEntrySep) nw->fEh = ph+fEntrySep;
1183 fMenuHeight += nw->fEh;
1184
1185 if (before)
1186 Reposition();
1187 else
1189}
1190
1191////////////////////////////////////////////////////////////////////////////////
1192/// Add a (cascading) popup menu to a popup menu. The string s is not
1193/// adopted. If before is not 0, the entry will be added before it.
1194
1196 TGMenuEntry *before, const TGPicture *p)
1197{
1198 AddPopup(new TGHotString(s), popup, before, p);
1199}
1200
1201////////////////////////////////////////////////////////////////////////////////
1202/// Reposition entries in popup menu. Called after menu item has been
1203/// hidden or removed or inserted at a specified location.
1204
1206{
1207 // in case any of these magic values is changes, check also the ctor.
1208 fMenuHeight = 6;
1209 fMenuWidth = 8;
1210 fXl = 16;
1211
1212 TGMenuEntry *ptr;
1213 TIter next(fEntryList);
1214
1215 while ((ptr = (TGMenuEntry *) next())) {
1216
1217 if (ptr->fStatus & kMenuHideMask) continue;
1218
1219 if (ptr->fPic) {
1220 UInt_t pw = ptr->fPic->GetWidth();
1221 if (pw+12 > fXl) { fMenuWidth += pw+12-fXl; fXl = pw+12; }
1222 }
1223 ptr->fEx = 2;
1224 ptr->fEy = fMenuHeight-2;
1226 fMenuHeight += ptr->fEh;
1227 }
1229}
1230
1231////////////////////////////////////////////////////////////////////////////////
1232/// Popup a popup menu. If stick mode is true keep the menu up. If
1233/// grab_pointer is true the pointer will be grabbed, which means that
1234/// all pointer events will go to the popup menu, independent of in
1235/// which window the pointer is.
1236
1238{
1239 void *ud;
1240 EndMenu(ud);
1241
1242 Int_t rx, ry;
1243 UInt_t rw, rh;
1244
1246 fCurrent = 0;
1247
1248 // Parent is root window for a popup menu
1249 gVirtualX->GetWindowSize(fParent->GetId(), rx, ry, rw, rh);
1250
1251 if (gVirtualX->InheritsFrom("TGWin32")) {
1252 if ((x > 0) && ((x + abs(rx) + (Int_t)fMenuWidth) > (Int_t)rw))
1253 x = rw - abs(rx) - fMenuWidth;
1254 if ((y > 0) && (y + abs(ry) + (Int_t)fMenuHeight > (Int_t)rh))
1255 y = rh - fMenuHeight;
1256 } else {
1257 if (x < 0) x = 0;
1258 if (x + fMenuWidth > rw) x = rw - fMenuWidth;
1259 if (y < 0) y = 0;
1260 if (y + fMenuHeight > rh) y = rh - fMenuHeight;
1261 }
1262
1263 Move(x, y);
1264 MapRaised();
1265
1266 if (grab_pointer) {
1269 fHasGrab = kTRUE;
1270 } else {
1271 fHasGrab = kFALSE;
1272 }
1273
1274 fPoppedUp = kTRUE;
1275 PoppedUp();
1277
1278 fClient->RegisterPopup(this);
1279}
1280
1281////////////////////////////////////////////////////////////////////////////////
1282/// Close menu and return ID of selected menu item.
1283/// In case of cascading menus, recursively close all menus.
1284
1286{
1287 Int_t id;
1288
1289 if (fDelay) fDelay->Remove();
1290
1291 // destroy any cascaded children and get any ID
1292
1293 if (fCurrent != 0) {
1294
1295 // deactivate the entry
1297
1298 if ((fCurrent->fType == kMenuPopup) && fCurrent->fPopup) {
1300 } else {
1301 // return the ID if the entry is enabled, otherwise -1
1303 id = fCurrent->fEntryId;
1305 } else {
1306 id = -1;
1307 userData = 0;
1308 }
1309 }
1310
1311 } else {
1312 // if no entry selected...
1313 id = -1;
1314 userData = 0;
1315 }
1316
1317 // then unmap itself
1318 UnmapWindow();
1319
1320 gClient->UnregisterPopup(this);
1322
1323 if (fPoppedUp) {
1324 fPoppedUp = kFALSE;
1325 PoppedDown();
1326 }
1327
1328 return id;
1329}
1330
1331////////////////////////////////////////////////////////////////////////////////
1332/// Handle button event in the popup menu.
1333
1335{
1336 int id;
1337 void *ud = 0;
1338
1339 if (event->fType == kButtonRelease) {
1340 if (fStick) {
1341 fStick = kFALSE;
1342 return kTRUE;
1343 }
1344 //if (fCurrent != 0)
1345 // if (fCurrent->fType == kMenuPopup) return kTRUE;
1346 id = EndMenu(ud);
1347 if (fHasGrab) gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab
1348 if (fCurrent != 0) {
1352 (Longptr_t)ud);
1353 Activated(id);
1354 }
1355 }
1356 }
1357 return kTRUE;
1358}
1359
1360////////////////////////////////////////////////////////////////////////////////
1361/// Handle pointer crossing event in popup menu.
1362
1364{
1365 if (event->fType == kEnterNotify) {
1366
1367 TGMenuEntry *ptr;
1368 TIter next(fEntryList);
1369
1370 while ((ptr = (TGMenuEntry *) next())) {
1371 if (ptr->fStatus & kMenuHideMask) continue;
1372
1373 if ((event->fX >= ptr->fEx) && (event->fX <= ptr->fEx+(Int_t)fMenuWidth-10) &&
1374 (event->fY >= ptr->fEy) && (event->fY <= ptr->fEy+(Int_t)ptr->fEh))
1375 break;
1376 }
1377 Activate(ptr);
1378 } else {
1379 Activate((TGMenuEntry*)0);
1380 }
1383
1384 return kTRUE;
1385}
1386
1387////////////////////////////////////////////////////////////////////////////////
1388/// Handle pointer motion event in popup menu.
1389
1391{
1392 TGFrame::HandleMotion(event);
1393 static Int_t twice = 0;
1394 TGMenuEntry *ptr;
1395 TIter next(fEntryList);
1396
1397 if (twice < 2) {
1398 // hack to eat mouse move events generated by Windows when
1399 // pressing/releasing a mouse button
1400 ++twice;
1401 }
1402 else {
1403 twice = 0;
1404 fStick = kFALSE; // be careful with this, use some threshold
1405 }
1406 while ((ptr = (TGMenuEntry *) next())) {
1407 if (ptr->fStatus & kMenuHideMask) continue;
1408
1409 if ((event->fX >= ptr->fEx) && (event->fX <= ptr->fEx+(Int_t)fMenuWidth-4) && //fMenuWidth-10??
1410 (event->fY >= ptr->fEy) && (event->fY <= ptr->fEy+(Int_t)ptr->fEh))
1411 break;
1412 }
1413 Activate(ptr);
1414
1415 return kTRUE;
1416}
1417
1418////////////////////////////////////////////////////////////////////////////////
1419/// Activate a menu entry in a popup menu.
1420
1422{
1423 if (entry == fCurrent) return;
1424
1425 //-- Deactivate the current entry
1426
1427 if (fCurrent != 0) {
1428 void *ud;
1429 if (entry == 0 && fCurrent->fType == kMenuPopup) return;
1430 if ((fCurrent->fType == kMenuPopup) && fCurrent->fPopup)
1434 }
1435
1436 if (fDelay) fDelay->Remove();
1437
1438 //-- Activate the new one
1439
1440 if (entry) {
1441 entry->fStatus |= kMenuActiveMask;
1443 if (entry->fType == kMenuPopup) {
1444 if (!fDelay) fDelay = new TPopupDelayTimer(this, 350);
1445 fDelay->Reset();
1447 // after delay expires it will popup the cascading popup menu
1448 // iff it is still the current entry
1449 } else if (entry->fType == kMenuEntry) {
1450 // test...
1452 entry->fEntryId, (Longptr_t)entry->fUserData);
1453 Highlighted(entry->fEntryId);
1454 }
1455 }
1456 fCurrent = entry;
1457}
1458
1459////////////////////////////////////////////////////////////////////////////////
1460/// If TPopupDelayTimer times out popup cascading popup menu (if it is
1461/// still the current entry).
1462
1464{
1465 if (fCurrent != 0) {
1466 if ((fCurrent->fType == kMenuPopup) && fCurrent->fPopup) {
1467 Int_t ax, ay;
1469
1470 gVirtualX->TranslateCoordinates(fId,
1471 (fCurrent->fPopup->GetParent())->GetId(),
1473 ax, ay, wdummy);
1474#ifdef R__HAS_COCOA
1475 gVirtualX->SetWMTransientHint(fCurrent->fPopup->GetId(), GetId());
1476#endif
1478 }
1479 }
1480 fDelay->Remove();
1481
1482 return kTRUE;
1483}
1484
1485////////////////////////////////////////////////////////////////////////////////
1486/// Draw popup menu.
1487
1489{
1491
1492 TGMenuEntry *ptr;
1493 TIter next(fEntryList);
1494
1495 while ((ptr = (TGMenuEntry *) next()))
1496 DrawEntry(ptr);
1497}
1498
1499////////////////////////////////////////////////////////////////////////////////
1500/// Draw popup menu entry.
1501
1503{
1504 FontStruct_t font;
1506
1507 if (entry->fStatus & kMenuHideMask)
1508 return;
1509
1510 if (entry->fStatus & kMenuDefaultMask) {
1511 font = fHifontStruct;
1512 gcval.fMask = kGCFont;
1513 gcval.fFont = gVirtualX->GetFontHandle(font);
1514 gVirtualX->ChangeGC(fNormGC, &gcval);
1515 gVirtualX->ChangeGC(fSelGC, &gcval);
1516 } else {
1517 font = fFontStruct;
1518 }
1519
1520 UInt_t tw = 0;
1522 gVirtualX->GetFontProperties(font, max_ascent, max_descent);
1523 int tx = entry->fEx + fXl;
1524 // center text
1525 int offset = (entry->fEh - (max_ascent + max_descent)) / 2;
1526 int ty = entry->fEy + max_ascent + offset - 1;
1527 if (entry->fShortcut)
1528 tw = 7 + gVirtualX->TextWidth(fFontStruct, entry->fShortcut->Data(), entry->fShortcut->Length());
1529
1530 switch (entry->fType) {
1531 case kMenuPopup:
1532 case kMenuLabel:
1533 case kMenuEntry:
1534 if ((entry->fStatus & kMenuActiveMask) && entry->fType != kMenuLabel) {
1535 gVirtualX->FillRectangle(fId, fSelbackGC, entry->fEx+1, entry->fEy-1,
1536 fMenuWidth-6, entry->fEh);
1537 if (gClient->GetStyle() > 1)
1538 gVirtualX->DrawRectangle(fId, GetShadowGC()(), entry->fEx+1, entry->fEy-2,
1539 fMenuWidth-7, entry->fEh);
1540 if (entry->fType == kMenuPopup)
1542 if (entry->fStatus & kMenuCheckedMask)
1543 DrawCheckMark(fSelGC, 6, entry->fEy+fEntrySep, 14, entry->fEy+11);
1544 if (entry->fStatus & kMenuRadioMask)
1545 DrawRCheckMark(fSelGC, 6, entry->fEy+fEntrySep, 14, entry->fEy+11);
1546 if (entry->fPic != 0)
1547 entry->fPic->Draw(fId, fSelGC, 8, entry->fEy+1);
1548 entry->fLabel->Draw(fId,
1549 (entry->fStatus & kMenuEnableMask) ? fSelGC : GetShadowGC()(),
1550 tx, ty);
1551 if (entry->fShortcut)
1552 entry->fShortcut->Draw(fId, (entry->fStatus & kMenuEnableMask) ? fSelGC : GetShadowGC()(),
1553 fMenuWidth - tw, ty);
1554 } else {
1555 if (gClient->GetStyle() > 1)
1556 gVirtualX->DrawRectangle(fId, GetBckgndGC()(), entry->fEx+1, entry->fEy-2,
1557 fMenuWidth-7, entry->fEh);
1558 gVirtualX->FillRectangle(fId, GetBckgndGC()(), entry->fEx+1, entry->fEy-1,
1559 fMenuWidth-6, entry->fEh);
1560 if (entry->fType == kMenuPopup)
1562 if (entry->fStatus & kMenuCheckedMask)
1563 DrawCheckMark(fNormGC, 6, entry->fEy+fEntrySep, 14, entry->fEy+11);
1564 if (entry->fStatus & kMenuRadioMask)
1565 DrawRCheckMark(fNormGC, 6, entry->fEy+fEntrySep, 14, entry->fEy+11);
1566 if (entry->fPic != 0)
1567 entry->fPic->Draw(fId, fNormGC, 8, entry->fEy+1);
1568 if (entry->fStatus & kMenuEnableMask) {
1569 entry->fLabel->Draw(fId, fNormGC, tx, ty);
1570 if (entry->fShortcut)
1571 entry->fShortcut->Draw(fId, fNormGC, fMenuWidth - tw, ty);
1572 } else {
1573 entry->fLabel->Draw(fId, GetHilightGC()(), tx+1, ty+1);
1574 entry->fLabel->Draw(fId, GetShadowGC()(), tx, ty);
1575 if (entry->fShortcut) {
1576 entry->fShortcut->Draw(fId, GetHilightGC()(), fMenuWidth - tw+1, ty+1);
1577 entry->fShortcut->Draw(fId, GetShadowGC()(), fMenuWidth - tw, ty);
1578 }
1579 }
1580 }
1581 break;
1582
1583 case kMenuSeparator:
1584 gVirtualX->DrawLine(fId, GetShadowGC()(), 2, entry->fEy, fMenuWidth-fEntrySep, entry->fEy);
1585 gVirtualX->DrawLine(fId, GetHilightGC()(), 2, entry->fEy+1, fMenuWidth-fEntrySep, entry->fEy+1);
1586 break;
1587 }
1588
1589 // restore font
1590 if (entry->fStatus & kMenuDefaultMask) {
1591 gcval.fFont = gVirtualX->GetFontHandle(fFontStruct);
1592 gVirtualX->ChangeGC(fNormGC, &gcval);
1593 gVirtualX->ChangeGC(fSelGC, &gcval);
1594 }
1595}
1596
1597////////////////////////////////////////////////////////////////////////////////
1598/// Draw border round popup menu.
1599
1601{
1602 if (gClient->GetStyle() > 0) {
1603 // new modern (flat) version
1604 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, 0, fMenuHeight-1);
1605 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, fMenuHeight-1, fMenuWidth-1, fMenuHeight-1);
1606 gVirtualX->DrawLine(fId, GetShadowGC()(), fMenuWidth-1, fMenuHeight-1, fMenuWidth-1, 0);
1607 gVirtualX->DrawLine(fId, GetShadowGC()(), fMenuWidth-1, 0, 0, 0);
1608 }
1609 else {
1610 // old (raised frame) version
1611 gVirtualX->DrawLine(fId, GetBckgndGC()(), 0, 0, fMenuWidth-2, 0);
1612 gVirtualX->DrawLine(fId, GetBckgndGC()(), 0, 0, 0, fMenuHeight-2);
1613 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 1, fMenuWidth-fEntrySep, 1);
1614 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 1, 1, fMenuHeight-fEntrySep);
1615
1616 gVirtualX->DrawLine(fId, GetShadowGC()(), 1, fMenuHeight-2, fMenuWidth-2, fMenuHeight-2);
1617 gVirtualX->DrawLine(fId, GetShadowGC()(), fMenuWidth-2, fMenuHeight-2, fMenuWidth-2, 1);
1618 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, fMenuHeight-1, fMenuWidth-1, fMenuHeight-1);
1619 gVirtualX->DrawLine(fId, GetBlackGC()(), fMenuWidth-1, fMenuHeight-1, fMenuWidth-1, 0);
1620 }
1621}
1622
1623////////////////////////////////////////////////////////////////////////////////
1624/// Draw triangle pattern. Used for menu entries that are of type
1625/// kMenuPopup (i.e. cascading menus).
1626
1628 Int_t r, Int_t b)
1629{
1630 Point_t points[3];
1631
1632 int m = (t + b) >> 1;
1633
1634 points[0].fX = l;
1635 points[0].fY = t;
1636 points[1].fX = l;
1637 points[1].fY = b;
1638 points[2].fX = r;
1639 points[2].fY = m;
1640
1641 gVirtualX->FillPolygon(fId, gc, points, 3);
1642}
1643
1644////////////////////////////////////////////////////////////////////////////////
1645/// Draw check mark. Used for checked button type menu entries.
1646
1648{
1649 Segment_t seg[6];
1650
1651 t = (t + b - 8) >> 1; ++t;
1652
1653 seg[0].fX1 = 1+l; seg[0].fY1 = 3+t; seg[0].fX2 = 3+l; seg[0].fY2 = 5+t;
1654 seg[1].fX1 = 1+l; seg[1].fY1 = 4+t; seg[1].fX2 = 3+l; seg[1].fY2 = 6+t;
1655 seg[2].fX1 = 1+l; seg[2].fY1 = 5+t; seg[2].fX2 = 3+l; seg[2].fY2 = 7+t;
1656 seg[3].fX1 = 3+l; seg[3].fY1 = 5+t; seg[3].fX2 = 7+l; seg[3].fY2 = 1+t;
1657 seg[4].fX1 = 3+l; seg[4].fY1 = 6+t; seg[4].fX2 = 7+l; seg[4].fY2 = 2+t;
1658 seg[5].fX1 = 3+l; seg[5].fY1 = 7+t; seg[5].fX2 = 7+l; seg[5].fY2 = 3+t;
1659
1660 gVirtualX->DrawSegments(fId, gc, seg, 6);
1661}
1662
1663////////////////////////////////////////////////////////////////////////////////
1664/// Draw radio check mark. Used for radio button type menu entries.
1665
1667{
1668 Segment_t seg[5];
1669
1670 t = (t + b - 5) >> 1; ++t;
1671 l = (l + r - 5) >> 1; ++l;
1672
1673 seg[0].fX1 = 1+l; seg[0].fY1 = 0+t; seg[0].fX2 = 3+l; seg[0].fY2 = 0+t;
1674 seg[1].fX1 = 0+l; seg[1].fY1 = 1+t; seg[1].fX2 = 4+l; seg[1].fY2 = 1+t;
1675 seg[2].fX1 = 0+l; seg[2].fY1 = 2+t; seg[2].fX2 = 4+l; seg[2].fY2 = 2+t;
1676 seg[3].fX1 = 0+l; seg[3].fY1 = 3+t; seg[3].fX2 = 4+l; seg[3].fY2 = 3+t;
1677 seg[4].fX1 = 1+l; seg[4].fY1 = 4+t; seg[4].fX2 = 3+l; seg[4].fY2 = 4+t;
1678
1679 gVirtualX->DrawSegments(fId, gc, seg, 5);
1680}
1681
1682////////////////////////////////////////////////////////////////////////////////
1683/// Set default entry (default entries are drawn with bold text).
1684
1686{
1687 TGMenuEntry *ptr;
1688 TIter next(fEntryList);
1689
1690 while ((ptr = (TGMenuEntry *) next())) {
1691 if (ptr->fEntryId == id)
1692 ptr->fStatus |= kMenuDefaultMask;
1693 else
1694 ptr->fStatus &= ~kMenuDefaultMask;
1695 }
1696}
1697
1698////////////////////////////////////////////////////////////////////////////////
1699/// Enable entry. By default entries are enabled.
1700
1702{
1703 TGMenuEntry *ptr;
1704 TIter next(fEntryList);
1705
1706 while ((ptr = (TGMenuEntry *) next()))
1707 if (ptr->fEntryId == id) {
1708 ptr->fStatus |= kMenuEnableMask;
1709 if (ptr->fStatus & kMenuHideMask) {
1710 ptr->fStatus &= ~kMenuHideMask;
1711 Reposition();
1712 }
1713 break;
1714 }
1715}
1716
1717////////////////////////////////////////////////////////////////////////////////
1718/// Disable entry (disabled entries appear in a sunken relieve).
1719
1721{
1722 TGMenuEntry *ptr;
1723 TIter next(fEntryList);
1724
1725 while ((ptr = (TGMenuEntry *) next()))
1726 if (ptr->fEntryId == id) { ptr->fStatus &= ~kMenuEnableMask; break; }
1727}
1728
1729////////////////////////////////////////////////////////////////////////////////
1730/// Return true if menu entry is enabled.
1731
1733{
1734 TGMenuEntry *ptr;
1735 TIter next(fEntryList);
1736
1737 while ((ptr = (TGMenuEntry *) next()))
1738 if (ptr->fEntryId == id)
1739 return (ptr->fStatus & kMenuEnableMask) ? kTRUE : kFALSE;
1740 return kFALSE;
1741}
1742
1743////////////////////////////////////////////////////////////////////////////////
1744/// Hide entry (hidden entries are not shown in the menu).
1745/// To enable a hidden entry call EnableEntry().
1746
1748{
1749 TGMenuEntry *ptr;
1750 TIter next(fEntryList);
1751
1752 while ((ptr = (TGMenuEntry *) next()))
1753 if (ptr->fEntryId == id) {
1754 ptr->fStatus |= kMenuHideMask;
1755 ptr->fStatus &= ~kMenuEnableMask;
1756 Reposition();
1757 break;
1758 }
1759}
1760
1761////////////////////////////////////////////////////////////////////////////////
1762/// Return true if menu entry is hidden.
1763
1765{
1766 TGMenuEntry *ptr;
1767 TIter next(fEntryList);
1768
1769 while ((ptr = (TGMenuEntry *) next()))
1770 if (ptr->fEntryId == id)
1771 return (ptr->fStatus & kMenuHideMask) ? kTRUE : kFALSE;
1772 return kFALSE;
1773}
1774
1775////////////////////////////////////////////////////////////////////////////////
1776/// Check a menu entry (i.e. add a check mark in front of it).
1777
1779{
1780 TGMenuEntry *ptr;
1781 TIter next(fEntryList);
1782
1783 while ((ptr = (TGMenuEntry *) next()))
1784 if (ptr->fEntryId == id) { ptr->fStatus |= kMenuCheckedMask; break; }
1785}
1786
1787////////////////////////////////////////////////////////////////////////////////
1788/// Check a menu entry (i.e. add a check mark in front of it).
1789/// The input argument is user data associated with entry
1790
1792{
1793 TGMenuEntry *ptr;
1794 TIter next(fEntryList);
1795
1796 while ((ptr = (TGMenuEntry *) next()))
1797 if (ptr->fUserData == user_data) { ptr->fStatus |= kMenuCheckedMask; break; }
1798}
1799
1800////////////////////////////////////////////////////////////////////////////////
1801/// Uncheck menu entry (i.e. remove check mark).
1802
1804{
1805 TGMenuEntry *ptr;
1806 TIter next(fEntryList);
1807
1808 while ((ptr = (TGMenuEntry *) next()))
1809 if (ptr->fEntryId == id) { ptr->fStatus &= ~kMenuCheckedMask; break; }
1810}
1811
1812////////////////////////////////////////////////////////////////////////////////
1813/// Uncheck all entries.
1814
1816{
1817 TGMenuEntry *ptr;
1818 TIter next(fEntryList);
1819
1820 while ((ptr = (TGMenuEntry *) next())) {
1821 ptr->fStatus &= ~kMenuCheckedMask;
1822 }
1823}
1824
1825////////////////////////////////////////////////////////////////////////////////
1826/// Uncheck a menu entry (i.e. remove check mark in front of it).
1827/// The input argument is user data associated with entry
1828
1830{
1831 TGMenuEntry *ptr;
1832 TIter next(fEntryList);
1833
1834 while ((ptr = (TGMenuEntry *) next()))
1835 if (ptr->fUserData == user_data) { ptr->fStatus &= ~kMenuCheckedMask; break; }
1836}
1837
1838////////////////////////////////////////////////////////////////////////////////
1839/// Return true if menu item is checked.
1840
1842{
1843 TGMenuEntry *ptr;
1844 TIter next(fEntryList);
1845
1846 while ((ptr = (TGMenuEntry *) next()))
1847 if (ptr->fEntryId == id)
1848 return (ptr->fStatus & kMenuCheckedMask) ? kTRUE : kFALSE;
1849 return kFALSE;
1850}
1851
1852////////////////////////////////////////////////////////////////////////////////
1853/// Radio-select entry (note that they cannot be unselected,
1854/// the selection must be moved to another entry instead).
1855
1857{
1858 TGMenuEntry *ptr;
1859 TIter next(fEntryList);
1860
1861 while ((ptr = (TGMenuEntry *) next()))
1862 if (ptr->fEntryId == id)
1864 else
1865 if (ptr->fEntryId >= IDfirst && ptr->fEntryId <= IDlast) {
1866 ptr->fStatus &= ~kMenuRadioMask;
1868 }
1869}
1870
1871////////////////////////////////////////////////////////////////////////////////
1872/// Return true if menu item has radio check mark.
1873
1875{
1876 TGMenuEntry *ptr;
1877 TIter next(fEntryList);
1878
1879 while ((ptr = (TGMenuEntry *) next()))
1880 if (ptr->fEntryId == id)
1881 return (ptr->fStatus & kMenuRadioMask) ? kTRUE : kFALSE;
1882 return kFALSE;
1883}
1884
1885////////////////////////////////////////////////////////////////////////////////
1886/// Find entry with specified id. Use the returned entry in DeleteEntry()
1887/// or as the "before" item in the AddXXXX() methods. Returns 0 if entry
1888/// is not found. To find entries that don't have an id like the separators,
1889/// use the GetListOfEntries() method to get the complete entry
1890/// list and iterate over it and check the type of each entry
1891/// to find the separators.
1892
1894{
1895 TGMenuEntry *ptr;
1896 TIter next(fEntryList);
1897
1898 while ((ptr = (TGMenuEntry *) next()))
1899 if (ptr->fEntryId == id)
1900 return ptr;
1901 return 0;
1902}
1903
1904////////////////////////////////////////////////////////////////////////////////
1905/// Find entry with specified name. Name must match the original
1906/// name without hot key symbol, like "Print" and not "&Print".
1907/// Use the returned entry in DeleteEntry() or as the "before" item
1908/// in the AddXXXX() methods. Returns 0 if entry is not found.
1909/// To find entries that don't have a name like the separators,
1910/// use the GetListOfEntries() method to get the complete entry
1911/// list and iterate over it and check the type of each entry
1912/// to find the separators.
1913
1915{
1916 return (TGMenuEntry*) fEntryList->FindObject(s);
1917}
1918
1919////////////////////////////////////////////////////////////////////////////////
1920/// Delete entry with specified id from menu.
1921
1923{
1924 TGMenuEntry *ptr;
1925 TIter next(fEntryList);
1926
1927 while ((ptr = (TGMenuEntry *) next()))
1928 if (ptr->fEntryId == id) {
1929 fEntryList->Remove(ptr);
1930 delete ptr;
1931 Reposition();
1932 if (fCurrent == ptr)
1933 fCurrent = 0;
1934 return;
1935 }
1936}
1937
1938////////////////////////////////////////////////////////////////////////////////
1939/// Delete specified entry from menu.
1940
1942{
1943 TGMenuEntry *ptr;
1944 TIter next(fEntryList);
1945
1946 while ((ptr = (TGMenuEntry *) next()))
1947 if (ptr == entry) {
1948 fEntryList->Remove(ptr);
1949 delete ptr;
1950 Reposition();
1951 if (fCurrent == ptr)
1952 fCurrent = 0;
1953 return;
1954 }
1955}
1956
1957////////////////////////////////////////////////////////////////////////////////
1958/// Return default graphics context.
1959
1961{
1962 if (!fgDefaultGC)
1963 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
1964 return *fgDefaultGC;
1965}
1966
1967////////////////////////////////////////////////////////////////////////////////
1968/// Return the selection graphics context in use.
1969
1971{
1973 fgDefaultSelectedGC = gClient->GetResourcePool()->GetSelectedGC();
1974 return *fgDefaultSelectedGC;
1975}
1976
1977////////////////////////////////////////////////////////////////////////////////
1978/// Return the selection background graphics context in use.
1979
1981{
1983 fgDefaultSelectedBackgroundGC = gClient->GetResourcePool()->GetSelectedBckgndGC();
1985}
1986
1987////////////////////////////////////////////////////////////////////////////////
1988/// Return the default font structure in use.
1989
1991{
1992 if (!fgDefaultFont)
1993 fgDefaultFont = gClient->GetResourcePool()->GetMenuFont();
1994 return fgDefaultFont->GetFontStruct();
1995}
1996
1997////////////////////////////////////////////////////////////////////////////////
1998/// Return the font structure in use for highlighted menu entries.
1999
2001{
2002 if (!fgHilightFont)
2003 fgHilightFont = gClient->GetResourcePool()->GetMenuHiliteFont();
2004 return fgHilightFont->GetFontStruct();
2005}
2006
2007
2008//////////////////////////////////////////////////////////////////////////
2009// //
2010// TGMenuTitle member functions. //
2011// //
2012//////////////////////////////////////////////////////////////////////////
2013
2014////////////////////////////////////////////////////////////////////////////////
2015/// Create a menu title. This object is created by a menu bar when adding
2016/// a popup menu. The menu title adopts the hotstring.
2017
2019 GContext_t norm, FontStruct_t font, UInt_t options)
2020 : TGFrame(p, 1, 1, options)
2021{
2022 fLabel = s;
2023 fMenu = menu;
2024 fFontStruct = font;
2026 fNormGC = norm;
2027 fState = kFALSE;
2028 fTitleId = -1;
2030 fTitleData = 0;
2031
2032 Int_t hotchar;
2033 if (s && (hotchar = s->GetHotChar()) != 0)
2034 fHkeycode = gVirtualX->KeysymToKeycode(hotchar);
2035 else
2036 fHkeycode = 0;
2037
2038 UInt_t tw = 0;
2040 if (fLabel)
2041 tw = gVirtualX->TextWidth(fFontStruct, fLabel->GetString(), fLabel->GetLength());
2042 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
2043
2044 Resize(tw + 8, max_ascent + max_descent + 7);
2045
2046 if (p && p->InheritsFrom(TGMenuBar::Class())) {
2047 TGMenuBar *bar = (TGMenuBar*)p;
2048 fMenu->SetMenuBar(bar);
2049 }
2050}
2051
2052////////////////////////////////////////////////////////////////////////////////
2053/// Set state of menu title.
2054
2056{
2057 fState = state;
2058 if (state) {
2059 if (fMenu != 0) {
2060 Int_t ax, ay;
2062
2063 gVirtualX->TranslateCoordinates(fId, (fMenu->GetParent())->GetId(),
2064 0, 0, ax, ay, wdummy);
2065
2066 // place the menu just under the window:
2067#ifdef R__HAS_COCOA
2068 gVirtualX->SetWMTransientHint(fMenu->GetId(), GetId());
2069#endif
2070 fMenu->PlaceMenu(ax-1, ay+fHeight, kTRUE, kFALSE); //kTRUE);
2071 }
2072 } else {
2073 if (fMenu != 0) {
2075 }
2076 }
2078 fClient->NeedRedraw(this);
2079}
2080
2081////////////////////////////////////////////////////////////////////////////////
2082/// Draw a menu title.
2083
2085{
2087
2088 int x, y, max_ascent, max_descent;
2089 x = y = 4;
2090
2091 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
2092
2093 if (fState) {
2095 if (gClient->GetStyle() > 1) {
2096 gVirtualX->FillRectangle(fId, fNormGC, 1, 2, fWidth-3, fHeight-4);
2097 gVirtualX->DrawRectangle(fId, GetShadowGC()(), 1, 1, fWidth-3, fHeight-3);
2098 }
2099 else {
2100 gVirtualX->FillRectangle(fId, fNormGC, 0, 0, fWidth, fHeight);
2101 }
2102 gVirtualX->SetForeground(fNormGC, GetForeground());
2104 } else {
2105 // Use same background color than the menu bar
2107 if (fMenu && fMenu->fMenuBar && fMenu->fMenuBar->GetBackground() != back)
2108 back = fMenu->fMenuBar->GetBackground();
2109 gVirtualX->SetForeground(fNormGC, back);
2110 if (gClient->GetStyle() > 1) {
2111 gVirtualX->DrawRectangle(fId, fNormGC, 1, 1, fWidth-3, fHeight-3);
2112 gVirtualX->FillRectangle(fId, fNormGC, 1, 2, fWidth-3, fHeight-4);
2113 }
2114 else {
2115 gVirtualX->FillRectangle(fId, fNormGC, 0, 0, fWidth, fHeight);
2116 }
2117 gVirtualX->SetForeground(fNormGC, fTextColor);
2119 if (fTextColor != GetForeground())
2120 gVirtualX->SetForeground(fNormGC, GetForeground());
2121 }
2122}
2123
2124////////////////////////////////////////////////////////////////////////////////
2125/// Send final selected menu item to be processed.
2126
2128{
2129 if (fMenu)
2130 if (fTitleId != -1) {
2134 }
2135}
2136
2137////////////////////////////////////////////////////////////////////////////////
2138/// Return default font structure in use.
2139
2141{
2142 if (!fgDefaultFont)
2143 fgDefaultFont = gClient->GetResourcePool()->GetMenuFont();
2144 return fgDefaultFont->GetFontStruct();
2145}
2146
2147////////////////////////////////////////////////////////////////////////////////
2148/// Return default graphics context in use.
2149
2151{
2152 if (!fgDefaultGC)
2153 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
2154 return *fgDefaultGC;
2155}
2156
2157////////////////////////////////////////////////////////////////////////////////
2158/// Return default selection graphics context in use.
2159
2161{
2163 fgDefaultSelectedGC = gClient->GetResourcePool()->GetSelectedGC();
2164 return *fgDefaultSelectedGC;
2165}
2166
2167////////////////////////////////////////////////////////////////////////////////
2168/// Save a popup menu widget as a C++ statement(s) on output stream out.
2169
2170void TGPopupMenu::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2171{
2172 out << " TGPopupMenu *" << GetName() << " = new TGPopupMenu(gClient->GetDefaultRoot()"
2173 << "," << GetWidth() << "," << GetHeight() << "," << GetOptionString() << ");\n";
2174
2177 r_active = r_first = r_last = -1;
2178
2179 TIter next(GetListOfEntries());
2180
2181 while (auto mentry = static_cast<TGMenuEntry *> (next())) {
2182 Int_t hotpos = mentry->fLabel ? mentry->fLabel->GetHotPos() : 0;
2183 TString outtext = mentry->GetName(), pic_prefix;
2184 if ((hotpos > 0) && (hotpos < outtext.Length()))
2185 outtext.Insert(hotpos - 1, "&");
2186 if (mentry->fShortcut) {
2187 outtext.Append("\t");
2188 outtext.Append(mentry->fShortcut->GetString());
2189 }
2190 outtext.ReplaceSpecialCppChars();
2191
2192 switch (mentry->GetType()) {
2193 case kMenuEntry:
2194 out << " " << GetName() << "->AddEntry(\"" << outtext << "\", " << mentry->GetEntryId();
2195 pic_prefix = ", nullptr, ";
2196 break;
2197 case kMenuPopup:
2198 out << "\n // cascaded menu \"" << mentry->GetName() << "\"\n";
2199 mentry->fPopup->SavePrimitive(out, option);
2200 out << " " << GetName() << "->AddPopup(\"" << outtext << "\", " << mentry->fPopup->GetName();
2201 pic_prefix = ", nullptr, ";
2202 break;
2203 case kMenuLabel:
2204 out << " " << GetName() << "->AddLabel(\"" << outtext << "\"";
2205 pic_prefix = ", ";
2206 break;
2207 case kMenuSeparator: out << " " << GetName() << "->AddSeparator("; break;
2208 }
2209 if (pic_prefix.Length() && mentry->fPic) {
2210 TString picname = gSystem->UnixPathName(mentry->fPic->GetName());
2212 out << pic_prefix << "gClient->GetPicture(\"" << picname.ReplaceSpecialCppChars() << "\")";
2213 }
2214 out << ");\n";
2215
2216 if (!(mentry->GetStatus() & kMenuEnableMask))
2217 out << " " << GetName() << "->DisableEntry(" << mentry->GetEntryId() << ");\n";
2218 if (mentry->GetStatus() & kMenuHideMask)
2219 out << " " << GetName() << "->HideEntry(" << mentry->GetEntryId() << ");\n";
2220 if (mentry->GetStatus() & kMenuCheckedMask)
2221 out << " " << GetName() << "->CheckEntry(" << mentry->GetEntryId() << ");\n";
2222 if (mentry->GetStatus() & kMenuDefaultMask)
2223 out << " " << GetName() << "->DefaultEntry(" << mentry->GetEntryId() << ");\n";
2224 if (mentry->GetStatus() & kMenuRadioEntryMask) {
2225 if (hasradio) {
2226 r_last = mentry->GetEntryId();
2227 if (IsEntryRChecked(mentry->GetEntryId()))
2228 r_active = mentry->GetEntryId();
2229 } else {
2230 r_first = mentry->GetEntryId();
2231 hasradio = kTRUE;
2232 if (IsEntryRChecked(mentry->GetEntryId()))
2233 r_active = mentry->GetEntryId();
2234 }
2235 } else if (hasradio) {
2236 out << " " << GetName() << "->RCheckEntry(" << r_active << "," << r_first << "," << r_last << ");\n";
2237 hasradio = kFALSE;
2238 r_active = r_first = r_last = -1;
2239 }
2240 }
2241}
2242
2243////////////////////////////////////////////////////////////////////////////////
2244/// Save a title menu widget as a C++ statement(s) on output stream out.
2245
2246void TGMenuTitle::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2247{
2248 out << "\n // \"" << fLabel->GetString() << "\" menu\n";
2249
2250 fMenu->SavePrimitive(out, option);
2251
2254 if (hotpos > 0)
2255 outtext.Insert(hotpos - 1, "&");
2256 out << " " << fParent->GetName() << "->AddPopup(\"" << outtext.ReplaceSpecialCppChars() << "\", "
2257 << fMenu->GetName();
2258}
2259
2260////////////////////////////////////////////////////////////////////////////////
2261/// Save a menu bar widget as a C++ statement(s) on output stream out.
2262
2263void TGMenuBar::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2264{
2265 out << "\n // menu bar\n";
2266 out << " TGMenuBar *" << GetName() << " = new TGMenuBar(" << fParent->GetName() << "," << GetWidth() << ","
2267 << GetHeight() << "," << GetOptionString() << ");\n";
2268 if (option && strstr(option, "keep_names"))
2269 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
2270
2271 if (!fList)
2272 return;
2273
2274 TIter next(fList);
2275
2276 while (auto el = static_cast<TGFrameElement *>(next())) {
2277 el->fFrame->SavePrimitive(out, option);
2278 el->fLayout->SavePrimitive(out, option);
2279 out << ");\n";
2280 }
2281}
@ kGKeyPress
Definition GuiTypes.h:60
@ kButtonRelease
Definition GuiTypes.h:60
@ kButtonPress
Definition GuiTypes.h:60
@ kEnterNotify
Definition GuiTypes.h:61
@ kKeyRelease
Definition GuiTypes.h:60
const Mask_t kWAOverrideRedirect
Definition GuiTypes.h:149
const Mask_t kKeyLockMask
Definition GuiTypes.h:196
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
const Mask_t kKeyMod1Mask
typically the Alt key
Definition GuiTypes.h:198
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
const Mask_t kWASaveUnder
Definition GuiTypes.h:150
const Mask_t kAnyModifier
Definition GuiTypes.h:210
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
const Mask_t kButton1Mask
Definition GuiTypes.h:203
const Mask_t kGCFont
Definition GuiTypes.h:300
const Mask_t kPointerMotionMask
Definition GuiTypes.h:163
const Mask_t kKeyShiftMask
Definition GuiTypes.h:195
@ kRaisedFrame
Definition GuiTypes.h:384
@ kSunkenFrame
Definition GuiTypes.h:383
@ kHorizontalFrame
Definition GuiTypes.h:382
@ kOwnBackground
Definition GuiTypes.h:391
const Handle_t kNone
Definition GuiTypes.h:88
const Mask_t kKeyMod2Mask
typically mod on numeric keys
Definition GuiTypes.h:199
const Mask_t kLeaveWindowMask
Definition GuiTypes.h:168
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
const Mask_t kEnterWindowMask
Definition GuiTypes.h:167
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
@ kButton1
Definition GuiTypes.h:214
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
EKeySym
Definition KeySymbols.h:25
@ kKey_Right
Definition KeySymbols.h:42
@ kKey_Down
Definition KeySymbols.h:43
@ kKey_Up
Definition KeySymbols.h:41
@ kKey_Return
Definition KeySymbols.h:30
@ kKey_Left
Definition KeySymbols.h:40
@ kKey_Escape
Definition KeySymbols.h:26
@ kKey_Enter
Definition KeySymbols.h:31
int main()
Definition Prototype.cxx:12
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:89
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:208
#define gClient
Definition TGClient.h:157
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsTop
Definition TGLayout.h:27
@ kMenuRadioMask
Definition TGMenu.h:28
@ kMenuRadioEntryMask
Definition TGMenu.h:30
@ kMenuHideMask
Definition TGMenu.h:29
@ kMenuCheckedMask
Definition TGMenu.h:27
@ kMenuActiveMask
Definition TGMenu.h:24
@ kMenuDefaultMask
Definition TGMenu.h:26
@ kMenuEnableMask
Definition TGMenu.h:25
@ kMenuEntry
Definition TGMenu.h:38
@ kMenuSeparator
Definition TGMenu.h:36
@ kMenuPopup
Definition TGMenu.h:39
@ kMenuLabel
Definition TGMenu.h:37
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 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 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 target
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 on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
#define gVirtualX
Definition TVirtualX.h:337
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
@ kCM_MENU
@ kCM_MENUSELECT
@ kC_COMMAND
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition TGClient.cxx:233
void RegisterPopup(TGWindow *w)
Add a popup menu to the list of popups.
Definition TGClient.cxx:541
const TGResourcePool * GetResourcePool() const
Definition TGClient.h:124
TGWindow * GetWindowById(Window_t sw) const
Find a TGWindow via its handle. If window is not found return 0.
Definition TGClient.cxx:602
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:380
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
virtual TList * GetList() const
Definition TGFrame.h:312
UInt_t GetDefaultWidth() const override
Definition TGFrame.h:314
Int_t MustCleanup() const override
Definition TGFrame.h:362
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1156
TList * fList
container of frame elements
Definition TGFrame.h:294
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition TGFrame.cxx:1141
static TGLayoutHints * fgDefaultHints
Definition TGFrame.h:299
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
static Pixel_t GetDefaultSelectedBackground()
Get default selected frame background.
Definition TGFrame.cxx:688
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:331
static const TGGC & GetBlackGC()
Get black graphics context.
Definition TGFrame.cxx:727
UInt_t fOptions
frame options
Definition TGFrame.h:94
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
UInt_t fHeight
frame height
Definition TGFrame.h:88
Int_t fBorderWidth
frame border width
Definition TGFrame.h:93
TGDimension GetSize() const
Definition TGFrame.h:232
void DoRedraw() override
Redraw the frame.
Definition TGFrame.cxx:422
virtual Pixel_t GetForeground() const
Return frame foreground color.
Definition TGFrame.cxx:295
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition TGFrame.cxx:747
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:675
void Move(Int_t x, Int_t y) override
Move frame.
Definition TGFrame.cxx:585
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition TGFrame.cxx:2512
void UnmapWindow() override
unmap window
Definition TGFrame.h:208
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:637
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:757
UInt_t fWidth
frame width
Definition TGFrame.h:87
virtual Bool_t HandleMotion(Event_t *)
Definition TGFrame.h:166
UInt_t GetHeight() const
Definition TGFrame.h:227
virtual void Layout()
Definition TGFrame.h:201
virtual Pixel_t GetBackground() const
Definition TGFrame.h:194
UInt_t GetWidth() const
Definition TGFrame.h:226
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition TGFrame.cxx:767
void MapRaised() override
map raised
Definition TGFrame.h:207
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:387
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
Int_t GetHotPos() const
Definition TGString.h:58
Int_t GetHotChar() const
Definition TGString.h:57
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:399
The TGMenu.h header contains all different menu classes.
Definition TGMenu.h:282
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a menu bar widget as a C++ statement(s) on output stream out.
Definition TGMenu.cxx:2263
TGPopupMenu * fMenuMore
extra >> menu
Definition TGMenu.h:293
virtual TGPopupMenu * RemovePopup(const char *s)
Remove popup menu from menu bar.
Definition TGMenu.cxx:557
Bool_t fStick
stick mode (popup menu stays sticked on screen)
Definition TGMenu.h:290
~TGMenuBar() override
Delete menu bar object.
Definition TGMenu.cxx:151
Bool_t HandleMotion(Event_t *event) override
Handle a mouse motion event in a menu bar.
Definition TGMenu.cxx:586
virtual void AddFrameBefore(TGFrame *f, TGLayoutHints *l=nullptr, TGPopupMenu *before=nullptr)
Private version of AddFrame for menubar, to make sure that we indeed only add TGMenuTitle objects to ...
Definition TGMenu.cxx:499
virtual void BindHotKey(Int_t keycode, Bool_t on=kTRUE)
If on kTRUE bind hot keys, otherwise remove key binding.
Definition TGMenu.cxx:379
Bool_t fWithExt
indicates whether the >> menu is shown or not
Definition TGMenu.h:295
TGMenuTitle * fCurrent
current menu title
Definition TGMenu.h:287
virtual TGPopupMenu * GetPopup(const char *s)
Return popup menu with the specified name.
Definition TGMenu.cxx:536
static TClass * Class()
Bool_t HandleButton(Event_t *event) override
Handle a mouse button event in a menubar.
Definition TGMenu.cxx:619
void Layout() override
Calculates whether the >> menu must be shown or not and which menu titles are hidden.
Definition TGMenu.cxx:189
TList * fTrash
garbage
Definition TGMenu.h:291
virtual void BindKeys(Bool_t on=kTRUE)
If on kTRUE bind arrow, popup menu hot keys, otherwise remove key bindings.
Definition TGMenu.cxx:333
void BindMenu(TGPopupMenu *subMenu, Bool_t on)
If on kTRUE bind subMenu hot keys, otherwise remove key bindings.
Definition TGMenu.cxx:351
TList * fOutLayouts
keeps trace of layouts of hidden menus
Definition TGMenu.h:296
TGFrameElement * GetLastOnLeft()
Returns the last visible menu title on the left of the '>>' in the menu bar.
Definition TGMenu.cxx:264
void PopupConnection()
Connects the corresponding cascaded menu to the proper slots, according to the highlighted menu entry...
Definition TGMenu.cxx:285
TList * fNeededSpace
keeps trace of space needed for hidden menus
Definition TGMenu.h:297
Cursor_t fDefaultCursor
right pointing cursor
Definition TGMenu.h:289
TGMenuBar(const TGMenuBar &)=delete
Bool_t fKeyNavigate
kTRUE if arrow key navigation is on
Definition TGMenu.h:292
TGLayoutHints * fMenuBarMoreLayout
layout of the extra menu
Definition TGMenu.h:294
TList * fTitles
list of menu titles
Definition TGMenu.h:288
Bool_t HandleKey(Event_t *event) override
Handle keyboard events in a menu bar.
Definition TGMenu.cxx:682
virtual void AddTitle(TGMenuTitle *title, TGLayoutHints *l, TGPopupMenu *before=nullptr)
Add popup via created before menu title.
Definition TGMenu.cxx:431
friend class TGPopupMenu
Definition TGMenu.h:284
virtual void AddPopup(TGHotString *s, TGPopupMenu *menu, TGLayoutHints *l, TGPopupMenu *before=nullptr)
Add popup menu to menu bar.
Definition TGMenu.cxx:414
This class contains all information about a menu entry.
Definition TGMenu.h:57
Int_t fEx
Definition TGMenu.h:67
Int_t fStatus
entry status (OR of EMenuEntryState)
Definition TGMenu.h:66
Int_t fEntryId
the entry id (used for event processing)
Definition TGMenu.h:63
UInt_t fEw
Definition TGMenu.h:68
virtual Int_t GetStatus() const
Definition TGMenu.h:86
const TGPicture * fPic
menu entry icon
Definition TGMenu.h:71
void * fUserData
pointer to user data structure
Definition TGMenu.h:64
Int_t fEy
position of entry
Definition TGMenu.h:67
EMenuEntryType GetType() const
Definition TGMenu.h:87
EMenuEntryType fType
type of entry
Definition TGMenu.h:65
UInt_t fEh
width and height of entry
Definition TGMenu.h:68
TGPopupMenu * fPopup
pointer to popup menu (in case of cascading menus)
Definition TGMenu.h:72
This class creates a menu title.
Definition TGMenu.h:234
const char * GetName() const override
Returns name of object.
Definition TGMenu.h:274
TGHotString * fLabel
menu title
Definition TGMenu.h:238
static const TGGC * fgDefaultGC
Definition TGMenu.h:251
void * fTitleData
user data associated with selected item
Definition TGMenu.h:240
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use.
Definition TGMenu.cxx:2140
TGPopupMenu * fMenu
attached popup menu
Definition TGMenu.h:237
void DoRedraw() override
Draw a menu title.
Definition TGMenu.cxx:2084
Int_t fHkeycode
hot key code
Definition TGMenu.h:242
virtual void SetState(Bool_t state)
Set state of menu title.
Definition TGMenu.cxx:2055
GContext_t fNormGC
Definition TGMenu.h:245
static const TGFont * fgDefaultFont
Definition TGMenu.h:249
static const TGGC & GetDefaultGC()
Return default graphics context in use.
Definition TGMenu.cxx:2150
Int_t GetHotKeyCode() const
Definition TGMenu.h:272
static const TGGC * fgDefaultSelectedGC
Definition TGMenu.h:250
TGPopupMenu * GetMenu() const
Definition TGMenu.h:273
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a title menu widget as a C++ statement(s) on output stream out.
Definition TGMenu.cxx:2246
static const TGGC & GetDefaultSelectedGC()
Return default selection graphics context in use.
Definition TGMenu.cxx:2160
TGMenuTitle(const TGMenuTitle &)=delete
virtual void DoSendMessage()
Send final selected menu item to be processed.
Definition TGMenu.cxx:2127
Pixel_t fTextColor
text color
Definition TGMenu.h:244
GContext_t fSelGC
normal and selection graphics contexts
Definition TGMenu.h:245
Bool_t fState
menu title state (active/not active)
Definition TGMenu.h:241
FontStruct_t fFontStruct
font
Definition TGMenu.h:243
Int_t fTitleId
id of selected menu item
Definition TGMenu.h:239
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
virtual void PoppedUp()
Definition TGMenu.h:216
Bool_t HandleCrossing(Event_t *event) override
Handle pointer crossing event in popup menu.
Definition TGMenu.cxx:1363
TList * fEntryList
list of menu entries
Definition TGMenu.h:117
virtual void HideEntry(Int_t id)
Hide entry (hidden entries are not shown in the menu).
Definition TGMenu.cxx:1747
virtual void DefaultEntry(Int_t id)
Set default entry (default entries are drawn with bold text).
Definition TGMenu.cxx:1685
TGPopupMenu(const TGPopupMenu &)=delete
Bool_t fPoppedUp
true if menu is currently popped up
Definition TGMenu.h:121
virtual void AddLabel(TGHotString *s, const TGPicture *p=nullptr, TGMenuEntry *before=nullptr)
Add a menu label to the menu.
Definition TGMenu.cxx:1091
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a popup menu widget as a C++ statement(s) on output stream out.
Definition TGMenu.cxx:2170
static const TGGC * fgDefaultGC
Definition TGMenu.h:139
TGMenuEntry * fCurrent
currently selected menu entry
Definition TGMenu.h:118
void Activate(Bool_t) override
Definition TGMenu.h:209
virtual TGMenuEntry * GetEntry(Int_t id)
Find entry with specified id.
Definition TGMenu.cxx:1893
static const TGGC & GetDefaultSelectedGC()
Return the selection graphics context in use.
Definition TGMenu.cxx:1970
Cursor_t fDefaultCursor
right pointing cursor
Definition TGMenu.h:131
static const TGGC * fgDefaultSelectedBackgroundGC
Definition TGMenu.h:141
virtual Bool_t IsEntryChecked(Int_t id)
Return true if menu item is checked.
Definition TGMenu.cxx:1841
UInt_t fMenuHeight
height of popup menu
Definition TGMenu.h:124
virtual Bool_t IsEntryRChecked(Int_t id)
Return true if menu item has radio check mark.
Definition TGMenu.cxx:1874
virtual void CheckEntryByData(void *user_data)
Check a menu entry (i.e.
Definition TGMenu.cxx:1791
TGSplitButton * fSplitButton
split button (if any)
Definition TGMenu.h:134
virtual void SetMenuBar(TGMenuBar *bar)
Definition TGMenu.h:207
GContext_t fNormGC
normal drawing graphics context
Definition TGMenu.h:126
void DoRedraw() override
Draw popup menu.
Definition TGMenu.cxx:1488
GContext_t fSelGC
graphics context for drawing selections
Definition TGMenu.h:127
virtual void Highlighted(Int_t id)
Definition TGMenu.h:218
static const TGGC & GetDefaultGC()
Return default graphics context.
Definition TGMenu.cxx:1960
void DrawBorder() override
Draw border round popup menu.
Definition TGMenu.cxx:1600
virtual void UnCheckEntries()
Uncheck all entries.
Definition TGMenu.cxx:1815
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:1148
static FontStruct_t GetDefaultFontStruct()
Return the default font structure in use.
Definition TGMenu.cxx:1990
static const TGGC * fgDefaultSelectedGC
Definition TGMenu.h:140
static const TGFont * fgDefaultFont
Definition TGMenu.h:137
virtual void CheckEntry(Int_t id)
Check a menu entry (i.e. add a check mark in front of it).
Definition TGMenu.cxx:1778
UInt_t fEntrySep
separation distance between entries
Definition TGMenu.h:135
TGMenuBar * fMenuBar
menu bar (if any)
Definition TGMenu.h:133
virtual void Reposition()
Reposition entries in popup menu.
Definition TGMenu.cxx:1205
Bool_t HandleTimer(TTimer *t) override
If TPopupDelayTimer times out popup cascading popup menu (if it is still the current entry).
Definition TGMenu.cxx:1463
virtual void DisableEntry(Int_t id)
Disable entry (disabled entries appear in a sunken relieve).
Definition TGMenu.cxx:1720
virtual void DrawEntry(TGMenuEntry *entry)
Draw popup menu entry.
Definition TGMenu.cxx:1502
virtual void EnableEntry(Int_t id)
Enable entry. By default entries are enabled.
Definition TGMenu.cxx:1701
virtual void UnCheckEntryByData(void *user_data)
Uncheck a menu entry (i.e.
Definition TGMenu.cxx:1829
virtual void PoppedDown()
Definition TGMenu.h:217
virtual Bool_t IsEntryHidden(Int_t id)
Return true if menu entry is hidden.
Definition TGMenu.cxx:1764
TTimer * fDelay
delay before popping up cascading menu
Definition TGMenu.h:125
UInt_t fXl
Max width of all menu entries.
Definition TGMenu.h:122
FontStruct_t fFontStruct
font to draw menu entries
Definition TGMenu.h:129
virtual void UnCheckEntry(Int_t id)
Uncheck menu entry (i.e. remove check mark).
Definition TGMenu.cxx:1803
virtual Int_t EndMenu(void *&userData)
Close menu and return ID of selected menu item.
Definition TGMenu.cxx:1285
virtual TGMenuEntry * GetCurrent() const
Definition TGMenu.h:198
virtual void DeleteEntry(Int_t id)
Delete entry with specified id from menu.
Definition TGMenu.cxx:1922
static FontStruct_t GetHilightFontStruct()
Return the font structure in use for highlighted menu entries.
Definition TGMenu.cxx:2000
const TGWindow * fMsgWindow
window which handles menu events
Definition TGMenu.h:132
static const TGGC & GetDefaultSelectedBackgroundGC()
Return the selection background graphics context in use.
Definition TGMenu.cxx:1980
virtual void AddSeparator(TGMenuEntry *before=nullptr)
Add a menu separator to the menu.
Definition TGMenu.cxx:1056
Bool_t fStick
stick mode (popup menu stays sticked on screen)
Definition TGMenu.h:119
FontStruct_t fHifontStruct
font to draw highlighted entries
Definition TGMenu.h:130
void DrawRCheckMark(GContext_t gc, Int_t l, Int_t t, Int_t r, Int_t b)
Draw radio check mark. Used for radio button type menu entries.
Definition TGMenu.cxx:1666
void DrawCheckMark(GContext_t gc, Int_t l, Int_t t, Int_t r, Int_t b)
Draw check mark. Used for checked button type menu entries.
Definition TGMenu.cxx:1647
virtual void RCheckEntry(Int_t id, Int_t IDfirst, Int_t IDlast)
Radio-select entry (note that they cannot be unselected, the selection must be moved to another entry...
Definition TGMenu.cxx:1856
virtual void AddEntry(TGHotString *s, Int_t id, void *ud=nullptr, const TGPicture *p=nullptr, TGMenuEntry *before=nullptr)
Add a menu entry.
Definition TGMenu.cxx:986
UInt_t fMenuWidth
width of popup menu
Definition TGMenu.h:123
virtual void PlaceMenu(Int_t x, Int_t y, Bool_t stick_mode, Bool_t grab_pointer)
Popup a popup menu.
Definition TGMenu.cxx:1237
~TGPopupMenu() override
Delete a popup menu.
Definition TGMenu.cxx:971
const TList * GetListOfEntries() const
Definition TGMenu.h:200
virtual void Activated(Int_t id)
Definition TGMenu.h:219
GContext_t fSelbackGC
graphics context for drawing selection background
Definition TGMenu.h:128
Bool_t HandleMotion(Event_t *event) override
Handle pointer motion event in popup menu.
Definition TGMenu.cxx:1390
Bool_t HandleButton(Event_t *event) override
Handle button event in the popup menu.
Definition TGMenu.cxx:1334
static const TGFont * fgHilightFont
Definition TGMenu.h:138
Bool_t fHasGrab
true if menu has grabbed pointer
Definition TGMenu.h:120
void DrawTrianglePattern(GContext_t gc, Int_t l, Int_t t, Int_t r, Int_t b)
Draw triangle pattern.
Definition TGMenu.cxx:1627
virtual Bool_t IsEntryEnabled(Int_t id)
Return true if menu entry is enabled.
Definition TGMenu.cxx:1732
Bool_t fKeyNavigate
kTRUE if key navigation is being used
Definition TGButton.h:404
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition TGString.h:20
Int_t GetLength() const
Definition TGString.h:29
const char * GetString() const
Definition TGString.h:30
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition TGWindow.cxx:150
virtual void RequestFocus()
request focus
Definition TGWindow.cxx:230
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
virtual void DestroyWindow()
destroy window
Definition TGWindow.cxx:190
const TGWindow * GetParent() const
Definition TGWindow.h:83
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:334
void Reset()
A doubly linked list.
Definition TList.h:38
TObject * After(const TObject *obj) const override
Returns the object after object obj.
Definition TList.cxx:327
TObject * Before(const TObject *obj) const override
Returns the object before object obj.
Definition TList.cxx:368
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:575
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:819
void AddLast(TObject *obj) override
Add object at the end of the list.
Definition TList.cxx:149
TObject * Last() const override
Return the last object in the list. Returns 0 when list is empty.
Definition TList.cxx:690
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:656
void AddBefore(const TObject *before, TObject *obj) override
Insert object before object before in the list.
Definition TList.cxx:193
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:467
SCoord_t fY
Definition TPoint.h:36
SCoord_t fX
Definition TPoint.h:35
Bool_t Notify() override
Notify when timer times out and reset the timer.
Definition TGMenu.cxx:105
TGPopupMenu * fPopup
Definition TGMenu.cxx:96
TPopupDelayTimer(TGPopupMenu *p, Long_t ms)
Definition TGMenu.cxx:98
TQConnection class is an internal class, used in the object communication mechanism.
TList * GetListOfSignals() const
Definition TQObject.h:88
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition TQObject.cxx:865
Bool_t Disconnect(const char *signal=nullptr, void *receiver=nullptr, const char *slot=nullptr)
Disconnects signal of this object from slot of receiver.
Basic string class.
Definition TString.h:138
Ssiz_t Length() const
Definition TString.h:425
const char * Data() const
Definition TString.h:384
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:659
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1285
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1073
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition TSystem.cxx:469
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
void Reset()
Reset the timer.
Definition TTimer.cxx:162
void Remove() override
Definition TTimer.h:86
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:251
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
Int_t fY
pointer x, y coordinates in event window
Definition GuiTypes.h:178
UInt_t fState
key or button mask
Definition GuiTypes.h:181
Int_t fX
Definition GuiTypes.h:178
UInt_t fCode
key or button code
Definition GuiTypes.h:180
Graphics context structure.
Definition GuiTypes.h:224
Point structure (maps to the X11 XPoint structure)
Definition GuiTypes.h:356
Used for drawing line segments (maps to the X11 XSegments structure)
Definition GuiTypes.h:351
Attributes that can be used when creating or changing a window.
Definition GuiTypes.h:93
TMarker m
Definition textangle.C:8
TLine l
Definition textangle.C:4