ROOT logo
#ifndef __TGMrbButtonFrame_h__
#define __TGMrbButtonFrame_h__

//_________________________________________________[C++ CLASS DEFINITION FILE]
//////////////////////////////////////////////////////////////////////////////
// Name:           gutils/inc/TGMrbButtonFrame.h
// Purpose:        Define utilities to be used with the MARaBOU GUI
// Class:          TGMrbButtonFrame    -- a composite frame containing buttons
// Description:    Graphic utilities for the MARaBOU GUI.
// Author:         R. Lutter
// Revision:       $Id: TGMrbButtonFrame.h,v 1.12 2008-10-14 17:27:06 Marabou Exp $       
// Date:           
// Keywords:
//////////////////////////////////////////////////////////////////////////////

#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"

//______________________________________________________[C++ CLASS DEFINITION]
//////////////////////////////////////////////////////////////////////////////
// Name:           TGMrbSpecialButton
// Purpose:        Declare a special button for check button lists
// Description:    Defines a special button (all, none, default)
//                 to be used in check button lists/groups.
// Keywords:
//////////////////////////////////////////////////////////////////////////////

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() {};			// dtor

		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)				// [GraphUtils] A "special" button
};

//______________________________________________________[C++ CLASS DEFINITION]
//////////////////////////////////////////////////////////////////////////////
// Name:           TGMrbButtonFrame
// Purpose:        Base class for lists of buttons
// Description:    A base class for lists of buttons. 
// Keywords:
//////////////////////////////////////////////////////////////////////////////

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() {};			// dtor

		TGMrbButtonFrame(const TGMrbButtonFrame & /*f*/) {};	// default copy ctor

		void SetState(UInt_t Pattern, EButtonState State = kButtonDown, Bool_t Emit = kFALSE);	// set button state
		UInt_t GetActive(); 												// return button state
		TMrbNamedX * GetActiveNx();

		inline void CheckButtonClicked(Int_t Button) { this->UpdateState((UInt_t) Button); }; 	// slot methods
		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); 	//*SIGNAL*

		void FlipState(UInt_t Pattern);					// flip state
		void UpdateState(UInt_t Pattern);				// update state
		void ClearAll();								// clear all buttons

		void SetButtonWidth(Int_t Width, Int_t ButtonIndex = 0);	// set button width
		Int_t GetButtonWidth(Int_t ButtonIndex = 0) const;	// get button width
		void JustifyButton(ETextJustification Justify, Int_t ButtonIndex = 0);	// justify button text
		TGButton * GetButton(Int_t ButtonIndex) const;		// get button by index

		void ChangeButtonBackground(ULong_t Color, Int_t Index = 0); 	// set background color

		inline void Help() { gSystem->Exec("mrbHelp TGMrbButtonFrame"); };

	protected:
		void PlaceButtons();						// place buttons in a subframe CxL
		TGMrbSpecialButton * FindSpecialButton(Int_t Index);

	protected:
		const TGWindow * fParent; 						// parent window
		UInt_t fType;								// button type: text, radio, check, or picture; list or group
		Int_t fFrameId;								// frame id to be used with signals/slots
		TString fLabel; 							// label text
		TMrbLofNamedX fButtons;						// list of buttons: labels, indices, widgets
		Int_t fWidth;								// frame width
		Int_t fHeight;								// frame height
		Int_t fNofCL;								// button grid CxL: number of columns/lines
		TGMrbLayout * fFrameGC;						// frame layout
		TGMrbLayout * fLabelGC;						// label layout
		TGMrbLayout * fButtonGC;					// button layout
		UInt_t fFrameOptions;						// frame options
		UInt_t fButtonOptions;						// button options
		UInt_t fRBState;							// radio button settings

		TObjArray * fLofSpecialButtons; 			//! list of special buttons
		
		TGCompositeFrame * fFrame;
		TGClient * fParentClient;
		
	ClassDef(TGMrbButtonFrame, 0)					// [GraphUtils] A frame of buttons
};

#endif
 TGMrbButtonFrame.h:1
 TGMrbButtonFrame.h:2
 TGMrbButtonFrame.h:3
 TGMrbButtonFrame.h:4
 TGMrbButtonFrame.h:5
 TGMrbButtonFrame.h:6
 TGMrbButtonFrame.h:7
 TGMrbButtonFrame.h:8
 TGMrbButtonFrame.h:9
 TGMrbButtonFrame.h:10
 TGMrbButtonFrame.h:11
 TGMrbButtonFrame.h:12
 TGMrbButtonFrame.h:13
 TGMrbButtonFrame.h:14
 TGMrbButtonFrame.h:15
 TGMrbButtonFrame.h:16
 TGMrbButtonFrame.h:17
 TGMrbButtonFrame.h:18
 TGMrbButtonFrame.h:19
 TGMrbButtonFrame.h:20
 TGMrbButtonFrame.h:21
 TGMrbButtonFrame.h:22
 TGMrbButtonFrame.h:23
 TGMrbButtonFrame.h:24
 TGMrbButtonFrame.h:25
 TGMrbButtonFrame.h:26
 TGMrbButtonFrame.h:27
 TGMrbButtonFrame.h:28
 TGMrbButtonFrame.h:29
 TGMrbButtonFrame.h:30
 TGMrbButtonFrame.h:31
 TGMrbButtonFrame.h:32
 TGMrbButtonFrame.h:33
 TGMrbButtonFrame.h:34
 TGMrbButtonFrame.h:35
 TGMrbButtonFrame.h:36
 TGMrbButtonFrame.h:37
 TGMrbButtonFrame.h:38
 TGMrbButtonFrame.h:39
 TGMrbButtonFrame.h:40
 TGMrbButtonFrame.h:41
 TGMrbButtonFrame.h:42
 TGMrbButtonFrame.h:43
 TGMrbButtonFrame.h:44
 TGMrbButtonFrame.h:45
 TGMrbButtonFrame.h:46
 TGMrbButtonFrame.h:47
 TGMrbButtonFrame.h:48
 TGMrbButtonFrame.h:49
 TGMrbButtonFrame.h:50
 TGMrbButtonFrame.h:51
 TGMrbButtonFrame.h:52
 TGMrbButtonFrame.h:53
 TGMrbButtonFrame.h:54
 TGMrbButtonFrame.h:55
 TGMrbButtonFrame.h:56
 TGMrbButtonFrame.h:57
 TGMrbButtonFrame.h:58
 TGMrbButtonFrame.h:59
 TGMrbButtonFrame.h:60
 TGMrbButtonFrame.h:61
 TGMrbButtonFrame.h:62
 TGMrbButtonFrame.h:63
 TGMrbButtonFrame.h:64
 TGMrbButtonFrame.h:65
 TGMrbButtonFrame.h:66
 TGMrbButtonFrame.h:67
 TGMrbButtonFrame.h:68
 TGMrbButtonFrame.h:69
 TGMrbButtonFrame.h:70
 TGMrbButtonFrame.h:71
 TGMrbButtonFrame.h:72
 TGMrbButtonFrame.h:73
 TGMrbButtonFrame.h:74
 TGMrbButtonFrame.h:75
 TGMrbButtonFrame.h:76
 TGMrbButtonFrame.h:77
 TGMrbButtonFrame.h:78
 TGMrbButtonFrame.h:79
 TGMrbButtonFrame.h:80
 TGMrbButtonFrame.h:81
 TGMrbButtonFrame.h:82
 TGMrbButtonFrame.h:83
 TGMrbButtonFrame.h:84
 TGMrbButtonFrame.h:85
 TGMrbButtonFrame.h:86
 TGMrbButtonFrame.h:87
 TGMrbButtonFrame.h:88
 TGMrbButtonFrame.h:89
 TGMrbButtonFrame.h:90
 TGMrbButtonFrame.h:91
 TGMrbButtonFrame.h:92
 TGMrbButtonFrame.h:93
 TGMrbButtonFrame.h:94
 TGMrbButtonFrame.h:95
 TGMrbButtonFrame.h:96
 TGMrbButtonFrame.h:97
 TGMrbButtonFrame.h:98
 TGMrbButtonFrame.h:99
 TGMrbButtonFrame.h:100
 TGMrbButtonFrame.h:101
 TGMrbButtonFrame.h:102
 TGMrbButtonFrame.h:103
 TGMrbButtonFrame.h:104
 TGMrbButtonFrame.h:105
 TGMrbButtonFrame.h:106
 TGMrbButtonFrame.h:107
 TGMrbButtonFrame.h:108
 TGMrbButtonFrame.h:109
 TGMrbButtonFrame.h:110
 TGMrbButtonFrame.h:111
 TGMrbButtonFrame.h:112
 TGMrbButtonFrame.h:113
 TGMrbButtonFrame.h:114
 TGMrbButtonFrame.h:115
 TGMrbButtonFrame.h:116
 TGMrbButtonFrame.h:117
 TGMrbButtonFrame.h:118
 TGMrbButtonFrame.h:119
 TGMrbButtonFrame.h:120
 TGMrbButtonFrame.h:121
 TGMrbButtonFrame.h:122
 TGMrbButtonFrame.h:123
 TGMrbButtonFrame.h:124
 TGMrbButtonFrame.h:125
 TGMrbButtonFrame.h:126
 TGMrbButtonFrame.h:127
 TGMrbButtonFrame.h:128
 TGMrbButtonFrame.h:129
 TGMrbButtonFrame.h:130
 TGMrbButtonFrame.h:131
 TGMrbButtonFrame.h:132
 TGMrbButtonFrame.h:133
 TGMrbButtonFrame.h:134
 TGMrbButtonFrame.h:135
 TGMrbButtonFrame.h:136
 TGMrbButtonFrame.h:137
 TGMrbButtonFrame.h:138
 TGMrbButtonFrame.h:139
 TGMrbButtonFrame.h:140
 TGMrbButtonFrame.h:141
 TGMrbButtonFrame.h:142
 TGMrbButtonFrame.h:143
 TGMrbButtonFrame.h:144
 TGMrbButtonFrame.h:145
 TGMrbButtonFrame.h:146
 TGMrbButtonFrame.h:147
 TGMrbButtonFrame.h:148
 TGMrbButtonFrame.h:149
 TGMrbButtonFrame.h:150
 TGMrbButtonFrame.h:151