TGTab.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGTab.h 26180 2008-11-13 15:51:56Z bellenot $
00002 // Author: Fons Rademakers   13/01/98
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGTab
00013 #define ROOT_TGTab
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TGTab, TGTabElement, TGTabLayout                                     //
00019 //                                                                      //
00020 // A tab widget contains a set of composite frames each with a little   //
00021 // tab with a name (like a set of folders with tabs).                   //
00022 //                                                                      //
00023 // The TGTab is user callable. The TGTabElement and TGTabLayout are     //
00024 // is a service classes of the tab widget.                              //
00025 //                                                                      //
00026 // Clicking on a tab will bring the associated composite frame to the   //
00027 // front and generate the following event:                              //
00028 // kC_COMMAND, kCM_TAB, tab id, 0.                                      //
00029 //                                                                      //
00030 //////////////////////////////////////////////////////////////////////////
00031 
00032 #ifndef ROOT_TGFrame
00033 #include "TGFrame.h"
00034 #endif
00035 #ifndef ROOT_TGWidget
00036 #include "TGWidget.h"
00037 #endif
00038 
00039 class TList;
00040 class TGTabElement;
00041 class TGTab;
00042 class TGPicture;
00043 
00044 class TGTabLayout : public TGLayoutManager {
00045 
00046 protected:
00047    TGTab    *fMain;      // container frame
00048    TList    *fList;      // list of frames to arrange
00049 
00050 private:
00051    TGTabLayout(const TGTabLayout&);             // not implemented
00052    TGTabLayout& operator=(const TGTabLayout&);  // not implemented
00053 
00054 public:
00055    TGTabLayout(TGTab *main);
00056 
00057    virtual void Layout();
00058    virtual TGDimension GetDefaultSize() const;
00059    virtual void SavePrimitive(ostream &out, Option_t *option = "");
00060 
00061    ClassDef(TGTabLayout,0)  // Layout manager for TGTab widget
00062 };
00063 
00064 
00065 
00066 class TGTab : public TGCompositeFrame, public TGWidget {
00067 
00068 protected:
00069    Int_t               fCurrent;        // index of current tab
00070    UInt_t              fTabh;           // tab height
00071    TGCompositeFrame   *fContainer;      // main container
00072    TList              *fRemoved;        // list of removed tabs
00073    FontStruct_t        fFontStruct;     // font
00074    GContext_t          fNormGC;         // drawing context
00075 
00076    void ChangeTab(Int_t tabIndex, Bool_t emit=kTRUE);
00077 
00078    static const TGFont *fgDefaultFont;
00079    static const TGGC   *fgDefaultGC;
00080 
00081 private:
00082    TGTab(const TGTab&);             // not implemented
00083    TGTab& operator=(const TGTab&);  // not implemented
00084 
00085 public:
00086    static FontStruct_t  GetDefaultFontStruct();
00087    static const TGGC   &GetDefaultGC();
00088 
00089    TGTab(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
00090          GContext_t norm = GetDefaultGC()(),
00091          FontStruct_t font = GetDefaultFontStruct(),
00092          UInt_t options = kChildFrame,
00093          Pixel_t back = GetDefaultFrameBackground());
00094    virtual ~TGTab();
00095 
00096    virtual TGCompositeFrame *AddTab(TGString *text);
00097    virtual TGCompositeFrame *AddTab(const char *text);
00098    virtual void              AddTab(const char *text, TGCompositeFrame *cf);
00099    virtual void              AddTab(TGString *text, TGCompositeFrame *cf);
00100 
00101    virtual void              NewTab(const char *text = "tab");   // *MENU*icon=bld_newtab.png*
00102    virtual void              RemoveTab(Int_t tabIndex = -1,
00103                                        Bool_t storeRemoved = kTRUE); // *MENU*icon=bld_removetab.png*
00104    virtual Bool_t            SetTab(Int_t tabIndex, Bool_t emit = kTRUE);
00105    virtual Bool_t            SetTab(const char *name, Bool_t emit = kTRUE);
00106    virtual void              DrawBorder() { }
00107 
00108    TGCompositeFrame *GetContainer() const { return fContainer; }
00109    Int_t             GetCurrent() const { return fCurrent; }
00110    TGCompositeFrame *GetTabContainer(Int_t tabIndex) const;
00111    TGCompositeFrame *GetTabContainer(const char *name) const;
00112    TGTabElement     *GetTabTab(Int_t tabIndex) const;
00113    TGTabElement     *GetTabTab(const char *name) const;
00114    TGCompositeFrame *GetCurrentContainer() const { return GetTabContainer(fCurrent); }
00115    TGTabElement     *GetCurrentTab() const { return GetTabTab(fCurrent); }
00116    UInt_t            GetTabHeight() const { return fTabh; }
00117    Int_t             GetNumberOfTabs() const;
00118    virtual void      SetEnabled(Int_t tabIndex, Bool_t on = kTRUE);  //*MENU*
00119    virtual void      SetText(const char *text = "tab");              //*MENU*icon=bld_rename.png*
00120    Bool_t            IsEnabled(Int_t tabIndex) const;
00121 
00122    virtual void      SavePrimitive(ostream &out, Option_t *option = "");
00123 
00124    virtual void CloseTab(Int_t id) { Emit("CloseTab(Int_t)", id); }  //*SIGNAL*
00125    virtual void Removed(Int_t id) { Emit("Removed(Int_t)", id); }    //*SIGNAL*
00126    virtual void Selected(Int_t id) { Emit("Selected(Int_t)", id); }  //*SIGNAL*
00127    virtual TGLayoutManager *GetLayoutManager() const;
00128 
00129    ClassDef(TGTab,0)  // Tab widget
00130 };
00131 
00132 
00133 
00134 class TGTabElement : public TGFrame {
00135 
00136 protected:
00137    TGString        *fText;            // text on tab
00138    const TGPicture *fClosePic;        // "close tab" icon
00139    const TGPicture *fClosePicD;       // "close tab" icon (disabled)
00140    GContext_t       fNormGC;          // graphics context for drawing tab
00141    FontStruct_t     fFontStruct;      // font used for tab
00142    UInt_t           fTWidth;          // width of tab text
00143    UInt_t           fTHeight;         // height of tab text
00144    Bool_t           fEnabled;         // enabled or disabled
00145    Bool_t           fShowClose;       // show or hide close icon
00146    Bool_t           fActive;          // true if active (in front)
00147 
00148 private:
00149    TGTabElement(const TGTabElement&);             // not implemented
00150    TGTabElement& operator=(const TGTabElement&);  // not implemented
00151 
00152 public:
00153    TGTabElement(const TGWindow *p = 0, TGString *text = 0, UInt_t w = 1, UInt_t h = 1,
00154                 GContext_t norm = TGTab::GetDefaultGC()(),
00155                 FontStruct_t font = TGTab::GetDefaultFontStruct(),
00156                 UInt_t options = kRaisedFrame,
00157                 Pixel_t back = GetDefaultFrameBackground());
00158    virtual ~TGTabElement();
00159 
00160    virtual void        DrawBorder();
00161    virtual TGDimension GetDefaultSize() const;
00162    const TGString     *GetText() const { return fText; }
00163    const char         *GetString() const { return fText->GetString(); }
00164    virtual Bool_t      HandleButton(Event_t *event);
00165    void                SetText(TGString *text);
00166    virtual void        SetEnabled(Bool_t on = kTRUE) { fEnabled = on; }
00167    Bool_t              IsEnabled() const { return fEnabled; }
00168    virtual void        SetEditDisabled(UInt_t) {}
00169    virtual void        ShowClose(Bool_t on = kTRUE);
00170    Bool_t              IsCloseShown() const { return fShowClose; }
00171    virtual void        SetActive(Bool_t on = kTRUE) { fActive = on; }
00172    Bool_t              IsActive() const { return fActive; }
00173 
00174    ClassDef(TGTabElement,0)  // Little tab on tab widget
00175 };
00176 
00177 #endif

Generated on Tue Jul 5 14:20:08 2011 for ROOT_528-00b_version by  doxygen 1.5.1