diff options
author | Christophe Cornu <ccornu> | 2003-12-10 19:30:34 +0000 |
---|---|---|
committer | Christophe Cornu <ccornu> | 2003-12-10 19:30:34 +0000 |
commit | d95369a732c4ebf503133f7a906e0bf5a4f4d541 (patch) | |
tree | f39a412ad32ec756e39e7b2cfccc463343785d6a /bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java | |
parent | 92840bf1dc9c70e7ea3cb593123b2ec10d732093 (diff) | |
download | eclipse.platform.swt-d95369a732c4ebf503133f7a906e0bf5a4f4d541.tar.gz eclipse.platform.swt-d95369a732c4ebf503133f7a906e0bf5a4f4d541.tar.xz eclipse.platform.swt-d95369a732c4ebf503133f7a906e0bf5a4f4d541.zip |
22228
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java | 73 |
1 files changed, 65 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java index 81873f71ae..6a5e3f67f6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.swt.widgets; - import org.eclipse.swt.*; import org.eclipse.swt.internal.gtk.*; import org.eclipse.swt.graphics.*; @@ -90,6 +89,7 @@ import org.eclipse.swt.graphics.*; public class Decorations extends Canvas { String text; Image image; + Image [] images = new Image [0]; boolean minimized, maximized; Menu menuBar; Menu [] menus; @@ -262,10 +262,15 @@ public Button getDefaultButton () { * </ul> */ public Image getImage () { - checkWidget(); + checkWidget (); return image; } +public Image [] getImages () { + checkWidget (); + return images; +} + /** * Returns <code>true</code> if the receiver is currently * maximized, and false otherwise. @@ -383,6 +388,7 @@ void releaseWidget () { menus = null; super.releaseWidget (); image = null; + images = null; } boolean restoreFocus () { @@ -451,15 +457,66 @@ public void setDefaultButton (Button button) { * </ul> */ public void setImage (Image image) { - checkWidget(); + checkWidget (); this.image = image; - int pixmap = 0, mask = 0; + setImages (image, images); +} + +public void setImages (Image [] images) { + checkWidget (); + if (images == null) error (SWT.ERROR_INVALID_ARGUMENT); + this.images = images; + setImages (image, images); +} + +void setImages (Image image, Image [] images) { if (image != null) { - pixmap = image.pixmap; - mask = image.mask; + Image [] tmp = new Image [images.length + 1]; + System.arraycopy (images, 0, tmp, 1, images.length); + tmp [0] = image; + images = tmp; + } + int pixbufs = 0; + for (int i = 0; i < images.length; i++) { + Image img = images [i]; + int [] w = new int [1], h = new int [1]; + OS.gdk_drawable_get_size (img.pixmap, w, h); + int width = w [0], height = h [0]; + boolean hasMask = img.mask != 0; + int pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, hasMask, 8, width, height); + if (pixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES); + int colormap = OS.gdk_colormap_get_system (); + OS.gdk_pixbuf_get_from_drawable (pixbuf, img.pixmap, colormap, 0, 0, 0, 0, width, height); + if (hasMask) { + int gdkMaskImagePtr = OS.gdk_drawable_get_image (img.mask, 0, 0, width, height); + if (gdkMaskImagePtr == 0) SWT.error (SWT.ERROR_NO_HANDLES); + int stride = OS.gdk_pixbuf_get_rowstride (pixbuf); + int pixels = OS.gdk_pixbuf_get_pixels (pixbuf); + byte [] line = new byte [stride]; + for (int y=0; y<height; y++) { + int offset = pixels + (y * stride); + OS.memmove (line, offset, stride); + for (int x=0; x<width; x++) { + if (OS.gdk_image_get_pixel (gdkMaskImagePtr, x, y) == 0) { + line[x*4+3] = 0; + } + } + OS.memmove (offset, line, stride); + } + OS.g_object_unref (gdkMaskImagePtr); + } + pixbufs = OS.g_list_append (pixbufs, pixbuf); + } + int window = OS.GTK_WIDGET_WINDOW (topHandle ()); + OS.gdk_window_set_icon_list (window, pixbufs); + int [] data = new int [1]; + int temp = pixbufs; + while (temp != 0) { + OS.memmove (data, temp, 4); + OS.g_object_unref (data [0]); + temp = OS.g_list_next (temp); } - int window = OS.GTK_WIDGET_WINDOW(topHandle()); - OS.gdk_window_set_icon (window, 0, pixmap, mask); + OS.g_list_free (pixbufs); } /** |