Skip to main content

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


Calling redraw() is not a synchronous thing.  The redraw() call causes a paint event to be queued that will be processed at some later time.  You can not draw outside of the paint event of a widget.  Instead you should add a paint listener to the Sash and draw the lines on top of the sash in the paint listener of the sash.  Please note however that this is not really recommended.  There is no guarantee that a widget will only draw in its paint event (may also vary between platforms) so your lines may be overdrawn at any time.  That being said, drawing in the paint event will have a 99.9% success rate which is better than what you are currently seeing.

sash.addListener(SWT.Paint, new Listener() {
        public void handleEvent(Event e){
                //render lines here
        }
});



Dennis Meyer <durchgedreht@xxxxxx>
Sent by: platform-swt-dev-bounces@xxxxxxxxxxx

18/10/2006 02:20 AM

Please respond to
Dennis Meyer <durchgedreht@xxxxxx>; Please respond to
"Eclipse Platform SWT component developers list." <platform-swt-dev@xxxxxxxxxxx>

To
platform-swt-dev@xxxxxxxxxxx
cc
Subject
[platform-swt-dev] redraw problem in custom Widget (Sash)





Hi,

I'm developing a new Widget, where two Trees are separated by a Sash.
The Sash will contain lines connecting two tree entries (left-right
links). Line drawing works well but I have problems when using
Sash.redraw(). I forst call redraw() and then paint the lines. But the
redraw will take place AFTER drawing lines resulting in an empty sash.

I tried the following:

       private void renderLinks(final Sash sash, int orientation){
//              sash.getDisplay().asyncExec(
//                      new Runnable() {
//                              public void run(){
//                                      sash.redraw();
//                              }
//                      }
//              );
//      
               sash.redraw();
               ...
               render lines here
               ...

THX,
Dennis                          mailto:durchgedreht@xxxxxx

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev


Back to the top