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-2000, 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 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TGTab, TGTabElement, TGTabLayout //
19 // //
20 // A tab widget contains a set of composite frames each with a little //
21 // tab with a name (like a set of folders with tabs). //
22 // //
23 // The TGTab is user callable. The TGTabElement and TGTabLayout are //
24 // is a service classes of the tab widget. //
25 // //
26 // Clicking on a tab will bring the associated composite frame to the //
27 // front and generate the following event: //
28 // kC_COMMAND, kCM_TAB, tab id, 0. //
29 // //
30 //////////////////////////////////////////////////////////////////////////
31 
32 #include "TGFrame.h"
33 #include "TGWidget.h"
34 
35 class TList;
36 class TGTabElement;
37 class TGTab;
38 class TGPicture;
39 
40 class TGTabLayout : public TGLayoutManager {
41 
42 protected:
43  TGTab *fMain; // container frame
44  TList *fList; // list of frames to arrange
45 
46 private:
47  TGTabLayout(const TGTabLayout&); // not implemented
48  TGTabLayout& operator=(const TGTabLayout&); // not implemented
49 
50 public:
52 
53  virtual void Layout();
54  virtual TGDimension GetDefaultSize() const;
55  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
56 
57  ClassDef(TGTabLayout,0) // Layout manager for TGTab widget
58 };
59 
60 
61 
62 class TGTab : public TGCompositeFrame, public TGWidget {
63 
64 protected:
65  Int_t fCurrent; // index of current tab
66  UInt_t fTabh; // tab height
67  TGCompositeFrame *fContainer; // main container
68  TList *fRemoved; // list of removed tabs
70  GContext_t fNormGC; // drawing context
71 
72  void ChangeTab(Int_t tabIndex, Bool_t emit=kTRUE);
73 
74  static const TGFont *fgDefaultFont;
75  static const TGGC *fgDefaultGC;
76 
77 private:
78  TGTab(const TGTab&); // not implemented
79  TGTab& operator=(const TGTab&); // not implemented
80 
81 public:
83  static const TGGC &GetDefaultGC();
84 
85  TGTab(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
86  GContext_t norm = GetDefaultGC()(),
88  UInt_t options = kChildFrame,
90  virtual ~TGTab();
91 
93  virtual TGCompositeFrame *AddTab(const char *text);
94  virtual void AddTab(const char *text, TGCompositeFrame *cf);
95  virtual void AddTab(TGString *text, TGCompositeFrame *cf);
96 
97  virtual void NewTab(const char *text = "tab"); // *MENU*icon=bld_newtab.png*
98  virtual void RemoveTab(Int_t tabIndex = -1,
99  Bool_t storeRemoved = kTRUE); // *MENU*icon=bld_removetab.png*
100  virtual Bool_t SetTab(Int_t tabIndex, Bool_t emit = kTRUE);
101  virtual Bool_t SetTab(const char *name, Bool_t emit = kTRUE);
102  virtual void DrawBorder() { }
103 
105  Int_t GetCurrent() const { return fCurrent; }
106  TGCompositeFrame *GetTabContainer(Int_t tabIndex) const;
107  TGCompositeFrame *GetTabContainer(const char *name) const;
108  TGTabElement *GetTabTab(Int_t tabIndex) const;
109  TGTabElement *GetTabTab(const char *name) const;
112  UInt_t GetTabHeight() const { return fTabh; }
113  Int_t GetNumberOfTabs() const;
114  virtual void SetEnabled(Int_t tabIndex, Bool_t on = kTRUE); //*MENU*
115  virtual void SetText(const char *text = "tab"); //*MENU*icon=bld_rename.png*
116  Bool_t IsEnabled(Int_t tabIndex) const;
117 
118  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
119 
120  virtual void CloseTab(Int_t id) { Emit("CloseTab(Int_t)", id); } //*SIGNAL*
121  virtual void Removed(Int_t id) { Emit("Removed(Int_t)", id); } //*SIGNAL*
122  virtual void Selected(Int_t id) { Emit("Selected(Int_t)", id); } //*SIGNAL*
123  virtual TGLayoutManager *GetLayoutManager() const;
124 
125  ClassDef(TGTab,0) // Tab widget
126 };
127 
128 
129 
130 class TGTabElement : public TGFrame {
131 
132 protected:
133  TGString *fText; // text on tab
134  const TGPicture *fClosePic; // "close tab" icon
135  const TGPicture *fClosePicD; // "close tab" icon (disabled)
136  GContext_t fNormGC; // graphics context for drawing tab
137  FontStruct_t fFontStruct; // font used for tab
138  UInt_t fTWidth; // width of tab text
139  UInt_t fTHeight; // height of tab text
140  Bool_t fEnabled; // enabled or disabled
141  Bool_t fShowClose; // show or hide close icon
142  Bool_t fActive; // true if active (in front)
143 
144 private:
145  TGTabElement(const TGTabElement&); // not implemented
146  TGTabElement& operator=(const TGTabElement&); // not implemented
147 
148 public:
149  TGTabElement(const TGWindow *p = 0, TGString *text = 0, UInt_t w = 1, UInt_t h = 1,
150  GContext_t norm = TGTab::GetDefaultGC()(),
152  UInt_t options = kRaisedFrame,
154  virtual ~TGTabElement();
155 
156  virtual void DrawBorder();
157  virtual TGDimension GetDefaultSize() const;
158  const TGString *GetText() const { return fText; }
159  const char *GetString() const { return fText->GetString(); }
160  virtual Bool_t HandleButton(Event_t *event);
161  void SetText(TGString *text);
162  virtual void SetEnabled(Bool_t on = kTRUE) { fEnabled = on; }
163  Bool_t IsEnabled() const { return fEnabled; }
164  virtual void SetEditDisabled(UInt_t) {}
165  virtual void ShowClose(Bool_t on = kTRUE);
166  Bool_t IsCloseShown() const { return fShowClose; }
167  virtual void SetActive(Bool_t on = kTRUE) { fActive = on; }
168  Bool_t IsActive() const { return fActive; }
169 
170  ClassDef(TGTabElement,0) // Little tab on tab widget
171 };
172 
173 #endif
TGTab::GetCurrentTab
TGTabElement * GetCurrentTab() const
Definition: TGTab.h:111
TGTab::GetCurrent
Int_t GetCurrent() const
Definition: TGTab.h:105
TGTab::fgDefaultGC
static const TGGC * fgDefaultGC
Definition: TGTab.h:75
TGTab::GetCurrentContainer
TGCompositeFrame * GetCurrentContainer() const
Definition: TGTab.h:110
TGWindow
Definition: TGWindow.h:31
TGTabElement::fNormGC
GContext_t fNormGC
Definition: TGTab.h:136
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TGTab::~TGTab
virtual ~TGTab()
Delete tab widget.
Definition: TGTab.cxx:332
TGTabElement::~TGTabElement
virtual ~TGTabElement()
Delete tab element.
Definition: TGTab.cxx:90
TGPicture
Definition: TGPicture.h:36
TGDimension
Definition: TGDimension.h:27
TGTabElement::fClosePic
const TGPicture * fClosePic
Definition: TGTab.h:134
TGTabElement::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle button event in the tab widget.
Definition: TGTab.cxx:134
TGTabElement::SetEnabled
virtual void SetEnabled(Bool_t on=kTRUE)
Definition: TGTab.h:162
TGTab::GetTabContainer
TGCompositeFrame * GetTabContainer(Int_t tabIndex) const
Return container of tab with index tabIndex.
Definition: TGTab.cxx:565
Pixel_t
ULong_t Pixel_t
Definition: GuiTypes.h:39
TGTab::SetEnabled
virtual void SetEnabled(Int_t tabIndex, Bool_t on=kTRUE)
Enable or disable tab.
Definition: TGTab.cxx:437
FontStruct_t
Handle_t FontStruct_t
Definition: GuiTypes.h:38
TGTab::NewTab
virtual void NewTab(const char *text="tab")
Create new tab. Used in context menu.
Definition: TGTab.cxx:698
TGTab::fgDefaultFont
static const TGFont * fgDefaultFont
Definition: TGTab.h:74
TGTabElement::GetDefaultSize
virtual TGDimension GetDefaultSize() const
Return default size of tab element.
Definition: TGTab.cxx:171
TGTabElement::fText
TGString * fText
Definition: TGTab.h:133
TGTabElement::fActive
Bool_t fActive
Definition: TGTab.h:142
TGTab::GetDefaultGC
static const TGGC & GetDefaultGC()
Return default graphics context in use.
Definition: TGTab.cxx:688
Int_t
int Int_t
Definition: RtypesCore.h:45
TGWidget
Definition: TGWidget.h:55
TGTabElement::GetText
const TGString * GetText() const
Definition: TGTab.h:158
TGTab::DrawBorder
virtual void DrawBorder()
Draw frame border.
Definition: TGTab.h:102
TGTab::GetContainer
TGCompositeFrame * GetContainer() const
Definition: TGTab.h:104
TGFrame::GetDefaultFrameBackground
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:668
TGTabLayout::TGTabLayout
TGTabLayout(const TGTabLayout &)
TGTabElement::operator=
TGTabElement & operator=(const TGTabElement &)
TGTab::operator=
TGTab & operator=(const TGTab &)
TGTab::fCurrent
Int_t fCurrent
Definition: TGTab.h:65
TGTabElement::IsActive
Bool_t IsActive() const
Definition: TGTab.h:168
TGFrame
Definition: TGFrame.h:105
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TGTabElement::IsCloseShown
Bool_t IsCloseShown() const
Definition: TGTab.h:166
TGTabElement::DrawBorder
virtual void DrawBorder()
Draw little tab element.
Definition: TGTab.cxx:100
TGTab::TGTab
TGTab(const TGTab &)
TGTabElement
Definition: TGTab.h:130
TGTab::GetDefaultFontStruct
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use.
Definition: TGTab.cxx:678
text
TText * text
Definition: entrylist_figure1.C:10
TGTab::CloseTab
virtual void CloseTab(Int_t id)
Definition: TGTab.h:120
bool
TGTab::fFontStruct
FontStruct_t fFontStruct
Definition: TGTab.h:69
TGTabLayout::fList
TList * fList
Definition: TGTab.h:44
TGLayoutManager
Definition: TGLayout.h:142
TGTab::Selected
virtual void Selected(Int_t id)
Definition: TGTab.h:122
GContext_t
Handle_t GContext_t
Definition: GuiTypes.h:37
TGTab::fRemoved
TList * fRemoved
Definition: TGTab.h:68
TGTabElement::fTWidth
UInt_t fTWidth
Definition: TGTab.h:138
TGTab::fContainer
TGCompositeFrame * fContainer
Definition: TGTab.h:67
TGTabElement::SetActive
virtual void SetActive(Bool_t on=kTRUE)
Definition: TGTab.h:167
TGTab::SetText
virtual void SetText(const char *text="tab")
Set text to current tab.
Definition: TGTab.cxx:713
TGTab::GetLayoutManager
virtual TGLayoutManager * GetLayoutManager() const
Return layout manager.
Definition: TGTab.cxx:722
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TGTabElement::fTHeight
UInt_t fTHeight
Definition: TGTab.h:139
h
#define h(i)
Definition: RSha256.hxx:124
TGGC
Definition: TGGC.h:31
TGTab::AddTab
virtual TGCompositeFrame * AddTab(TGString *text)
Add a tab to the tab widget.
Definition: TGTab.cxx:343
TGTabElement::fShowClose
Bool_t fShowClose
Definition: TGTab.h:141
TGTabElement::GetString
const char * GetString() const
Definition: TGTab.h:159
TGFrame.h
main
int main(int argc, char **argv)
Definition: histspeedtest.cxx:751
TGWidget::IsEnabled
Bool_t IsEnabled() const
Definition: TGWidget.h:81
TGTab
Definition: TGTab.h:62
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:509
TGTab::ChangeTab
void ChangeTab(Int_t tabIndex, Bool_t emit=kTRUE)
Make tabIdx the current tab.
Definition: TGTab.cxx:460
TGTabLayout::operator=
TGTabLayout & operator=(const TGTabLayout &)
TGWidget.h
kRaisedFrame
@ kRaisedFrame
Definition: GuiTypes.h:384
TGTabElement::IsEnabled
Bool_t IsEnabled() const
Definition: TGTab.h:163
unsigned int
TGTabLayout::Layout
virtual void Layout()
Layout the tab widget.
Definition: TGTab.cxx:223
TGTabLayout::fMain
TGTab * fMain
Definition: TGTab.h:43
TGTabElement::fFontStruct
FontStruct_t fFontStruct
Definition: TGTab.h:137
TGTabLayout::GetDefaultSize
virtual TGDimension GetDefaultSize() const
Get default size of tab widget.
Definition: TGTab.cxx:267
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:736
TGTab::fNormGC
GContext_t fNormGC
Definition: TGTab.h:70
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:394
TGTabElement::fEnabled
Bool_t fEnabled
Definition: TGTab.h:140
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:837
Event_t
Definition: GuiTypes.h:173
name
char name[80]
Definition: TGX11.cxx:110
TGTabLayout
Definition: TGTab.h:40
TGString::GetString
const char * GetString() const
Definition: TGString.h:46
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:199
TGTabElement::TGTabElement
TGTabElement(const TGTabElement &)
TGTab::Removed
virtual void Removed(Int_t id)
Definition: TGTab.h:121
TGTab::GetNumberOfTabs
Int_t GetNumberOfTabs() const
Return number of tabs.
Definition: TGTab.cxx:660
TGFont
Definition: TGFont.h:149
TGTab::GetTabTab
TGTabElement * GetTabTab(Int_t tabIndex) const
Return the tab element of tab with index tabIndex.
Definition: TGTab.cxx:614
TGCompositeFrame
Definition: TGFrame.h:324
TGString
Definition: TGString.h:30
TGTabElement::fClosePicD
const TGPicture * fClosePicD
Definition: TGTab.h:135
TGTab::GetTabHeight
UInt_t GetTabHeight() const
Definition: TGTab.h:112
TGTab::fTabh
UInt_t fTabh
Definition: TGTab.h:66
TGTabElement::SetText
void SetText(TGString *text)
Set new tab text.
Definition: TGTab.cxx:182
TList
Definition: TList.h:44
TQObject::Emit
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
kChildFrame
@ kChildFrame
Definition: GuiTypes.h:379
int
TGTabElement::SetEditDisabled
virtual void SetEditDisabled(UInt_t)
Definition: TGTab.h:164