summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeronika Irvine <veronika>2003-03-05 16:31:55 +0000
committerVeronika Irvine <veronika>2003-03-05 16:31:55 +0000
commit209476d2ae732f161d1c3f0a7b436ce4fac87db2 (patch)
tree62a6f414680c5b03948785e10ab88b57d2c29771
parent0f99bec31b38228ace2a40c17f22b37abcc90b59 (diff)
downloadeclipse.platform.swt-209476d2ae732f161d1c3f0a7b436ce4fac87db2.tar.gz
eclipse.platform.swt-209476d2ae732f161d1c3f0a7b436ce4fac87db2.tar.xz
eclipse.platform.swt-209476d2ae732f161d1c3f0a7b436ce4fac87db2.zip
Converting Binary files to ASCII
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDragUnderEffect.java426
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ImageList.java280
2 files changed, 353 insertions, 353 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDragUnderEffect.java
index c4fd236893..3b7da8dffd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDragUnderEffect.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDragUnderEffect.java
@@ -1,216 +1,216 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.SWT;
-
-class TreeDragUnderEffect extends DragUnderEffect {
-
- private Tree tree;
- private int currentEffect = DND.FEEDBACK_NONE;
- private TreeItem[] selection = new TreeItem[0];
- private TreeItem dropSelection = null;
- private TreeItem insertMark = null;
- private boolean insertBefore = false;
-
- private TreeItem scrollItem;
- private long scrollBeginTime;
- private static final int SCROLL_HYSTERESIS = 400; // milli seconds
- private static final int SCROLL_WIDTH = 100; // pixels
-
- private TreeItem expandItem;
- private long expandBeginTime;
- private static final int EXPAND_HYSTERESIS = 1000; // milli seconds
-
-TreeDragUnderEffect(Tree tree) {
- this.tree = tree;
-}
-void show(int effect, int x, int y) {
- effect = checkEffect(effect);
- TreeItem item = findItem(x, y);
- if (item == null) effect = DND.FEEDBACK_NONE;
- if (currentEffect == DND.FEEDBACK_NONE && effect != DND.FEEDBACK_NONE) {
- selection = tree.getSelection();
- tree.deselectAll();
- }
- scrollHover(effect, item, x, y);
- expandHover(effect, item, x, y);
- setDragUnderEffect(effect, item);
- if (currentEffect != DND.FEEDBACK_NONE && effect == DND.FEEDBACK_NONE) {
- tree.setSelection(selection);
- selection = new TreeItem[0];
- }
- currentEffect = effect;
-}
-private int checkEffect(int effect) {
- // Some effects are mutually exclusive. Make sure that only one of the mutually exclusive effects has been specified.
- int mask = DND.FEEDBACK_INSERT_AFTER | DND.FEEDBACK_INSERT_BEFORE | DND.FEEDBACK_SELECT;
- int bits = effect & mask;
- if (bits == DND.FEEDBACK_INSERT_AFTER || bits == DND.FEEDBACK_INSERT_BEFORE || bits == DND.FEEDBACK_SELECT) return effect;
- return (effect & ~mask);
-}
-private TreeItem findItem(int x , int y){
- Point coordinates = new Point(x, y);
- coordinates = tree.toControl(coordinates);
- Rectangle area = tree.getClientArea();
- if (!area.contains(coordinates)) return null;
-
- TreeItem item = tree.getItem(coordinates);
- if (item != null) return item;
-
- // Scan across the width of the tree.
- for (int x1 = area.x; x1 < area.x + area.width; x1++) {
- coordinates = new Point(x1, coordinates.y);
- item = tree.getItem(coordinates);
- if (item != null) return item;
- }
- // Check if we are just below the last item of the tree
- coordinates = new Point(x, y);
- coordinates = tree.toControl(coordinates);
- if (coordinates.y > area.y + area.height - tree.getItemHeight()) {;
- int y1 = area.y + area.height - tree.getItemHeight();
- coordinates = new Point(coordinates.x, y1);
-
- item = tree.getItem(coordinates);
- if (item != null) return item;
-
- // Scan across the width of the tree just above the bottom..
- for (int x1 = area.x; x1 < area.x + area.width; x1++) {
- coordinates = new Point(x1, y1);
- item = tree.getItem(coordinates);
- if (item != null) return item;
- }
- }
- return null;
-}
-private void setDragUnderEffect(int effect, TreeItem item) {
- if ((effect & DND.FEEDBACK_SELECT) != 0) {
- if ((currentEffect & DND.FEEDBACK_INSERT_AFTER) != 0 ||
- (currentEffect & DND.FEEDBACK_INSERT_BEFORE) != 0) {
- tree.setInsertMark(null, false);
- }
- setDropSelection(item);
- return;
- }
- if ((effect & DND.FEEDBACK_INSERT_AFTER) != 0 ||
- (effect & DND.FEEDBACK_INSERT_BEFORE) != 0) {
- if ((currentEffect & DND.FEEDBACK_SELECT) != 0) {
- setDropSelection(null);
- }
- setInsertMark(item, (effect & DND.FEEDBACK_INSERT_BEFORE) != 0);
- return;
- }
-
- setInsertMark(null, false);
- setDropSelection(null);
-}
-private void setDropSelection (TreeItem item) {
- if (item == dropSelection) return;
- if (dropSelection != null) tree.deselectAll();
- dropSelection = item;
- if (dropSelection != null) tree.setSelection(new TreeItem[]{dropSelection});
-}
-private void setInsertMark(TreeItem item, boolean before) {
- if (item == insertMark && before == insertBefore) return;
- insertMark = item;
- insertBefore = before;
- tree.setInsertMark(item, before);
-}
-private void scrollHover (int effect, TreeItem item, int x, int y) {
- if ((effect & DND.FEEDBACK_SCROLL) == 0) {
- scrollBeginTime = 0;
- scrollItem = null;
- return;
- }
- if (scrollItem == item && scrollBeginTime != 0) {
- if (System.currentTimeMillis() >= scrollBeginTime) {
- scroll(item, x, y);
- scrollBeginTime = 0;
- scrollItem = null;
- }
- return;
- }
- scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
- scrollItem = item;
-}
-private void scroll(TreeItem item, int x, int y) {
- if (item == null) return;
- Point coordinates = new Point(x, y);
- coordinates = tree.toControl(coordinates);
- Rectangle area = tree.getClientArea();
- TreeItem showItem = null;
- if (coordinates.y - area.y < SCROLL_WIDTH) {
- showItem = getPreviousVisibleItem(item);
- } else if ((area.y + area.height - coordinates.y) < SCROLL_WIDTH) {
- showItem = getNextVisibleItem(item, true);
- }
- if (showItem != null) {
- tree.showItem(showItem);
- }
-}
-private void expandHover (int effect, TreeItem item, int x, int y) {
- if ((effect & DND.FEEDBACK_EXPAND) == 0) {
- expandBeginTime = 0;
- expandItem = null;
- return;
- }
- if (expandItem == item && expandBeginTime != 0) {
- if (System.currentTimeMillis() >= expandBeginTime) {
- expand(item, x, y);
- expandBeginTime = 0;
- expandItem = null;
- }
- return;
- }
- expandBeginTime = System.currentTimeMillis() + EXPAND_HYSTERESIS;
- expandItem = item;
-}
-private void expand(TreeItem item, int x, int y) {
- if (item == null || item.getExpanded()) return;
- Event event = new Event();
- event.x = x;
- event.y = y;
- event.item = item;
- event.time = (int) System.currentTimeMillis();
- tree.notifyListeners(SWT.Expand, event);
- if (item.isDisposed()) return;
- item.setExpanded(true);
-}
-private TreeItem getNextVisibleItem(TreeItem item, boolean includeChildren) {
- // look down
- // neccesary on the first pass only
- if (includeChildren && item.getItemCount() > 0 && item.getExpanded()) {
- return item.getItems()[0];
- }
- // look sideways
- TreeItem parent = item.getParentItem();
- TreeItem[] peers = (parent != null) ? parent.getItems() : tree.getItems();
- for (int i = 0; i < peers.length - 1; i++) {
- if (peers[i] == item) return peers[i + 1];
- }
- // look up
- if (parent != null) return getNextVisibleItem(parent, false);
- return null;
-}
-private TreeItem getPreviousVisibleItem(TreeItem item) {
- // look sideways
- TreeItem parent = item.getParentItem();
- TreeItem[] peers = (parent != null) ? parent.getItems() : tree.getItems();
- for (int i = peers.length - 1; i > 0; i--) {
- if (peers[i] == item) {
- TreeItem peer = peers[i-1];
- if (!peer.getExpanded() || peer.getItemCount() == 0) return peer;
- TreeItem[] peerItems = peer.getItems();
- return peerItems[peerItems.length - 1];
- }
- }
- // look up
- return parent;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.SWT;
+
+class TreeDragUnderEffect extends DragUnderEffect {
+
+ private Tree tree;
+ private int currentEffect = DND.FEEDBACK_NONE;
+ private TreeItem[] selection = new TreeItem[0];
+ private TreeItem dropSelection = null;
+ private TreeItem insertMark = null;
+ private boolean insertBefore = false;
+
+ private TreeItem scrollItem;
+ private long scrollBeginTime;
+ private static final int SCROLL_HYSTERESIS = 400; // milli seconds
+ private static final int SCROLL_WIDTH = 100; // pixels
+
+ private TreeItem expandItem;
+ private long expandBeginTime;
+ private static final int EXPAND_HYSTERESIS = 1000; // milli seconds
+
+TreeDragUnderEffect(Tree tree) {
+ this.tree = tree;
+}
+void show(int effect, int x, int y) {
+ effect = checkEffect(effect);
+ TreeItem item = findItem(x, y);
+ if (item == null) effect = DND.FEEDBACK_NONE;
+ if (currentEffect == DND.FEEDBACK_NONE && effect != DND.FEEDBACK_NONE) {
+ selection = tree.getSelection();
+ tree.deselectAll();
+ }
+ scrollHover(effect, item, x, y);
+ expandHover(effect, item, x, y);
+ setDragUnderEffect(effect, item);
+ if (currentEffect != DND.FEEDBACK_NONE && effect == DND.FEEDBACK_NONE) {
+ tree.setSelection(selection);
+ selection = new TreeItem[0];
+ }
+ currentEffect = effect;
+}
+private int checkEffect(int effect) {
+ // Some effects are mutually exclusive. Make sure that only one of the mutually exclusive effects has been specified.
+ int mask = DND.FEEDBACK_INSERT_AFTER | DND.FEEDBACK_INSERT_BEFORE | DND.FEEDBACK_SELECT;
+ int bits = effect & mask;
+ if (bits == DND.FEEDBACK_INSERT_AFTER || bits == DND.FEEDBACK_INSERT_BEFORE || bits == DND.FEEDBACK_SELECT) return effect;
+ return (effect & ~mask);
+}
+private TreeItem findItem(int x , int y){
+ Point coordinates = new Point(x, y);
+ coordinates = tree.toControl(coordinates);
+ Rectangle area = tree.getClientArea();
+ if (!area.contains(coordinates)) return null;
+
+ TreeItem item = tree.getItem(coordinates);
+ if (item != null) return item;
+
+ // Scan across the width of the tree.
+ for (int x1 = area.x; x1 < area.x + area.width; x1++) {
+ coordinates = new Point(x1, coordinates.y);
+ item = tree.getItem(coordinates);
+ if (item != null) return item;
+ }
+ // Check if we are just below the last item of the tree
+ coordinates = new Point(x, y);
+ coordinates = tree.toControl(coordinates);
+ if (coordinates.y > area.y + area.height - tree.getItemHeight()) {;
+ int y1 = area.y + area.height - tree.getItemHeight();
+ coordinates = new Point(coordinates.x, y1);
+
+ item = tree.getItem(coordinates);
+ if (item != null) return item;
+
+ // Scan across the width of the tree just above the bottom..
+ for (int x1 = area.x; x1 < area.x + area.width; x1++) {
+ coordinates = new Point(x1, y1);
+ item = tree.getItem(coordinates);
+ if (item != null) return item;
+ }
+ }
+ return null;
+}
+private void setDragUnderEffect(int effect, TreeItem item) {
+ if ((effect & DND.FEEDBACK_SELECT) != 0) {
+ if ((currentEffect & DND.FEEDBACK_INSERT_AFTER) != 0 ||
+ (currentEffect & DND.FEEDBACK_INSERT_BEFORE) != 0) {
+ tree.setInsertMark(null, false);
+ }
+ setDropSelection(item);
+ return;
+ }
+ if ((effect & DND.FEEDBACK_INSERT_AFTER) != 0 ||
+ (effect & DND.FEEDBACK_INSERT_BEFORE) != 0) {
+ if ((currentEffect & DND.FEEDBACK_SELECT) != 0) {
+ setDropSelection(null);
+ }
+ setInsertMark(item, (effect & DND.FEEDBACK_INSERT_BEFORE) != 0);
+ return;
+ }
+
+ setInsertMark(null, false);
+ setDropSelection(null);
+}
+private void setDropSelection (TreeItem item) {
+ if (item == dropSelection) return;
+ if (dropSelection != null) tree.deselectAll();
+ dropSelection = item;
+ if (dropSelection != null) tree.setSelection(new TreeItem[]{dropSelection});
+}
+private void setInsertMark(TreeItem item, boolean before) {
+ if (item == insertMark && before == insertBefore) return;
+ insertMark = item;
+ insertBefore = before;
+ tree.setInsertMark(item, before);
+}
+private void scrollHover (int effect, TreeItem item, int x, int y) {
+ if ((effect & DND.FEEDBACK_SCROLL) == 0) {
+ scrollBeginTime = 0;
+ scrollItem = null;
+ return;
+ }
+ if (scrollItem == item && scrollBeginTime != 0) {
+ if (System.currentTimeMillis() >= scrollBeginTime) {
+ scroll(item, x, y);
+ scrollBeginTime = 0;
+ scrollItem = null;
+ }
+ return;
+ }
+ scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
+ scrollItem = item;
+}
+private void scroll(TreeItem item, int x, int y) {
+ if (item == null) return;
+ Point coordinates = new Point(x, y);
+ coordinates = tree.toControl(coordinates);
+ Rectangle area = tree.getClientArea();
+ TreeItem showItem = null;
+ if (coordinates.y - area.y < SCROLL_WIDTH) {
+ showItem = getPreviousVisibleItem(item);
+ } else if ((area.y + area.height - coordinates.y) < SCROLL_WIDTH) {
+ showItem = getNextVisibleItem(item, true);
+ }
+ if (showItem != null) {
+ tree.showItem(showItem);
+ }
+}
+private void expandHover (int effect, TreeItem item, int x, int y) {
+ if ((effect & DND.FEEDBACK_EXPAND) == 0) {
+ expandBeginTime = 0;
+ expandItem = null;
+ return;
+ }
+ if (expandItem == item && expandBeginTime != 0) {
+ if (System.currentTimeMillis() >= expandBeginTime) {
+ expand(item, x, y);
+ expandBeginTime = 0;
+ expandItem = null;
+ }
+ return;
+ }
+ expandBeginTime = System.currentTimeMillis() + EXPAND_HYSTERESIS;
+ expandItem = item;
+}
+private void expand(TreeItem item, int x, int y) {
+ if (item == null || item.getExpanded()) return;
+ Event event = new Event();
+ event.x = x;
+ event.y = y;
+ event.item = item;
+ event.time = (int) System.currentTimeMillis();
+ tree.notifyListeners(SWT.Expand, event);
+ if (item.isDisposed()) return;
+ item.setExpanded(true);
+}
+private TreeItem getNextVisibleItem(TreeItem item, boolean includeChildren) {
+ // look down
+ // neccesary on the first pass only
+ if (includeChildren && item.getItemCount() > 0 && item.getExpanded()) {
+ return item.getItems()[0];
+ }
+ // look sideways
+ TreeItem parent = item.getParentItem();
+ TreeItem[] peers = (parent != null) ? parent.getItems() : tree.getItems();
+ for (int i = 0; i < peers.length - 1; i++) {
+ if (peers[i] == item) return peers[i + 1];
+ }
+ // look up
+ if (parent != null) return getNextVisibleItem(parent, false);
+ return null;
+}
+private TreeItem getPreviousVisibleItem(TreeItem item) {
+ // look sideways
+ TreeItem parent = item.getParentItem();
+ TreeItem[] peers = (parent != null) ? parent.getItems() : tree.getItems();
+ for (int i = peers.length - 1; i > 0; i--) {
+ if (peers[i] == item) {
+ TreeItem peer = peers[i-1];
+ if (!peer.getExpanded() || peer.getItemCount() == 0) return peer;
+ TreeItem[] peerItems = peer.getItems();
+ return peerItems[peerItems.length - 1];
+ }
+ }
+ // look up
+ return parent;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ImageList.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ImageList.java
index 5c5023c727..54690f47a2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ImageList.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ImageList.java
@@ -1,140 +1,140 @@
-package org.eclipse.swt.widgets;
-
-/*
- * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-class ImageList {
- int [] pixbufs;
- Image [] images;
-
-public ImageList() {
- images = new Image [4];
- pixbufs = new int [4];
-}
-
-public int add (Image image) {
- int index = 0;
- while (index < images.length) {
- if (images [index] != null) {
- if (images [index].isDisposed ()) {
- OS.g_object_unref (pixbufs [index]);
- images [index] = null;
- pixbufs [index] = 0;
- }
- }
- if (images [index] == null) break;
- index++;
- }
- int [] w = new int [1], h = new int [1];
- OS.gdk_drawable_get_size (image.pixmap, w, h);
- int width = w [0], height = h [0];
- boolean hasMask = image.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, image.pixmap, colormap, 0, 0, 0, 0, width, height);
- if (hasMask) {
- int gdkMaskImagePtr = OS.gdk_drawable_get_image (image.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] = (byte)0xFF;
- } else {
- line[x*4+3] = 0;
- }
- }
- OS.memmove (offset, line, stride);
- }
- OS.g_object_unref (gdkMaskImagePtr);
- }
- if (index == images.length) {
- Image [] newImages = new Image [images.length + 4];
- System.arraycopy (images, 0, newImages, 0, images.length);
- images = newImages;
- int [] newPixbufs = new int [pixbufs.length + 4];
- System.arraycopy (pixbufs, 0, newPixbufs, 0, pixbufs.length);
- pixbufs = newPixbufs;
- }
- pixbufs [index] = pixbuf;
- images [index] = image;
- return index;
-}
-
-public void dispose () {
- if (pixbufs == null) return;
- for (int index=0; index<pixbufs.length; index++) {
- if (pixbufs [index] != 0) OS.g_object_unref (pixbufs [index]);
- }
- images = null;
- pixbufs = null;
-}
-
-public Image get (int index) {
- return images [index];
-}
-
-int getPixbuf (int index) {
- return pixbufs [index];
-}
-
-public int indexOf (Image image) {
- if (image == null) return -1;
- for (int index=0; index<images.length; index++) {
- if (image == images [index]) return index;
- }
- return -1;
-}
-
-int indexOf (int pixbuf) {
- if (pixbuf == 0) return -1;
- for (int index=0; index<images.length; index++) {
- if (pixbuf == pixbufs [index]) return index;
- }
- return -1;
-}
-
-public boolean isDisposed () {
- return images == null;
-}
-
-public void remove (Image image) {
- if (image == null) return;
- for (int index=0; index<images.length; index++) {
- if (image == images [index]){
- OS.g_object_unref (pixbufs [index]);
- images [index] = null;
- pixbufs [index] = 0;
- }
- }
-}
-
-public int size () {
- int result = 0;
- for (int index=0; index<images.length; index++) {
- if (images [index] != null) {
- if (images [index].isDisposed ()) {
- OS.g_object_unref (pixbufs [index]);
- images [index] = null;
- pixbufs [index] = 0;
- }
- if (images [index] != null) result++;
- }
- }
- return result;
-}
-
-}
+package org.eclipse.swt.widgets;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+class ImageList {
+ int [] pixbufs;
+ Image [] images;
+
+public ImageList() {
+ images = new Image [4];
+ pixbufs = new int [4];
+}
+
+public int add (Image image) {
+ int index = 0;
+ while (index < images.length) {
+ if (images [index] != null) {
+ if (images [index].isDisposed ()) {
+ OS.g_object_unref (pixbufs [index]);
+ images [index] = null;
+ pixbufs [index] = 0;
+ }
+ }
+ if (images [index] == null) break;
+ index++;
+ }
+ int [] w = new int [1], h = new int [1];
+ OS.gdk_drawable_get_size (image.pixmap, w, h);
+ int width = w [0], height = h [0];
+ boolean hasMask = image.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, image.pixmap, colormap, 0, 0, 0, 0, width, height);
+ if (hasMask) {
+ int gdkMaskImagePtr = OS.gdk_drawable_get_image (image.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] = (byte)0xFF;
+ } else {
+ line[x*4+3] = 0;
+ }
+ }
+ OS.memmove (offset, line, stride);
+ }
+ OS.g_object_unref (gdkMaskImagePtr);
+ }
+ if (index == images.length) {
+ Image [] newImages = new Image [images.length + 4];
+ System.arraycopy (images, 0, newImages, 0, images.length);
+ images = newImages;
+ int [] newPixbufs = new int [pixbufs.length + 4];
+ System.arraycopy (pixbufs, 0, newPixbufs, 0, pixbufs.length);
+ pixbufs = newPixbufs;
+ }
+ pixbufs [index] = pixbuf;
+ images [index] = image;
+ return index;
+}
+
+public void dispose () {
+ if (pixbufs == null) return;
+ for (int index=0; index<pixbufs.length; index++) {
+ if (pixbufs [index] != 0) OS.g_object_unref (pixbufs [index]);
+ }
+ images = null;
+ pixbufs = null;
+}
+
+public Image get (int index) {
+ return images [index];
+}
+
+int getPixbuf (int index) {
+ return pixbufs [index];
+}
+
+public int indexOf (Image image) {
+ if (image == null) return -1;
+ for (int index=0; index<images.length; index++) {
+ if (image == images [index]) return index;
+ }
+ return -1;
+}
+
+int indexOf (int pixbuf) {
+ if (pixbuf == 0) return -1;
+ for (int index=0; index<images.length; index++) {
+ if (pixbuf == pixbufs [index]) return index;
+ }
+ return -1;
+}
+
+public boolean isDisposed () {
+ return images == null;
+}
+
+public void remove (Image image) {
+ if (image == null) return;
+ for (int index=0; index<images.length; index++) {
+ if (image == images [index]){
+ OS.g_object_unref (pixbufs [index]);
+ images [index] = null;
+ pixbufs [index] = 0;
+ }
+ }
+}
+
+public int size () {
+ int result = 0;
+ for (int index=0; index<images.length; index++) {
+ if (images [index] != null) {
+ if (images [index].isDisposed ()) {
+ OS.g_object_unref (pixbufs [index]);
+ images [index] = null;
+ pixbufs [index] = 0;
+ }
+ if (images [index] != null) result++;
+ }
+ }
+ return result;
+}
+
+}