Re: [ROOT] TGListBox - thanks and another question

From: Mark Thomson (thomson@hep.phy.cam.ac.uk)
Date: Mon Aug 13 2001 - 17:54:05 MEST


Hi Fons,

Thanks for replying so quickly, your fast response is really appreciated.
Calling gSystem->ProcessEvents() at the appropriate time solved the
problem (which only occurred at when trying to add entries at high rates).

I have a related question. To limit the size of the ListBox I restrict
the number of entries to some fixed number (e.g. 1000). When this number
is exceeded the 10 entries at the bottom of the list are removed using
               fListBox->RemoveEntries() 
This causes problems in TGListBox::Layout() - the screen TGListBox
window momentarily goes white. Stepping through in the debugger I find 
that this occurs when container->Resize(cw,tch) is called from 
TGListBox::Layout() the size of the container.  It looks like there
is some mismatch between the   viewport position/scrollbar position and
container size. Things are fine after the ProcessEvents but this causes
an annoying screen flicker.

                Any suggestions ? 
                       cheers,
                           Mark.  

  fListBox->AddEntry(pLBT2,fLayout);
  if(_iListBoxEntry>_nDepth)iCount++;
  if(_iListBoxEntry>_nDepth)fListBox->RemoveEntry(_iListBoxEntry-_nDepth);
  if(iCount==_nKillEntries){
    nCount++;
    fListBox->RemoveEntries((nCount-1)*_nKillEntries+1,nCount*_nKillEntries);
    iCount =0;
  }  
  int nThatFit =fListBox->GetHeight()/(pLBT2->GetHeight()+1+fLayout->GetPadTop()+fLayout->GetPadBottom()) ;
  fListBox->MapSubwindows();
  fListBox->Layout();
  if(_iListBoxEntry>nThatFit)fListBox->SetTopEntry(_iListBoxEntry-nThatFit);
  gSystem->ProcessEvents();

   
p.s. I use fListBox->RemoveEntries() since it is much faster than
the correspoding multiple calls to fListBox->RemoveEntry().




On Mon, 13 Aug 2001, Fons Rademakers wrote:

> Hi Mark,
> 
>   in principle what you do is correct. However, are you returning after this
> code snipped back into the event loop or are you continuing some lengthy
> calculation. Remember, the GUI gets only refresh when it gets back to the
> event loop. You can force this by calling gSystem->ProcessEvents() once
> in a while when in a tight calculating loop.
> 
> Cheers, Fons.
> 
> 
> 
> Mark Thomson wrote:
> > 
> > Dear Rooters,
> > 
> > I've written a simple GUI application to display logging messages based on
> > the TGListBox class. On the whole things work fine. However I have a problem
> > which causes the screen updates to be rather jittery:
> > 
> >   1) How do I force the window to redraw immediately after I add a
> >      new entry. I had expected the new TGTextLBEntry to be drawn
> >      immediately after the code (see below) has been executed - it
> >      doesn't.
> > 
> >      What am I doing wrong  ? How do I force the listbox and entry to be
> >      drawn after adding each TGTextLBEntry.
> > 
> >                 cheers,
> >                        Mark Thomson
> > 
> >   // Make the new entry - associate it with the LB container
> >   TGTextLBEntry* pLBT2 = new TGTextLBEntry(fListBox->GetContainer(),
> >                                     pString,++_iListBoxEntry,
> >                                     theGC, theFont,
> >                                     kHorizontalFrame,backColor);
> >   TGLayoutHints* fLayout = new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX,
> >                                     1, 0, 0, 1 );
> > 
> >   // NOTE the list box adopts pLBT2 and fLayout
> >   // Add the entry and try to display it
> >   fListBox->AddEntry(pLBT2,fLayout);
> >   fListBox->MapSubwindows();
> >   fListBox->Layout();
> >   // Scroll so that new entry is at the bottom of the screen
> >   int nThatFit = fListBox->GetHeight()/(pLBT2->GetHeight()+
> >                        fLayout->GetPadTop()+fLayout->GetPadBottom());
> > 
> >   if(_iListBoxEntry>nThatFit)fListBox->SetTopEntry(_iListBoxEntry+1-nThatFit);
> 
> -- 
> Org:    CERN, European Laboratory for Particle Physics.
> Mail:   1211 Geneve 23, Switzerland
> E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
> WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7677910
> 



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:57 MET