| package org.eclipse.nebula.widgets.nattable.renderer.swt.layer.viewport |
| |
| import org.eclipse.nebula.widgets.nattable.core.graphics.GraphicsContext |
| import org.eclipse.nebula.widgets.nattable.core.layer.LayerPainter |
| import org.eclipse.nebula.widgets.nattable.core.layer.impl.GridLineCellLayerPainter |
| import org.eclipse.nebula.widgets.nattable.core.layer.impl.viewport.ViewportLayer |
| import org.eclipse.nebula.widgets.nattable.renderer.swt.geometry.SWTControlPixelArea |
| import org.eclipse.nebula.widgets.nattable.renderer.swt.graphics.SWTGraphicsContext |
| import org.eclipse.swt.SWT |
| import org.eclipse.swt.graphics.Rectangle |
| import org.eclipse.swt.widgets.Canvas |
| |
| class SWTViewportLayerPainter implements LayerPainter<ViewportLayer> { |
| |
| val defaultPainter = new GridLineCellLayerPainter |
| |
| Canvas viewportCanvas |
| |
| override paintLayer(ViewportLayer viewportLayer, GraphicsContext gc) { |
| val swtGC = gc as SWTGraphicsContext |
| if (viewportCanvas == null) { |
| viewportCanvas = new Canvas(swtGC.SWTComposite, SWT::H_SCROLL.bitwiseOr(SWT::V_SCROLL)) |
| |
| viewportLayer.pixelArea = new SWTControlPixelArea(viewportCanvas) |
| |
| viewportCanvas.horizontalBar.addListener(SWT::Selection, [ event | println(event) ]) |
| viewportCanvas.verticalBar.addListener(SWT::Selection, [ event | println(event) ]) |
| viewportCanvas.addPaintListener([ event | defaultPainter.paintLayer(viewportLayer, new SWTGraphicsContext(viewportCanvas, event.gc)) ]) |
| } |
| val clipBounds = swtGC.SWTGC.clipping |
| println('''viewport clipBounds «clipBounds»''') |
| viewportCanvas.bounds = new Rectangle(clipBounds.x, clipBounds.y, clipBounds.width, clipBounds.height) |
| } |
| |
| } |