// // Author: Ilka Antcheva 1/12/2006 // This macro gives an example of how to create a status bar related to // an embedded canvas that shows the info of the selected object exactly // as the status bar of any canvas window // To run it do either: // .x statusBar.C // .x statusBar.C++ #include #include #include #include #include #include #include #include #include #include #include #include class MyMainFrame : public TGMainFrame { private: TGStatusBar *fStatusBar; public: MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h); virtual ~MyMainFrame(); void DoExit(); void DoDraw(); ClassDef(MyMainFrame, 0) }; void MyMainFrame::DoDraw() { // Draw something in the canvas Printf("Processing..."); fStatusBar->SetText("Processing..."); //fStatusBar->Layout(); gClient->NeedRedraw(fStatusBar); float S = 0.f; for (int i = 0; i < 10000000; ++i) S += i*i; Printf("%f", S); fStatusBar->SetText("Ready"); } void MyMainFrame::DoExit() { printf("Exit application..."); gApplication->Terminate(0); } MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) : TGMainFrame(p, w, h) { // Create a horizontal frame containing two buttons TGHorizontalFrame *hframe = new TGHorizontalFrame(this, 200, 40); TGTextButton *draw = new TGTextButton(hframe, "&Draw"); draw->Connect("Clicked()", "MyMainFrame", this, "DoDraw()"); hframe->AddFrame(draw, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4)); TGTextButton *exit = new TGTextButton(hframe, "&Exit "); exit->Connect("Pressed()", "MyMainFrame", this, "DoExit()"); hframe->AddFrame(exit, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4)); AddFrame(hframe, new TGLayoutHints(kLHintsCenterX, 2, 2, 2, 2)); // status bar fStatusBar = new TGStatusBar(this, 50, 10, kVerticalFrame); AddFrame(fStatusBar, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); // Set a name to the main frame MapSubwindows(); // Initialize the layout algorithm via Resize() Resize(GetDefaultSize()); // Map main frame MapWindow(); } MyMainFrame::~MyMainFrame() { // Clean up main frame... Cleanup(); } void statusBar() { // Popup the GUI... new MyMainFrame(gClient->GetRoot(), 200, 200); }