ROOT logo
#ifndef __TGMrbFileObject_h__
#define __TGMrbFileObject_h__

//_________________________________________________[C++ CLASS DEFINITION FILE]
//////////////////////////////////////////////////////////////////////////////
// Name:           gutils/inc/TGMrbFileObject.h
// Purpose:        Define utilities to be used with the MARaBOU GUI
// Class:          TGMrbFileObjectCombo   -- a file entry together with
//                                           a combo box containing file objects
//                 TGMrbFileObjectList    -- a file entry together with
//                                           a list box containing file objects
// Description:    Graphic utilities for the MARaBOU GUI.
// Author:         R. Lutter
// Revision:       $Id: TGMrbFileObject.h,v 1.12 2008-09-23 10:44:11 Rudolf.Lutter Exp $       
// Date:           
// Keywords:
//////////////////////////////////////////////////////////////////////////////

#include "Rtypes.h"
#include "TSystem.h"
#include "TObjArray.h"
#include "TGWindow.h"
#include "TGFrame.h"
#include "TGButton.h"
#include "TGTextEntry.h"
#include "TGFileDialog.h"
#include "TGComboBox.h"

#include "TMrbLofNamedX.h"
#include "TGMrbObject.h"
#include "TGMrbLayout.h"

//______________________________________________________[C++ CLASS DEFINITION]
//////////////////////////////////////////////////////////////////////////////
// Name:           TGMrbFileObjectCombo
// Purpose:        Define a labelled file entry and an associated combo box
// Description:    Defines a labelled file entry (TGMrbFileEntry) together
//                 with a combo box showing ROOT objects from selected file.
// Keywords:
//////////////////////////////////////////////////////////////////////////////

class TGMrbFileObjectCombo: public TGCompositeFrame, public TGMrbObject {

	public:
		TGMrbFileObjectCombo(const TGWindow * Parent, const Char_t * Label,				// ctor
							Int_t BufferSize, Int_t FrameId,
							Int_t Width, Int_t Height,
							Int_t EntryWidth, Int_t ComboWidth,
							TGMrbLayout * FrameGC,
							TGMrbLayout * LabelGC = NULL,
							TGMrbLayout * EntryGC = NULL,
							TGMrbLayout * BrowseGC = NULL,
							TGMrbLayout * ComboGC = NULL,
							UInt_t FrameOptions = kHorizontalFrame,
							UInt_t EntryOptions = kHorizontalFrame | kSunkenFrame | kDoubleBorder,
							UInt_t ComboOptions = kHorizontalFrame | kSunkenFrame | kDoubleBorder);

		~TGMrbFileObjectCombo() {};				// default dtor

		inline TGTextEntry * GetEntry() const { return(fEntry); };
		inline TGComboBox * GetComboBox() const { return(fCombo); };

		Bool_t OpenFile(const Char_t * FileName);

#if ROOT_VERSION_CODE >= ROOT_VERSION(5,10,0)
		inline void ClearList() { fCombo->RemoveAll(); };
#else
		inline void ClearList() { fCombo->RemoveEntries(0, 1000); };
#endif

		void SetFileEntry(const Char_t * File);
		const Char_t * GetFileEntry(TString & FileName, Bool_t FullPath = kTRUE) const;	// get selected file
		Int_t GetSelectionAsString(TString & SelString, Bool_t FullPath = kTRUE) const; // get selected file/object -- string
		Int_t GetSelection(TObjArray & SelArr, Bool_t FullPath = kTRUE) const;			// ... -- array
		void SetSelectionFromString(TString & SelString, Bool_t IsNewFile = kFALSE);  	// set items
		void SetSelection(TObjArray & SelArr, Bool_t IsNewFile = kFALSE); 				// ... -- array

		inline const Char_t * GetText() const { return(fText.Data()); };					// return text field data
		inline void SetText(const Char_t * Text) { fText = Text; }; 				// set text field
		
		inline const Char_t * GetFileName() { return(fFileName.Data()); };

		void Browse();												// slot methods
		void EntryChanged();
		inline void SelectionChanged(Int_t Selection) { this->SelectionChanged(fFrameId, Selection); };

		void FileChanged(Int_t FrameId, Int_t Selection = 0); 		//*SIGNAL*
		void SelectionChanged(Int_t FrameId, Int_t Selection);		//*SIGNAL*

		inline void Help() { gSystem->Exec(Form("mrbHelp %s", this->ClassName())); };

	protected:
		Int_t fFrameId;

		TGVerticalFrame * fEC;				//!
		TGHorizontalFrame * fEB;			//!
			
		TGTextEntry * fEntry;				//!
		TGComboBox * fCombo;				//!
		TGPictureButton * fBrowse;	 		//!

		TString fFileName;					// file name
		TString fText;

		TGFileInfo fFileInfo; 				//!

	ClassDef(TGMrbFileObjectCombo, 1) 	// [GraphUtils] A file browser showing ROOT objects in a combo box
};

//______________________________________________________[C++ CLASS DEFINITION]
//////////////////////////////////////////////////////////////////////////////
// Name:           TGMrbFileObjectListBox
// Purpose:        Define a labelled file entry and an associated listbox
// Description:    Defines a labelled file entry (TGMrbFileEntry) together
//                 with a listbox showing ROOT objects from selected file.
// Keywords:
//////////////////////////////////////////////////////////////////////////////

class TGMrbFileObjectListBox: public TGCompositeFrame, public TGMrbObject {

	public:
		enum	{	kBtnBrowse,
					kBtnSingle,
					kBtnRange,
					kBtnClear,
					kBtnApply
				};

	public:
		TGMrbFileObjectListBox(const TGWindow * Parent, const Char_t * Label,				// ctor
							Int_t BufferSize, Int_t FrameId,
							Int_t Width, Int_t Height,
							Int_t EntryWidth, Int_t ListBoxWidth,
							TGMrbLayout * FrameGC,
							TGMrbLayout * LabelGC = NULL,
							TGMrbLayout * EntryGC = NULL,
							TGMrbLayout * BrowseGC = NULL,
							TGMrbLayout * ListBoxGC = NULL,
							UInt_t FrameOptions = kHorizontalFrame,
							UInt_t EntryOptions = kHorizontalFrame | kSunkenFrame | kDoubleBorder,
							UInt_t ListBoxOptions = kHorizontalFrame | kSunkenFrame | kDoubleBorder);

		~TGMrbFileObjectListBox() {};				// default dtor

		inline TGTextEntry * GetEntry() const { return(fEntry); };
		inline TGListBox * GetListBox() const { return(fListBox); };

		Bool_t OpenFile(const Char_t * FileName);
		void SetList(TObjArray & LofEntries);
#if ROOT_VERSION_CODE >= ROOT_VERSION(5,10,0)
		inline void ClearList() { fListBox->RemoveAll(); };
#else
		inline void ClearList() { fListBox->RemoveEntries(0, 1000); };
#endif

		void SetFileEntry(const Char_t * File);
		const Char_t * GetFileEntry(TString & FileName, Bool_t FullPath = kTRUE) const;	// get selected file
		Int_t GetSelectionAsString(TString & SelString, Bool_t FullPath = kTRUE) const;	// get selected file/object -- string
		Int_t GetSelection(TObjArray & SelArr, Bool_t FullPath = kTRUE) const;			// ... -- array
		void SetSelectionFromString(TString & SelString, Bool_t IsNewFile = kFALSE);  	// set items
		void SetSelection(TObjArray & SelArr, Bool_t IsNewFile = kFALSE); 				// ... -- array

		inline const Char_t * GetText() const { return(fText.Data()); };					// return text field data
		inline void SetText(const Char_t * Text) { fText = Text; }; 				// set text field
		
		inline const Char_t * GetFileName() { return(fFileName.Data()); };

		void Browse();											// slot methods
		void EntryChanged();
		void ListBoxChanged(Int_t);
		void Single();
		void Range();
		void Clear();
		void Apply();
		inline void SelectionChanged(Int_t Selection) { this->SelectionChanged(fFrameId, Selection); };

		void FileChanged(Int_t FrameId, Int_t Selection = 0); 		//*SIGNAL*
		void SelectionChanged(Int_t FrameId, Int_t Selection);	//*SIGNAL*


		inline void Help() { gSystem->Exec(Form("mrbHelp %s", this->ClassName())); };

	protected:
		Int_t fFrameId;

		TGVerticalFrame * fEC;				//!
		TGHorizontalFrame * fEB1;			//!
		TGHorizontalFrame * fEB2;			//!
			
		TGTextEntry * fEntry;				//!
		TGListBox * fListBox;				//!
		TGPictureButton * fBrowse;	 		//!

		TGRadioButton * fRBSingle;			//!
		TGRadioButton * fRBRange;			//!
		TGTextButton * fTBClear;			//!
		TGTextButton * fTBApply;			//!

		Int_t fStartIndex;
		TString fFileName;					// file name
		TMrbLofNamedX fLofListItems;		// entries

		TString fText;

		TGFileInfo fFileInfo; 				//!

	ClassDef(TGMrbFileObjectListBox, 1) 	// [GraphUtils] A file browser showing ROOT objects in a list box
};

#endif
 TGMrbFileObject.h:1
 TGMrbFileObject.h:2
 TGMrbFileObject.h:3
 TGMrbFileObject.h:4
 TGMrbFileObject.h:5
 TGMrbFileObject.h:6
 TGMrbFileObject.h:7
 TGMrbFileObject.h:8
 TGMrbFileObject.h:9
 TGMrbFileObject.h:10
 TGMrbFileObject.h:11
 TGMrbFileObject.h:12
 TGMrbFileObject.h:13
 TGMrbFileObject.h:14
 TGMrbFileObject.h:15
 TGMrbFileObject.h:16
 TGMrbFileObject.h:17
 TGMrbFileObject.h:18
 TGMrbFileObject.h:19
 TGMrbFileObject.h:20
 TGMrbFileObject.h:21
 TGMrbFileObject.h:22
 TGMrbFileObject.h:23
 TGMrbFileObject.h:24
 TGMrbFileObject.h:25
 TGMrbFileObject.h:26
 TGMrbFileObject.h:27
 TGMrbFileObject.h:28
 TGMrbFileObject.h:29
 TGMrbFileObject.h:30
 TGMrbFileObject.h:31
 TGMrbFileObject.h:32
 TGMrbFileObject.h:33
 TGMrbFileObject.h:34
 TGMrbFileObject.h:35
 TGMrbFileObject.h:36
 TGMrbFileObject.h:37
 TGMrbFileObject.h:38
 TGMrbFileObject.h:39
 TGMrbFileObject.h:40
 TGMrbFileObject.h:41
 TGMrbFileObject.h:42
 TGMrbFileObject.h:43
 TGMrbFileObject.h:44
 TGMrbFileObject.h:45
 TGMrbFileObject.h:46
 TGMrbFileObject.h:47
 TGMrbFileObject.h:48
 TGMrbFileObject.h:49
 TGMrbFileObject.h:50
 TGMrbFileObject.h:51
 TGMrbFileObject.h:52
 TGMrbFileObject.h:53
 TGMrbFileObject.h:54
 TGMrbFileObject.h:55
 TGMrbFileObject.h:56
 TGMrbFileObject.h:57
 TGMrbFileObject.h:58
 TGMrbFileObject.h:59
 TGMrbFileObject.h:60
 TGMrbFileObject.h:61
 TGMrbFileObject.h:62
 TGMrbFileObject.h:63
 TGMrbFileObject.h:64
 TGMrbFileObject.h:65
 TGMrbFileObject.h:66
 TGMrbFileObject.h:67
 TGMrbFileObject.h:68
 TGMrbFileObject.h:69
 TGMrbFileObject.h:70
 TGMrbFileObject.h:71
 TGMrbFileObject.h:72
 TGMrbFileObject.h:73
 TGMrbFileObject.h:74
 TGMrbFileObject.h:75
 TGMrbFileObject.h:76
 TGMrbFileObject.h:77
 TGMrbFileObject.h:78
 TGMrbFileObject.h:79
 TGMrbFileObject.h:80
 TGMrbFileObject.h:81
 TGMrbFileObject.h:82
 TGMrbFileObject.h:83
 TGMrbFileObject.h:84
 TGMrbFileObject.h:85
 TGMrbFileObject.h:86
 TGMrbFileObject.h:87
 TGMrbFileObject.h:88
 TGMrbFileObject.h:89
 TGMrbFileObject.h:90
 TGMrbFileObject.h:91
 TGMrbFileObject.h:92
 TGMrbFileObject.h:93
 TGMrbFileObject.h:94
 TGMrbFileObject.h:95
 TGMrbFileObject.h:96
 TGMrbFileObject.h:97
 TGMrbFileObject.h:98
 TGMrbFileObject.h:99
 TGMrbFileObject.h:100
 TGMrbFileObject.h:101
 TGMrbFileObject.h:102
 TGMrbFileObject.h:103
 TGMrbFileObject.h:104
 TGMrbFileObject.h:105
 TGMrbFileObject.h:106
 TGMrbFileObject.h:107
 TGMrbFileObject.h:108
 TGMrbFileObject.h:109
 TGMrbFileObject.h:110
 TGMrbFileObject.h:111
 TGMrbFileObject.h:112
 TGMrbFileObject.h:113
 TGMrbFileObject.h:114
 TGMrbFileObject.h:115
 TGMrbFileObject.h:116
 TGMrbFileObject.h:117
 TGMrbFileObject.h:118
 TGMrbFileObject.h:119
 TGMrbFileObject.h:120
 TGMrbFileObject.h:121
 TGMrbFileObject.h:122
 TGMrbFileObject.h:123
 TGMrbFileObject.h:124
 TGMrbFileObject.h:125
 TGMrbFileObject.h:126
 TGMrbFileObject.h:127
 TGMrbFileObject.h:128
 TGMrbFileObject.h:129
 TGMrbFileObject.h:130
 TGMrbFileObject.h:131
 TGMrbFileObject.h:132
 TGMrbFileObject.h:133
 TGMrbFileObject.h:134
 TGMrbFileObject.h:135
 TGMrbFileObject.h:136
 TGMrbFileObject.h:137
 TGMrbFileObject.h:138
 TGMrbFileObject.h:139
 TGMrbFileObject.h:140
 TGMrbFileObject.h:141
 TGMrbFileObject.h:142
 TGMrbFileObject.h:143
 TGMrbFileObject.h:144
 TGMrbFileObject.h:145
 TGMrbFileObject.h:146
 TGMrbFileObject.h:147
 TGMrbFileObject.h:148
 TGMrbFileObject.h:149
 TGMrbFileObject.h:150
 TGMrbFileObject.h:151
 TGMrbFileObject.h:152
 TGMrbFileObject.h:153
 TGMrbFileObject.h:154
 TGMrbFileObject.h:155
 TGMrbFileObject.h:156
 TGMrbFileObject.h:157
 TGMrbFileObject.h:158
 TGMrbFileObject.h:159
 TGMrbFileObject.h:160
 TGMrbFileObject.h:161
 TGMrbFileObject.h:162
 TGMrbFileObject.h:163
 TGMrbFileObject.h:164
 TGMrbFileObject.h:165
 TGMrbFileObject.h:166
 TGMrbFileObject.h:167
 TGMrbFileObject.h:168
 TGMrbFileObject.h:169
 TGMrbFileObject.h:170
 TGMrbFileObject.h:171
 TGMrbFileObject.h:172
 TGMrbFileObject.h:173
 TGMrbFileObject.h:174
 TGMrbFileObject.h:175
 TGMrbFileObject.h:176
 TGMrbFileObject.h:177
 TGMrbFileObject.h:178
 TGMrbFileObject.h:179
 TGMrbFileObject.h:180
 TGMrbFileObject.h:181
 TGMrbFileObject.h:182
 TGMrbFileObject.h:183
 TGMrbFileObject.h:184
 TGMrbFileObject.h:185
 TGMrbFileObject.h:186
 TGMrbFileObject.h:187
 TGMrbFileObject.h:188
 TGMrbFileObject.h:189
 TGMrbFileObject.h:190
 TGMrbFileObject.h:191
 TGMrbFileObject.h:192
 TGMrbFileObject.h:193
 TGMrbFileObject.h:194
 TGMrbFileObject.h:195
 TGMrbFileObject.h:196
 TGMrbFileObject.h:197
 TGMrbFileObject.h:198
 TGMrbFileObject.h:199
 TGMrbFileObject.h:200
 TGMrbFileObject.h:201
 TGMrbFileObject.h:202
 TGMrbFileObject.h:203
 TGMrbFileObject.h:204
 TGMrbFileObject.h:205
 TGMrbFileObject.h:206
 TGMrbFileObject.h:207
 TGMrbFileObject.h:208
 TGMrbFileObject.h:209
 TGMrbFileObject.h:210