#ifndef __TGMrbButtonFrame_h__
#define __TGMrbButtonFrame_h__
#include "Rtypes.h"
#include "TSystem.h"
#include "TString.h"
#include "TGWindow.h"
#include "TGButton.h"
#include "RQ_OBJECT.h"
#include "TMrbNamedX.h"
#include "TMrbLofNamedX.h"
#include "TGMrbObject.h"
#include "TGMrbLayout.h"
class TGMrbSpecialButton: public TMrbNamedX {
public:
TGMrbSpecialButton( Int_t Index, const Char_t * Name, const Char_t * Title,
UInt_t Pattern, const Char_t * Picture = NULL) : TMrbNamedX(Index, Name, Title) {
fPattern = Pattern;
if (Picture) fPicture = Picture; else fPicture.Resize(0);
}
~TGMrbSpecialButton() {};
inline UInt_t GetPattern() const { return(fPattern); };
inline void SetPattern(UInt_t Pattern) { fPattern = Pattern; };
inline const Char_t * GetPicture() const { return(fPicture.Length() > 0 ? fPicture.Data() : NULL); };
inline void SetPicture(const Char_t * Picture) { fPicture = Picture; };
protected:
UInt_t fPattern;
TString fPicture;
ClassDef(TGMrbSpecialButton, 0)
};
class TGMrbButtonFrame: public TGMrbObject {
RQ_OBJECT("TGMrbButtonFrame")
public:
enum EGMrbButtonType { kGMrbTextButton = BIT(0),
kGMrbRadioButton = BIT(1),
kGMrbCheckButton = BIT(2),
kGMrbPictureButton = BIT(3)
};
enum EGMrbButtonFrameType { kGMrbButtonList = BIT(4),
kGMrbButtonGroup = BIT(5)
};
enum { kFrameIdShift = 16 };
public:
TGMrbButtonFrame(const TGWindow * Parent, const Char_t * Label, UInt_t ButtonType,
TMrbLofNamedX * Buttons, Int_t BtnId, Int_t NofCL,
Int_t Width, Int_t Height,
TGMrbLayout * FrameGC, TGMrbLayout * LabelGC, TGMrbLayout * ButtonGC,
UInt_t FrameOptions, UInt_t ButtonOptions);
virtual ~TGMrbButtonFrame() {};
TGMrbButtonFrame(const TGMrbButtonFrame & ) {};
void SetState(UInt_t Pattern, EButtonState State = kButtonDown, Bool_t Emit = kFALSE);
UInt_t GetActive();
TMrbNamedX * GetActiveNx();
inline void CheckButtonClicked(Int_t Button) { this->UpdateState((UInt_t) Button); };
inline void RadioButtonClicked(Int_t Button) { this->SetState((UInt_t) Button, kButtonDown, kTRUE); };
inline void TextButtonClicked(Int_t Button) { this->UpdateState((UInt_t) Button); };
inline void PictureButtonClicked(Int_t Button) { this->UpdateState((UInt_t) Button); };
inline void ButtonPressed(Int_t Button) { this->ButtonPressed(fFrameId, Button); };
void ButtonPressed(Int_t FrameId, Int_t Button);
void FlipState(UInt_t Pattern);
void UpdateState(UInt_t Pattern);
void ClearAll();
void SetButtonWidth(Int_t Width, Int_t ButtonIndex = 0);
Int_t GetButtonWidth(Int_t ButtonIndex = 0) const;
void JustifyButton(ETextJustification Justify, Int_t ButtonIndex = 0);
TGButton * GetButton(Int_t ButtonIndex) const;
void ChangeButtonBackground(ULong_t Color, Int_t Index = 0);
inline void Help() { gSystem->Exec("mrbHelp TGMrbButtonFrame"); };
protected:
void PlaceButtons();
TGMrbSpecialButton * FindSpecialButton(Int_t Index);
protected:
const TGWindow * fParent;
UInt_t fType;
Int_t fFrameId;
TString fLabel;
TMrbLofNamedX fButtons;
Int_t fWidth;
Int_t fHeight;
Int_t fNofCL;
TGMrbLayout * fFrameGC;
TGMrbLayout * fLabelGC;
TGMrbLayout * fButtonGC;
UInt_t fFrameOptions;
UInt_t fButtonOptions;
UInt_t fRBState;
TObjArray * fLofSpecialButtons;
TGCompositeFrame * fFrame;
TGClient * fParentClient;
ClassDef(TGMrbButtonFrame, 0)
};
#endif