Logo ROOT   6.08/07
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 #ifndef ROOT_TGFrame
24 #include "TGFrame.h"
25 #endif
26 #ifndef ROOT_TMap
27 #include "TMap.h"
28 #endif
29 
30 
31 class TGButton;
32 
33 
34 
35 class TGButtonGroup : public TGGroupFrame {
36 
37 friend class TGButton;
38 
39 private:
40  TGButtonGroup(const TGButtonGroup&); // Not implemented
41  TGButtonGroup& operator=(const TGButtonGroup&); // Not implemented
42 
43 protected:
44  Bool_t fState; // kTRUE if group is enabled
45  Bool_t fExclGroup; // kTRUE if group is exclusive
46  Bool_t fRadioExcl; // kTRUE if radio buttons are exclusive
47  Bool_t fDrawBorder; // kTRUE if border and title are drawn
48  TMap *fMapOfButtons; // map of button/id pairs in this group
49 
50  void Init();
51  virtual void DoRedraw();
52 
53 public:
54  TGButtonGroup(const TGWindow *parent = 0,
55  const TString &title = "",
56  UInt_t options = kChildFrame | kVerticalFrame,
60 
61  TGButtonGroup(const TGWindow *parent,
62  UInt_t r, UInt_t c, Int_t s = 0, Int_t h = 0 ,
63  const TString &title = "",
67 
68  virtual ~TGButtonGroup();
69 
70  virtual void Pressed(Int_t id) { Emit("Pressed(Int_t)",id); } //*SIGNAL*
71  virtual void Released(Int_t id) { Emit("Released(Int_t)",id);} //*SIGNAL*
72  virtual void Clicked(Int_t id) { Emit("Clicked(Int_t)",id); } //*SIGNAL*
73 
74  virtual void ButtonPressed();
75  virtual void ButtonReleased();
76  virtual void ButtonClicked();
77  virtual void ReleaseButtons();
78 
79  Bool_t IsEnabled() const { return fState; }
80  Bool_t IsExclusive() const { return fExclGroup; }
82  Bool_t IsBorderDrawn() const { return fDrawBorder; }
83  Int_t GetCount() const { return fMapOfButtons->GetSize(); }
84  Int_t GetId(TGButton *button) const;
85 
86  virtual void SetExclusive(Bool_t flag = kTRUE);
87  virtual void SetRadioButtonExclusive(Bool_t flag = kTRUE);
88  virtual void SetState(Bool_t state = kTRUE);
89  virtual void SetBorderDrawn(Bool_t enable = kTRUE);
90  virtual void SetButton(Int_t id, Bool_t down = kTRUE);
91  virtual void SetTitle(TGString *title);
92  virtual void SetTitle(const char *title);
93 
94  virtual Int_t Insert(TGButton *button, int id = -1);
95  virtual void Remove(TGButton *button);
96  virtual TGButton *Find(Int_t id) const;
97  virtual TGButton *GetButton(Int_t id) const { return Find(id); }
98  virtual void Show();
99  virtual void Hide();
100  virtual void DrawBorder();
101  virtual void SetLayoutHints(TGLayoutHints *l, TGButton *button = 0);
102  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
103 
104  ClassDef(TGButtonGroup,0) // Organizes TGButtons in a group
105 };
106 
107 
109 
110 public:
111  TGVButtonGroup(const TGWindow *parent,
112  const TString &title = "",
116  TGButtonGroup(parent, title, kChildFrame | kVerticalFrame,
117  norm, font, back) { }
118 
119  virtual ~TGVButtonGroup() { }
120  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
121 
122  ClassDef(TGVButtonGroup,0) // A button group with one vertical column
123 };
124 
125 
127 
128 public:
129  TGHButtonGroup(const TGWindow *parent,
130  const TString &title = "",
134  TGButtonGroup(parent, title, kChildFrame | kHorizontalFrame,
135  norm, font, back) { }
136 
137  virtual ~TGHButtonGroup() { }
138  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
139 
140  ClassDef(TGHButtonGroup,0) // A button group with one horizontal row
141 };
142 
143 #endif
Handle_t FontStruct_t
Definition: GuiTypes.h:40
virtual void Released(Int_t id)
Definition: TGButtonGroup.h:71
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:82
return c
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:46
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:39
Basic string class.
Definition: TString.h:137
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:79
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:52
#define ClassDef(name, id)
Definition: Rtypes.h:254
ULong_t Pixel_t
Definition: GuiTypes.h:41
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:48
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.
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:561
Int_t GetCount() const
Definition: TGButtonGroup.h:83
virtual void Clicked(Int_t id)
Definition: TGButtonGroup.h:72
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:80
virtual void DoRedraw()
Redraw the group frame.
TLine * l
Definition: textangle.C:4
virtual TGButton * GetButton(Int_t id) const
Definition: TGButtonGroup.h:97
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:81
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:44
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 &)
virtual Int_t GetSize() const
Definition: TCollection.h:95
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void Pressed(Int_t id)
Definition: TGButtonGroup.h:70
Bool_t fDrawBorder
Definition: TGButtonGroup.h:47
double norm(double *x, double *p)
Definition: unuranDistr.cxx:40
Bool_t fExclGroup
Definition: TGButtonGroup.h:45