Logo ROOT   6.08/07
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 #ifndef ROOT_TGFrame
33 #include "TGFrame.h"
34 #endif
35 #ifndef ROOT_TGWidget
36 #include "TGWidget.h"
37 #endif
38 
39 class TList;
40 class TGTabElement;
41 class TGTab;
42 class TGPicture;
43 
44 class TGTabLayout : public TGLayoutManager {
45 
46 protected:
47  TGTab *fMain; // container frame
48  TList *fList; // list of frames to arrange
49 
50 private:
51  TGTabLayout(const TGTabLayout&); // not implemented
52  TGTabLayout& operator=(const TGTabLayout&); // not implemented
53 
54 public:
56 
57  virtual void Layout();
58  virtual TGDimension GetDefaultSize() const;
59  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
60 
61  ClassDef(TGTabLayout,0) // Layout manager for TGTab widget
62 };
63 
64 
65 
66 class TGTab : public TGCompositeFrame, public TGWidget {
67 
68 protected:
69  Int_t fCurrent; // index of current tab
70  UInt_t fTabh; // tab height
71  TGCompositeFrame *fContainer; // main container
72  TList *fRemoved; // list of removed tabs
74  GContext_t fNormGC; // drawing context
75 
76  void ChangeTab(Int_t tabIndex, Bool_t emit=kTRUE);
77 
78  static const TGFont *fgDefaultFont;
79  static const TGGC *fgDefaultGC;
80 
81 private:
82  TGTab(const TGTab&); // not implemented
83  TGTab& operator=(const TGTab&); // not implemented
84 
85 public:
86  static FontStruct_t GetDefaultFontStruct();
87  static const TGGC &GetDefaultGC();
88 
89  TGTab(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
90  GContext_t norm = GetDefaultGC()(),
91  FontStruct_t font = GetDefaultFontStruct(),
92  UInt_t options = kChildFrame,
93  Pixel_t back = GetDefaultFrameBackground());
94  virtual ~TGTab();
95 
96  virtual TGCompositeFrame *AddTab(TGString *text);
97  virtual TGCompositeFrame *AddTab(const char *text);
98  virtual void AddTab(const char *text, TGCompositeFrame *cf);
99  virtual void AddTab(TGString *text, TGCompositeFrame *cf);
100 
101  virtual void NewTab(const char *text = "tab"); // *MENU*icon=bld_newtab.png*
102  virtual void RemoveTab(Int_t tabIndex = -1,
103  Bool_t storeRemoved = kTRUE); // *MENU*icon=bld_removetab.png*
104  virtual Bool_t SetTab(Int_t tabIndex, Bool_t emit = kTRUE);
105  virtual Bool_t SetTab(const char *name, Bool_t emit = kTRUE);
106  virtual void DrawBorder() { }
107 
108  TGCompositeFrame *GetContainer() const { return fContainer; }
109  Int_t GetCurrent() const { return fCurrent; }
110  TGCompositeFrame *GetTabContainer(Int_t tabIndex) const;
111  TGCompositeFrame *GetTabContainer(const char *name) const;
112  TGTabElement *GetTabTab(Int_t tabIndex) const;
113  TGTabElement *GetTabTab(const char *name) const;
114  TGCompositeFrame *GetCurrentContainer() const { return GetTabContainer(fCurrent); }
115  TGTabElement *GetCurrentTab() const { return GetTabTab(fCurrent); }
116  UInt_t GetTabHeight() const { return fTabh; }
117  Int_t GetNumberOfTabs() const;
118  virtual void SetEnabled(Int_t tabIndex, Bool_t on = kTRUE); //*MENU*
119  virtual void SetText(const char *text = "tab"); //*MENU*icon=bld_rename.png*
120  Bool_t IsEnabled(Int_t tabIndex) const;
121 
122  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
123 
124  virtual void CloseTab(Int_t id) { Emit("CloseTab(Int_t)", id); } //*SIGNAL*
125  virtual void Removed(Int_t id) { Emit("Removed(Int_t)", id); } //*SIGNAL*
126  virtual void Selected(Int_t id) { Emit("Selected(Int_t)", id); } //*SIGNAL*
127  virtual TGLayoutManager *GetLayoutManager() const;
128 
129  ClassDef(TGTab,0) // Tab widget
130 };
131 
132 
133 
134 class TGTabElement : public TGFrame {
135 
136 protected:
137  TGString *fText; // text on tab
138  const TGPicture *fClosePic; // "close tab" icon
139  const TGPicture *fClosePicD; // "close tab" icon (disabled)
140  GContext_t fNormGC; // graphics context for drawing tab
141  FontStruct_t fFontStruct; // font used for tab
142  UInt_t fTWidth; // width of tab text
143  UInt_t fTHeight; // height of tab text
144  Bool_t fEnabled; // enabled or disabled
145  Bool_t fShowClose; // show or hide close icon
146  Bool_t fActive; // true if active (in front)
147 
148 private:
149  TGTabElement(const TGTabElement&); // not implemented
150  TGTabElement& operator=(const TGTabElement&); // not implemented
151 
152 public:
153  TGTabElement(const TGWindow *p = 0, TGString *text = 0, UInt_t w = 1, UInt_t h = 1,
156  UInt_t options = kRaisedFrame,
157  Pixel_t back = GetDefaultFrameBackground());
158  virtual ~TGTabElement();
159 
160  virtual void DrawBorder();
161  virtual TGDimension GetDefaultSize() const;
162  const TGString *GetText() const { return fText; }
163  const char *GetString() const { return fText->GetString(); }
164  virtual Bool_t HandleButton(Event_t *event);
165  void SetText(TGString *text);
166  virtual void SetEnabled(Bool_t on = kTRUE) { fEnabled = on; }
167  Bool_t IsEnabled() const { return fEnabled; }
168  virtual void SetEditDisabled(UInt_t) {}
169  virtual void ShowClose(Bool_t on = kTRUE);
170  Bool_t IsCloseShown() const { return fShowClose; }
171  virtual void SetActive(Bool_t on = kTRUE) { fActive = on; }
172  Bool_t IsActive() const { return fActive; }
173 
174  ClassDef(TGTabElement,0) // Little tab on tab widget
175 };
176 
177 #endif
TGCompositeFrame * GetCurrentContainer() const
Definition: TGTab.h:114
Handle_t FontStruct_t
Definition: GuiTypes.h:40
GContext_t fNormGC
Definition: TGTab.h:140
TGTabElement * GetCurrentTab() const
Definition: TGTab.h:115
Int_t GetCurrent() const
Definition: TGTab.h:109
Definition: TGTab.h:66
const TGPicture * fClosePicD
Definition: TGTab.h:139
const char Option_t
Definition: RtypesCore.h:62
TH1 * h
Definition: legend2.C:5
static const TGGC & GetDefaultGC()
Return default graphics context in use.
Definition: TGTab.cxx:686
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use.
Definition: TGTab.cxx:676
Handle_t GContext_t
Definition: GuiTypes.h:39
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TGCompositeFrame * GetContainer() const
Definition: TGTab.h:108
TGTabLayout(const TGTabLayout &)
TList * fRemoved
Definition: TGTab.h:72
TGString * fText
Definition: TGTab.h:137
TGCompositeFrame * fContainer
Definition: TGTab.h:71
Int_t fCurrent
Definition: TGTab.h:69
TList * fList
Definition: TGTab.h:48
static const TGFont * fgDefaultFont
Definition: TGTab.h:78
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual void Selected(Int_t id)
Definition: TGTab.h:126
ULong_t Pixel_t
Definition: GuiTypes.h:41
Bool_t fShowClose
Definition: TGTab.h:145
virtual void SetEditDisabled(UInt_t)
Definition: TGTab.h:168
Bool_t fActive
Definition: TGTab.h:146
Bool_t IsActive() const
Definition: TGTab.h:172
const TGPicture * fClosePic
Definition: TGTab.h:138
virtual void DrawBorder()
Draw frame border.
Definition: TGTab.h:106
FontStruct_t fFontStruct
Definition: TGTab.h:73
A doubly linked list.
Definition: TList.h:47
virtual void CloseTab(Int_t id)
Definition: TGTab.h:124
Bool_t IsEnabled() const
Definition: TGTab.h:167
FontStruct_t fFontStruct
Definition: TGTab.h:141
virtual TGDimension GetDefaultSize() const
Get default size of tab widget.
Definition: TGTab.cxx:265
unsigned int UInt_t
Definition: RtypesCore.h:42
TGTabLayout & operator=(const TGTabLayout &)
UInt_t fTWidth
Definition: TGTab.h:142
TGTab * fMain
Definition: TGTab.h:47
const char * GetString() const
Definition: TGString.h:44
UInt_t fTHeight
Definition: TGTab.h:143
TText * text
virtual void Layout()
Layout the tab widget.
Definition: TGTab.cxx:221
virtual void SetActive(Bool_t on=kTRUE)
Definition: TGTab.h:171
Definition: TGFont.h:155
const TGString * GetText() const
Definition: TGTab.h:162
UInt_t GetTabHeight() const
Definition: TGTab.h:116
virtual void Removed(Int_t id)
Definition: TGTab.h:125
GContext_t fNormGC
Definition: TGTab.h:74
Bool_t IsCloseShown() const
Definition: TGTab.h:170
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGTab.cxx:835
const char * GetString() const
Definition: TGTab.h:163
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void SetEnabled(Bool_t on=kTRUE)
Definition: TGTab.h:166
double norm(double *x, double *p)
Definition: unuranDistr.cxx:40
Definition: TGGC.h:35
Bool_t fEnabled
Definition: TGTab.h:144
int main(int argc, char **argv)
char name[80]
Definition: TGX11.cxx:109
static const TGGC * fgDefaultGC
Definition: TGTab.h:79
UInt_t fTabh
Definition: TGTab.h:70