00001
00002 #include "BesVisLib/BesGMenuBar.h"
00003
00004 ClassImp(BesGMenuBar)
00005
00006
00007 BesGMenuBar::BesGMenuBar(const TGWindow *p, UInt_t w, UInt_t h, UInt_t options)
00008 : TGMenuBar(p, w, h, options)
00009 {
00010
00011 }
00012
00013
00014 void BesGMenuBar::AddPopup(TGHotString *s, TGPopupMenu *menu, TGLayoutHints *l,
00015 TGPopupMenu *before)
00016 {
00017
00018
00019
00020
00021 BesGMenuTitle *t;
00022 Int_t keycode;
00023
00024 AddFrameBefore(t = new BesGMenuTitle(this, s, menu), l, before);
00025 fTitles->Add(t);
00026
00027 if ((keycode = t->GetHotKeyCode()) != 0) {
00028 BindHotKey(keycode, kTRUE);
00029 }
00030 }
00031
00032
00033 void BesGMenuBar::AddPopup(const char *s, TGPopupMenu *menu, TGLayoutHints *l,
00034 TGPopupMenu *before)
00035 {
00036
00037
00038
00039 AddPopup(new TGHotString(s), menu, l, before);
00040 }
00041
00042
00043 void BesGMenuBar::AddFrameBefore(TGFrame *f, TGLayoutHints *l,
00044 TGPopupMenu *before)
00045 {
00046
00047
00048
00049
00050 if (f->IsA() != BesGMenuTitle::Class()) {
00051 Error("AddFrameBefore", "may only add BesGMenuTitle objects to a menu bar");
00052 return;
00053 }
00054
00055 if (!before) {
00056 AddFrame(f, l);
00057 return;
00058 }
00059
00060 TGFrameElement *nw;
00061
00062 nw = new TGFrameElement;
00063 nw->fFrame = f;
00064 nw->fLayout = l ? l : fgDefaultHints;
00065 nw->fState = 1;
00066
00067 TGFrameElement *el;
00068 TIter next(fList);
00069 while ((el = (TGFrameElement *) next())) {
00070 BesGMenuTitle *t = (BesGMenuTitle *) el->fFrame;
00071 if (t->GetMenu() == before) {
00072 fList->AddBefore(el, nw);
00073 return;
00074 }
00075 }
00076 fList->Add(nw);
00077 }
00078
00079
00080 BesGMenuTitle *BesGMenuBar::GetMenuTitle(Int_t i)
00081 {
00082 if (i >= 0 && i < fTitles->GetSize()) return (BesGMenuTitle*)fTitles->At(i);
00083 else return 0;
00084 }
00085
00086