[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: Problems with Double Buffer

Thank you for your answer
More stuff to be clear


[1] What is the difference between SWT.DOUBLE_BUFFER and SWT.NO_BACKGROUND? im using Windows XP Pro, eclipse europa. what is the specific difference between them in usage?



[2] The stuff (bar, line, axis, etc) shown on the screen are being drawn as following. Could this be any problem by getting new GC and draw every time?
if(image != null) {
GC gc = new GC(image);
// do something
gc.dispose();
}



[3] While screen resizing, flickering has gone; however, still when moving scroll-bar left to right, there's the flickering.
and also in the middle of a bar chart, bar seems to be separated instantly. In other words, i could say that it is visible the bar redrawing quickly.
i think i am lack of knowledge about this theory or making a simple mistake but unable to catch or something else.
Somehow, can you give me any advice as you see following code below? i will appreciate.



Canvas canvas = new Canvas(parent, SWT.NO_BACKGROUND | SWT.H_SCROLL | SWT.NO_REDRAW_RESIZE);


		canvas.addListener(SWT.Resize, new Listener() {
			public void handleEvent(Event event) {
				if (image != null) {
					image.dispose();
				}

				image = new Image(display, w, h);
				canvs.redraw();

				setScrollPosition();
			}
		});

		canvas.addListener(SWT.Paint, new Listener() {
			public void handleEvent(Event event) {
				if (manager.getProperty().getImageX() != null) {
					GC gc = event.gc;
					gc.drawImage(image, origin.x, origin.y);
					gc.dispose();
					}
			}
		});
		
		private void setScrollPosition() {
		Rectangle client =canvas.getBounds();
		Rectangle rect = image.getBounds();
		hBar.setMaximum(rect.width);
		hBar.setThumb(Math.min(rect.width, client.width));

		int hPage = rect.width - client.width;
		int hSelection = hBar.getSelection();

		if (hSelection >= hPage) {
			if (hPage <= 0) {
				hSelection = 0;
			}
			origin.x = -hSelection;
		}
		
		canvas.redraw();
	}