Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re[2]: [platform-swt-dev] redraw problem in custom Widget (Sash)

Hi Veronika,

you are right. I'm using a PaintListener now and all works fine. If I
want to refresh the view (e.g. a srolling occurs) I call e
sash.redraw() and all looks good and it even works faster than I
thought. Drawing will be reference take place on top of the
vcomponent, but as this is platform dependent, there are some
heavyweight components one is not able to draw on top. These
components are not usual and there are only few of them.

I also found a good introduction to GC here:
http://www.eclipse.org/articles/Article-SWT-graphics/SWT_graphics.html

Thank you very much for your help,
Dennis                          mailto: Veronika,


Thursday, October 19, 2006, 12:35:06 AM, you wrote:


VI>  
VI> Calling redraw() is not a synchronous thing.  The redraw() call
VI> causes a paint event to be queued that will be processed at some
VI> later time.  You can not draw outside of the paint event of a
VI> widget.  Instead you should add a paint listener to the Sash and
VI> draw the lines on top of the sash in the paint listener of the
VI> sash.  Please note however that this is not really recommended. 
VI> There is no guarantee that a widget will only draw in its paint
VI> event (may also vary between platforms) so your lines may be
VI> overdrawn at any time.  That being said, drawing in the paint
VI> event will have a 99.9% success rate which is better than what you are currently seeing.
VI>  
VI> sash.addListener(SWT.Paint, new Listener() { 
VI>         public void handleEvent(Event e){ 
VI>                 //render lines here 
VI>         } 
VI> }); 
VI>  
VI>  
VI>  
VI>    Dennis Meyer <durchgedreht@xxxxxx>  
VI> Sent by: platform-swt-dev-bounces@xxxxxxxxxxx 
VI> 18/10/2006 02:20 AM 
VI>    
VI> Please respond to
VI>  Dennis Meyer <durchgedreht@xxxxxx>; Please respond to
VI>  "Eclipse Platform SWT component developers list." <platform-swt-dev@xxxxxxxxxxx>
VI>  
VI>      
VI> To
VI>  platform-swt-dev@xxxxxxxxxxx   
VI> cc
VI>     
VI> Subject
VI>  [platform-swt-dev] redraw problem in custom Widget (Sash) 
VI>      
VI>  
VI>  
VI>  
VI> Hi,
VI>  
VI>  I'm developing a new Widget, where two Trees are separated by a Sash.
VI>  The Sash will contain lines connecting two tree entries (left-right
VI>  links). Line drawing works well but I have problems when using
VI>  Sash.redraw(). I forst call redraw() and then paint the lines. But the
VI>  redraw will take place AFTER drawing lines resulting in an empty sash.
VI>  
VI>  I tried the following:
VI>  
VI>         private void renderLinks(final Sash sash, int orientation){
VI>  //              sash.getDisplay().asyncExec(
VI>  //                      new Runnable() {
VI>  //                              public void run(){
VI>  //                                      sash.redraw();
VI>  //                              }
VI>  //                      }
VI>  //              );
VI>  //      
VI>                 sash.redraw();
VI>                 ...
VI>                 render lines here
VI>                 ...
VI>  
VI>  THX,
VI>  Dennis                          mailto:durchgedreht@xxxxxx
VI>  
VI>  _______________________________________________
VI>  platform-swt-dev mailing list
VI>  platform-swt-dev@xxxxxxxxxxx
VI>  https://dev.eclipse.org/mailman/listinfo/platform-swt-dev
VI>   
VI>  



Back to the top