Logo ROOT  
Reference Guide
TGTab.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 13/01/98
3 
4 /*************************************************************************
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  *************************************************************************/
11 
12 #ifndef ROOT_TGTab
13 #define ROOT_TGTab
14 
15 
16 #include "TGFrame.h"
17 #include "TGWidget.h"
18 
19 class TList;
20 class TGTabElement;
21 class TGTab;
22 class TGPicture;
23 
24 class TGTabLayout : public TGLayoutManager {
25 
26 protected:
27  TGTab *fMain; // container frame
28  TList *fList; // list of frames to arrange
29 
30 private:
31  TGTabLayout(const TGTabLayout&) = delete;
32  TGTabLayout& operator=(const TGTabLayout&) = delete;
33 
34 public:
36 
37  virtual void Layout();
38  virtual TGDimension GetDefaultSize() const;
39  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
40 
41  ClassDef(TGTabLayout,0) // Layout manager for TGTab widget
42 };
43 
44 
45 
46 class TGTab : public TGCompositeFrame, public TGWidget {
47 
48 protected:
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
56 
57  void ChangeTab(Int_t tabIndex, Bool_t emit=kTRUE);
58 
59  static const TGFont *fgDefaultFont;
60  static const TGGC *fgDefaultGC;
61 
62 private:
63  TGTab(const TGTab&) = delete;
64  TGTab& operator=(const TGTab&) = delete;
65 
66 public:
68  static const TGGC &GetDefaultGC();
69 
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  virtual ~TGTab();
76 
78  virtual TGCompositeFrame *AddTab(const char *text);
79  virtual void AddTab(const char *text, TGCompositeFrame *cf);
80  virtual void AddTab(TGString *text, TGCompositeFrame *cf);
81 
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  virtual void DrawBorder() { }
88 
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);
103  Bool_t IsScrollingEnabled() const;
104 
105  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
106 
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  virtual TGLayoutManager *GetLayoutManager() const;
111 
112  ClassDef(TGTab,0) // Tab widget
113 };
114 
115 
116 
117 class TGTabElement : public TGFrame {
118 
119 protected:
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)
130 
131 private:
132  TGTabElement(const TGTabElement&) = delete;
134 
135 public:
136  TGTabElement(const TGWindow *p = nullptr, TGString *text = nullptr, UInt_t w = 1, UInt_t h = 1,
137  GContext_t norm = TGTab::GetDefaultGC()(),
139  UInt_t options = kRaisedFrame,
141  virtual ~TGTabElement();
142 
143  virtual void DrawBorder();
144  virtual TGDimension GetDefaultSize() const;
145  const TGString *GetText() const { return fText; }
146  const char *GetString() const { return fText->GetString(); }
147  virtual Bool_t HandleButton(Event_t *event);
148  void SetText(TGString *text);
149  virtual void SetEnabled(Bool_t on = kTRUE) { fEnabled = on; }
150  Bool_t IsEnabled() const { return fEnabled; }
151  virtual void SetEditDisabled(UInt_t) {}
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 { return fActive; }
156 
157  ClassDef(TGTabElement,0) // Little tab on tab widget
158 };
159 
160 #endif
TGTab::GetCurrentTab
TGTabElement * GetCurrentTab() const
Definition: TGTab.h:96
TGTab::GetCurrent
Int_t GetCurrent() const
Definition: TGTab.h:90
TGTab::fgDefaultGC
static const TGGC * fgDefaultGC
Definition: TGTab.h:60
TGTab::GetCurrentContainer
TGCompositeFrame * GetCurrentContainer() const
Definition: TGTab.h:95
TGWindow
ROOT GUI Window base class.
Definition: TGWindow.h:23
TGTabElement::fNormGC
GContext_t fNormGC
graphics context for drawing tab
Definition: TGTab.h:123
TGTab::IsScrollingEnabled
Bool_t IsScrollingEnabled() const
Returns true if tab scrolling is enabled.
Definition: TGTab.cxx:482
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
TGTab::~TGTab
virtual ~TGTab()
Delete tab widget.
Definition: TGTab.cxx:365
TGTabElement::~TGTabElement
virtual ~TGTabElement()
Delete tab element.
Definition: TGTab.cxx:97
TGPicture
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition: TGPicture.h:25
TGDimension
Definition: TGDimension.h:18
Option_t
const char Option_t
Definition: RtypesCore.h:66
TGTabElement::fClosePic
const TGPicture * fClosePic
"close tab" icon
Definition: TGTab.h:121
TGTab::fScrolling
Bool_t fScrolling
true if tab scrolling enabled
Definition: TGTab.h:55
TGTabElement::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle button event in the tab widget.
Definition: TGTab.cxx:141
TGTabElement::SetEnabled
virtual void SetEnabled(Bool_t on=kTRUE)
Definition: TGTab.h:149
TGTab::GetTabContainer
TGCompositeFrame * GetTabContainer(Int_t tabIndex) const
Return container of tab with index tabIndex.
Definition: TGTab.cxx:614
Pixel_t
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
TGTab::SetEnabled
virtual void SetEnabled(Int_t tabIndex, Bool_t on=kTRUE)
Enable or disable tab.
Definition: TGTab.cxx:470
FontStruct_t
Handle_t FontStruct_t
Pointer to font structure.
Definition: GuiTypes.h:39
TGTab::NewTab
virtual void NewTab(const char *text="tab")
Create new tab. Used in context menu.
Definition: TGTab.cxx:747
TGTab::fgDefaultFont
static const TGFont * fgDefaultFont
Definition: TGTab.h:59
TGTabElement::GetDefaultSize
virtual TGDimension GetDefaultSize() const
Return default size of tab element.
Definition: TGTab.cxx:202
TGTab::TGTab
TGTab(const TGTab &)=delete
TGTabElement::fText
TGString * fText
text on tab
Definition: TGTab.h:120
TGTabElement::fActive
Bool_t fActive
true if active (in front)
Definition: TGTab.h:129
TGTab::SetScrollingEnabled
virtual void SetScrollingEnabled(Bool_t on=kTRUE)
Enable or disable tab scrolling.
Definition: TGTab.cxx:490
TGTab::GetDefaultGC
static const TGGC & GetDefaultGC()
Return default graphics context in use.
Definition: TGTab.cxx:737
Int_t
int Int_t
Definition: RtypesCore.h:45
TGWidget
The widget base class.
Definition: TGWidget.h:43
event
Definition: triangle.c:552
TGTabElement::GetText
const TGString * GetText() const
Definition: TGTab.h:145
TGTab::DrawBorder
virtual void DrawBorder()
Draw frame border.
Definition: TGTab.h:87
TGTab::GetContainer
TGCompositeFrame * GetContainer() const
Definition: TGTab.h:89
TGFrame::GetDefaultFrameBackground
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:683
TGTab::fCurrent
Int_t fCurrent
index of current tab
Definition: TGTab.h:49
TGTabElement::IsActive
Bool_t IsActive() const
Definition: TGTab.h:155
TGFrame
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition: TGFrame.h:80
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TGTabElement::IsCloseShown
Bool_t IsCloseShown() const
Definition: TGTab.h:153
TGTabElement::DrawBorder
virtual void DrawBorder()
Draw little tab element.
Definition: TGTab.cxx:107
TGTabElement
Service classes of the tab widget.
Definition: TGTab.h:117
TGTab::GetDefaultFontStruct
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use.
Definition: TGTab.cxx:727
text
TText * text
Definition: entrylist_figure1.C:10
TGTab::CloseTab
virtual void CloseTab(Int_t id)
Definition: TGTab.h:107
bool
TGTab::fFontStruct
FontStruct_t fFontStruct
font
Definition: TGTab.h:53
TGTabLayout::TGTabLayout
TGTabLayout(const TGTabLayout &)=delete
TGTabLayout::fList
TList * fList
Definition: TGTab.h:28
TGLayoutManager
Frame layout manager.
Definition: TGLayout.h:135
TGTab::Selected
virtual void Selected(Int_t id)
Definition: TGTab.h:109
GContext_t
Handle_t GContext_t
Graphics context handle.
Definition: GuiTypes.h:38
TGTab::fRemoved
TList * fRemoved
list of removed tabs
Definition: TGTab.h:52
TGTabElement::fTWidth
UInt_t fTWidth
width of tab text
Definition: TGTab.h:125
TGTab::fContainer
TGCompositeFrame * fContainer
main container
Definition: TGTab.h:51
TGTabElement::SetActive
virtual void SetActive(Bool_t on=kTRUE)
Definition: TGTab.h:154
TGTab::SetText
virtual void SetText(const char *text="tab")
Set text to current tab.
Definition: TGTab.cxx:762
TGTab::GetLayoutManager
virtual TGLayoutManager * GetLayoutManager() const
Return layout manager.
Definition: TGTab.cxx:771
TGTabElement::fTHeight
UInt_t fTHeight
height of tab text
Definition: TGTab.h:126
h
#define h(i)
Definition: RSha256.hxx:106
TGGC
Encapsulate a graphics context used in the low level graphics.
Definition: TGGC.h:22
TGTab::AddTab
virtual TGCompositeFrame * AddTab(TGString *text)
Add a tab to the tab widget.
Definition: TGTab.cxx:376
TGTabElement::TGTabElement
TGTabElement(const TGTabElement &)=delete
TGTabElement::fShowClose
Bool_t fShowClose
show or hide close icon
Definition: TGTab.h:128
TGTabElement::GetString
const char * GetString() const
Definition: TGTab.h:146
TGFrame.h
TGWidget::IsEnabled
Bool_t IsEnabled() const
Definition: TGWidget.h:69
TGTab
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
TGTab::SetTab
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
TGTab::ChangeTab
void ChangeTab(Int_t tabIndex, Bool_t emit=kTRUE)
Make tabIdx the current tab.
Definition: TGTab.cxx:509
TGWidget.h
kRaisedFrame
@ kRaisedFrame
Definition: GuiTypes.h:384
TGTabElement::IsEnabled
Bool_t IsEnabled() const
Definition: TGTab.h:150
unsigned int
TGTabLayout::Layout
virtual void Layout()
Layout the tab widget.
Definition: TGTab.cxx:254
TGTabLayout::fMain
TGTab * fMain
Definition: TGTab.h:27
TGTabElement::fFontStruct
FontStruct_t fFontStruct
font used for tab
Definition: TGTab.h:124
TGTabLayout::operator=
TGTabLayout & operator=(const TGTabLayout &)=delete
TGTabLayout::GetDefaultSize
virtual TGDimension GetDefaultSize() const
Get default size of tab widget.
Definition: TGTab.cxx:298
TGTab::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a tab widget as a C++ statement(s) on output stream out.
Definition: TGTab.cxx:785
TGTab::fNormGC
GContext_t fNormGC
drawing context
Definition: TGTab.h:54
TGTab::RemoveTab
virtual void RemoveTab(Int_t tabIndex=-1, Bool_t storeRemoved=kTRUE)
Remove container and tab of tab with index tabIndex.
Definition: TGTab.cxx:427
TGTabElement::fEnabled
Bool_t fEnabled
enabled or disabled
Definition: TGTab.h:127
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGTabLayout::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGTab.cxx:886
Event_t
Event structure.
Definition: GuiTypes.h:174
name
char name[80]
Definition: TGX11.cxx:110
TGTabLayout
Service classes of the tab widget.
Definition: TGTab.h:24
TGString::GetString
const char * GetString() const
Definition: TGString.h:30
TGTabElement::operator=
TGTabElement & operator=(const TGTabElement &)=delete
TGTabElement::ShowClose
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
TGTab::Removed
virtual void Removed(Int_t id)
Definition: TGTab.h:108
TGTab::GetNumberOfTabs
Int_t GetNumberOfTabs() const
Return number of tabs.
Definition: TGTab.cxx:709
TGFont
Encapsulate fonts used in the GUI system.
Definition: TGFont.h:140
TGTab::GetTabTab
TGTabElement * GetTabTab(Int_t tabIndex) const
Return the tab element of tab with index tabIndex.
Definition: TGTab.cxx:663
TGCompositeFrame
The base class for composite widgets (menu bars, list boxes, etc.).
Definition: TGFrame.h:287
TGString
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition: TGString.h:20
TGTabElement::fClosePicD
const TGPicture * fClosePicD
"close tab" icon (disabled)
Definition: TGTab.h:122
TGTab::GetTabHeight
UInt_t GetTabHeight() const
Definition: TGTab.h:97
TGTab::fTabh
UInt_t fTabh
tab height
Definition: TGTab.h:50
TGTabElement::SetText
void SetText(TGString *text)
Set new tab text.
Definition: TGTab.cxx:213
TGTab::operator=
TGTab & operator=(const TGTab &)=delete
TList
A doubly linked list.
Definition: TList.h:44
TQObject::Emit
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
main
int main(int argc, char *argv[])
Definition: cef_main.cxx:54
kChildFrame
@ kChildFrame
Definition: GuiTypes.h:379
int
TGTabElement::SetEditDisabled
virtual void SetEditDisabled(UInt_t)
Definition: TGTab.h:151