tags:

views:

17

answers:

1

I am trying to draw and animate with SWT using PaintListeners. I would like to influence the timing of the animation, so I have looked far and wide but could not found anything explaining where and how the PaintEvents are generated and how to influence that, e.g enforcing a framerate or sending the PaintEvent only to cetrain Widgets.

So, how can this be done? And, should this be done at all ? - finding nothing on that topic suggests that there may be a better way.

+1  A: 

PaintEvents are generated by SWT for you each time it's needed. For example the first time a widget is displayed or after a widget is becoming visible again beacause a window has been moved.

You can force paint event to occur on a Control using:

control.redraw();
control.update();

See here: http://help.eclipse.org/helios/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Control.html#redraw()

Manuel Selva
Thank you, im aware of the 'redraw()' and 'update()' methods. If I understand the API correctly, the first one just marks the wiget for processing when the next pain request comes and the seconde one forces all outstanding requests to be processed. Neither of them has influence on the generation of the requests. So, that does not answer my question. Maybe you could elaborate on your first part "generated by SWT" and "each time its needed". By which part of SWT? And how is the need determined?
kostja
@kostja I think SWT doesn't really generate these paint events himself but rely on the underlying Window System (motif, gtk or Windows). Why does the redraw/update doesn't fit your needs ?
Manuel Selva
I want to achieve consistent framerates across different systems, so I thought a good idea would be to get hold of the PaintEvent generation and control it with timerExec() or similar. Maybe there is a better way to do it?
kostja
Just do that with redraw() and update(). Create a timeExec calling redraw() and then update() on your widget and this will generate a paint event for you. I still don't get your problem using this solution.
Manuel Selva