added some more gc methods
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/graphics/GraphicsContext.xtend b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/graphics/GraphicsContext.xtend
index 98e1b69..53868bc 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/graphics/GraphicsContext.xtend
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/graphics/GraphicsContext.xtend
@@ -32,6 +32,8 @@
def void setForegroundColor(Color foregroundColor)
+ def void setBackgroundColor(Color backgroundColor)
+
def PixelRectangle getClipBounds()
def void setClipBounds(PixelRectangle clipBounds)
@@ -42,6 +44,7 @@
* Draws the specified text at the position specified by x and y coordinates.
* Ensure that drawing the text doesn't draw a background and line delimiters
* are handled correctly.
+ *
* @param text The text to draw.
* @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
* @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
@@ -49,7 +52,7 @@
def void drawText(String text, int x, int y)
/**
- * Draws a line, using the foreground color, between the points
+ * Draws a line using the foreground color between the points
* (<code>x1</code>, <code>y1</code>) and (<code>x2</code>, <code>y2</code>).
*
* @param x1 the first point's x coordinate
@@ -60,6 +63,20 @@
def void drawLine(int x1, int y1, int x2, int y2)
/**
+ * Draws a rectangle with the specified bounds using the foreground color.
+ *
+ * @param rect The rectangle's pixel bounds.
+ */
+ def void drawRectangle(PixelRectangle rect)
+
+ /**
+ * Fills the specified rectangular pixel area with the background color.
+ *
+ * @param rect The rectangle's pixel bounds.
+ */
+ def void fillRectangle(PixelRectangle rect)
+
+ /**
* Returns the calculated pixel width of the given string if drawn in the current font in the receiver.
* Tab expansion and carriage return processing are performed.
* <p>
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/graphics/GraphicsPropertiesEnum.xtend b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/graphics/GraphicsPropertiesEnum.xtend
index 9e78bef..4debb03 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/graphics/GraphicsPropertiesEnum.xtend
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/graphics/GraphicsPropertiesEnum.xtend
@@ -3,6 +3,7 @@
enum GraphicsPropertiesEnum {
FOREGROUND_COLOR,
+ BACKGROUND_COLOR,
CLIP_BOUNDS,
X_OFFSET,
Y_OFFSET
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/impl/DefaultCellPainter.xtend b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/impl/DefaultCellPainter.xtend
index 29e2340..1c1be30 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/impl/DefaultCellPainter.xtend
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/impl/DefaultCellPainter.xtend
@@ -1,9 +1,9 @@
package org.eclipse.nebula.widgets.nattable.core.layer.cell.impl
+import org.eclipse.nebula.widgets.nattable.core.geometry.PixelRectangle
import org.eclipse.nebula.widgets.nattable.core.graphics.GraphicsContext
import org.eclipse.nebula.widgets.nattable.core.layer.cell.Cell
import org.eclipse.nebula.widgets.nattable.core.layer.cell.CellPainter
-import org.eclipse.nebula.widgets.nattable.core.geometry.PixelRectangle
class DefaultCellPainter implements CellPainter {
diff --git a/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/graphics/JavaFXGraphicsContext.xtend b/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/graphics/JavaFXGraphicsContext.xtend
index 3529965..a8c9f02 100644
--- a/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/graphics/JavaFXGraphicsContext.xtend
+++ b/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/graphics/JavaFXGraphicsContext.xtend
@@ -36,18 +36,36 @@
)
}
+ override setBackgroundColor(Color backgroundColor) {
+ gc.fill = new javafx.scene.paint.Color(
+ backgroundColor.red as double / 255,
+ backgroundColor.green as double / 255,
+ backgroundColor.blue as double / 255,
+ backgroundColor.alpha as double / 255
+ )
+ }
+
override getClipBounds() {
- throw new UnsupportedOperationException("TODO: auto-generated method stub")
+ println("getClipBounds() not implemented")
+ new PixelRectangle(0, 0, 0, 0)
}
override setClipBounds(PixelRectangle clipBounds) {
- throw new UnsupportedOperationException("TODO: auto-generated method stub")
+ println("setClipBounds(clipBounds) not implemented")
}
override drawLine(int x1, int y1, int x2, int y2) {
gc.strokeLine(x1, y1, x2, y2)
}
+ override drawRectangle(PixelRectangle rect) {
+ gc.strokeRect(rect.x, rect.y, rect.width, rect.height)
+ }
+
+ override fillRectangle(PixelRectangle rect) {
+ gc.fillRect(rect.x, rect.y, rect.width, rect.height)
+ }
+
override drawText(String text, int x, int y) {
gc.strokeText(text, x, y)
}
diff --git a/org.eclipse.nebula.widgets.nattable.renderer.swt/src/org/eclipse/nebula/widgets/nattable/renderer/swt/graphics/SWTGraphicsContext.xtend b/org.eclipse.nebula.widgets.nattable.renderer.swt/src/org/eclipse/nebula/widgets/nattable/renderer/swt/graphics/SWTGraphicsContext.xtend
index 351c042..6e301aa 100644
--- a/org.eclipse.nebula.widgets.nattable.renderer.swt/src/org/eclipse/nebula/widgets/nattable/renderer/swt/graphics/SWTGraphicsContext.xtend
+++ b/org.eclipse.nebula.widgets.nattable.renderer.swt/src/org/eclipse/nebula/widgets/nattable/renderer/swt/graphics/SWTGraphicsContext.xtend
@@ -63,6 +63,7 @@
for (property : originalState.keySet) {
switch (property) {
case FOREGROUND_COLOR: gc.foreground = originalState.get(property) as org.eclipse.swt.graphics.Color
+ case BACKGROUND_COLOR: gc.background = originalState.get(property) as org.eclipse.swt.graphics.Color
case CLIP_BOUNDS: gc.clipping = originalState.get(property) as Rectangle
case X_OFFSET: xOffset = originalState.get(property) as Integer
case Y_OFFSET: yOffset = originalState.get(property) as Integer
@@ -89,6 +90,16 @@
)
}
+ override setBackgroundColor(Color backgroundColor) {
+ originalState.put(BACKGROUND_COLOR, gc.background)
+ gc.background = new org.eclipse.swt.graphics.Color(
+ gc.device,
+ backgroundColor.red,
+ backgroundColor.green,
+ backgroundColor.blue
+ )
+ }
+
override getClipBounds() {
new PixelRectangle(gc.clipping.x - xOffset, gc.clipping.y - yOffset, gc.clipping.width, gc.clipping.height)
}
@@ -102,6 +113,14 @@
gc.drawLine(xOffset + x1, yOffset + y1, xOffset + x2, yOffset + y2)
}
+ override drawRectangle(PixelRectangle rect) {
+ gc.drawRectangle(rect.x, rect.y, rect.width, rect.height)
+ }
+
+ override fillRectangle(PixelRectangle rect) {
+ gc.fillRectangle(rect.x, rect.y, rect.width, rect.height)
+ }
+
override drawText(String text, int x, int y) {
gc.drawText(text, xOffset + x, yOffset + y, SWT::DRAW_TRANSPARENT.bitwiseOr(SWT::DRAW_DELIMITER))