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 gVirtualX->SetWindowHint(fId, TVirtualX::kHintPopup);
965
967}
968
969////////////////////////////////////////////////////////////////////////////////
970/// Delete a popup menu.
971
973{
974 gClient->UnregisterPopup(this);
975
977 delete fEntryList;
978 delete fDelay;
979}
980
981////////////////////////////////////////////////////////////////////////////////
982/// Add a menu entry. The hotstring is adopted by the menu (actually by
983/// the TGMenuEntry) and deleted when possible. A possible picture is
984/// borrowed from the picture pool and therefore not adopted.
985/// If before is not 0, the entry will be added before it.
986
988 const TGPicture *p, TGMenuEntry *before)
989{
990 if (!s) return;
992 Ssiz_t tab = s->Index('\t');
993 if (tab > 0) {
994 TString ts(s->Data());
995 TString shortcut = ts(tab+1, s->Length());
996 nw->fShortcut = new TGString(shortcut.Data());
997 nw->fLabel = new TGHotString(*s);
998 nw->fLabel->Remove(tab);
999 }
1000 else {
1001 nw->fLabel = s;
1002 }
1003 nw->fPic = p;
1004 nw->fType = kMenuEntry;
1005 nw->fEntryId = id;
1006 nw->fUserData = ud;
1007 nw->fPopup = 0;
1008 nw->fStatus = kMenuEnableMask;
1009 nw->fEx = 2;
1010 nw->fEy = fMenuHeight-2;
1011
1012 if (before)
1014 else
1015 fEntryList->Add(nw);
1016
1017 UInt_t tw, ph = 0, pw = 0;
1018 tw = gVirtualX->TextWidth(fHifontStruct, s->GetString(), s->GetLength());
1019 if (p) {
1020 ph = p->GetHeight();
1021 pw = p->GetWidth();
1022 if (pw+12 > fXl) { fMenuWidth += pw+12-fXl; fXl = pw+12; }
1023 }
1024 if (nw->fShortcut) {
1025 tw += 10;
1026 delete s;
1027 }
1028
1030 nw->fEw = tw + pw /*+8*/+18+12;
1032 gVirtualX->GetFontProperties(fHifontStruct, max_ascent, max_descent);
1034 if (nw->fEh < ph+fEntrySep) nw->fEh = ph+fEntrySep;
1035 fMenuHeight += nw->fEh;
1036
1037 if (before)
1038 Reposition();
1039 else
1041}
1042
1043////////////////////////////////////////////////////////////////////////////////
1044/// Add a menu entry. The string s in not adopted.
1045/// If before is not 0, the entry will be added before it.
1046
1047void TGPopupMenu::AddEntry(const char *s, Int_t id, void *ud,
1048 const TGPicture *p, TGMenuEntry *before)
1049{
1050 AddEntry(new TGHotString(s), id, ud, p, before);
1051}
1052
1053////////////////////////////////////////////////////////////////////////////////
1054/// Add a menu separator to the menu.
1055/// If before is not 0, the entry will be added before it.
1056
1058{
1059 TGMenuEntry *nw = new TGMenuEntry;
1060
1061 nw->fLabel = 0;
1062 nw->fPic = 0;
1063 nw->fType = kMenuSeparator;
1064 nw->fEntryId = -1;
1065 nw->fUserData = 0;
1066 nw->fPopup = 0;
1067 nw->fStatus = kMenuEnableMask;
1068 nw->fEx = 2;
1069 nw->fEy = fMenuHeight-2;
1070
1071 if (before)
1073 else
1074 fEntryList->Add(nw);
1075
1076 nw->fEw = 0;
1077 nw->fEh = 4;
1078 fMenuHeight += nw->fEh;
1079
1080 if (before)
1081 Reposition();
1082 else
1084}
1085
1086////////////////////////////////////////////////////////////////////////////////
1087/// Add a menu label to the menu. The hotstring is adopted by the menu
1088/// (actually by the TGMenuEntry) and deleted when possible. A possible
1089/// picture is borrowed from the picture pool and therefore not adopted.
1090/// If before is not 0, the entry will be added before it.
1091
1094{
1095 TGMenuEntry *nw = new TGMenuEntry;
1096
1097 nw->fLabel = s;
1098 nw->fPic = p;
1099 nw->fType = kMenuLabel;
1100 nw->fEntryId = -1;
1101 nw->fUserData = 0;
1102 nw->fPopup = 0;
1103 nw->fStatus = kMenuEnableMask | kMenuDefaultMask;
1104 nw->fEx = 2;
1105 nw->fEy = fMenuHeight-2;
1106
1107 if (before)
1109 else
1110 fEntryList->Add(nw);
1111
1112 UInt_t tw, ph = 0, pw = 0;
1113 tw = gVirtualX->TextWidth(fHifontStruct, s->GetString(), s->GetLength());
1114 if (p) {
1115 ph = p->GetHeight();
1116 pw = p->GetWidth();
1117 if (pw+12 > fXl) { fMenuWidth += pw+12-fXl; fXl = pw+12; }
1118 }
1119
1121 nw->fEw = tw + pw /*+8*/+18+12;
1123 gVirtualX->GetFontProperties(fHifontStruct, max_ascent, max_descent);
1125 if (nw->fEh < ph+fEntrySep) nw->fEh = ph+fEntrySep;
1126 fMenuHeight += nw->fEh;
1127
1128 if (before)
1129 Reposition();
1130 else
1132}
1133
1134////////////////////////////////////////////////////////////////////////////////
1135/// Add a menu label to the menu. The string s in not adopted.
1136/// If before is not 0, the entry will be added before it.
1137
1138void TGPopupMenu::AddLabel(const char *s, const TGPicture *p,
1140{
1141 AddLabel(new TGHotString(s), p, before);
1142}
1143
1144////////////////////////////////////////////////////////////////////////////////
1145/// Add a (cascading) popup menu to a popup menu. The hotstring is adopted
1146/// by the menu (actually by the TGMenuEntry) and deleted when possible.
1147/// If before is not 0, the entry will be added before it.
1148
1150 TGMenuEntry *before, const TGPicture *p)
1151{
1152 TGMenuEntry *nw = new TGMenuEntry;
1153
1154 nw->fLabel = s;
1155 nw->fPic = p;
1156 nw->fType = kMenuPopup;
1157 nw->fEntryId = -2;
1158 nw->fUserData = 0;
1159 nw->fPopup = popup;
1160 nw->fStatus = kMenuEnableMask;
1161 nw->fEx = 2;
1162 nw->fEy = fMenuHeight-2;
1163
1164 if (before)
1166 else
1167 fEntryList->Add(nw);
1168
1169 UInt_t tw = gVirtualX->TextWidth(fHifontStruct, s->GetString(),
1170 s->GetLength());
1171
1172 UInt_t ph = 0, pw = 8;
1173 if (p) {
1174 ph = p->GetHeight();
1175 pw = p->GetWidth();
1176 if (pw+12 > fXl) { fMenuWidth += pw+12-fXl; fXl = pw+12; }
1177 }
1179 nw->fEw = tw + pw+18+12;
1181 gVirtualX->GetFontProperties(fHifontStruct, max_ascent, max_descent);
1183 if (nw->fEh < ph+fEntrySep) nw->fEh = ph+fEntrySep;
1184 fMenuHeight += nw->fEh;
1185
1186 if (before)
1187 Reposition();
1188 else
1190}
1191
1192////////////////////////////////////////////////////////////////////////////////
1193/// Add a (cascading) popup menu to a popup menu. The string s is not
1194/// adopted. If before is not 0, the entry will be added before it.
1195
1197 TGMenuEntry *before, const TGPicture *p)
1198{
1199 AddPopup(new TGHotString(s), popup, before, p);
1200}
1201
1202////////////////////////////////////////////////////////////////////////////////
1203/// Reposition entries in popup menu. Called after menu item has been
1204/// hidden or removed or inserted at a specified location.
1205
1207{
1208 // in case any of these magic values is changes, check also the ctor.
1209 fMenuHeight = 6;
1210 fMenuWidth = 8;
1211 fXl = 16;
1212
1213 TGMenuEntry *ptr;
1214 TIter next(fEntryList);
1215
1216 while ((ptr = (TGMenuEntry *) next())) {
1217
1218 if (ptr->fStatus & kMenuHideMask) continue;
1219
1220 if (ptr->fPic) {
1221 UInt_t pw = ptr->fPic->GetWidth();
1222 if (pw+12 > fXl) { fMenuWidth += pw+12-fXl; fXl = pw+12; }
1223 }
1224 ptr->fEx = 2;
1225 ptr->fEy = fMenuHeight-2;
1227 fMenuHeight += ptr->fEh;
1228 }
1230}
1231
1232////////////////////////////////////////////////////////////////////////////////
1233/// Popup a popup menu. If stick mode is true keep the menu up. If
1234/// grab_pointer is true the pointer will be grabbed, which means that
1235/// all pointer events will go to the popup menu, independent of in
1236/// which window the pointer is.
1237
1239{
1240 void *ud;
1241 EndMenu(ud);
1242
1243 Int_t rx, ry;
1244 UInt_t rw, rh;
1245
1247 fCurrent = 0;
1248
1249 // Parent is root window for a popup menu
1250 gVirtualX->GetWindowSize(fParent->GetId(), rx, ry, rw, rh);
1251
1252 if (gVirtualX->InheritsFrom("TGWin32")) {
1253 if ((x > 0) && ((x + abs(rx) + (Int_t)fMenuWidth) > (Int_t)rw))
1254 x = rw - abs(rx) - fMenuWidth;
1255 if ((y > 0) && (y + abs(ry) + (Int_t)fMenuHeight > (Int_t)rh))
1256 y = rh - fMenuHeight;
1257 } else {
1258 if (x < 0) x = 0;
1259 if (x + fMenuWidth > rw) x = rw - fMenuWidth;
1260 if (y < 0) y = 0;
1261 if (y + fMenuHeight > rh) y = rh - fMenuHeight;
1262 }
1263
1264 Move(x, y);
1265 MapRaised();
1266
1267 if (grab_pointer) {
1270 fHasGrab = kTRUE;
1271 } else {
1272 fHasGrab = kFALSE;
1273 }
1274
1275 fPoppedUp = kTRUE;
1276 PoppedUp();
1278
1279 fClient->RegisterPopup(this);
1280}
1281
1282////////////////////////////////////////////////////////////////////////////////
1283/// Close menu and return ID of selected menu item.
1284/// In case of cascading menus, recursively close all menus.
1285
1287{
1288 Int_t id;
1289
1290 if (fDelay) fDelay->Remove();
1291
1292 // destroy any cascaded children and get any ID
1293
1294 if (fCurrent != 0) {
1295
1296 // deactivate the entry
1298
1299 if ((fCurrent->fType == kMenuPopup) && fCurrent->fPopup) {
1301 } else {
1302 // return the ID if the entry is enabled, otherwise -1
1304 id = fCurrent->fEntryId;
1306 } else {
1307 id = -1;
1308 userData = 0;
1309 }
1310 }
1311
1312 } else {
1313 // if no entry selected...
1314 id = -1;
1315 userData = 0;
1316 }
1317
1318 // then unmap itself
1319 UnmapWindow();
1320
1321 gClient->UnregisterPopup(this);
1323
1324 if (fPoppedUp) {
1325 fPoppedUp = kFALSE;
1326 PoppedDown();
1327 }
1328
1329 return id;
1330}
1331
1332////////////////////////////////////////////////////////////////////////////////
1333/// Handle button event in the popup menu.
1334
1336{
1337 int id;
1338 void *ud = 0;
1339
1340 if (event->fType == kButtonRelease) {
1341 if (fStick) {
1342 fStick = kFALSE;
1343 return kTRUE;
1344 }
1345 //if (fCurrent != 0)
1346 // if (fCurrent->fType == kMenuPopup) return kTRUE;
1347 id = EndMenu(ud);
1348 if (fHasGrab) gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab
1349 if (fCurrent != 0) {
1353 (Longptr_t)ud);
1354 Activated(id);
1355 }
1356 }
1357 }
1358 return kTRUE;
1359}
1360
1361////////////////////////////////////////////////////////////////////////////////
1362/// Handle pointer crossing event in popup menu.
1363
1365{
1366 if (event->fType == kEnterNotify) {
1367
1368 TGMenuEntry *ptr;
1369 TIter next(fEntryList);
1370
1371 while ((ptr = (TGMenuEntry *) next())) {
1372 if (ptr->fStatus & kMenuHideMask) continue;
1373
1374 if ((event->fX >= ptr->fEx) && (event->fX <= ptr->fEx+(Int_t)fMenuWidth-10) &&
1375 (event->fY >= ptr->fEy) && (event->fY <= ptr->fEy+(Int_t)ptr->fEh))
1376 break;
1377 }
1378 Activate(ptr);
1379 } else {
1380 Activate((TGMenuEntry*)0);
1381 }
1384
1385 return kTRUE;
1386}
1387
1388////////////////////////////////////////////////////////////////////////////////
1389/// Handle pointer motion event in popup menu.
1390
1392{
1393 TGFrame::HandleMotion(event);
1394 static Int_t twice = 0;
1395 TGMenuEntry *ptr;
1396 TIter next(fEntryList);
1397
1398 if (twice < 2) {
1399 // hack to eat mouse move events generated by Windows when
1400 // pressing/releasing a mouse button
1401 ++twice;
1402 }
1403 else {
1404 twice = 0;
1405 fStick = kFALSE; // be careful with this, use some threshold
1406 }
1407 while ((ptr = (TGMenuEntry *) next())) {
1408 if (ptr->fStatus & kMenuHideMask) continue;
1409
1410 if ((event->fX >= ptr->fEx) && (event->fX <= ptr->fEx+(Int_t)fMenuWidth-4) && //fMenuWidth-10??
1411 (event->fY >= ptr->fEy) && (event->fY <= ptr->fEy+(Int_t)ptr->fEh))
1412 break;
1413 }
1414 Activate(ptr);
1415
1416 return kTRUE;
1417}
1418
1419////////////////////////////////////////////////////////////////////////////////
1420/// Activate a menu entry in a popup menu.
1421
1423{
1424 if (entry == fCurrent) return;
1425
1426 //-- Deactivate the current entry
1427
1428 if (fCurrent != 0) {
1429 void *ud;
1430 if (entry == 0 && fCurrent->fType == kMenuPopup) return;
1431 if ((fCurrent->fType == kMenuPopup) && fCurrent->fPopup)
1435 }
1436
1437 if (fDelay) fDelay->Remove();
1438
1439 //-- Activate the new one
1440
1441 if (entry) {
1442 entry->fStatus |= kMenuActiveMask;
1444 if (entry->fType == kMenuPopup) {
1445 if (!fDelay) fDelay = new TPopupDelayTimer(this, 350);
1446 fDelay->Reset();
1448 // after delay expires it will popup the cascading popup menu
1449 // iff it is still the current entry
1450 } else if (entry->fType == kMenuEntry) {
1451 // test...
1453 entry->fEntryId, (Longptr_t)entry->fUserData);
1454 Highlighted(entry->fEntryId);
1455 }
1456 }
1457 fCurrent = entry;
1458}
1459
1460////////////////////////////////////////////////////////////////////////////////
1461/// If TPopupDelayTimer times out popup cascading popup menu (if it is
1462/// still the current entry).
1463
1465{
1466 if (fCurrent != 0) {
1467 if ((fCurrent->fType == kMenuPopup) && fCurrent->fPopup) {
1468 Int_t ax, ay;
1470
1471 gVirtualX->TranslateCoordinates(fId,
1472 (fCurrent->fPopup->GetParent())->GetId(),
1474 ax, ay, wdummy);
1475#ifdef R__HAS_COCOA
1476 gVirtualX->SetWMTransientHint(fCurrent->fPopup->GetId(), GetId());
1477#endif
1479 }
1480 }
1481 fDelay->Remove();
1482
1483 return kTRUE;
1484}
1485
1486////////////////////////////////////////////////////////////////////////////////
1487/// Draw popup menu.
1488
1490{
1492
1493 TGMenuEntry *ptr;
1494 TIter next(fEntryList);
1495
1496 while ((ptr = (TGMenuEntry *) next()))
1497 DrawEntry(ptr);
1498}
1499
1500////////////////////////////////////////////////////////////////////////////////
1501/// Draw popup menu entry.
1502
1504{
1505 FontStruct_t font;
1507
1508 if (entry->fStatus & kMenuHideMask)
1509 return;
1510
1511 if (entry->fStatus & kMenuDefaultMask) {
1512 font = fHifontStruct;
1513 gcval.fMask = kGCFont;
1514 gcval.fFont = gVirtualX->GetFontHandle(font);
1515 gVirtualX->ChangeGC(fNormGC, &gcval);
1516 gVirtualX->ChangeGC(fSelGC, &gcval);
1517 } else {
1518 font = fFontStruct;
1519 }
1520
1521 UInt_t tw = 0;
1523 gVirtualX->GetFontProperties(font, max_ascent, max_descent);
1524 int tx = entry->fEx + fXl;
1525 // center text
1526 int offset = (entry->fEh - (max_ascent + max_descent)) / 2;
1527 int ty = entry->fEy + max_ascent + offset - 1;
1528 if (entry->fShortcut)
1529 tw = 7 + gVirtualX->TextWidth(fFontStruct, entry->fShortcut->Data(), entry->fShortcut->Length());
1530
1531 switch (entry->fType) {
1532 case kMenuPopup:
1533 case kMenuLabel:
1534 case kMenuEntry:
1535 if ((entry->fStatus & kMenuActiveMask) && entry->fType != kMenuLabel) {
1536 gVirtualX->FillRectangle(fId, fSelbackGC, entry->fEx+1, entry->fEy-1,
1537 fMenuWidth-6, entry->fEh);
1538 if (gClient->GetStyle() > 1)
1539 gVirtualX->DrawRectangle(fId, GetShadowGC()(), entry->fEx+1, entry->fEy-2,
1540 fMenuWidth-7, entry->fEh);
1541 if (entry->fType == kMenuPopup)
1543 if (entry->fStatus & kMenuCheckedMask)
1544 DrawCheckMark(fSelGC, 6, entry->fEy+fEntrySep, 14, entry->fEy+11);
1545 if (entry->fStatus & kMenuRadioMask)
1546 DrawRCheckMark(fSelGC, 6, entry->fEy+fEntrySep, 14, entry->fEy+11);
1547 if (entry->fPic != 0)
1548 entry->fPic->Draw(fId, fSelGC, 8, entry->fEy+1);
1549 entry->fLabel->Draw(fId,
1550 (entry->fStatus & kMenuEnableMask) ? fSelGC : GetShadowGC()(),
1551 tx, ty);
1552 if (entry->fShortcut)
1553 entry->fShortcut->Draw(fId, (entry->fStatus & kMenuEnableMask) ? fSelGC : GetShadowGC()(),
1554 fMenuWidth - tw, ty);
1555 } else {
1556 if (gClient->GetStyle() > 1)
1557 gVirtualX->DrawRectangle(fId, GetBckgndGC()(), entry->fEx+1, entry->fEy-2,
1558 fMenuWidth-7, entry->fEh);
1559 gVirtualX->FillRectangle(fId, GetBckgndGC()(), entry->fEx+1, entry->fEy-1,
1560 fMenuWidth-6, entry->fEh);
1561 if (entry->fType == kMenuPopup)
1563 if (entry->fStatus & kMenuCheckedMask)
1564 DrawCheckMark(fNormGC, 6, entry->fEy+fEntrySep, 14, entry->fEy+11);
1565 if (entry->fStatus & kMenuRadioMask)
1566 DrawRCheckMark(fNormGC, 6, entry->fEy+fEntrySep, 14, entry->fEy+11);
1567 if (entry->fPic != 0)
1568 entry->fPic->Draw(fId, fNormGC, 8, entry->fEy+1);
1569 if (entry->fStatus & kMenuEnableMask) {
1570 entry->fLabel->Draw(fId, fNormGC, tx, ty);
1571 if (entry->fShortcut)
1572 entry->fShortcut->Draw(fId, fNormGC, fMenuWidth - tw, ty);
1573 } else {
1574 entry->fLabel->Draw(fId, GetHilightGC()(), tx+1, ty+1);
1575 entry->fLabel->Draw(fId, GetShadowGC()(), tx, ty);
1576 if (entry->fShortcut) {
1577 entry->fShortcut->Draw(fId, GetHilightGC()(), fMenuWidth - tw+1, ty+1);
1578 entry->fShortcut->Draw(fId, GetShadowGC()(), fMenuWidth - tw, ty);
1579 }
1580 }
1581 }
1582 break;
1583
1584 case kMenuSeparator:
1585 gVirtualX->DrawLine(fId, GetShadowGC()(), 2, entry->fEy, fMenuWidth-fEntrySep, entry->fEy);
1586 gVirtualX->DrawLine(fId, GetHilightGC()(), 2, entry->fEy+1, fMenuWidth-fEntrySep, entry->fEy+1);
1587 break;
1588 }
1589
1590 // restore font
1591 if (entry->fStatus & kMenuDefaultMask) {
1592 gcval.fFont = gVirtualX->GetFontHandle(fFontStruct);
1593 gVirtualX->ChangeGC(fNormGC, &gcval);
1594 gVirtualX->ChangeGC(fSelGC, &gcval);
1595 }
1596}
1597
1598////////////////////////////////////////////////////////////////////////////////
1599/// Draw border round popup menu.
1600
1602{
1603 if (gClient->GetStyle() > 0) {
1604 // new modern (flat) version
1605 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, 0, fMenuHeight-1);
1606 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, fMenuHeight-1, fMenuWidth-1, fMenuHeight-1);
1607 gVirtualX->DrawLine(fId, GetShadowGC()(), fMenuWidth-1, fMenuHeight-1, fMenuWidth-1, 0);
1608 gVirtualX->DrawLine(fId, GetShadowGC()(), fMenuWidth-1, 0, 0, 0);
1609 }
1610 else {
1611 // old (raised frame) version
1612 gVirtualX->DrawLine(fId, GetBckgndGC()(), 0, 0, fMenuWidth-2, 0);
1613 gVirtualX->DrawLine(fId, GetBckgndGC()(), 0, 0, 0, fMenuHeight-2);
1614 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 1, fMenuWidth-fEntrySep, 1);
1615 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 1, 1, fMenuHeight-fEntrySep);
1616
1617 gVirtualX->DrawLine(fId, GetShadowGC()(), 1, fMenuHeight-2, fMenuWidth-2, fMenuHeight-2);
1618 gVirtualX->DrawLine(fId, GetShadowGC()(), fMenuWidth-2, fMenuHeight-2, fMenuWidth-2, 1);
1619 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, fMenuHeight-1, fMenuWidth-1, fMenuHeight-1);
1620 gVirtualX->DrawLine(fId, GetBlackGC()(), fMenuWidth-1, fMenuHeight-1, fMenuWidth-1, 0);
1621 }
1622}
1623
1624////////////////////////////////////////////////////////////////////////////////
1625/// Draw triangle pattern. Used for menu entries that are of type
1626/// kMenuPopup (i.e. cascading menus).
1627
1629 Int_t r, Int_t b)
1630{
1631 Point_t points[3];
1632
1633 int m = (t + b) >> 1;
1634
1635 points[0].fX = l;
1636 points[0].fY = t;
1637 points[1].fX = l;
1638 points[1].fY = b;
1639 points[2].fX = r;
1640 points[2].fY = m;
1641
1642 gVirtualX->FillPolygon(fId, gc, points, 3);
1643}
1644
1645////////////////////////////////////////////////////////////////////////////////
1646/// Draw check mark. Used for checked button type menu entries.
1647
1649{
1650 Segment_t seg[6];
1651
1652 t = (t + b - 8) >> 1; ++t;
1653
1654 seg[0].fX1 = 1+l; seg[0].fY1 = 3+t; seg[0].fX2 = 3+l; seg[0].fY2 = 5+t;
1655 seg[1].fX1 = 1+l; seg[1].fY1 = 4+t; seg[1].fX2 = 3+l; seg[1].fY2 = 6+t;
1656 seg[2].fX1 = 1+l; seg[2].fY1 = 5+t; seg[2].fX2 = 3+l; seg[2].fY2 = 7+t;
1657 seg[3].fX1 = 3+l; seg[3].fY1 = 5+t; seg[3].fX2 = 7+l; seg[3].fY2 = 1+t;
1658 seg[4].fX1 = 3+l; seg[4].fY1 = 6+t; seg[4].fX2 = 7+l; seg[4].fY2 = 2+t;
1659 seg[5].fX1 = 3+l; seg[5].fY1 = 7+t; seg[5].fX2 = 7+l; seg[5].fY2 = 3+t;
1660
1661 gVirtualX->DrawSegments(fId, gc, seg, 6);
1662}
1663
1664////////////////////////////////////////////////////////////////////////////////
1665/// Draw radio check mark. Used for radio button type menu entries.
1666
1668{
1669 Segment_t seg[5];
1670
1671 t = (t + b - 5) >> 1; ++t;
1672 l = (l + r - 5) >> 1; ++l;
1673
1674 seg[0].fX1 = 1+l; seg[0].fY1 = 0+t; seg[0].fX2 = 3+l; seg[0].fY2 = 0+t;
1675 seg[1].fX1 = 0+l; seg[1].fY1 = 1+t; seg[1].fX2 = 4+l; seg[1].fY2 = 1+t;
1676 seg[2].fX1 = 0+l; seg[2].fY1 = 2+t; seg[2].fX2 = 4+l; seg[2].fY2 = 2+t;
1677 seg[3].fX1 = 0+l; seg[3].fY1 = 3+t; seg[3].fX2 = 4+l; seg[3].fY2 = 3+t;
1678 seg[4].fX1 = 1+l; seg[4].fY1 = 4+t; seg[4].fX2 = 3+l; seg[4].fY2 = 4+t;
1679
1680 gVirtualX->DrawSegments(fId, gc, seg, 5);
1681}
1682
1683////////////////////////////////////////////////////////////////////////////////
1684/// Set default entry (default entries are drawn with bold text).
1685
1687{
1688 TGMenuEntry *ptr;
1689 TIter next(fEntryList);
1690
1691 while ((ptr = (TGMenuEntry *) next())) {
1692 if (ptr->fEntryId == id)
1693 ptr->fStatus |= kMenuDefaultMask;
1694 else
1695 ptr->fStatus &= ~kMenuDefaultMask;
1696 }
1697}
1698
1699////////////////////////////////////////////////////////////////////////////////
1700/// Enable entry. By default entries are enabled.
1701
1703{
1704 TGMenuEntry *ptr;
1705 TIter next(fEntryList);
1706
1707 while ((ptr = (TGMenuEntry *) next()))
1708 if (ptr->fEntryId == id) {
1709 ptr->fStatus |= kMenuEnableMask;
1710 if (ptr->fStatus & kMenuHideMask) {
1711 ptr->fStatus &= ~kMenuHideMask;
1712 Reposition();
1713 }
1714 break;
1715 }
1716}
1717
1718////////////////////////////////////////////////////////////////////////////////
1719/// Disable entry (disabled entries appear in a sunken relieve).
1720
1722{
1723 TGMenuEntry *ptr;
1724 TIter next(fEntryList);
1725
1726 while ((ptr = (TGMenuEntry *) next()))
1727 if (ptr->fEntryId == id) { ptr->fStatus &= ~kMenuEnableMask; break; }
1728}
1729
1730////////////////////////////////////////////////////////////////////////////////
1731/// Return true if menu entry is enabled.
1732
1734{
1735 TGMenuEntry *ptr;
1736 TIter next(fEntryList);
1737
1738 while ((ptr = (TGMenuEntry *) next()))
1739 if (ptr->fEntryId == id)
1740 return (ptr->fStatus & kMenuEnableMask) ? kTRUE : kFALSE;
1741 return kFALSE;
1742}
1743
1744////////////////////////////////////////////////////////////////////////////////
1745/// Hide entry (hidden entries are not shown in the menu).
1746/// To enable a hidden entry call EnableEntry().
1747
1749{
1750 TGMenuEntry *ptr;
1751 TIter next(fEntryList);
1752
1753 while ((ptr = (TGMenuEntry *) next()))
1754 if (ptr->fEntryId == id) {
1755 ptr->fStatus |= kMenuHideMask;
1756 ptr->fStatus &= ~kMenuEnableMask;
1757 Reposition();
1758 break;
1759 }
1760}
1761
1762////////////////////////////////////////////////////////////////////////////////
1763/// Return true if menu entry is hidden.
1764
1766{
1767 TGMenuEntry *ptr;
1768 TIter next(fEntryList);
1769
1770 while ((ptr = (TGMenuEntry *) next()))
1771 if (ptr->fEntryId == id)
1772 return (ptr->fStatus & kMenuHideMask) ? kTRUE : kFALSE;
1773 return kFALSE;
1774}
1775
1776////////////////////////////////////////////////////////////////////////////////
1777/// Check a menu entry (i.e. add a check mark in front of it).
1778
1780{
1781 TGMenuEntry *ptr;
1782 TIter next(fEntryList);
1783
1784 while ((ptr = (TGMenuEntry *) next()))
1785 if (ptr->fEntryId == id) { ptr->fStatus |= kMenuCheckedMask; break; }
1786}
1787
1788////////////////////////////////////////////////////////////////////////////////
1789/// Check a menu entry (i.e. add a check mark in front of it).
1790/// The input argument is user data associated with entry
1791
1793{
1794 TGMenuEntry *ptr;
1795 TIter next(fEntryList);
1796
1797 while ((ptr = (TGMenuEntry *) next()))
1798 if (ptr->fUserData == user_data) { ptr->fStatus |= kMenuCheckedMask; break; }
1799}
1800
1801////////////////////////////////////////////////////////////////////////////////
1802/// Uncheck menu entry (i.e. remove check mark).
1803
1805{
1806 TGMenuEntry *ptr;
1807 TIter next(fEntryList);
1808
1809 while ((ptr = (TGMenuEntry *) next()))
1810 if (ptr->fEntryId == id) { ptr->fStatus &= ~kMenuCheckedMask; break; }
1811}
1812
1813////////////////////////////////////////////////////////////////////////////////
1814/// Uncheck all entries.
1815
1817{
1818 TGMenuEntry *ptr;
1819 TIter next(fEntryList);
1820
1821 while ((ptr = (TGMenuEntry *) next())) {
1822 ptr->fStatus &= ~kMenuCheckedMask;
1823 }
1824}
1825
1826////////////////////////////////////////////////////////////////////////////////
1827/// Uncheck a menu entry (i.e. remove check mark in front of it).
1828/// The input argument is user data associated with entry
1829
1831{
1832 TGMenuEntry *ptr;
1833 TIter next(fEntryList);
1834
1835 while ((ptr = (TGMenuEntry *) next()))
1836 if (ptr->fUserData == user_data) { ptr->fStatus &= ~kMenuCheckedMask; break; }
1837}
1838
1839////////////////////////////////////////////////////////////////////////////////
1840/// Return true if menu item is checked.
1841
1843{
1844 TGMenuEntry *ptr;
1845 TIter next(fEntryList);
1846
1847 while ((ptr = (TGMenuEntry *) next()))
1848 if (ptr->fEntryId == id)
1849 return (ptr->fStatus & kMenuCheckedMask) ? kTRUE : kFALSE;
1850 return kFALSE;
1851}
1852
1853////////////////////////////////////////////////////////////////////////////////
1854/// Radio-select entry (note that they cannot be unselected,
1855/// the selection must be moved to another entry instead).
1856
1858{
1859 TGMenuEntry *ptr;
1860 TIter next(fEntryList);
1861
1862 while ((ptr = (TGMenuEntry *) next()))
1863 if (ptr->fEntryId == id)
1865 else
1866 if (ptr->fEntryId >= IDfirst && ptr->fEntryId <= IDlast) {
1867 ptr->fStatus &= ~kMenuRadioMask;
1869 }
1870}
1871
1872////////////////////////////////////////////////////////////////////////////////
1873/// Return true if menu item has radio check mark.
1874
1876{
1877 TGMenuEntry *ptr;
1878 TIter next(fEntryList);
1879
1880 while ((ptr = (TGMenuEntry *) next()))
1881 if (ptr->fEntryId == id)
1882 return (ptr->fStatus & kMenuRadioMask) ? kTRUE : kFALSE;
1883 return kFALSE;
1884}
1885
1886////////////////////////////////////////////////////////////////////////////////
1887/// Find entry with specified id. Use the returned entry in DeleteEntry()
1888/// or as the "before" item in the AddXXXX() methods. Returns 0 if entry
1889/// is not found. To find entries that don't have an id like the separators,
1890/// use the GetListOfEntries() method to get the complete entry
1891/// list and iterate over it and check the type of each entry
1892/// to find the separators.
1893
1895{
1896 TGMenuEntry *ptr;
1897 TIter next(fEntryList);
1898
1899 while ((ptr = (TGMenuEntry *) next()))
1900 if (ptr->fEntryId == id)
1901 return ptr;
1902 return 0;
1903}
1904
1905////////////////////////////////////////////////////////////////////////////////
1906/// Find entry with specified name. Name must match the original
1907/// name without hot key symbol, like "Print" and not "&Print".
1908/// Use the returned entry in DeleteEntry() or as the "before" item
1909/// in the AddXXXX() methods. Returns 0 if entry is not found.
1910/// To find entries that don't have a name like the separators,
1911/// use the GetListOfEntries() method to get the complete entry
1912/// list and iterate over it and check the type of each entry
1913/// to find the separators.
1914
1916{
1917 return (TGMenuEntry*) fEntryList->FindObject(s);
1918}
1919
1920////////////////////////////////////////////////////////////////////////////////
1921/// Delete entry with specified id from menu.
1922
1924{
1925 TGMenuEntry *ptr;
1926 TIter next(fEntryList);
1927
1928 while ((ptr = (TGMenuEntry *) next()))
1929 if (ptr->fEntryId == id) {
1930 fEntryList->Remove(ptr);
1931 delete ptr;
1932 Reposition();
1933 if (fCurrent == ptr)
1934 fCurrent = 0;
1935 return;
1936 }
1937}
1938
1939////////////////////////////////////////////////////////////////////////////////
1940/// Delete specified entry from menu.
1941
1943{
1944 TGMenuEntry *ptr;
1945 TIter next(fEntryList);
1946
1947 while ((ptr = (TGMenuEntry *) next()))
1948 if (ptr == entry) {
1949 fEntryList->Remove(ptr);
1950 delete ptr;
1951 Reposition();
1952 if (fCurrent == ptr)
1953 fCurrent = 0;
1954 return;
1955 }
1956}
1957
1958////////////////////////////////////////////////////////////////////////////////
1959/// Return default graphics context.
1960
1962{
1963 if (!fgDefaultGC)
1964 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
1965 return *fgDefaultGC;
1966}
1967
1968////////////////////////////////////////////////////////////////////////////////
1969/// Return the selection graphics context in use.
1970
1972{
1974 fgDefaultSelectedGC = gClient->GetResourcePool()->GetSelectedGC();
1975 return *fgDefaultSelectedGC;
1976}
1977
1978////////////////////////////////////////////////////////////////////////////////
1979/// Return the selection background graphics context in use.
1980
1982{
1984 fgDefaultSelectedBackgroundGC = gClient->GetResourcePool()->GetSelectedBckgndGC();
1986}
1987
1988////////////////////////////////////////////////////////////////////////////////
1989/// Return the default font structure in use.
1990
1992{
1993 if (!fgDefaultFont)
1994 fgDefaultFont = gClient->GetResourcePool()->GetMenuFont();
1995 return fgDefaultFont->GetFontStruct();
1996}
1997
1998////////////////////////////////////////////////////////////////////////////////
1999/// Return the font structure in use for highlighted menu entries.
2000
2002{
2003 if (!fgHilightFont)
2004 fgHilightFont = gClient->GetResourcePool()->GetMenuHiliteFont();
2005 return fgHilightFont->GetFontStruct();
2006}
2007
2008
2009//////////////////////////////////////////////////////////////////////////
2010// //
2011// TGMenuTitle member functions. //
2012// //
2013//////////////////////////////////////////////////////////////////////////
2014
2015////////////////////////////////////////////////////////////////////////////////
2016/// Create a menu title. This object is created by a menu bar when adding
2017/// a popup menu. The menu title adopts the hotstring.
2018
2020 GContext_t norm, FontStruct_t font, UInt_t options)
2021 : TGFrame(p, 1, 1, options)
2022{
2023 fLabel = s;
2024 fMenu = menu;
2025 fFontStruct = font;
2027 fNormGC = norm;
2028 fState = kFALSE;
2029 fTitleId = -1;
2031 fTitleData = 0;
2032
2033 Int_t hotchar;
2034 if (s && (hotchar = s->GetHotChar()) != 0)
2035 fHkeycode = gVirtualX->KeysymToKeycode(hotchar);
2036 else
2037 fHkeycode = 0;
2038
2039 UInt_t tw = 0;
2041 if (fLabel)
2042 tw = gVirtualX->TextWidth(fFontStruct, fLabel->GetString(), fLabel->GetLength());
2043 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
2044
2045 Resize(tw + 8, max_ascent + max_descent + 7);
2046
2047 if (p && p->InheritsFrom(TGMenuBar::Class())) {
2048 TGMenuBar *bar = (TGMenuBar*)p;
2049 fMenu->SetMenuBar(bar);
2050 }
2051}
2052
2053////////////////////////////////////////////////////////////////////////////////
2054/// Set state of menu title.
2055
2057{
2058 fState = state;
2059 if (state) {
2060 if (fMenu != 0) {
2061 Int_t ax, ay;
2063
2064 gVirtualX->TranslateCoordinates(fId, (fMenu->GetParent())->GetId(),
2065 0, 0, ax, ay, wdummy);
2066
2067 // place the menu just under the window:
2068#ifdef R__HAS_COCOA
2069 gVirtualX->SetWMTransientHint(fMenu->GetId(), GetId());
2070#endif
2071 fMenu->PlaceMenu(ax-1, ay+fHeight, kTRUE, kFALSE); //kTRUE);
2072 }
2073 } else {
2074 if (fMenu != 0) {
2076 }
2077 }
2079 fClient->NeedRedraw(this);
2080}
2081
2082////////////////////////////////////////////////////////////////////////////////
2083/// Draw a menu title.
2084
2086{
2088
2089 int x, y, max_ascent, max_descent;
2090 x = y = 4;
2091
2092 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
2093
2094 if (fState) {
2096 if (gClient->GetStyle() > 1) {
2097 gVirtualX->FillRectangle(fId, fNormGC, 1, 2, fWidth-3, fHeight-4);
2098 gVirtualX->DrawRectangle(fId, GetShadowGC()(), 1, 1, fWidth-3, fHeight-3);
2099 }
2100 else {
2101 gVirtualX->FillRectangle(fId, fNormGC, 0, 0, fWidth, fHeight);
2102 }
2103 gVirtualX->SetForeground(fNormGC, GetForeground());
2105 } else {
2106 // Use same background color than the menu bar
2108 if (fMenu && fMenu->fMenuBar && fMenu->fMenuBar->GetBackground() != back)
2109 back = fMenu->fMenuBar->GetBackground();
2110 gVirtualX->SetForeground(fNormGC, back);
2111 if (gClient->GetStyle() > 1) {
2112 gVirtualX->DrawRectangle(fId, fNormGC, 1, 1, fWidth-3, fHeight-3);
2113 gVirtualX->FillRectangle(fId, fNormGC, 1, 2, fWidth-3, fHeight-4);
2114 }
2115 else {
2116 gVirtualX->FillRectangle(fId, fNormGC, 0, 0, fWidth, fHeight);
2117 }
2118 gVirtualX->SetForeground(fNormGC, fTextColor);
2120 if (fTextColor != GetForeground())
2121 gVirtualX->SetForeground(fNormGC, GetForeground());
2122 }
2123}
2124
2125////////////////////////////////////////////////////////////////////////////////
2126/// Send final selected menu item to be processed.
2127
2129{
2130 if (fMenu)
2131 if (fTitleId != -1) {
2135 }
2136}
2137
2138////////////////////////////////////////////////////////////////////////////////
2139/// Return default font structure in use.
2140
2142{
2143 if (!fgDefaultFont)
2144 fgDefaultFont = gClient->GetResourcePool()->GetMenuFont();
2145 return fgDefaultFont->GetFontStruct();
2146}
2147
2148////////////////////////////////////////////////////////////////////////////////
2149/// Return default graphics context in use.
2150
2152{
2153 if (!fgDefaultGC)
2154 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
2155 return *fgDefaultGC;
2156}
2157
2158////////////////////////////////////////////////////////////////////////////////
2159/// Return default selection graphics context in use.
2160
2162{
2164 fgDefaultSelectedGC = gClient->GetResourcePool()->GetSelectedGC();
2165 return *fgDefaultSelectedGC;
2166}
2167
2168////////////////////////////////////////////////////////////////////////////////
2169/// Save a popup menu widget as a C++ statement(s) on output stream out.
2170
2171void TGPopupMenu::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2172{
2173 out << " TGPopupMenu *" << GetName() << " = new TGPopupMenu(gClient->GetDefaultRoot()"
2174 << "," << GetWidth() << "," << GetHeight() << "," << GetOptionString() << ");\n";
2175
2178 r_active = r_first = r_last = -1;
2179
2180 TIter next(GetListOfEntries());
2181
2182 while (auto mentry = static_cast<TGMenuEntry *> (next())) {
2183 Int_t hotpos = mentry->fLabel ? mentry->fLabel->GetHotPos() : 0;
2184 TString outtext = mentry->GetName(), pic_prefix;
2185 if ((hotpos > 0) && (hotpos < outtext.Length()))
2186 outtext.Insert(hotpos - 1, "&");
2187 if (mentry->fShortcut) {
2188 outtext.Append("\t");
2189 outtext.Append(mentry->fShortcut->GetString());
2190 }
2191 outtext.ReplaceSpecialCppChars();
2192
2193 switch (mentry->GetType()) {
2194 case kMenuEntry:
2195 out << " " << GetName() << "->AddEntry(\"" << outtext << "\", " << mentry->GetEntryId();
2196 pic_prefix = ", nullptr, ";
2197 break;
2198 case kMenuPopup:
2199 out << "\n // cascaded menu \"" << mentry->GetName() << "\"\n";
2200 mentry->fPopup->SavePrimitive(out, option);
2201 out << " " << GetName() << "->AddPopup(\"" << outtext << "\", " << mentry->fPopup->GetName();
2202 pic_prefix = ", nullptr, ";
2203 break;
2204 case kMenuLabel:
2205 out << " " << GetName() << "->AddLabel(\"" << outtext << "\"";
2206 pic_prefix = ", ";
2207 break;
2208 case kMenuSeparator: out << " " << GetName() << "->AddSeparator("; break;
2209 }
2210 if (pic_prefix.Length() && mentry->fPic) {
2211 TString picname = gSystem->UnixPathName(mentry->fPic->GetName());
2213 out << pic_prefix << "gClient->GetPicture(\"" << picname.ReplaceSpecialCppChars() << "\")";
2214 }
2215 out << ");\n";
2216
2217 if (!(mentry->GetStatus() & kMenuEnableMask))
2218 out << " " << GetName() << "->DisableEntry(" << mentry->GetEntryId() << ");\n";
2219 if (mentry->GetStatus() & kMenuHideMask)
2220 out << " " << GetName() << "->HideEntry(" << mentry->GetEntryId() << ");\n";
2221 if (mentry->GetStatus() & kMenuCheckedMask)
2222 out << " " << GetName() << "->CheckEntry(" << mentry->GetEntryId() << ");\n";
2223 if (mentry->GetStatus() & kMenuDefaultMask)
2224 out << " " << GetName() << "->DefaultEntry(" << mentry->GetEntryId() << ");\n";
2225 if (mentry->GetStatus() & kMenuRadioEntryMask) {
2226 if (hasradio) {
2227 r_last = mentry->GetEntryId();
2228 if (IsEntryRChecked(mentry->GetEntryId()))
2229 r_active = mentry->GetEntryId();
2230 } else {
2231 r_first = mentry->GetEntryId();
2232 hasradio = kTRUE;
2233 if (IsEntryRChecked(mentry->GetEntryId()))
2234 r_active = mentry->GetEntryId();
2235 }
2236 } else if (hasradio) {
2237 out << " " << GetName() << "->RCheckEntry(" << r_active << "," << r_first << "," << r_last << ");\n";
2238 hasradio = kFALSE;
2239 r_active = r_first = r_last = -1;
2240 }
2241 }
2242}
2243
2244////////////////////////////////////////////////////////////////////////////////
2245/// Save a title menu widget as a C++ statement(s) on output stream out.
2246
2247void TGMenuTitle::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2248{
2249 out << "\n // \"" << fLabel->GetString() << "\" menu\n";
2250
2251 fMenu->SavePrimitive(out, option);
2252
2255 if (hotpos > 0)
2256 outtext.Insert(hotpos - 1, "&");
2257 out << " " << fParent->GetName() << "->AddPopup(\"" << outtext.ReplaceSpecialCppChars() << "\", "
2258 << fMenu->GetName();
2259}
2260
2261////////////////////////////////////////////////////////////////////////////////
2262/// Save a menu bar widget as a C++ statement(s) on output stream out.
2263
2264void TGMenuBar::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2265{
2266 out << "\n // menu bar\n";
2267 out << " TGMenuBar *" << GetName() << " = new TGMenuBar(" << fParent->GetName() << "," << GetWidth() << ","
2268 << GetHeight() << "," << GetOptionString() << ");\n";
2269 if (option && strstr(option, "keep_names"))
2270 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
2271
2272 if (!fList)
2273 return;
2274
2275 TIter next(fList);
2276
2277 while (auto el = static_cast<TGFrameElement *>(next())) {
2278 el->fFrame->SavePrimitive(out, option);
2279 el->fLayout->SavePrimitive(out, option);
2280 out << ");\n";
2281 }
2282}
@ kGKeyPress
Definition GuiTypes.h:61
@ kButtonRelease
Definition GuiTypes.h:61
@ kButtonPress
Definition GuiTypes.h:61
@ kEnterNotify
Definition GuiTypes.h:62
@ kKeyRelease
Definition GuiTypes.h:61
const Mask_t kWAOverrideRedirect
Definition GuiTypes.h:150
const Mask_t kKeyLockMask
Definition GuiTypes.h:197
const Mask_t kButtonPressMask
Definition GuiTypes.h:162
const Mask_t kKeyMod1Mask
typically the Alt key
Definition GuiTypes.h:199
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
const Mask_t kWASaveUnder
Definition GuiTypes.h:151
const Mask_t kAnyModifier
Definition GuiTypes.h:211
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:39
const Mask_t kButton1Mask
Definition GuiTypes.h:204
const Mask_t kGCFont
Definition GuiTypes.h:301
const Mask_t kPointerMotionMask
Definition GuiTypes.h:164
const Mask_t kKeyShiftMask
Definition GuiTypes.h:196
@ kRaisedFrame
Definition GuiTypes.h:385
@ kSunkenFrame
Definition GuiTypes.h:384
@ kHorizontalFrame
Definition GuiTypes.h:383
@ kOwnBackground
Definition GuiTypes.h:392
const Handle_t kNone
Definition GuiTypes.h:89
const Mask_t kKeyMod2Mask
typically mod on numeric keys
Definition GuiTypes.h:200
const Mask_t kLeaveWindowMask
Definition GuiTypes.h:169
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:163
const Mask_t kEnterWindowMask
Definition GuiTypes.h:168
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
@ kButton1
Definition GuiTypes.h:215
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:40
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:582
#define gVirtualX
Definition TVirtualX.h:377
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:1110
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:1157
TList * fList
container of frame elements
Definition TGFrame.h:294
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition TGFrame.cxx:1142
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:689
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:332
static const TGGC & GetBlackGC()
Get black graphics context.
Definition TGFrame.cxx:728
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:598
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:423
virtual Pixel_t GetForeground() const
Return frame foreground color.
Definition TGFrame.cxx:296
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition TGFrame.cxx:748
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:676
void Move(Int_t x, Int_t y) override
Move frame.
Definition TGFrame.cxx:586
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition TGFrame.cxx:2515
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:638
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:758
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:768
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:2264
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:2141
TGPopupMenu * fMenu
attached popup menu
Definition TGMenu.h:237
void DoRedraw() override
Draw a menu title.
Definition TGMenu.cxx:2085
Int_t fHkeycode
hot key code
Definition TGMenu.h:242
virtual void SetState(Bool_t state)
Set state of menu title.
Definition TGMenu.cxx:2056
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:2151
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:2247
static const TGGC & GetDefaultSelectedGC()
Return default selection graphics context in use.
Definition TGMenu.cxx:2161
TGMenuTitle(const TGMenuTitle &)=delete
virtual void DoSendMessage()
Send final selected menu item to be processed.
Definition TGMenu.cxx:2128
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:1364
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:1748
virtual void DefaultEntry(Int_t id)
Set default entry (default entries are drawn with bold text).
Definition TGMenu.cxx:1686
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:1092
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:2171
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:1894
static const TGGC & GetDefaultSelectedGC()
Return the selection graphics context in use.
Definition TGMenu.cxx:1971
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:1842
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:1875
virtual void CheckEntryByData(void *user_data)
Check a menu entry (i.e.
Definition TGMenu.cxx:1792
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:1489
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:1961
void DrawBorder() override
Draw border round popup menu.
Definition TGMenu.cxx:1601
virtual void UnCheckEntries()
Uncheck all entries.
Definition TGMenu.cxx:1816
virtual void AddPopup(TGHotString *s, TGPopupMenu *popup, TGMenuEntry *before=nullptr, const TGPicture *p=nullptr)
Add a (cascading) popup menu to a popup menu.
Definition TGMenu.cxx:1149
static FontStruct_t GetDefaultFontStruct()
Return the default font structure in use.
Definition TGMenu.cxx:1991
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:1779
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:1206
Bool_t HandleTimer(TTimer *t) override
If TPopupDelayTimer times out popup cascading popup menu (if it is still the current entry).
Definition TGMenu.cxx:1464
virtual void DisableEntry(Int_t id)
Disable entry (disabled entries appear in a sunken relieve).
Definition TGMenu.cxx:1721
virtual void DrawEntry(TGMenuEntry *entry)
Draw popup menu entry.
Definition TGMenu.cxx:1503
virtual void EnableEntry(Int_t id)
Enable entry. By default entries are enabled.
Definition TGMenu.cxx:1702
virtual void UnCheckEntryByData(void *user_data)
Uncheck a menu entry (i.e.
Definition TGMenu.cxx:1830
virtual void PoppedDown()
Definition TGMenu.h:217
virtual Bool_t IsEntryHidden(Int_t id)
Return true if menu entry is hidden.
Definition TGMenu.cxx:1765
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:1804
virtual Int_t EndMenu(void *&userData)
Close menu and return ID of selected menu item.
Definition TGMenu.cxx:1286
virtual TGMenuEntry * GetCurrent() const
Definition TGMenu.h:198
virtual void DeleteEntry(Int_t id)
Delete entry with specified id from menu.
Definition TGMenu.cxx:1923
static FontStruct_t GetHilightFontStruct()
Return the font structure in use for highlighted menu entries.
Definition TGMenu.cxx:2001
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:1981
virtual void AddSeparator(TGMenuEntry *before=nullptr)
Add a menu separator to the menu.
Definition TGMenu.cxx:1057
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:1667
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:1648
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:1857
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
~TGPopupMenu() override
Delete a popup menu.
Definition TGMenu.cxx:972
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:1391
Bool_t HandleButton(Event_t *event) override
Handle button event in the popup menu.
Definition TGMenu.cxx:1335
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:1628
virtual Bool_t IsEntryEnabled(Int_t id)
Return true if menu entry is enabled.
Definition TGMenu.cxx:1733
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:460
TObject * Before(const TObject *obj) const override
Returns the object before object obj.
Definition TList.cxx:501
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:708
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:952
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:823
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:789
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:600
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:660
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1289
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1077
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition TSystem.cxx:473
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:249
Event structure.
Definition GuiTypes.h:175
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:176
Int_t fY
pointer x, y coordinates in event window
Definition GuiTypes.h:179
UInt_t fState
key or button mask
Definition GuiTypes.h:182
Int_t fX
Definition GuiTypes.h:179
UInt_t fCode
key or button code
Definition GuiTypes.h:181
Graphics context structure.
Definition GuiTypes.h:225
Point structure (maps to the X11 XPoint structure)
Definition GuiTypes.h:357
Used for drawing line segments (maps to the X11 XSegments structure)
Definition GuiTypes.h:352
Attributes that can be used when creating or changing a window.
Definition GuiTypes.h:94
TMarker m
Definition textangle.C:8
TLine l
Definition textangle.C:4