// Modified buttonTest.C, for use in ROOT talk // J. Ljungvall // // // // To run it do either: // .x buttonTest.C // .x buttonTest.C++ #include #include #include #include #include "TGTextView.h" #include #include #include #include #include #include #include "TSystem.h" class help { public: help(){;} ~help(){;} void Bla(std::ostream &anostream = std::cout); }; //////////////////////////////////////////////////////////////////////////////// class ButtonWindow : public TGMainFrame { RQ_OBJECT("ButtonWindow"); protected: TGTextButton *fButton; TGTextView *fTextView; help h; public: ButtonWindow(); void FillTextEntry(); ClassDef(ButtonWindow, 0) }; //______________________________________________________________________________ ButtonWindow::ButtonWindow() : TGMainFrame(gClient->GetRoot(), 10, 10, kVerticalFrame) { // Main test window. SetCleanup(kDeepCleanup); // Contents TGHorizontalFrame *contents = new TGHorizontalFrame(this); AddFrame(contents, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5)); // The button for test fButton = new TGTextButton(contents, "Press"); fButton->Resize(300, 200); fButton->ChangeOptions(fButton->GetOptions() | kFixedSize); fButton->SetToolTipText("The assigned tooltip\ncan be multi-line also", 200); fButton->Connect("Clicked()","ButtonWindow",this,"FillTextEntry()"); contents->AddFrame(fButton, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 20, 20, 20, 20)); // TextView contents->AddFrame(fTextView = new TGTextView(contents,300,400,"")); TGTextButton *quit = new TGTextButton(this, "Quit"); AddFrame(quit, new TGLayoutHints(kLHintsBottom | kLHintsExpandX, 0, 0, 0, 5)); quit->Connect("Pressed()", "TApplication", gApplication, "Terminate()"); Connect("CloseWindow()", "TApplication", gApplication, "Terminate()"); DontCallClose(); MapSubwindows(); Resize(); SetWMSizeHints(GetDefaultWidth(), GetDefaultHeight(), 1000, 1000, 0 ,0); SetWindowName("Button Test"); MapRaised(); } //______________________________________________________________________________ void help::Bla(std::ostream &anostream) { for (int i=0; i<10; i++){ anostream << i << "\n"; gSystem->Sleep(700); } } void ButtonWindow::FillTextEntry() { std::cout << "Clicked\n"; h.Bla(std::cout); std::ostringstream tmp; h.Bla(tmp); fTextView->LoadBuffer(tmp.str().c_str()); } void buttonTest() { // Main program. new ButtonWindow(); }