Re: [ROOT] TGListBox - advice would be greatly appreciated

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Mon Aug 13 2001 - 14:56:45 MEST


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