#include "TGClient.h" #include "TGFrame.h" #include "TGButton.h" #include "TGTextEntry.h" #include "TGFileDialog.h" const char *filetypes[] = { "ROOT files", "*.root", "All files", "*", 0, 0 }; class MyMainFrame : public TGMainFrame { protected: TGTextButton *fButton; TGTextEntry *fTextEntry; public: MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h); virtual ~MyMainFrame(); void Browse(); }; //______________________________________________________________________ MyMainFrame::~MyMainFrame() { // Clean up main frame... Cleanup(); } //______________________________________________________________________ MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) : TGMainFrame(p, w, h) { SetCleanup(kDeepCleanup); ChangeOptions((GetOptions() & ~kVerticalFrame) | kHorizontalFrame); fTextEntry = new TGTextEntry(this, new TGTextBuffer(100)); AddFrame(fTextEntry, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY, 5, 5, 5, 5)); fButton = new TGTextButton(this, "browse..."); AddFrame(fButton, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 5, 5, 5, 5)); fButton->Connect("Clicked()", "MyMainFrame", this, "Browse()"); //******************************** MapSubwindows(); MapWindow(); Layout(); } //______________________________________________________________________ void MyMainFrame::Browse() { static TString dir("."); TGFileInfo fi; fi.fFileTypes = filetypes; fi.fIniDir = StrDup(dir); new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fi); if (fi.fFilename) // here add code to open the file... dir = fi.fIniDir; } //______________________________________________________________________ void simpleExample() { new MyMainFrame(gClient->GetRoot(), 300, 50); }