summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeronika Irvine <veronika>2006-02-08 20:13:49 +0000
committerVeronika Irvine <veronika>2006-02-08 20:13:49 +0000
commit7fcb12202d5234213fbad4d76b30672d0511249d (patch)
tree70263ca922356470927b811c9211fb43fb8fbd1d
parent0c2e9abc4565e700564488b96dc45c231ce0c033 (diff)
downloadeclipse.platform.swt-7fcb12202d5234213fbad4d76b30672d0511249d.tar.gz
eclipse.platform.swt-7fcb12202d5234213fbad4d76b30672d0511249d.tar.xz
eclipse.platform.swt-7fcb12202d5234213fbad4d76b30672d0511249d.zip
add support for drag source image
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java66
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java18
6 files changed, 121 insertions, 3 deletions
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties
index 573841ea41..508d4b8360 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties
@@ -2266,6 +2266,12 @@ OS__gtk_drag_get_data_1=cast=(GdkDragContext *)
OS__gtk_drag_get_data_2=cast=(GdkAtom)
OS__gtk_drag_get_data_3=cast=(guint32)
+OS__gtk_drag_set_icon_pixbuf=
+OS__gtk_drag_set_icon_pixbuf_0=cast=(GdkDragContext *)
+OS__gtk_drag_set_icon_pixbuf_1=cast=(GdkPixbuf *)
+OS__gtk_drag_set_icon_pixbuf_2=
+OS__gtk_drag_set_icon_pixbuf_3=
+
OS__gtk_drawing_area_new=
OS__gtk_editable_copy_clipboard=
@@ -3628,6 +3634,10 @@ OS__gtk_tree_view_column_set_widget=
OS__gtk_tree_view_column_set_widget_0=cast=(GtkTreeViewColumn *)
OS__gtk_tree_view_column_set_widget_1=cast=(GtkWidget *)
+OS__gtk_tree_view_create_row_drag_icon=
+OS__gtk_tree_view_create_row_drag_icon_0=cast=(GtkTreeView *)
+OS__gtk_tree_view_create_row_drag_icon_1=cast=(GtkTreePath *)
+
OS__gtk_tree_view_expand_row=
OS__gtk_tree_view_expand_row_0=cast=(GtkTreeView *)
OS__gtk_tree_view_expand_row_1=cast=(GtkTreePath *)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java
index 637b226050..b7df08f530 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java
@@ -289,7 +289,15 @@ void drag(Event dragEvent) {
if (targetList == 0) return;
int actions = opToOsOp(getStyle());
- OS.gtk_drag_begin(control.handle, targetList, actions, 1, 0);
+ ImageData imageData = effect.getDragSourceImage(dragEvent.x, dragEvent.y);
+ int context = OS.gtk_drag_begin(control.handle, targetList, actions, 1, 0);
+ if (context != 0 && imageData != null) {
+ Image image = new Image(getDisplay(), imageData);
+ int /*long*/ pixbuf = createPixbuf(image);
+ OS.gtk_drag_set_icon_pixbuf(context, pixbuf, 0, 0);
+ OS.g_object_unref(pixbuf);
+ image.dispose();
+ }
}
void dragEnd(int /*long*/ widget, int /*long*/ context){
@@ -494,4 +502,60 @@ public void setTransfer(Transfer[] transferAgents){
OS.g_free(targets[i].target);
}
}
+
+static int /*long*/ createPixbuf(Image image) {
+ int [] w = new int [1], h = new int [1];
+ OS.gdk_drawable_get_size (image.pixmap, w, h);
+ int /*long*/ colormap = OS.gdk_colormap_get_system ();
+ int /*long*/ pixbuf;
+ boolean hasMask = image.mask != 0 && OS.gdk_drawable_get_depth (image.mask) == 1;
+ if (hasMask) {
+ pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, true, 8, w [0], h [0]);
+ if (pixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+ OS.gdk_pixbuf_get_from_drawable (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]);
+ int /*long*/ maskPixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, w [0], h [0]);
+ if (maskPixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+ OS.gdk_pixbuf_get_from_drawable(maskPixbuf, image.mask, 0, 0, 0, 0, 0, w [0], h [0]);
+ int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
+ int /*long*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf);
+ byte[] line = new byte[stride];
+ int maskStride = OS.gdk_pixbuf_get_rowstride(maskPixbuf);
+ int /*long*/ maskPixels = OS.gdk_pixbuf_get_pixels(maskPixbuf);
+ byte[] maskLine = new byte[maskStride];
+ for (int y=0; y<h[0]; y++) {
+ int /*long*/ offset = pixels + (y * stride);
+ OS.memmove(line, offset, stride);
+ int /*long*/ maskOffset = maskPixels + (y * maskStride);
+ OS.memmove(maskLine, maskOffset, maskStride);
+ for (int x=0; x<w[0]; x++) {
+ if (maskLine[x * 3] == 0) {
+ line[x * 4 + 3] = 0;
+ }
+ }
+ OS.memmove(offset, line, stride);
+ }
+ OS.g_object_unref(maskPixbuf);
+ } else {
+ ImageData data = image.getImageData ();
+ boolean hasAlpha = data.getTransparencyType () == SWT.TRANSPARENCY_ALPHA;
+ pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, hasAlpha, 8, w [0], h [0]);
+ if (pixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+ OS.gdk_pixbuf_get_from_drawable (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]);
+ if (hasAlpha) {
+ byte [] alpha = data.alphaData;
+ int stride = OS.gdk_pixbuf_get_rowstride (pixbuf);
+ int /*long*/ pixels = OS.gdk_pixbuf_get_pixels (pixbuf);
+ byte [] line = new byte [stride];
+ for (int y = 0; y < h [0]; y++) {
+ int /*long*/ offset = pixels + (y * stride);
+ OS.memmove (line, offset, stride);
+ for (int x = 0; x < w [0]; x++) {
+ line [x*4+3] = alpha [y*w [0]+x];
+ }
+ OS.memmove (offset, line, stride);
+ }
+ }
+ }
+ return pixbuf;
+}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
index 8a1d7f445e..bce944524b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
@@ -6188,6 +6188,16 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1drag_1get_1data)
}
#endif
+#ifndef NO__1gtk_1drag_1set_1icon_1pixbuf
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1drag_1set_1icon_1pixbuf)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ OS_NATIVE_ENTER(env, that, _1gtk_1drag_1set_1icon_1pixbuf_FUNC);
+ gtk_drag_set_icon_pixbuf((GdkDragContext *)arg0, (GdkPixbuf *)arg1, arg2, arg3);
+ OS_NATIVE_EXIT(env, that, _1gtk_1drag_1set_1icon_1pixbuf_FUNC);
+}
+#endif
+
#ifndef NO__1gtk_1drawing_1area_1new
JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1drawing_1area_1new)
(JNIEnv *env, jclass that)
@@ -10580,6 +10590,18 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1set_1widget)
}
#endif
+#ifndef NO__1gtk_1tree_1view_1create_1row_1drag_1icon
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1view_1create_1row_1drag_1icon)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1create_1row_1drag_1icon_FUNC);
+ rc = (jint)gtk_tree_view_create_row_drag_icon((GtkTreeView *)arg0, (GtkTreePath *)arg1);
+ OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1create_1row_1drag_1icon_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1gtk_1tree_1view_1expand_1row
JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1view_1expand_1row)
(JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
index a514af5fee..9ed0a5ff51 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
@@ -18,8 +18,8 @@
#ifdef NATIVE_STATS
-int OS_nativeFunctionCount = 1063;
-int OS_nativeFunctionCallCount[1063];
+int OS_nativeFunctionCount = 1065;
+int OS_nativeFunctionCallCount[1065];
char * OS_nativeFunctionNames[] = {
"Call",
"GDK_1EVENT_1TYPE",
@@ -485,6 +485,7 @@ char * OS_nativeFunctionNames[] = {
"_1gtk_1drag_1dest_1unset",
"_1gtk_1drag_1finish",
"_1gtk_1drag_1get_1data",
+ "_1gtk_1drag_1set_1icon_1pixbuf",
"_1gtk_1drawing_1area_1new",
"_1gtk_1editable_1copy_1clipboard",
"_1gtk_1editable_1cut_1clipboard",
@@ -823,6 +824,7 @@ char * OS_nativeFunctionNames[] = {
"_1gtk_1tree_1view_1column_1set_1title",
"_1gtk_1tree_1view_1column_1set_1visible",
"_1gtk_1tree_1view_1column_1set_1widget",
+ "_1gtk_1tree_1view_1create_1row_1drag_1icon",
"_1gtk_1tree_1view_1expand_1row",
"_1gtk_1tree_1view_1get_1background_1area",
"_1gtk_1tree_1view_1get_1bin_1window",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
index 38edd3ceb4..6fc49b3f65 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
@@ -489,6 +489,7 @@ typedef enum {
_1gtk_1drag_1dest_1unset_FUNC,
_1gtk_1drag_1finish_FUNC,
_1gtk_1drag_1get_1data_FUNC,
+ _1gtk_1drag_1set_1icon_1pixbuf_FUNC,
_1gtk_1drawing_1area_1new_FUNC,
_1gtk_1editable_1copy_1clipboard_FUNC,
_1gtk_1editable_1cut_1clipboard_FUNC,
@@ -827,6 +828,7 @@ typedef enum {
_1gtk_1tree_1view_1column_1set_1title_FUNC,
_1gtk_1tree_1view_1column_1set_1visible_FUNC,
_1gtk_1tree_1view_1column_1set_1widget_FUNC,
+ _1gtk_1tree_1view_1create_1row_1drag_1icon_FUNC,
_1gtk_1tree_1view_1expand_1row_FUNC,
_1gtk_1tree_1view_1get_1background_1area_FUNC,
_1gtk_1tree_1view_1get_1bin_1window_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index e577263be9..47e07314cc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -4003,6 +4003,15 @@ public static final void gtk_drag_get_data(int /*long*/ widget, int /*long*/ con
lock.unlock();
}
}
+public static final native void _gtk_drag_set_icon_pixbuf(int /*long*/ context, int /*long*/ pixbuf, int hot_x, int hot_y);
+public static final void gtk_drag_set_icon_pixbuf(int /*long*/ context, int /*long*/ pixbuf, int hot_x, int hot_y) {
+ lock.lock();
+ try {
+ _gtk_drag_set_icon_pixbuf(context, pixbuf, hot_x, hot_y);
+ } finally {
+ lock.unlock();
+ }
+}
public static final native int /*long*/ _gtk_drawing_area_new();
public static final int /*long*/ gtk_drawing_area_new() {
lock.lock();
@@ -6776,6 +6785,15 @@ public static final void gtk_tree_store_set(int /*long*/ store, int /*long*/ ite
lock.unlock();
}
}
+public static final native int _gtk_tree_view_create_row_drag_icon(int /*long*/ view, int /*long*/ path);
+public static final int gtk_tree_view_create_row_drag_icon(int /*long*/ view, int /*long*/ path) {
+ lock.lock();
+ try {
+ return _gtk_tree_view_create_row_drag_icon(view, path);
+ } finally {
+ lock.unlock();
+ }
+}
public static final native boolean _gtk_tree_view_collapse_row(int /*long*/ view, int /*long*/ path);
public static final boolean gtk_tree_view_collapse_row(int /*long*/ view, int /*long*/ path) {
lock.lock();