library: libGui #include "TGMenu.h"

# TGMenuBar

class description - source file - inheritance tree (.pdf)

## class TGMenuBar : public TGHorizontalFrame

| Inheritance Chart:
`TObject`
| <- | `TGObject`
| <- | `TGWindow`
`TQObject`
| <- | `TGFrame`
| <- | `TGCompositeFrame`
| <- | `TGHorizontalFrame`
| <- | `TGMenuBar` |

        protected:

          virtual void AddFrameBefore(TGFrame* f, TGLayoutHints* l = 0, TGPopupMenu* before = 0)
          virtual void BindHotKey(Int_t keycode, Bool_t on = kTRUE)
          virtual void BindKeys(Bool_t on = kTRUE)

        public:

                               TGMenuBar(const TGWindow* p = 0, UInt_t w = 60, UInt_t h = 20, UInt_t options = kHorizontalFrame|kRaisedFrame)
                               TGMenuBar(const TGMenuBar&)
                       virtual ~TGMenuBar()
                  virtual void AddPopup(TGHotString* s, TGPopupMenu* menu, TGLayoutHints* l, TGPopupMenu* before = 0)
                  virtual void AddPopup(const char* s, TGPopupMenu* menu, TGLayoutHints* l, TGPopupMenu* before = 0)
          virtual TGPopupMenu* AddPopup(const TString& s, Int_t padleft = 4, Int_t padright = 0, Int_t padtop = 0, Int_t padbottom = 0)
                static TClass* Class()
          virtual TGPopupMenu* GetPopup(const char* s)
                virtual Bool_t HandleButton(Event_t* event)
                virtual Bool_t HandleKey(Event_t* event)
                virtual Bool_t HandleMotion(Event_t* event)
               virtual TClass* IsA() const
          virtual TGPopupMenu* RemovePopup(const char* s)
                  virtual void SavePrimitive(ofstream& out, Option_t* option)
                  virtual void ShowMembers(TMemberInspector& insp, char* parent)
                  virtual void Streamer(TBuffer& b)
                          void StreamerNVirtual(TBuffer& b)

### Data Members

        protected:

          TGMenuTitle* fCurrent        current menu title
                TList* fTitles         list of menu titles
              Cursor_t fDefaultCursor  right pointing cursor
                Bool_t fStick          stick mode (popup menu stays sticked on screen)
                TList* fTrash          garbage
                Bool_t fKeyNavigate    kTRUE if arrow key navigation is on

## Class Description

     TGMenuBar, TGPopupMenu, TGMenuTitle and TGMenuEntry

     This header contains all different menu classes.

     Selecting a menu item will generate the event:
     kC_COMMAND, kCM_MENU, menu id, user data.

TGMenuBar(const TGWindow *p, UInt_t w, UInt_t h, UInt_t options) : TGHorizontalFrame(p, w, h, options | kHorizontalFrame)

     Create a menu bar object.

~TGMenuBar()

     Delete menu bar object. Removes also the hot keys from the main frame,
     so hitting them will not cause the menus to popup.

void BindKeys(Bool_t on)

     If on kTRUE bind arrow, popup menu hot keys, otherwise
     remove key bindings.

void BindHotKey(Int_t keycode, Bool_t on)

     If on kTRUE bind hot keys, otherwise remove key binding.

void AddPopup(TGHotString *s, TGPopupMenu *menu, TGLayoutHints *l, TGPopupMenu *before)

     Add popup menu to menu bar. The hot string will be adopted by the
     menubar (actually the menu title) and deleted when possible.
     If before is not 0 the menu will be added before it.

void AddPopup(const char *s, TGPopupMenu *menu, TGLayoutHints *l, TGPopupMenu *before)

     Add popup menu to menu bar. If before is not 0 the menu will be
     added before it.

TGPopupMenu* AddPopup(const TString &s, Int_t padleft, Int_t padright, Int_t padtop, Int_t padbottom)

     Add popup menu to menu bar.

     Comment:
        This method is valid  only for horizontal menu bars.
        The most common case is menu bar containing equidistant titles padding left side.
           TGMenuBar *bar;
           bar->AddPopup("title1", 10);
           bar->AddPopup("title2", 10);
           ...

        To add equidistant titles  padding right side padleft must be 0.
           TGMenuBar *bar;
           bar->AddPopup("title1", 0, 10);
           bar->AddPopup("title2", 0, 10);
           ...

        This method guarantee automatic cleanup when menu bar is destroyed.
        Do not delete returned popup-menu

void AddFrameBefore(TGFrame *f, TGLayoutHints *l, TGPopupMenu *before)

     Private version of AddFrame for menubar, to make sure that we
     indeed only add TGMenuTitle objects to it. If before is not 0
     the menu will be added before it.

TGPopupMenu* GetPopup(const char *s)

     Return popup menu with the specified name. Returns 0 if menu is
     not found. Returnes menu can be used as "before" in AddPopup().
     Don't use hot key (&) in name.

TGPopupMenu* RemovePopup(const char *s)

     Remove popup menu from menu bar. Returned menu has to be deleted by
     the user, or can be re-used in another AddPopup(). Returns 0 if
     menu is not found. Don't use hot key (&) in name.

Bool_t HandleMotion(Event_t *event)

     Handle a mouse motion event in a menu bar.

Bool_t HandleButton(Event_t *event)

     Handle a mouse button event in a menubar.

Bool_t HandleKey(Event_t *event)

     Handle keyboard events in a menu bar.

void SavePrimitive(ofstream &out, Option_t *option)

     Save a menu bar widget as a C++ statement(s) on output stream out.

### Inline Functions

                TClass* Class()
                TClass* IsA() const
                   void ShowMembers(TMemberInspector& insp, char* parent)
                   void Streamer(TBuffer& b)
                   void StreamerNVirtual(TBuffer& b)
              TGMenuBar TGMenuBar(const TGMenuBar&)

Author: Fons Rademakers 09/01/98
Last update: root/gui:$Name: $:$Id: TGMenu.cxx,v 1.51 2005/04/06 06:09:26 brun Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *