summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorAnatoly Spektor2012-06-19 10:27:41 (EDT)
committer Silenio Quarti2012-06-19 17:50:53 (EDT)
commit9a3f1e08acae6a5f050926a48e53d50c103a85e9 (patch)
treefcc60c3c69e9e386eaffc031be1c578e96d4d153
parent4df24be727bf7df22d7972cb27d4cc6882d010fa (diff)
downloadeclipse.platform.swt-9a3f1e08acae6a5f050926a48e53d50c103a85e9.zip
eclipse.platform.swt-9a3f1e08acae6a5f050926a48e53d50c103a85e9.tar.gz
eclipse.platform.swt-9a3f1e08acae6a5f050926a48e53d50c103a85e9.tar.bz2
Use Cairo instead of deprecated functions in ToolTip widget.
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c18
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java61
6 files changed, 93 insertions, 3 deletions
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 3bf70f6..97b16fc 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
@@ -5040,6 +5040,24 @@ fail:
}
#endif
+#ifndef NO__1gdk_1cairo_1set_1source_1pixbuf
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1cairo_1set_1source_1pixbuf)
+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jdouble arg2, jdouble arg3)
+{
+ OS_NATIVE_ENTER(env, that, _1gdk_1cairo_1set_1source_1pixbuf_FUNC);
+/*
+ gdk_cairo_set_source_pixbuf(arg0, (const GdkPixbuf *)arg1, arg2, arg3);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gdk_cairo_set_source_pixbuf)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(jintLong, const GdkPixbuf *, jdouble, jdouble))fp)(arg0, (const GdkPixbuf *)arg1, arg2, arg3);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1gdk_1cairo_1set_1source_1pixbuf_FUNC);
+}
+#endif
+
#ifndef NO__1gdk_1cairo_1set_1source_1window
JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1cairo_1set_1source_1window)
(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jint arg2, jint arg3)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
index 5cad191..310e9fb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
@@ -220,6 +220,7 @@
#define pango_cairo_font_map_get_default_LIB LIB_PANGOCAIRO
#define pango_cairo_font_map_set_resolution_LIB LIB_PANGOCAIRO
#define gdk_cairo_reset_clip_LIB LIB_GDK
+#define gdk_cairo_set_source_pixbuf_LIB LIB_GDK
#define gdk_cairo_set_source_color_LIB LIB_GDK
#define gdk_cairo_set_source_window_LIB LIB_GDK
#define gdk_cairo_region_LIB LIB_GDK
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 332cce9..a30c73c 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
@@ -430,6 +430,7 @@ char * OS_nativeFunctionNames[] = {
"_1gdk_1cairo_1region",
"_1gdk_1cairo_1reset_1clip",
"_1gdk_1cairo_1set_1source_1color",
+ "_1gdk_1cairo_1set_1source_1pixbuf",
"_1gdk_1cairo_1set_1source_1window",
"_1gdk_1color_1free",
"_1gdk_1color_1parse",
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 a784fb1..e8c483e 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
@@ -438,6 +438,7 @@ typedef enum {
_1gdk_1cairo_1region_FUNC,
_1gdk_1cairo_1reset_1clip_FUNC,
_1gdk_1cairo_1set_1source_1color_FUNC,
+ _1gdk_1cairo_1set_1source_1pixbuf_FUNC,
_1gdk_1cairo_1set_1source_1window_FUNC,
_1gdk_1color_1free_FUNC,
_1gdk_1color_1parse_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 6d058a7..4aab5e3 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
@@ -3709,6 +3709,20 @@ public static final void gdk_cairo_set_source_color(int /*long*/ cairo, GdkColor
}
/**
* @method flags=dynamic
+ * @param pixbuf cast=(const GdkPixbuf *)
+ */
+public static final native void _gdk_cairo_set_source_pixbuf(int /*long*/ cairo, int /*long*/ pixbuf, double pixbuf_x, double pixbuf_y);
+public static final void gdk_cairo_set_source_pixbuf(int /*long*/ cairo, int /*long*/ pixbuf, double pixbuf_x, double pixbuf_y) {
+ lock.lock();
+ try {
+ _gdk_cairo_set_source_pixbuf(cairo,pixbuf,pixbuf_x,pixbuf_y);
+ }
+ finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
* @param window cast=(GdkWindow *)
*/
public static final native void _gdk_cairo_set_source_window(int /*long*/ cairo, int /*long*/ window, int x, int y);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
index 94dbc00..c7da6c4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
@@ -16,6 +16,7 @@ import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.internal.cairo.Cairo;
/**
* Instances of this class represent popup windows that are used
@@ -472,11 +473,65 @@ int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
int /*long*/ gtk_expose_event (int /*long*/ widget, int /*long*/ eventPtr) {
if ((state & OBSCURED) != 0) return 0;
int /*long*/ window = OS.GTK_WIDGET_WINDOW (handle);
- //TODO: Use Cairo
- int /*long*/ gdkGC = OS.gdk_gc_new (window);
- OS.gdk_draw_polygon (window, gdkGC, 0, borderPolygon, borderPolygon.length / 2);
int x = BORDER + PADDING;
int y = BORDER + PADDING;
+ if (OS.USE_CAIRO) {
+ int /*long*/ cairo = OS.gdk_cairo_create(window);
+ if (cairo == 0) error (SWT.ERROR_NO_HANDLES);
+ int count = borderPolygon.length / 2;
+ if (count == 0) return 0;
+ Cairo.cairo_set_line_width(cairo, 1);
+ Cairo.cairo_move_to(cairo, borderPolygon[0], borderPolygon[1]);
+ for (int i=1,j=2; i<count; i++,j+=2) {
+ Cairo.cairo_line_to(cairo, borderPolygon[j]+0.5, borderPolygon[j+1]+0.5);
+ }
+ Cairo.cairo_close_path(cairo);
+ Cairo.cairo_stroke(cairo);
+ if (spikeAbove) y += TIP_HEIGHT;
+ if (layoutText != 0) {
+ byte[] buffer = null;
+ int id = style & (SWT.ICON_ERROR | SWT.ICON_INFORMATION | SWT.ICON_WARNING);
+ switch (id) {
+ case SWT.ICON_ERROR: buffer = Converter.wcsToMbcs (null, "gtk-dialog-error", true); break;
+ case SWT.ICON_INFORMATION: buffer = Converter.wcsToMbcs (null, "gtk-dialog-info", true); break;
+ case SWT.ICON_WARNING: buffer = Converter.wcsToMbcs (null, "gtk-dialog-warning", true); break;
+ }
+ if (buffer != null) {
+ int /*long*/ style = OS.gtk_widget_get_default_style ();
+ int /*long*/ pixbuf = OS.gtk_icon_set_render_icon (
+ OS.gtk_icon_factory_lookup_default (buffer),
+ style,
+ OS.GTK_TEXT_DIR_NONE,
+ OS.GTK_STATE_NORMAL,
+ OS.GTK_ICON_SIZE_MENU,
+ 0,
+ 0);
+ OS.gdk_cairo_set_source_pixbuf(cairo, pixbuf, x, y);
+ Cairo.cairo_paint (cairo);
+ OS.g_object_unref (pixbuf);
+ x += IMAGE_SIZE;
+ }
+ x += INSET;
+ int [] w = new int [1], h = new int [1];
+ Color foreground = display.getSystemColor (SWT.COLOR_INFO_FOREGROUND);
+ OS.gdk_cairo_set_source_color(cairo,foreground.handle);
+ Cairo.cairo_move_to(cairo, x,y );
+ OS.pango_cairo_show_layout(cairo, layoutText);
+ OS.pango_layout_get_size (layoutText, w, h);
+ y += 2 * PADDING + Math.max (IMAGE_SIZE, OS.PANGO_PIXELS (h [0]));
+ }
+ if (layoutMessage != 0) {
+ x = BORDER + PADDING + INSET;
+ Color foreground = display.getSystemColor (SWT.COLOR_INFO_FOREGROUND);
+ OS.gdk_cairo_set_source_color(cairo,foreground.handle);
+ Cairo.cairo_move_to(cairo, x, y);
+ OS.pango_cairo_show_layout(cairo, layoutMessage);
+ }
+ Cairo.cairo_destroy(cairo);
+ return 0;
+ }
+ int /*long*/ gdkGC = OS.gdk_gc_new (window);
+ OS.gdk_draw_polygon (window, gdkGC, 0, borderPolygon, borderPolygon.length / 2);
if (spikeAbove) y += TIP_HEIGHT;
if (layoutText != 0) {
byte[] buffer = null;