/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/EventDisplay/BesVisLib/BesVisLib-00-04-04/src/BesGMenuBar.cxx

Go to the documentation of this file.
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     // Add popup menu to menu bar. The hot string will be adopted by the
00018     // menubar (actually the menu title) and deleted when possible.
00019     // If before is not 0 the menu will be added before it.
00020 
00021     BesGMenuTitle *t;
00022     Int_t keycode;
00023 
00024     AddFrameBefore(t = new BesGMenuTitle(this, s, menu), l, before);
00025     fTitles->Add(t);  // keep track of menu titles for later cleanup in dtor
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     // Add popup menu to menu bar. If before is not 0 the menu will be
00037     // added before it.
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     // Private version of AddFrame for menubar, to make sure that we
00047     // indeed only add BesGMenuTitle objects to it. If before is not 0
00048     // the menu will be added before it.
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 

Generated on Tue Nov 29 23:12:04 2016 for BOSS_7.0.2 by  doxygen 1.4.7