Logo ROOT   6.10/09
Reference Guide
TGButtonGroup.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Valeriy Onuchin & Fons Rademakers 16/10/2000
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_TGButtonGroup
13 #define ROOT_TGButtonGroup
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TGButtonGroup, TGVButtonGroup and TGHButtonGroup //
18 // //
19 // This header defines button group frames. //
20 // //
21 //////////////////////////////////////////////////////////////////////////
22 
23 #include "TGFrame.h"
24 #include "TMap.h"
25 
26 
27 class TGButton;
28 
29 
30 
31 class TGButtonGroup : public TGGroupFrame {
32 
33 friend class TGButton;
34 
35 private:
36  TGButtonGroup(const TGButtonGroup&); // Not implemented
37  TGButtonGroup& operator=(const TGButtonGroup&); // Not implemented
38 
39 protected:
40  Bool_t fState; // kTRUE if group is enabled
41  Bool_t fExclGroup; // kTRUE if group is exclusive
42  Bool_t fRadioExcl; // kTRUE if radio buttons are exclusive
43  Bool_t fDrawBorder; // kTRUE if border and title are drawn
44  TMap *fMapOfButtons; // map of button/id pairs in this group
45 
46  void Init();
47  virtual void DoRedraw();
48 
49 public:
50  TGButtonGroup(const TGWindow *parent = 0,
51  const TString &title = "",
52  UInt_t options = kChildFrame | kVerticalFrame,
56 
57  TGButtonGroup(const TGWindow *parent,
58  UInt_t r, UInt_t c, Int_t s = 0, Int_t h = 0 ,
59  const TString &title = "",
63 
64  virtual ~TGButtonGroup();
65 
66  virtual void Pressed(Int_t id) { Emit("Pressed(Int_t)",id); } //*SIGNAL*
67  virtual void Released(Int_t id) { Emit("Released(Int_t)",id);} //*SIGNAL*
68  virtual void Clicked(Int_t id) { Emit("Clicked(Int_t)",id); } //*SIGNAL*
69 
70  virtual void ButtonPressed();
71  virtual void ButtonReleased();
72  virtual void ButtonClicked();
73  virtual void ReleaseButtons();
74 
75  Bool_t IsEnabled() const { return fState; }
76  Bool_t IsExclusive() const { return fExclGroup; }
78  Bool_t IsBorderDrawn() const { return fDrawBorder; }
79  Int_t GetCount() const { return fMapOfButtons->GetSize(); }
80  Int_t GetId(TGButton *button) const;
81 
82  virtual void SetExclusive(Bool_t flag = kTRUE);
83  virtual void SetRadioButtonExclusive(Bool_t flag = kTRUE);
84  virtual void SetState(Bool_t state = kTRUE);
85  virtual void SetBorderDrawn(Bool_t enable = kTRUE);
86  virtual void SetButton(Int_t id, Bool_t down = kTRUE);
87  virtual void SetTitle(TGString *title);
88  virtual void SetTitle(const char *title);
89 
90  virtual Int_t Insert(TGButton *button, int id = -1);
91  virtual void Remove(TGButton *button);
92  virtual TGButton *Find(Int_t id) const;
93  virtual TGButton *GetButton(Int_t id) const { return Find(id); }
94  virtual void Show();
95  virtual void Hide();
96  virtual void DrawBorder();
97  virtual void SetLayoutHints(TGLayoutHints *l, TGButton *button = 0);
98  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
99 
100  ClassDef(TGButtonGroup,0) // Organizes TGButtons in a group
101 };
102 
103 
105 
106 public:
107  TGVButtonGroup(const TGWindow *parent,
108  const TString &title = "",
112  TGButtonGroup(parent, title, kChildFrame | kVerticalFrame,
113  norm, font, back) { }
114 
115  virtual ~TGVButtonGroup() { }
116  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
117 
118  ClassDef(TGVButtonGroup,0) // A button group with one vertical column
119 };
120 
121 
123 
124 public:
125  TGHButtonGroup(const TGWindow *parent,
126  const TString &title = "",
130  TGButtonGroup(parent, title, kChildFrame | kHorizontalFrame,
131  norm, font, back) { }
132 
133  virtual ~TGHButtonGroup() { }
134  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
135 
136  ClassDef(TGHButtonGroup,0) // A button group with one horizontal row
137 };
138 
139 #endif
Handle_t FontStruct_t
Definition: GuiTypes.h:38
virtual void Released(Int_t id)
Definition: TGButtonGroup.h:67
static const TGGC & GetDefaultGC()
Return default graphics context in use.
Definition: TGFrame.cxx:2301
virtual void ButtonReleased()
This slot is activated when one of the buttons in the group emits the Released() signal.
Bool_t IsBorderDrawn() const
Definition: TGButtonGroup.h:78
const char Option_t
Definition: RtypesCore.h:62
virtual void SetBorderDrawn(Bool_t enable=kTRUE)
Makes border to be visible/invisible.
virtual void ButtonPressed()
This slot is activated when one of the buttons in the group emits the Pressed() signal.
virtual void SetButton(Int_t id, Bool_t down=kTRUE)
Sets the button with id to be on/down, and if this is an exclusive group, all other button in the gro...
TH1 * h
Definition: legend2.C:5
TGVButtonGroup(const TGWindow *parent, const TString &title="", GContext_t norm=GetDefaultGC()(), FontStruct_t font=GetDefaultFontStruct(), Pixel_t back=GetDefaultFrameBackground())
Bool_t fRadioExcl
Definition: TGButtonGroup.h:42
virtual void SetExclusive(Bool_t flag=kTRUE)
Sets the button group to be exclusive if enable is kTRUE, or to be non-exclusive if enable is kFALSE...
Handle_t GContext_t
Definition: GuiTypes.h:37
Basic string class.
Definition: TString.h:129
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual TGButton * Find(Int_t id) const
Finds and returns a pointer to the button with the specified identifier id.
virtual ~TGHButtonGroup()
virtual void ButtonClicked()
This slot is activated when one of the buttons in the group emits the Clicked() signal.
virtual void Hide()
Hide group of buttons.
Bool_t IsEnabled() const
Definition: TGButtonGroup.h:75
virtual void SetState(Bool_t state=kTRUE)
Sets the state of all the buttons in the group to enable or disable.
Handle_t GetId() const
Definition: TGObject.h:48
#define ClassDef(name, id)
Definition: Rtypes.h:297
ULong_t Pixel_t
Definition: GuiTypes.h:39
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:665
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a button group widget as a C++ statement(s) on output stream out.
TMap * fMapOfButtons
Definition: TGButtonGroup.h:44
virtual void SetRadioButtonExclusive(Bool_t flag=kTRUE)
If enable is kTRUE, this button group will treat radio buttons as mutually exclusive, and other buttons according to IsExclusive().
virtual ~TGButtonGroup()
Destructor, we do not delete the buttons.
Int_t GetCount() const
Definition: TGButtonGroup.h:79
virtual void Clicked(Int_t id)
Definition: TGButtonGroup.h:68
virtual void SetTitle(TGString *title)
Set or change title.
TRandom2 r(17)
virtual void SetLayoutHints(TGLayoutHints *l, TGButton *button=0)
Set layout hints for the specified button or if button=0 for all buttons.
virtual void ReleaseButtons()
This slot is activated when one of the buttons in the exclusive group emits the Pressed() signal...
unsigned int UInt_t
Definition: RtypesCore.h:42
Bool_t IsExclusive() const
Definition: TGButtonGroup.h:76
virtual void DoRedraw()
Redraw the group frame.
TLine * l
Definition: textangle.C:4
virtual TGButton * GetButton(Int_t id) const
Definition: TGButtonGroup.h:93
TGHButtonGroup(const TGWindow *parent, const TString &title="", GContext_t norm=GetDefaultGC()(), FontStruct_t font=GetDefaultFontStruct(), Pixel_t back=GetDefaultFrameBackground())
TGButtonGroup(const TGButtonGroup &)
Bool_t IsRadioButtonExclusive() const
Definition: TGButtonGroup.h:77
virtual void Remove(TGButton *button)
Removes a button from the button group.
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:40
virtual Int_t Insert(TGButton *button, int id=-1)
Inserts a button with the identifier id into the button group.
virtual void Show()
Show group of buttons.
virtual ~TGVButtonGroup()
void Init()
Default init.
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use.
Definition: TGFrame.cxx:2291
virtual void DrawBorder()
Draw border of around the group frame.
TGButtonGroup & operator=(const TGButtonGroup &)
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
virtual Int_t GetSize() const
Definition: TCollection.h:89
virtual void Pressed(Int_t id)
Definition: TGButtonGroup.h:66
Bool_t fDrawBorder
Definition: TGButtonGroup.h:43
const Bool_t kTRUE
Definition: RtypesCore.h:91
double norm(double *x, double *p)
Definition: unuranDistr.cxx:40
Bool_t fExclGroup
Definition: TGButtonGroup.h:41