Hi Christian, You need to add the following two lines of code after mapping the main frame: ... fMain->MapWindow(); fMain->Move(420, 20); fFGTst->HideFrame(fFGroup1); //<--- added fFGTst->HideFrame(fFGroup2); //<--- added }//Constructor Best regards, Ilka cstrato wrote: > > Dear Rooters > > The enclosed macro "guiTestGroups.C" shows my problem. > > When I select tab "Group Test" then I see in the upper > left corner TGGroupFrame "Group 2" although it should > be hidden! Only after selecting "Group 2" from TGComboBox, > is Group 2 displayed correctly. > > I have tried different options, but the problem remains. > > Does anybody know where the mistake may be hidden? > Thank you in advance. > > My system is ROOT 4.00/01 (1.Feb 04) on MacOS X 10.3.1. > > Best regards > Christian > _._._._._._._._._._._._._._._._ > C.h.i.s.t.i.a.n S.t.r.a.t.o.w.a > V.i.e.n.n.a A.u.s.t.r.i.a > _._._._._._._._._._._._._._._._ > > ------------------------------------------------------------------------ > // Test gui > > //#ifndef __CINT__ > #include "RQ_OBJECT.h" > #include "TG3DLine.h" > #include "TGButton.h" > #include "TGComboBox.h" > #include "TGFrame.h" > #include "TGLabel.h" > #include "TGLayout.h" > #include "TGListBox.h" > #include "TGMenu.h" > #include "TGTab.h" > > #include "TList.h" > #include "TString.h" > #include "TROOT.h" > #include "TSystem.h" > //#endif > #include <Riostream.h> > > // Menu commands > enum EMenuCommands { > M_FILE, > M_FILE_EXIT, > }; > > class XFrameTestGroups { > > RQ_OBJECT("XFrameTestGroups") > > private: > TGMainFrame *fMain; > > TGPopupMenu *fMenuFile; > TGMenuBar *fMenuBar; > TGHorizontal3DLine *fLineH1; > TGLayoutHints *fMenuBarLayout; > TGLayoutHints *fMenuBarItemLayout; > TGLayoutHints *fLineLayout; > TGLayoutHints *fHintTL; > TGLayoutHints *fHintXY; > TGLayoutHints *fHintRXY; > > TGCompositeFrame *fFrame; > TGCanvas *fCanvas; > TGTab *fTab; > TGCompositeFrame *fFTab1; //Tab 1 > TGGroupFrame *fFG1; > TGCompositeFrame *fFTest; //Tab Test > TGGroupFrame *fFGTst; > TGComboBox *fTestBox; > TGGroupFrame *fFGroup1; > TGGroupFrame *fFGroup2; > > TList *fTrash; > Int_t fTestID; > > public: > XFrameTestGroups() {} > XFrameTestGroups(const TGWindow *window, UInt_t w, UInt_t h); > virtual ~XFrameTestGroups(); > > void DoMenu(Int_t id); > void DoCloseWindow(); > void DoSelectGroup(Int_t id = -1); > > private: > void CreateMenuBar(); > void DeleteMenuBar(); > > void CreateTab1(TGTab *tab); > void DeleteTab1(); > void CreateTabTest(TGTab *tab); > void DeleteTabTest(); > void CreateGroup1(TGCompositeFrame *parent); > void DeleteGroup1(); > void CreateGroup2(TGCompositeFrame *parent); > void DeleteGroup2(); > > #if !defined (__CINT__) || defined (__MAKECINT__) > ClassDef(XFrameTestGroups,0) //FrameMultiGroup > #endif > }; > > // Test Ids > enum ETest { > CB_GROUP1 = 1, > CB_GROUP2, > }; > > const Int_t kNTest = 2; > const char *kTest[2] = { "Group 1", > "Group 2"}; > > //debug: print function names > const Bool_t kCS = 1; > > #if !defined (__CINT__) || defined (__MAKECINT__) > ClassImp(XFrameTestGroups); > #endif > > //______________________________________________________________________________ > XFrameTestGroups::XFrameTestGroups(const TGWindow *window, UInt_t w, UInt_t h) > { > if(kCS) cout << "------XFrameTestGroups::XFrameTestGroups------" << endl; > > fTestID = 1; > > fTrash = new TList(); > fHintTL = new TGLayoutHints(kLHintsTop | kLHintsLeft); > fHintXY = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY); > fHintRXY = new TGLayoutHints(kLHintsRight | kLHintsExpandX | kLHintsExpandY); > > fMain = new TGMainFrame(window, w, h); > fMain->Connect("CloseWindow()", "XFrameTestGroups", this, "DoCloseWindow()"); > > CreateMenuBar(); > > fFrame = new TGVerticalFrame(fMain, w, h); > fCanvas = new TGCanvas(fFrame, w, h, 0); > fTab = new TGTab(fCanvas->GetViewPort(), 200, 20); > fTab->Associate(fMain); //? > fCanvas->SetContainer(fTab); > > CreateTab1(fTab); > CreateTabTest(fTab); > > fFrame->AddFrame(fCanvas, fHintXY); > fFrame->Resize(200, 260); > > fMain->AddFrame(fFrame, fHintRXY); > > fMain->SetWindowName("TestGroups"); > fMain->MapSubwindows(); > fMain->Resize(640, 620); > fMain->MapWindow(); > fMain->Move(420, 20); > }//Constructor > > //______________________________________________________________________________ > XFrameTestGroups::~XFrameTestGroups() > { > if(kCS) cout << "------XFrameTestGroups::~XFrameTestGroups------" << endl; > > delete fHintTL; delete fHintXY; delete fHintRXY; > > DeleteMenuBar(); > > DeleteTabTest(); > DeleteTab1(); > > delete fTab; delete fCanvas; delete fFrame; > > fTrash->Delete(); > delete fTrash; > > delete fMain; > }//Destructor > > //______________________________________________________________________________ > void XFrameTestGroups::CreateMenuBar() > { > if(kCS) cout << "------XFrameTestGroups::CreateMenuBar------" << endl; > > fMenuFile = new TGPopupMenu(gClient->GetRoot()); > fMenuFile->AddEntry("&Exit", M_FILE_EXIT); > fMenuFile->Connect("Activated(Int_t)","XFrameTestGroups",this,"DoMenu(Int_t)"); > > fMenuBarLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 1, 1); > fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0); > > fMenuBar = new TGMenuBar(fMain, 1, 1, kHorizontalFrame); > fMenuBar->AddPopup("&File", fMenuFile, fMenuBarItemLayout); > > fMain->AddFrame(fMenuBar, fMenuBarLayout); > > fLineH1 = new TGHorizontal3DLine(fMain); > fLineLayout = new TGLayoutHints(kLHintsTop | kLHintsExpandX); > fMain->AddFrame(fLineH1, fLineLayout); > fLineH1->DrawBorder(); > }//CreateMenuBar > > //______________________________________________________________________________ > void XFrameTestGroups::DeleteMenuBar() > { > if(kCS) cout << "------XFrameTestGroups::DeleteMenuBar------" << endl; > > delete fLineLayout; > delete fLineH1; > > delete fMenuBarLayout; > delete fMenuBarItemLayout; > > delete fMenuBar; > delete fMenuFile; > }//DeleteMenuBar > > //______________________________________________________________________________ > void XFrameTestGroups::DoMenu(Int_t id) > { > if(kCS) cout << "------XFrameTestGroups::DoMenu------" << endl; > > switch (id) { > case M_FILE_EXIT: > DoCloseWindow(); > break; > > default: > printf("Error: <XFrameTestGroups::DoMenu> Unknown ID %d selected\n", id); > break; > } > }//DoMenu > > //______________________________________________________________________________ > void XFrameTestGroups::DoCloseWindow() > { > if(kCS) cout << "------XFrameTestGroups::DoCloseWindow------" << endl; > > delete this; //does not exit root > // gApplication->Terminate(0); //exit root, needed for standalone App > }//DoCloseWindow > > //______________________________________________________________________________ > void XFrameTestGroups::DoSelectGroup(Int_t id) > { > if(kCS) cout << "------XFrameTestGroups::DoSelectGroup------" << endl; > > if (id == fTestID) return; > > fFGTst->HideFrame(fFGroup1); > fFGTst->HideFrame(fFGroup2); > > switch (id) { > case CB_GROUP1: > fFGTst->ShowFrame(fFGroup1); > break; > > case CB_GROUP2: > fFGTst->ShowFrame(fFGroup2); > break; > > default: > printf("Error: <XFrameTestGroups::DoSelectGroup> Unknown ID %d selected\n", id); > break; > }//switch > > fTestID = id; > }//DoSelectGroup > > //______________________________________________________________________________ > void XFrameTestGroups::CreateTab1(TGTab *tab) > { > if(kCS) cout << "------XFrameTestGroups::CreateTab1------" << endl; > > TGLayoutHints *hint = 0; > TGCompositeFrame *tabframe = 0; > > tabframe = tab->AddTab("Tab 1"); > fFTab1 = new TGCompositeFrame(tabframe, 20, 20, kVerticalFrame); > hint = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 10, 5); > tabframe->AddFrame(fFTab1, hint); > fTrash->Add(hint); > > fFG1 = new TGGroupFrame(fFTab1, "Group Tab 1", kVerticalFrame); > hint = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 10, 10); > fFTab1->AddFrame(fFG1, hint); > fTrash->Add(hint); > fFG1->Resize(400,200); > > TGLabel *lab = new TGLabel(fFG1, new TGString("Group for Tab 1")); > hint = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 10, 5); > fFG1->AddFrame(lab,hint); > fTrash->Add(hint); > fTrash->Add(lab); > }//CreateTab1 > > //______________________________________________________________________________ > void XFrameTestGroups::DeleteTab1() > { > // Delete Groups tab frames > if(kCS) cout << "------XFrameTestGroups::DeleteTab1------" << endl; > > delete fFG1; > delete fFTab1; > }//DeleteTab1 > > //______________________________________________________________________________ > void XFrameTestGroups::CreateTabTest(TGTab *tab) > { > if(kCS) cout << "------XFrameTestGroups::CreateTabTest------" << endl; > > TGLayoutHints *hint = 0; > TGCompositeFrame *tabframe = 0; > > tabframe = tab->AddTab("Group Test"); > fFTest = new TGCompositeFrame(tabframe, 20, 20, kVerticalFrame); > hint = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 10, 5); > tabframe->AddFrame(fFTest, hint); > fTrash->Add(hint); > > fFGTst = new TGGroupFrame(fFTest, "Select Group", kVerticalFrame | kFixedSize); > fFTest->AddFrame(fFGTst, fHintTL); > fFGTst->Resize(600,460); > > fTestBox = new TGComboBox(fFGTst, -1); > fTestBox->Connect("Selected(Int_t)", "XFrameTestGroups", this, "DoSelectGroup(Int_t)"); > hint = new TGLayoutHints(kLHintsTop | kLHintsRight, 5, 5, 15, 15); > fFGTst->AddFrame(fTestBox, hint); > fTestBox->Resize(250, 20); > for (Int_t i = 0; i < kNTest; i++) { > fTestBox->AddEntry(kTest[i], i+1); > }//for_i > fTestBox->Select(1); > > this->CreateGroup1(fFGTst); > this->CreateGroup2(fFGTst); > > fFGTst->HideFrame(fFGroup2); > fFGTst->MapSubwindows(); > fFGTst->Layout(); > > // DoSelectGroup(1); > }//CreateTabTest > > //______________________________________________________________________________ > void XFrameTestGroups::DeleteTabTest() > { > if(kCS) cout << "------XFrameTestGroups::DeleteTabTest------" << endl; > > this->DeleteGroup2(); > this->DeleteGroup1(); > > delete fTestBox; delete fFGTst; > delete fFTest; > }//DeleteTabTest > > //______________________________________________________________________________ > void XFrameTestGroups::CreateGroup1(TGCompositeFrame *parent) > { > if(kCS) cout << "------XFrameTestGroups::CreateGroup1------" << endl; > > TGLayoutHints *hint = 0; > > fFGroup1 = new TGGroupFrame(parent, "Group 1", kVerticalFrame); > hint = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 10, 10); > parent->AddFrame(fFGroup1, hint); > fTrash->Add(hint); > fFGroup1->Resize(400,200); > > TGLabel *lab = new TGLabel(fFGroup1, new TGString("This is Group 1")); > hint = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 10, 5); > fFGroup1->AddFrame(lab,hint); > fTrash->Add(hint); > fTrash->Add(lab); > }//CreateGroup1 > > //______________________________________________________________________________ > void XFrameTestGroups::DeleteGroup1() > { > if(kCS) cout << "------XFrameTestGroups::DeleteGroup1------" << endl; > > delete fFGroup1; > }//DeleteGroup1 > > //______________________________________________________________________________ > void XFrameTestGroups::CreateGroup2(TGCompositeFrame *parent) > { > if(kCS) cout << "------XFrameTestGroups::CreateGroup2------" << endl; > > TGLayoutHints *hint = 0; > > fFGroup2 = new TGGroupFrame(parent, "Group 2", kVerticalFrame); > hint = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 10, 10); > parent->AddFrame(fFGroup2, hint); > fTrash->Add(hint); > fFGroup2->Resize(400,200); > > TGLabel *lab = new TGLabel(fFGroup2, new TGString("This is Group 2!!")); > hint = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 10, 5); > fFGroup2->AddFrame(lab,hint); > fTrash->Add(hint); > fTrash->Add(lab); > > // parent->HideFrame(fFGroup2); > }//CreateGroup2 > > //______________________________________________________________________________ > void XFrameTestGroups::DeleteGroup2() > { > if(kCS) cout << "------XFrameTestGroups::DeleteGroup2------" << endl; > > delete fFGroup2; > }//DeleteGroup2 > > //______________________________________________________________________________ > void guiTestGroups() > { > new XFrameTestGroups(gClient->GetRoot(), 400, 220); > }
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:05 MET