Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT.NO_REDRAW_RESIZE does not work within a SahsForm
SWT.NO_REDRAW_RESIZE does not work within a SahsForm [message #463973] Tue, 15 November 2005 16:03
Thomas Mauch is currently offline Thomas Mauch
Messages: 29
Registered: July 2009
Junior Member
Hello

I'm having problems with a Canvas where SWT.NO_REDRAW_RESIZE is set. This
works fine as if there is just the Canvas or if the Canvas is child of a
composite, but if the Canvas is in a SashForm, it seems not work anymore. I
include a test program to show the issue.

- If I enlarge the window, most of the time just the newly visible region is
included in the clipping region, but from time to time the whole client area
is, e.g.

Clipping rect: Rectangle {158, 0, 1, 126}
Clipping rect: Rectangle {159, 0, 1, 126}
Clipping rect: Rectangle {0, 0, 163, 126}
Clipping rect: Rectangle {163, 0, 1, 126}
Clipping rect: Rectangle {164, 0, 1, 126}

If you look at the the output of the test program, you can see that from
time to time something gets painted on the left side of the canvas.

- If I shrink the window, the whole client area is always returned as
clipping rectangle and if I look at the output, there is seems always to be
some painting on the left and the right side to occur.

What do you think?
Thomas


import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;

public class SWTTest {
public static void main(String[] args) {
new SWTTest();
}

boolean color;

public SWTTest() {
final Display display = Display.getDefault ();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());

SashForm sashForm = new SashForm(shell, SWT.BORDER|SWT.HORIZONTAL);

Label label = new Label(sashForm, SWT.NONE);
label.setText("LABEL");

final Canvas canvas = new Canvas(sashForm, SWT.NO_REDRAW_RESIZE);
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
GC gc = e.gc;
System.out.println("Clipping rect: " + gc.getClipping());
Rectangle clientArea = canvas.getClientArea();
if (color)
gc.setBackground(display.getSystemColor(SWT.COLOR_BLUE));
else
gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
color = !color;
gc.fillRectangle(0,0,clientArea.width,clientArea.height);
}
});

shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
Previous Topic:How to avoid flicker when resizing Composite or canvas?
Next Topic:Invert Tree Data?
Goto Forum:
  


Current Time: Tue May 21 07:43:01 EDT 2013

Powered by FUDForum. Page generated in 0.01547 seconds