File indexing completed on 2025-01-18 10:11:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TGButtonGroup
0013 #define ROOT_TGButtonGroup
0014
0015
0016 #include "TGFrame.h"
0017
0018 class TGButton;
0019 class TMap;
0020
0021 class TGButtonGroup : public TGGroupFrame {
0022
0023 friend class TGButton;
0024
0025 private:
0026 TGButtonGroup(const TGButtonGroup&) = delete;
0027 TGButtonGroup& operator=(const TGButtonGroup&) = delete;
0028
0029 protected:
0030 Bool_t fState;
0031 Bool_t fExclGroup;
0032 Bool_t fRadioExcl;
0033 Bool_t fDrawBorder;
0034 TMap *fMapOfButtons;
0035
0036 void Init();
0037 void DoRedraw() override;
0038
0039 public:
0040 TGButtonGroup(const TGWindow *parent = nullptr,
0041 const TString &title = "",
0042 UInt_t options = kChildFrame | kVerticalFrame,
0043 GContext_t norm = GetDefaultGC()(),
0044 FontStruct_t font = GetDefaultFontStruct(),
0045 Pixel_t back = GetDefaultFrameBackground());
0046
0047 TGButtonGroup(const TGWindow *parent,
0048 UInt_t r, UInt_t c, Int_t s = 0, Int_t h = 0 ,
0049 const TString &title = "",
0050 GContext_t norm = GetDefaultGC()(),
0051 FontStruct_t font = GetDefaultFontStruct(),
0052 Pixel_t back = GetDefaultFrameBackground());
0053
0054 ~TGButtonGroup() override;
0055
0056 virtual void Pressed(Int_t id) { Emit("Pressed(Int_t)",id); }
0057 virtual void Released(Int_t id) { Emit("Released(Int_t)",id);}
0058 virtual void Clicked(Int_t id) { Emit("Clicked(Int_t)",id); }
0059
0060 virtual void ButtonPressed();
0061 virtual void ButtonReleased();
0062 virtual void ButtonClicked();
0063 virtual void ReleaseButtons();
0064
0065 Bool_t IsEnabled() const { return fState; }
0066 Bool_t IsExclusive() const { return fExclGroup; }
0067 Bool_t IsRadioButtonExclusive() const { return fRadioExcl; }
0068 Bool_t IsBorderDrawn() const { return fDrawBorder; }
0069 Int_t GetCount() const;
0070 Int_t GetId(TGButton *button) const;
0071
0072 virtual void SetExclusive(Bool_t flag = kTRUE);
0073 virtual void SetRadioButtonExclusive(Bool_t flag = kTRUE);
0074 virtual void SetState(Bool_t state = kTRUE);
0075 virtual void SetBorderDrawn(Bool_t enable = kTRUE);
0076 virtual void SetButton(Int_t id, Bool_t down = kTRUE);
0077 void SetTitle(TGString *title) override;
0078 void SetTitle(const char *title) override;
0079
0080 virtual Int_t Insert(TGButton *button, int id = -1);
0081 virtual void Remove(TGButton *button);
0082 virtual TGButton *Find(Int_t id) const;
0083 virtual TGButton *GetButton(Int_t id) const { return Find(id); }
0084 virtual void Show();
0085 virtual void Hide();
0086 void DrawBorder() override;
0087 virtual void SetLayoutHints(TGLayoutHints *l, TGButton *button = nullptr);
0088 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0089
0090 ClassDefOverride(TGButtonGroup,0)
0091 };
0092
0093
0094 class TGVButtonGroup : public TGButtonGroup {
0095
0096 public:
0097 TGVButtonGroup(const TGWindow *parent,
0098 const TString &title = "",
0099 GContext_t norm = GetDefaultGC()(),
0100 FontStruct_t font = GetDefaultFontStruct(),
0101 Pixel_t back = GetDefaultFrameBackground()) :
0102 TGButtonGroup(parent, title, kChildFrame | kVerticalFrame,
0103 norm, font, back) {}
0104
0105 ~TGVButtonGroup() override {}
0106 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0107
0108 ClassDefOverride(TGVButtonGroup,0)
0109 };
0110
0111
0112 class TGHButtonGroup : public TGButtonGroup {
0113
0114 public:
0115 TGHButtonGroup(const TGWindow *parent,
0116 const TString &title = "",
0117 GContext_t norm = GetDefaultGC()(),
0118 FontStruct_t font = GetDefaultFontStruct(),
0119 Pixel_t back = GetDefaultFrameBackground()) :
0120 TGButtonGroup(parent, title, kChildFrame | kHorizontalFrame,
0121 norm, font, back) { }
0122
0123 ~TGHButtonGroup() override {}
0124 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0125
0126 ClassDefOverride(TGHButtonGroup,0)
0127 };
0128
0129 #endif