TGButtonGroup.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGButtonGroup.h 23115 2008-04-10 13:35:37Z rdm $
00002 // Author: Valeriy Onuchin & Fons Rademakers   16/10/2000
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGButtonGroup
00013 #define ROOT_TGButtonGroup
00014 
00015 //////////////////////////////////////////////////////////////////////////
00016 //                                                                      //
00017 // TGButtonGroup, TGVButtonGroup and TGHButtonGroup                     //
00018 //                                                                      //
00019 // This header defines button group frames.                             //
00020 //                                                                      //
00021 //////////////////////////////////////////////////////////////////////////
00022 
00023 #ifndef ROOT_TGFrame
00024 #include "TGFrame.h"
00025 #endif
00026 #ifndef ROOT_TMap
00027 #include "TMap.h"
00028 #endif
00029 
00030 
00031 class TGButton;
00032 
00033 
00034 
00035 class TGButtonGroup : public TGGroupFrame {
00036 
00037 friend class TGButton;
00038 
00039 private:
00040    TGButtonGroup(const TGButtonGroup&); // Not implemented
00041    TGButtonGroup& operator=(const TGButtonGroup&); // Not implemented
00042 
00043 protected:
00044    Bool_t  fState;           // kTRUE if group is enabled
00045    Bool_t  fExclGroup;       // kTRUE if group is exclusive
00046    Bool_t  fRadioExcl;       // kTRUE if radio buttons are exclusive
00047    Bool_t  fDrawBorder;      // kTRUE if border and title are drawn
00048    TMap   *fMapOfButtons;    // map of button/id pairs in this group
00049 
00050    void Init();
00051    virtual void DoRedraw();
00052 
00053 public:
00054    TGButtonGroup(const TGWindow *parent = 0,
00055                  const TString &title = "",
00056                  UInt_t options = kChildFrame | kVerticalFrame,
00057                  GContext_t norm = GetDefaultGC()(),
00058                  FontStruct_t font = GetDefaultFontStruct(),
00059                  Pixel_t back = GetDefaultFrameBackground());
00060 
00061    TGButtonGroup(const TGWindow *parent,
00062                  UInt_t r, UInt_t c, Int_t s = 0, Int_t h = 0 ,
00063                  const TString &title = "",
00064                  GContext_t norm = GetDefaultGC()(),
00065                  FontStruct_t font = GetDefaultFontStruct(),
00066                  Pixel_t back = GetDefaultFrameBackground());
00067 
00068    virtual ~TGButtonGroup();
00069 
00070    virtual void Pressed(Int_t id)  { Emit("Pressed(Int_t)",id); }   //*SIGNAL*
00071    virtual void Released(Int_t id) { Emit("Released(Int_t)",id);}   //*SIGNAL*
00072    virtual void Clicked(Int_t id)  { Emit("Clicked(Int_t)",id); }   //*SIGNAL*
00073 
00074    virtual void ButtonPressed();
00075    virtual void ButtonReleased();
00076    virtual void ButtonClicked();
00077    virtual void ReleaseButtons();
00078 
00079    Bool_t IsEnabled() const { return fState; }
00080    Bool_t IsExclusive() const { return fExclGroup; }
00081    Bool_t IsRadioButtonExclusive() const  { return fRadioExcl; }
00082    Bool_t IsBorderDrawn() const { return fDrawBorder; }
00083    Int_t  GetCount() const { return fMapOfButtons->GetSize(); }
00084    Int_t  GetId(TGButton *button) const;
00085 
00086    virtual void SetExclusive(Bool_t flag = kTRUE);
00087    virtual void SetRadioButtonExclusive(Bool_t flag = kTRUE);
00088    virtual void SetState(Bool_t state = kTRUE);
00089    virtual void SetBorderDrawn(Bool_t enable = kTRUE);
00090    virtual void SetButton(Int_t id, Bool_t down = kTRUE);
00091    virtual void SetTitle(TGString *title);
00092    virtual void SetTitle(const char *title);
00093 
00094    virtual Int_t     Insert(TGButton *button, int id = -1);
00095    virtual void      Remove(TGButton *button);
00096    virtual TGButton *Find(Int_t id) const;
00097    virtual TGButton *GetButton(Int_t id) const { return Find(id); }
00098    virtual void      Show();
00099    virtual void      Hide();
00100    virtual void      DrawBorder();
00101    virtual void      SetLayoutHints(TGLayoutHints *l, TGButton *button = 0);
00102    virtual void      SavePrimitive(ostream &out, Option_t *option = "");
00103 
00104    ClassDef(TGButtonGroup,0)  // Organizes TGButtons in a group
00105 };
00106 
00107 
00108 class TGVButtonGroup : public TGButtonGroup {
00109 
00110 public:
00111    TGVButtonGroup(const TGWindow *parent,
00112                   const TString &title = "",
00113                   GContext_t norm = GetDefaultGC()(),
00114                   FontStruct_t font = GetDefaultFontStruct(),
00115                   Pixel_t back = GetDefaultFrameBackground()) :
00116       TGButtonGroup(parent, title, kChildFrame | kVerticalFrame,
00117                     norm, font, back) { }
00118 
00119    virtual ~TGVButtonGroup() { }
00120    virtual void SavePrimitive(ostream &out, Option_t *option = "");
00121 
00122    ClassDef(TGVButtonGroup,0)  // A button group with one vertical column
00123 };
00124 
00125 
00126 class TGHButtonGroup : public TGButtonGroup {
00127 
00128 public:
00129    TGHButtonGroup(const TGWindow *parent,
00130                   const TString &title = "",
00131                   GContext_t norm = GetDefaultGC()(),
00132                   FontStruct_t font = GetDefaultFontStruct(),
00133                   Pixel_t back = GetDefaultFrameBackground()) :
00134       TGButtonGroup(parent, title, kChildFrame | kHorizontalFrame,
00135                     norm, font, back) { }
00136 
00137    virtual ~TGHButtonGroup() { }
00138    virtual void SavePrimitive(ostream &out, Option_t *option = "");
00139 
00140    ClassDef(TGHButtonGroup,0)  // A button group with one horizontal row
00141 };
00142 
00143 #endif

Generated on Tue Jul 5 14:19:51 2011 for ROOT_528-00b_version by  doxygen 1.5.1