deleting TGFrame

From: Judith Katzy (katzy@hehipc.phy.uic.edu)
Date: Tue Mar 21 2000 - 22:08:13 MET


hi,

I wrote a navigator that creates subframes and buttons and attaches logic 
to them, so that it knows which frames to show after a button has been
pushed. In that environment, I would like to create a TGFrame, that is 
child to a TGCompositeFrame and delete it later, in case I find that 
an identical TGFrame already exist. For some reasons I get a blank 
rectangular region in the TGCompositeFrame if I delete/don't add the frame 
to it. See an example macro below.

How can I get back to the state before I created the childframe?
(I tried any variation of TGCompositeFrame::RemoveFrame(..) & co., but 
nothing worked)

thanks for any help,
Judith


{
TGLayoutHints *lht =  new TGLayoutHints( kLHintsTop, 2, 2, 2, 2);
TGLayoutHints *lhl =  new TGLayoutHints( kLHintsLeft, 2, 2, 2, 2);

TGMainFrame *mf = new TGMainFrame(gClient->GetRoot(),200,200);
TGVerticalFrame *vfr = new TGVerticalFrame(mf, 100,100);
mf->AddFrame(vfr);

TGHorizontalFrame *hfr = new TGHorizontalFrame(vfr, 100,100);
TGTextButton *b1 = new TGTextButton(hfr,"horizontal1");
hfr->AddFrame(b1,lhl);
TGTextButton *b2 = new TGTextButton(hfr,"horizontal2");
hfr->AddFrame(b2,lhl);
vfr->AddFrame(hfr, lht);
Char_t name[25];

for(int i=0; i<=3; i++)
{
  sprintf(name,"test%d",i);
  TGVerticalFrame *vfr1 = new TGVerticalFrame(vfr, 100,100);
  TGTextButton *b = new TGTextButton(vfr1,name);
  vfr1->AddFrame(b,lhl);
  // if I use this line instead of the following 2 lines I see the full 
  // picture:
  //vfr->AddFrame(vfr1,lht); 

  // if I don't add the frame using this 2 lines I'll get a blank area:
  if(i!=1)  vfr->AddFrame(vfr1,lht); 
  else delete vfr1;
}
mf->Resize(200,200);
mf->MapSubwindows();
mf->ShowFrame(vfr);
mf->MapRaised();
}



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:21 MET