#include #include #include #include #include #include #include #include class MyMainFrame{ RQ_OBJECT("MyMainFrame") private: TGMainFrame *fMain; TRootEmbeddedCanvas *fEcanvas; public: MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h); virtual ~MyMainFrame(); void DoDraw(); }; MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h){ //Create main frame fMain = new TGMainFrame(p, w, h); //Create canvas widget fEcanvas = new TRootEmbeddedCanvas("Ecanvas", fMain, 200, 200); fMain->AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandX| kLHintsExpandY, 10, 10, 10, 1)); //Create a horizontal frame widget with buttons TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain, 200, 40); TGTextButton *doSomething = new TGTextButton(hframe, "&Go"); doSomething->Connect("Clicked()", "MyMainFrame", this, "DoSomething()"); hframe->AddFrame(doSomething, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4)); TGTextButton *exit = new TGTextButton(hframe, "&Exit", "gApplication->Terminate(0)"); hframe->AddFrame(exit, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4)); TGNumberEntry fN1 = new TGNumberEntry(hframe, .005, 9, kENTRY1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAPositive, TGNumberFOrmat::kNELNoLimits); hframe->AddFrame(fN1, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4)); fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX, 2, 2, 2, 2)); fMain->SetWindowName("blah"); //map all subwindows of main frame fMain->MapSubwindows(); //initialize layout algorithm fMain->Resize(fMain->GetDefaultSize()); //map main frame fMain->MapWindow(); } void MyMainFrame::DoSomething(){ //do something } MyMainFrame::~MyMainFrame(){ fMain->Cleanup(); delete fMain; } void example(){ new MyMainFrame(gClient->GetRoot(), 200, 200); }