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