Logo ROOT  
Reference Guide
No Matches
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 13/01/98
5 * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
12#ifndef ROOT_TGTab
13#define ROOT_TGTab
16#include "TGFrame.h"
17#include "TGWidget.h"
19class TList;
20class TGTabElement;
21class TGTab;
22class TGPicture;
27 TGTab *fMain; // container frame
28 TList *fList; // list of frames to arrange
31 TGTabLayout(const TGTabLayout&) = delete;
37 void Layout() override;
38 TGDimension GetDefaultSize() const override;
39 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
41 ClassDefOverride(TGTabLayout,0) // Layout manager for TGTab widget
46class TGTab : public TGCompositeFrame, public TGWidget {
49 Int_t fCurrent; ///< index of current tab
50 UInt_t fTabh; ///< tab height
51 TGCompositeFrame *fContainer; ///< main container
52 TList *fRemoved; ///< list of removed tabs
54 GContext_t fNormGC; ///< drawing context
55 Bool_t fScrolling; ///< true if tab scrolling enabled
57 void ChangeTab(Int_t tabIndex, Bool_t emit=kTRUE);
59 static const TGFont *fgDefaultFont;
60 static const TGGC *fgDefaultGC;
63 TGTab(const TGTab&) = delete;
64 TGTab& operator=(const TGTab&) = delete;
68 static const TGGC &GetDefaultGC();
70 TGTab(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
71 GContext_t norm = GetDefaultGC()(),
73 UInt_t options = kChildFrame,
75 ~TGTab() override;
78 virtual TGCompositeFrame *AddTab(const char *text);
79 virtual void AddTab(const char *text, TGCompositeFrame *cf);
80 virtual void AddTab(TGString *text, TGCompositeFrame *cf);
82 virtual void NewTab(const char *text = "tab"); // *MENU*icon=bld_newtab.png*
83 virtual void RemoveTab(Int_t tabIndex = -1,
84 Bool_t storeRemoved = kTRUE); // *MENU*icon=bld_removetab.png*
85 virtual Bool_t SetTab(Int_t tabIndex, Bool_t emit = kTRUE);
86 virtual Bool_t SetTab(const char *name, Bool_t emit = kTRUE);
87 void DrawBorder() override { }
90 Int_t GetCurrent() const { return fCurrent; }
91 TGCompositeFrame *GetTabContainer(Int_t tabIndex) const;
92 TGCompositeFrame *GetTabContainer(const char *name) const;
93 TGTabElement *GetTabTab(Int_t tabIndex) const;
94 TGTabElement *GetTabTab(const char *name) const;
97 UInt_t GetTabHeight() const { return fTabh; }
98 Int_t GetNumberOfTabs() const;
99 virtual void SetEnabled(Int_t tabIndex, Bool_t on = kTRUE); //*MENU*
100 virtual void SetText(const char *text = "tab"); //*MENU*icon=bld_rename.png*
101 Bool_t IsEnabled(Int_t tabIndex) const;
102 virtual void SetScrollingEnabled(Bool_t on = kTRUE);
105 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
107 virtual void CloseTab(Int_t id) { Emit("CloseTab(Int_t)", id); } //*SIGNAL*
108 virtual void Removed(Int_t id) { Emit("Removed(Int_t)", id); } //*SIGNAL*
109 virtual void Selected(Int_t id) { Emit("Selected(Int_t)", id); } //*SIGNAL*
110 TGLayoutManager *GetLayoutManager() const override;
112 ClassDefOverride(TGTab,0) // Tab widget
117class TGTabElement : public TGFrame {
120 TGString *fText; ///< text on tab
121 const TGPicture *fClosePic; ///< "close tab" icon
122 const TGPicture *fClosePicD; ///< "close tab" icon (disabled)
123 GContext_t fNormGC; ///< graphics context for drawing tab
124 FontStruct_t fFontStruct; ///< font used for tab
125 UInt_t fTWidth; ///< width of tab text
126 UInt_t fTHeight; ///< height of tab text
127 Bool_t fEnabled; ///< enabled or disabled
128 Bool_t fShowClose; ///< show or hide close icon
129 Bool_t fActive; ///< true if active (in front)
132 TGTabElement(const TGTabElement&) = delete;
136 TGTabElement(const TGWindow *p = nullptr, TGString *text = nullptr, UInt_t w = 1, UInt_t h = 1,
139 UInt_t options = kRaisedFrame,
141 ~TGTabElement() override;
143 void DrawBorder() override;
144 TGDimension GetDefaultSize() const override;
145 const TGString *GetText() const { return fText; }
146 const char *GetString() const { return fText->GetString(); }
147 Bool_t HandleButton(Event_t *event) override;
148 void SetText(TGString *text);
149 virtual void SetEnabled(Bool_t on = kTRUE) { fEnabled = on; }
150 Bool_t IsEnabled() const { return fEnabled; }
151 void SetEditDisabled(UInt_t) override {}
152 virtual void ShowClose(Bool_t on = kTRUE);
153 Bool_t IsCloseShown() const { return fShowClose; }
154 virtual void SetActive(Bool_t on = kTRUE) { fActive = on; }
155 Bool_t IsActive() const override { return fActive; }
157 ClassDefOverride(TGTabElement,0) // Little tab on tab widget
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
@ kChildFrame
Definition GuiTypes.h:379
@ kRaisedFrame
Definition GuiTypes.h:384
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
int main()
Definition Prototype.cxx:12
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char text
char name[80]
Definition TGX11.cxx:110
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:683
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
Frame layout manager.
Definition TGLayout.h:135
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition TGString.h:20
const char * GetString() const
Definition TGString.h:30
Service classes of the tab widget.
Definition TGTab.h:117
Bool_t IsCloseShown() const
Definition TGTab.h:153
TGDimension GetDefaultSize() const override
Return default size of tab element.
Definition TGTab.cxx:202
Bool_t fActive
true if active (in front)
Definition TGTab.h:129
Bool_t fShowClose
show or hide close icon
Definition TGTab.h:128
TGString * fText
text on tab
Definition TGTab.h:120
void SetText(TGString *text)
Set new tab text.
Definition TGTab.cxx:213
Bool_t HandleButton(Event_t *event) override
Handle button event in the tab widget.
Definition TGTab.cxx:141
GContext_t fNormGC
graphics context for drawing tab
Definition TGTab.h:123
virtual void SetEnabled(Bool_t on=kTRUE)
Definition TGTab.h:149
~TGTabElement() override
Delete tab element.
Definition TGTab.cxx:97
Bool_t fEnabled
enabled or disabled
Definition TGTab.h:127
void SetEditDisabled(UInt_t) override
Definition TGTab.h:151
Bool_t IsActive() const override
Definition TGTab.h:155
const char * GetString() const
Definition TGTab.h:146
UInt_t fTHeight
height of tab text
Definition TGTab.h:126
FontStruct_t fFontStruct
font used for tab
Definition TGTab.h:124
const TGPicture * fClosePic
"close tab" icon
Definition TGTab.h:121
UInt_t fTWidth
width of tab text
Definition TGTab.h:125
const TGString * GetText() const
Definition TGTab.h:145
TGTabElement(const TGTabElement &)=delete
virtual void SetActive(Bool_t on=kTRUE)
Definition TGTab.h:154
const TGPicture * fClosePicD
"close tab" icon (disabled)
Definition TGTab.h:122
virtual void ShowClose(Bool_t on=kTRUE)
Show/hide close icon on the tab element, then apply layout to compute correct elements size.
Definition TGTab.cxx:230
Bool_t IsEnabled() const
Definition TGTab.h:150
TGTabElement & operator=(const TGTabElement &)=delete
void DrawBorder() override
Draw little tab element.
Definition TGTab.cxx:107
Service classes of the tab widget.
Definition TGTab.h:24
TGTabLayout & operator=(const TGTabLayout &)=delete
TList * fList
Definition TGTab.h:28
void Layout() override
Layout the tab widget.
Definition TGTab.cxx:254
TGTab * fMain
Definition TGTab.h:27
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
Definition TGTab.cxx:886
TGTabLayout(const TGTabLayout &)=delete
TGDimension GetDefaultSize() const override
Get default size of tab widget.
Definition TGTab.cxx:298
A tab widget contains a set of composite frames each with a little tab with a name (like a set of fol...
Definition TGTab.h:46
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use.
Definition TGTab.cxx:727
TGCompositeFrame * GetCurrentContainer() const
Definition TGTab.h:95
virtual void NewTab(const char *text="tab")
Create new tab. Used in context menu.
Definition TGTab.cxx:747
TGCompositeFrame * GetContainer() const
Definition TGTab.h:89
TGCompositeFrame * fContainer
main container
Definition TGTab.h:51
virtual void SetEnabled(Int_t tabIndex, Bool_t on=kTRUE)
Enable or disable tab.
Definition TGTab.cxx:470
virtual void SetText(const char *text="tab")
Set text to current tab.
Definition TGTab.cxx:762
FontStruct_t fFontStruct
Definition TGTab.h:53
static const TGGC & GetDefaultGC()
Return default graphics context in use.
Definition TGTab.cxx:737
virtual void Removed(Int_t id)
Definition TGTab.h:108
TGTabElement * GetTabTab(Int_t tabIndex) const
Return the tab element of tab with index tabIndex.
Definition TGTab.cxx:663
TGTab & operator=(const TGTab &)=delete
Int_t fCurrent
index of current tab
Definition TGTab.h:49
~TGTab() override
Delete tab widget.
Definition TGTab.cxx:365
GContext_t fNormGC
drawing context
Definition TGTab.h:54
Int_t GetNumberOfTabs() const
Return number of tabs.
Definition TGTab.cxx:709
static const TGGC * fgDefaultGC
Definition TGTab.h:60
Bool_t fScrolling
true if tab scrolling enabled
Definition TGTab.h:55
virtual Bool_t SetTab(Int_t tabIndex, Bool_t emit=kTRUE)
Brings the composite frame with the index tabIndex to the front and generate the following event if t...
Definition TGTab.cxx:558
Int_t GetCurrent() const
Definition TGTab.h:90
UInt_t fTabh
tab height
Definition TGTab.h:50
virtual void SetScrollingEnabled(Bool_t on=kTRUE)
Enable or disable tab scrolling.
Definition TGTab.cxx:490
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a tab widget as a C++ statement(s) on output stream out.
Definition TGTab.cxx:785
TList * fRemoved
list of removed tabs
Definition TGTab.h:52
virtual void RemoveTab(Int_t tabIndex=-1, Bool_t storeRemoved=kTRUE)
Remove container and tab of tab with index tabIndex.
Definition TGTab.cxx:427
virtual void CloseTab(Int_t id)
Definition TGTab.h:107
virtual void Selected(Int_t id)
Definition TGTab.h:109
void ChangeTab(Int_t tabIndex, Bool_t emit=kTRUE)
Make tabIdx the current tab.
Definition TGTab.cxx:509
void DrawBorder() override
Draw frame border.
Definition TGTab.h:87
UInt_t GetTabHeight() const
Definition TGTab.h:97
TGCompositeFrame * GetTabContainer(Int_t tabIndex) const
Return container of tab with index tabIndex.
Definition TGTab.cxx:614
virtual TGCompositeFrame * AddTab(TGString *text)
Add a tab to the tab widget.
Definition TGTab.cxx:376
Bool_t IsScrollingEnabled() const
Returns true if tab scrolling is enabled.
Definition TGTab.cxx:482
TGTab(const TGTab &)=delete
TGTabElement * GetCurrentTab() const
Definition TGTab.h:96
TGLayoutManager * GetLayoutManager() const override
Return layout manager.
Definition TGTab.cxx:771
static const TGFont * fgDefaultFont
Definition TGTab.h:59
The widget base class.
Definition TGWidget.h:43
Bool_t IsEnabled() const
Definition TGWidget.h:69
ROOT GUI Window base class.
Definition TGWindow.h:23
A doubly linked list.
Definition TList.h:38
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
Event structure.
Definition GuiTypes.h:174