//#include "MainFrame.h" //#include "MyDialog.h" #include #include #include #include #include #include #include #include //ClassImp(MainFrame) class MainFrame { public: TRootEmbeddedCanvas *fEcanvas; TGMainFrame *fMain; TGCompositeFrame *fComp; TGTextButton *fAdd, *fExit; MainFrame(const TGWindow *p,UInt_t w,UInt_t h); virtual ~MainFrame(); MainFrame(); void CloseWindow(); }; MainFrame::MainFrame(const TGWindow *p,UInt_t w,UInt_t h) { // Create a main frame fMain = new TGMainFrame(p,w,h); fMain->Connect("CloseWindow()","MainFrame", this, "CloseWindow()"); // Create a canvas widget fEcanvas = new TRootEmbeddedCanvas("Ecanvas",fMain,500,500); cout <<"Get plotters canvas" << endl; //TCanvas* adoptee = GetCanvas(); cout << "Got it" << endl; ULong_t id = (ULong_t)fEcanvas->GetViewPort()->GetId(); Int_t CWinId = gVirtualX->InitWindow(id); TCanvas *adoptee = new TCanvas("Ecanvas", w, h, CWinId); fEcanvas->AdoptCanvas(adoptee); 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); // Create a frame containing a button fComp = new TGCompositeFrame(fMain,60,30,kHorizontalFrame | kSunkenFrame); fAdd = new TGTextButton(fComp, "&Add Chain "); //fAdd->Connect("Clicked()", "MainFrame", this, "DoDialog()"); fAdd->SetToolTipText("This is a button widget that pops up a dialog"); fComp->AddFrame(fAdd,new TGLayoutHints(kLHintsTop | kLHintsLeft,5,5,5,5)); fExit = new TGTextButton(fComp, " &Exit "); fExit->SetCommand("gApplication->Terminate()"); fComp->AddFrame(fExit, new TGLayoutHints(kLHintsTop | kLHintsRight,5,10,5,5)); fMain->AddFrame(fComp,new TGLayoutHints(kLHintsBottom | kLHintsExpandX,0,0,1,0)); // Set a name to the main frame fMain->SetWindowName("GUI"); // Map all sub windows of main frame fMain->MapSubwindows(); // Initialise the layout algorithm fMain->Resize (fMain->GetDefaultSize()); // Map main frame fMain->MapWindow(); } MainFrame::MainFrame() { } MainFrame::~MainFrame() { // Clean up used widgets: frames, buttons, layoutints // fMain->Cleanup(); // Clean up in direction children --> parents delete fExit; delete fAdd; delete fComp; delete fEcanvas; delete fMain; } void MainFrame::CloseWindow() { gApplication->Terminate(0); }