Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
19class TList;
20class TGTabElement;
21class TGTab;
22class TGPicture;
23
25
26protected:
27 TGTab *fMain; // container frame
28 TList *fList; // list of frames to arrange
29
30private:
31 TGTabLayout(const TGTabLayout&) = delete;
33
34public:
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
46class TGTab : public TGCompositeFrame, public TGWidget {
47
48protected:
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
62private:
63 TGTab(const TGTab&) = delete;
64 TGTab& operator=(const TGTab&) = delete;
65
66public:
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);
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
117class TGTabElement : public TGFrame {
118
119protected:
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
131private:
132 TGTabElement(const TGTabElement&) = delete;
134
135public:
136 TGTabElement(const TGWindow *p = nullptr, TGString *text = nullptr, UInt_t w = 1, UInt_t h = 1,
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(); }
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
@ kChildFrame
Definition GuiTypes.h:379
@ kRaisedFrame
Definition GuiTypes.h:384
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
int main()
Definition Prototype.cxx:12
#define h(i)
Definition RSha256.hxx:106
int Int_t
Definition RtypesCore.h:45
bool Bool_t
Definition RtypesCore.h:63
const Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassDef(name, id)
Definition Rtypes.h:325
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
virtual TGDimension GetDefaultSize() const
Return default size of tab element.
Definition TGTab.cxx:202
Bool_t IsCloseShown() const
Definition TGTab.h:153
virtual ~TGTabElement()
Delete tab element.
Definition TGTab.cxx:97
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
GContext_t fNormGC
graphics context for drawing tab
Definition TGTab.h:123
virtual void DrawBorder()
Draw little tab element.
Definition TGTab.cxx:107
virtual void SetEnabled(Bool_t on=kTRUE)
Definition TGTab.h:149
Bool_t fEnabled
enabled or disabled
Definition TGTab.h:127
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
virtual void SetEditDisabled(UInt_t)
Definition TGTab.h:151
const TGString * GetText() const
Definition TGTab.h:145
Bool_t IsActive() const
Definition TGTab.h:155
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
virtual Bool_t HandleButton(Event_t *event)
Handle button event in the tab widget.
Definition TGTab.cxx:141
Service classes of the tab widget.
Definition TGTab.h:24
TGTabLayout & operator=(const TGTabLayout &)=delete
TList * fList
Definition TGTab.h:28
TGTab * fMain
Definition TGTab.h:27
TGTabLayout(const TGTabLayout &)=delete
virtual void Layout()
Layout the tab widget.
Definition TGTab.cxx:254
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
virtual TGDimension GetDefaultSize() const
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
virtual TGLayoutManager * GetLayoutManager() const
Return layout manager.
Definition TGTab.cxx:771
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
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
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
font
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
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
virtual void DrawBorder()
Draw frame border.
Definition TGTab.h:87
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
UInt_t GetTabHeight() const
Definition TGTab.h:97
virtual ~TGTab()
Delete tab widget.
Definition TGTab.cxx:365
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
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
TText * text
Event structure.
Definition GuiTypes.h:174