Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TGTab.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/gui:$Id$
0002 // Author: Fons Rademakers   13/01/98
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TGTab
0013 #define ROOT_TGTab
0014 
0015 
0016 #include "TGFrame.h"
0017 #include "TGWidget.h"
0018 
0019 class TList;
0020 class TGTabElement;
0021 class TGTab;
0022 class TGPicture;
0023 
0024 class TGTabLayout : public TGLayoutManager {
0025 
0026 protected:
0027    TGTab    *fMain;      // container frame
0028    TList    *fList;      // list of frames to arrange
0029 
0030 private:
0031    TGTabLayout(const TGTabLayout&) = delete;
0032    TGTabLayout& operator=(const TGTabLayout&) = delete;
0033 
0034 public:
0035    TGTabLayout(TGTab *main);
0036 
0037    void Layout() override;
0038    TGDimension GetDefaultSize() const override;
0039    void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0040 
0041    ClassDefOverride(TGTabLayout,0)  // Layout manager for TGTab widget
0042 };
0043 
0044 
0045 
0046 class TGTab : public TGCompositeFrame, public TGWidget {
0047 
0048 protected:
0049    Int_t               fCurrent;        ///< index of current tab
0050    UInt_t              fTabh;           ///< tab height
0051    TGCompositeFrame   *fContainer;      ///< main container
0052    TList              *fRemoved;        ///< list of removed tabs
0053    FontStruct_t        fFontStruct;     ///< font
0054    GContext_t          fNormGC;         ///< drawing context
0055    Bool_t              fScrolling;      ///< true if tab scrolling enabled
0056 
0057    void ChangeTab(Int_t tabIndex, Bool_t emit=kTRUE);
0058 
0059    static const TGFont *fgDefaultFont;
0060    static const TGGC   *fgDefaultGC;
0061 
0062 private:
0063    TGTab(const TGTab&) = delete;
0064    TGTab& operator=(const TGTab&) = delete;
0065 
0066 public:
0067    static FontStruct_t  GetDefaultFontStruct();
0068    static const TGGC   &GetDefaultGC();
0069 
0070    TGTab(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
0071          GContext_t norm = GetDefaultGC()(),
0072          FontStruct_t font = GetDefaultFontStruct(),
0073          UInt_t options = kChildFrame,
0074          Pixel_t back = GetDefaultFrameBackground());
0075    ~TGTab() override;
0076 
0077    virtual TGCompositeFrame *AddTab(TGString *text);
0078    virtual TGCompositeFrame *AddTab(const char *text);
0079    virtual void     AddTab(const char *text, TGCompositeFrame *cf);
0080    virtual void     AddTab(TGString *text, TGCompositeFrame *cf);
0081 
0082    virtual void     NewTab(const char *text = "tab");   // *MENU*icon=bld_newtab.png*
0083    virtual void     RemoveTab(Int_t tabIndex = -1,
0084                               Bool_t storeRemoved = kTRUE); // *MENU*icon=bld_removetab.png*
0085    virtual Bool_t   SetTab(Int_t tabIndex, Bool_t emit = kTRUE);
0086    virtual Bool_t   SetTab(const char *name, Bool_t emit = kTRUE);
0087    void              DrawBorder() override { }
0088 
0089    TGCompositeFrame *GetContainer() const { return fContainer; }
0090    Int_t             GetCurrent() const { return fCurrent; }
0091    TGCompositeFrame *GetTabContainer(Int_t tabIndex) const;
0092    TGCompositeFrame *GetTabContainer(const char *name) const;
0093    TGTabElement     *GetTabTab(Int_t tabIndex) const;
0094    TGTabElement     *GetTabTab(const char *name) const;
0095    TGCompositeFrame *GetCurrentContainer() const { return GetTabContainer(fCurrent); }
0096    TGTabElement     *GetCurrentTab() const { return GetTabTab(fCurrent); }
0097    UInt_t            GetTabHeight() const { return fTabh; }
0098    Int_t             GetNumberOfTabs() const;
0099    virtual void      SetEnabled(Int_t tabIndex, Bool_t on = kTRUE);  //*MENU*
0100    virtual void      SetText(const char *text = "tab");              //*MENU*icon=bld_rename.png*
0101    Bool_t            IsEnabled(Int_t tabIndex) const;
0102    virtual void      SetScrollingEnabled(Bool_t on = kTRUE);
0103    Bool_t            IsScrollingEnabled() const;
0104 
0105    void              SavePrimitive(std::ostream &out, Option_t *option = "") override;
0106 
0107    virtual void CloseTab(Int_t id) { Emit("CloseTab(Int_t)", id); }  //*SIGNAL*
0108    virtual void Removed(Int_t id) { Emit("Removed(Int_t)", id); }    //*SIGNAL*
0109    virtual void Selected(Int_t id) { Emit("Selected(Int_t)", id); }  //*SIGNAL*
0110    TGLayoutManager *GetLayoutManager() const override;
0111 
0112    ClassDefOverride(TGTab,0)  // Tab widget
0113 };
0114 
0115 
0116 
0117 class TGTabElement : public TGFrame {
0118 
0119 protected:
0120    TGString        *fText;            ///< text on tab
0121    const TGPicture *fClosePic;        ///< "close tab" icon
0122    const TGPicture *fClosePicD;       ///< "close tab" icon (disabled)
0123    GContext_t       fNormGC;          ///< graphics context for drawing tab
0124    FontStruct_t     fFontStruct;      ///< font used for tab
0125    UInt_t           fTWidth;          ///< width of tab text
0126    UInt_t           fTHeight;         ///< height of tab text
0127    Bool_t           fEnabled;         ///< enabled or disabled
0128    Bool_t           fShowClose;       ///< show or hide close icon
0129    Bool_t           fActive;          ///< true if active (in front)
0130 
0131 private:
0132    TGTabElement(const TGTabElement&) = delete;
0133    TGTabElement& operator=(const TGTabElement&) = delete;
0134 
0135 public:
0136    TGTabElement(const TGWindow *p = nullptr, TGString *text = nullptr, UInt_t w = 1, UInt_t h = 1,
0137                 GContext_t norm = TGTab::GetDefaultGC()(),
0138                 FontStruct_t font = TGTab::GetDefaultFontStruct(),
0139                 UInt_t options = kRaisedFrame,
0140                 Pixel_t back = GetDefaultFrameBackground());
0141    ~TGTabElement() override;
0142 
0143    void             DrawBorder() override;
0144    TGDimension      GetDefaultSize() const override;
0145    const TGString  *GetText() const { return fText; }
0146    const char      *GetString() const { return fText->GetString(); }
0147    Bool_t           HandleButton(Event_t *event) override;
0148    void             SetText(TGString *text);
0149    virtual void     SetEnabled(Bool_t on = kTRUE) { fEnabled = on; }
0150    Bool_t           IsEnabled() const { return fEnabled; }
0151    void             SetEditDisabled(UInt_t) override {}
0152    virtual void     ShowClose(Bool_t on = kTRUE);
0153    Bool_t           IsCloseShown() const { return fShowClose; }
0154    virtual void     SetActive(Bool_t on = kTRUE) { fActive = on; }
0155    Bool_t           IsActive() const override { return fActive; }
0156 
0157    ClassDefOverride(TGTabElement,0)  // Little tab on tab widget
0158 };
0159 
0160 #endif