#include #include #include class MyMainFrame: public TGMainFrame { private: TGCanvas *fTreeCanvas; TGListTree *fTree; public: MyMainFrame( const TGWindow *p, UInt_t w, UInt_t h ); virtual ~MyMainFrame(); void CloseWindow(); //-- slots void OnTreeChecked(TObject*,Bool_t on); ClassDef(MyMainFrame,0); }; MyMainFrame::MyMainFrame( const TGWindow *p, UInt_t w, UInt_t h ) : TGMainFrame(p,w,h) { // create tree and its canvas fTree = new TGListTree(); fTreeCanvas = new TGCanvas(this,200,200); fTree = new TGListTree(this); fTree->SetCanvas( fTreeCanvas ); fTreeCanvas->SetContainer( fTree ); AddFrame( fTreeCanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY) ); // add items (with checkboxes) and connect slots fTree->AddItem( 0, "Item1", 0,0,kTRUE ); fTree->AddItem( 0, "Item2", 0,0,kTRUE ); fTree->Connect( "Checked(TObject*,Bool_t)", "MyMainFrame", this, "OnTreeChecked(TObject*,Bool_t)" ); // init mainwindow SetWindowName("Test Checked Callback of TGListTree"); MapSubwindows(); MapWindow(); } MyMainFrame::~MyMainFrame() { //delete fTree; // DELETE OR NOT? Cleanup(); } void MyMainFrame::CloseWindows() { DeleteWindow(); gApplication->Terminate(0); } void MyMainFrame::OnTreeChecked( TObject* entry, Bool_t on ) { //////////////////////////////////// // HERE IS THE PROBLEM: // *entry is always a null-pointer cout << "address of entry = " << entry << ", on = " << on << endl; } // named macro void checkbox() { new MyMainFrame(0, 200, 200); }