CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWPopupMenu.cc
Go to the documentation of this file.
1 #include "TGMenu.h"
2 #include "KeySymbols.h"
3 
4 class FWPopupMenu : public TGPopupMenu
5 {
6 public:
7  FWPopupMenu(const TGWindow* p=0, UInt_t w=10, UInt_t h=10, UInt_t options=0) :
8  TGPopupMenu(p, w, h, options)
9  {
10  AddInput(kKeyPressMask);
11  }
12 
13  // virtual void PlaceMenu(Int_t x, Int_t y, Bool_t stick_mode, Bool_t grab_pointer)
14  // {
15  // TGPopupMenu::PlaceMenu(x, y, stick_mode, grab_pointer);
16  // gVirtualX->GrabKey(fId, 0l, kAnyModifier, kTRUE);
17  // }
18 
19  virtual void PoppedUp()
20  {
21  TGPopupMenu::PoppedUp();
22  gVirtualX->SetInputFocus(fId);
23  gVirtualX->GrabKey(fId, 0l, kAnyModifier, kTRUE);
24 
25  }
26 
27  virtual void PoppedDown()
28  {
29  gVirtualX->GrabKey(fId, 0l, kAnyModifier, kFALSE);
30  TGPopupMenu::PoppedDown();
31  }
32 
33  virtual Bool_t HandleKey(Event_t* event)
34  {
35  if (event->fType != kGKeyPress) return kTRUE;
36 
37  UInt_t keysym;
38  char tmp[2];
39  gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
40 
41  TGMenuEntry *ce = fCurrent;
42 
43  switch (keysym)
44  {
45  case kKey_Up:
46  {
47  if (ce) ce = (TGMenuEntry*)GetListOfEntries()->Before(ce);
48  while (ce && ((ce->GetType() == kMenuSeparator) ||
49  (ce->GetType() == kMenuLabel) ||
50  !(ce->GetStatus() & kMenuEnableMask)))
51  {
52  ce = (TGMenuEntry*)GetListOfEntries()->Before(ce);
53  }
54  if (!ce) ce = (TGMenuEntry*)GetListOfEntries()->Last();
55  Activate(ce);
56  break;
57  }
58  case kKey_Down:
59  {
60  if (ce) ce = (TGMenuEntry*)GetListOfEntries()->After(ce);
61  while (ce && ((ce->GetType() == kMenuSeparator) ||
62  (ce->GetType() == kMenuLabel) ||
63  !(ce->GetStatus() & kMenuEnableMask)))
64  {
65  ce = (TGMenuEntry*)GetListOfEntries()->After(ce);
66  }
67  if (!ce) ce = (TGMenuEntry*)GetListOfEntries()->First();
68  Activate(ce);
69  break;
70  }
71  case kKey_Enter:
72  case kKey_Return:
73  {
74  Event_t ev;
75  ev.fType = kButtonRelease;
76  ev.fWindow = fId;
77  return HandleButton(&ev);
78  }
79  case kKey_Escape:
80  {
81  fCurrent = 0;
82  void *dummy = 0;
83  return EndMenu(dummy);
84  }
85  default:
86  {
87  break;
88  }
89  }
90 
91  return kTRUE;
92  }
93 };
FWPopupMenu(const TGWindow *p=0, UInt_t w=10, UInt_t h=10, UInt_t options=0)
Definition: FWPopupMenu.cc:7
virtual void PoppedDown()
Definition: FWPopupMenu.cc:27
virtual void PoppedUp()
Definition: FWPopupMenu.cc:19
virtual Bool_t HandleKey(Event_t *event)
Definition: FWPopupMenu.cc:33
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
unsigned int UInt_t
Definition: FUTypes.h:12
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
T w() const