diff options
author | Christophe Cornu <ccornu> | 2003-12-11 21:10:38 +0000 |
---|---|---|
committer | Christophe Cornu <ccornu> | 2003-12-11 21:10:38 +0000 |
commit | acc6dd2d5917dc00b39c7e0d615183d2ef0f852e (patch) | |
tree | 6d8fba67bbf62868cc378048762859229de6a299 /bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java | |
parent | 4b06fe5c5659f4a3f01ebbe16f0814da3dbc06dd (diff) | |
download | eclipse.platform.swt-acc6dd2d5917dc00b39c7e0d615183d2ef0f852e.tar.gz eclipse.platform.swt-acc6dd2d5917dc00b39c7e0d615183d2ef0f852e.tar.xz eclipse.platform.swt-acc6dd2d5917dc00b39c7e0d615183d2ef0f852e.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 | 100 |
1 files changed, 48 insertions, 52 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 4f108f1252..74e84b1329 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 @@ -150,6 +150,52 @@ static int checkStyle (int style) { return style; } +void _setImages (Image [] images) { + int pixbufs = 0; + if (images != null) { + for (int i = 0; i < images.length; i++) { + Image icon = images [i]; + int [] w = new int [1], h = new int [1]; + OS.gdk_drawable_get_size (icon.pixmap, w, h); + int width = w [0], height = h [0]; + boolean hasMask = icon.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, icon.pixmap, colormap, 0, 0, 0, 0, width, height); + if (hasMask) { + int gdkMaskImagePtr = OS.gdk_drawable_get_image (icon.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); + } + if (pixbufs != 0) OS.g_list_free (pixbufs); +} + void add (Menu menu) { if (menus == null) menus = new Menu [4]; for (int i=0; i<menus.length; i++) { @@ -459,7 +505,7 @@ public void setDefaultButton (Button button) { public void setImage (Image image) { checkWidget (); this.image = image; - setImages (image, images); + _setImages (image != null ? new Image [] {image} : null); } public void setImages (Image [] images) { @@ -469,57 +515,7 @@ public void setImages (Image [] images) { if (images [i] == null || images [i].isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); } this.images = images; - setImages (image, images); -} - -void setImages (Image image, Image [] images) { - if (image != null) { - 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 icon = images [i]; - int [] w = new int [1], h = new int [1]; - OS.gdk_drawable_get_size (icon.pixmap, w, h); - int width = w [0], height = h [0]; - boolean hasMask = icon.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, icon.pixmap, colormap, 0, 0, 0, 0, width, height); - if (hasMask) { - int gdkMaskImagePtr = OS.gdk_drawable_get_image (icon.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); - } - if (pixbufs != 0) OS.g_list_free (pixbufs); + _setImages (images); } /** |