summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse
diff options
context:
space:
mode:
authorSilenio Quarti <silenio_quarti@ca.ibm.com>2012-01-19 11:56:57 -0500
committerSilenio Quarti <silenio_quarti@ca.ibm.com>2012-01-19 11:56:57 -0500
commit2409e4895346facaeea6eeef6414188a3d1e2f65 (patch)
tree5b7075965c47e44cef692f420c89841614ab6115 /bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse
parent81769f86af686a9108c70f5eccca90f204a41cef (diff)
downloadeclipse.platform.swt-2409e4895346facaeea6eeef6414188a3d1e2f65.tar.gz
eclipse.platform.swt-2409e4895346facaeea6eeef6414188a3d1e2f65.tar.xz
eclipse.platform.swt-2409e4895346facaeea6eeef6414188a3d1e2f65.zip
cleanup before merging into master
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java134
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java48
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java10
4 files changed, 105 insertions, 97 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
index b5d2458746..18a3741139 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
@@ -4031,9 +4031,13 @@ public void setTransform(Transform transform) {
*/
public void setXORMode(boolean xor) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (OS.USE_CAIRO) {
- Cairo.cairo_set_operator(handle, xor ? Cairo.CAIRO_OPERATOR_DIFFERENCE : Cairo.CAIRO_OPERATOR_OVER);
- } else {
+ int /*long*/ cairo = data.cairo;
+ if (cairo != 0) {
+ if (Cairo.cairo_version() >= Cairo.CAIRO_VERSION_ENCODE(1, 10, 0)) {
+ Cairo.cairo_set_operator(handle, xor ? Cairo.CAIRO_OPERATOR_DIFFERENCE : Cairo.CAIRO_OPERATOR_OVER);
+ }
+ }
+ if (!OS.USE_CAIRO) {
OS.gdk_gc_set_function(handle, xor ? OS.GDK_XOR : OS.GDK_COPY);
}
data.xorMode = xor;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
index e1137cfb64..ec42448801 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
@@ -1089,7 +1089,7 @@ public Rectangle getBounds() {
*/
public ImageData getImageData() {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- ImageData data;
+
if (OS.USE_CAIRO) {
int /*long*/ surface = ImageList.convertSurface(this);
int format = Cairo.cairo_image_surface_get_format(surface);
@@ -1107,7 +1107,7 @@ public ImageData getImageData() {
byte[] srcData = new byte[stride * height];
OS.memmove(srcData, surfaceData, srcData.length);
PaletteData palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
- data = new ImageData(width, height, 32, palette, 4, srcData);
+ ImageData data = new ImageData(width, height, 32, palette, 4, srcData);
if (hasAlpha) {
byte[] alphaData = data.alphaData = new byte[width * height];
for (int y = 0, offset = 0, alphaOffset = 0; y < height; y++) {
@@ -1139,58 +1139,58 @@ public ImageData getImageData() {
}
}
Cairo.cairo_surface_destroy(surface);
- } else {
- int[] w = new int[1], h = new int[1];
- OS.gdk_drawable_get_size(pixmap, w, h);
- int width = w[0], height = h[0];
- int /*long*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, width, height);
- if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- int /*long*/ colormap = OS.gdk_colormap_get_system();
- OS.gdk_pixbuf_get_from_drawable(pixbuf, pixmap, colormap, 0, 0, 0, 0, width, height);
- int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
- int /*long*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf);
- byte[] srcData = new byte[stride * height];
- OS.memmove(srcData, pixels, srcData.length);
- OS.g_object_unref(pixbuf);
-
- PaletteData palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
- data = new ImageData(width, height, 24, palette, 4, srcData);
- data.bytesPerLine = stride;
-
- if (transparentPixel == -1 && type == SWT.ICON && mask != 0) {
- /* Get the icon mask data */
- int /*long*/ gdkImagePtr = OS.gdk_drawable_get_image(mask, 0, 0, width, height);
- if (gdkImagePtr == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- GdkImage gdkImage = new GdkImage();
- OS.memmove(gdkImage, gdkImagePtr);
- byte[] maskData = new byte[gdkImage.bpl * gdkImage.height];
- OS.memmove(maskData, gdkImage.mem, maskData.length);
- OS.g_object_unref(gdkImagePtr);
- int maskPad;
- for (maskPad = 1; maskPad < 128; maskPad++) {
- int bpl = (((width + 7) / 8) + (maskPad - 1)) / maskPad * maskPad;
- if (gdkImage.bpl == bpl) break;
- }
- /* Make mask scanline pad equals to 2 */
- data.maskPad = 2;
- maskData = ImageData.convertPad(maskData, width, height, 1, maskPad, data.maskPad);
- /* Bit swap the mask data if necessary */
- if (gdkImage.byte_order == OS.GDK_LSB_FIRST) {
- for (int i = 0; i < maskData.length; i++) {
- byte b = maskData[i];
- maskData[i] = (byte)(((b & 0x01) << 7) | ((b & 0x02) << 5) |
- ((b & 0x04) << 3) | ((b & 0x08) << 1) | ((b & 0x10) >> 1) |
- ((b & 0x20) >> 3) | ((b & 0x40) >> 5) | ((b & 0x80) >> 7));
- }
- }
- data.maskData = maskData;
+ return data;
+ }
+ int[] w = new int[1], h = new int[1];
+ OS.gdk_drawable_get_size(pixmap, w, h);
+ int width = w[0], height = h[0];
+ int /*long*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, width, height);
+ if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ int /*long*/ colormap = OS.gdk_colormap_get_system();
+ OS.gdk_pixbuf_get_from_drawable(pixbuf, pixmap, colormap, 0, 0, 0, 0, width, height);
+ int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
+ int /*long*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf);
+ byte[] srcData = new byte[stride * height];
+ OS.memmove(srcData, pixels, srcData.length);
+ OS.g_object_unref(pixbuf);
+
+ PaletteData palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
+ ImageData data = new ImageData(width, height, 24, palette, 4, srcData);
+ data.bytesPerLine = stride;
+
+ if (transparentPixel == -1 && type == SWT.ICON && mask != 0) {
+ /* Get the icon mask data */
+ int /*long*/ gdkImagePtr = OS.gdk_drawable_get_image(mask, 0, 0, width, height);
+ if (gdkImagePtr == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ GdkImage gdkImage = new GdkImage();
+ OS.memmove(gdkImage, gdkImagePtr);
+ byte[] maskData = new byte[gdkImage.bpl * gdkImage.height];
+ OS.memmove(maskData, gdkImage.mem, maskData.length);
+ OS.g_object_unref(gdkImagePtr);
+ int maskPad;
+ for (maskPad = 1; maskPad < 128; maskPad++) {
+ int bpl = (((width + 7) / 8) + (maskPad - 1)) / maskPad * maskPad;
+ if (gdkImage.bpl == bpl) break;
}
- data.transparentPixel = transparentPixel;
- data.alpha = alpha;
- if (alpha == -1 && alphaData != null) {
- data.alphaData = new byte[alphaData.length];
- System.arraycopy(alphaData, 0, data.alphaData, 0, alphaData.length);
+ /* Make mask scanline pad equals to 2 */
+ data.maskPad = 2;
+ maskData = ImageData.convertPad(maskData, width, height, 1, maskPad, data.maskPad);
+ /* Bit swap the mask data if necessary */
+ if (gdkImage.byte_order == OS.GDK_LSB_FIRST) {
+ for (int i = 0; i < maskData.length; i++) {
+ byte b = maskData[i];
+ maskData[i] = (byte)(((b & 0x01) << 7) | ((b & 0x02) << 5) |
+ ((b & 0x04) << 3) | ((b & 0x08) << 1) | ((b & 0x10) >> 1) |
+ ((b & 0x20) >> 3) | ((b & 0x40) >> 5) | ((b & 0x80) >> 7));
+ }
}
+ data.maskData = maskData;
+ }
+ data.transparentPixel = transparentPixel;
+ data.alpha = alpha;
+ if (alpha == -1 && alphaData != null) {
+ data.alphaData = new byte[alphaData.length];
+ System.arraycopy(alphaData, 0, data.alphaData, 0, alphaData.length);
}
return data;
}
@@ -1289,22 +1289,22 @@ void init(int width, int height) {
Cairo.cairo_destroy(cairo);
this.width = width;
this.height = height;
- } else {
- this.pixmap = OS.gdk_pixmap_new(OS.GDK_ROOT_PARENT(), width, height, -1);
- if (pixmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- /* Fill the bitmap with white */
- GdkColor white = new GdkColor();
- white.red = (short)0xFFFF;
- white.green = (short)0xFFFF;
- white.blue = (short)0xFFFF;
- int /*long*/ colormap = OS.gdk_colormap_get_system();
- OS.gdk_colormap_alloc_color(colormap, white, true, true);
- int /*long*/ gdkGC = OS.gdk_gc_new(pixmap);
- OS.gdk_gc_set_foreground(gdkGC, white);
- OS.gdk_draw_rectangle(pixmap, gdkGC, 1, 0, 0, width, height);
- OS.g_object_unref(gdkGC);
- OS.gdk_colormap_free_colors(colormap, white, 1);
+ return;
}
+ this.pixmap = OS.gdk_pixmap_new(OS.GDK_ROOT_PARENT(), width, height, -1);
+ if (pixmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ /* Fill the bitmap with white */
+ GdkColor white = new GdkColor();
+ white.red = (short)0xFFFF;
+ white.green = (short)0xFFFF;
+ white.blue = (short)0xFFFF;
+ int /*long*/ colormap = OS.gdk_colormap_get_system();
+ OS.gdk_colormap_alloc_color(colormap, white, true, true);
+ int /*long*/ gdkGC = OS.gdk_gc_new(pixmap);
+ OS.gdk_gc_set_foreground(gdkGC, white);
+ OS.gdk_draw_rectangle(pixmap, gdkGC, 1, 0, 0, width, height);
+ OS.g_object_unref(gdkGC);
+ OS.gdk_colormap_free_colors(colormap, white, 1);
}
void init(ImageData image) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java
index 013fafeb3a..ddb8b1c687 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java
@@ -128,32 +128,32 @@ boolean drawCaret () {
}
Cairo.cairo_fill(cairo);
Cairo.cairo_destroy(cairo);
+ return true;
+ }
+ int /*long*/ gc = OS.gdk_gc_new (window);
+ GdkColor color = new GdkColor ();
+ color.red = (short) 0xffff;
+ color.green = (short) 0xffff;
+ color.blue = (short) 0xffff;
+ int /*long*/ colormap = OS.gdk_colormap_get_system ();
+ OS.gdk_colormap_alloc_color (colormap, color, true, true);
+ OS.gdk_gc_set_foreground (gc, color);
+ OS.gdk_gc_set_function (gc, OS.GDK_XOR);
+ if (image != null && !image.isDisposed() && image.mask == 0) {
+ int[] width = new int[1]; int[] height = new int[1];
+ OS.gdk_drawable_get_size(image.pixmap, width, height);
+ int nX = x;
+ if ((parent.style & SWT.MIRRORED) != 0) nX = parent.getClientWidth () - width[0] - nX;
+ OS.gdk_draw_drawable(window, gc, image.pixmap, 0, 0, nX, y, width[0], height[0]);
} else {
- int /*long*/ gc = OS.gdk_gc_new (window);
- GdkColor color = new GdkColor ();
- color.red = (short) 0xffff;
- color.green = (short) 0xffff;
- color.blue = (short) 0xffff;
- int /*long*/ colormap = OS.gdk_colormap_get_system ();
- OS.gdk_colormap_alloc_color (colormap, color, true, true);
- OS.gdk_gc_set_foreground (gc, color);
- OS.gdk_gc_set_function (gc, OS.GDK_XOR);
- if (image != null && !image.isDisposed() && image.mask == 0) {
- int[] width = new int[1]; int[] height = new int[1];
- OS.gdk_drawable_get_size(image.pixmap, width, height);
- int nX = x;
- if ((parent.style & SWT.MIRRORED) != 0) nX = parent.getClientWidth () - width[0] - nX;
- OS.gdk_draw_drawable(window, gc, image.pixmap, 0, 0, nX, y, width[0], height[0]);
- } else {
- int nWidth = width, nHeight = height;
- if (nWidth <= 0) nWidth = DEFAULT_WIDTH;
- int nX = x;
- if ((parent.style & SWT.MIRRORED) != 0) nX = parent.getClientWidth () - nWidth - nX;
- OS.gdk_draw_rectangle (window, gc, 1, nX, y, nWidth, nHeight);
- }
- OS.g_object_unref (gc);
- OS.gdk_colormap_free_colors (colormap, color, 1);
+ int nWidth = width, nHeight = height;
+ if (nWidth <= 0) nWidth = DEFAULT_WIDTH;
+ int nX = x;
+ if ((parent.style & SWT.MIRRORED) != 0) nX = parent.getClientWidth () - nWidth - nX;
+ OS.gdk_draw_rectangle (window, gc, 1, nX, y, nWidth, nHeight);
}
+ OS.g_object_unref (gc);
+ OS.gdk_colormap_free_colors (colormap, color, 1);
return true;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index dcada53e7d..60b74181bd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -3817,8 +3817,13 @@ void setBackgroundPixmap (Image image) {
if (image.pixmap != 0) {
OS.gdk_window_set_back_pixmap (window, image.pixmap, false);
} else if (image.surface != 0) {
- // TODO background pixmap does not have colormap. For now draw background in windowProc()
- // Another option would be to create a pixmap from the surface
+ /*
+ * TODO This code code is commented because it does not work since the pixmap
+ * created with gdk_pixmap_foreign_new() does not have colormap. Another option
+ * would be to create a pixmap on the fly from the surface.
+ *
+ * For now draw background in windowProc().
+ */
// int /*long*/ surface = image.surface;
// int type = Cairo.cairo_surface_get_type(surface);
// switch (type) {
@@ -3828,7 +3833,6 @@ void setBackgroundPixmap (Image image) {
// OS.g_object_unref(pixmap);
// break;
// }
-//
}
}
}