56 |
"()V"); |
"()V"); |
57 |
} |
} |
58 |
|
|
59 |
|
struct state_table *cp_gtk_native_graphics_state_table; |
60 |
|
|
61 |
|
static struct state_table *native_graphics_global_ref_table; |
62 |
|
|
63 |
|
#define NSA_GLOBAL_G_INIT(env, clazz) \ |
64 |
|
native_graphics_global_ref_table = cp_gtk_init_state_table (env, clazz) |
65 |
|
|
66 |
|
#define NSA_GET_GLOBAL_G_REF(env, obj) \ |
67 |
|
cp_gtk_get_state (env, obj, native_graphics_global_ref_table) |
68 |
|
|
69 |
|
#define NSA_SET_GLOBAL_G_REF(env, obj) \ |
70 |
|
do {jobject *globRefPtr; \ |
71 |
|
globRefPtr = (jobject *) malloc (sizeof (jobject)); \ |
72 |
|
*globRefPtr = (*env)->NewGlobalRef (env, obj); \ |
73 |
|
cp_gtk_set_state (env, obj, native_graphics_global_ref_table, (void *)globRefPtr);} while (0) |
74 |
|
|
75 |
|
#define NSA_DEL_GLOBAL_G_REF(env, obj) \ |
76 |
|
do {jobject *globRefPtr = cp_gtk_get_state (env, obj, native_graphics_global_ref_table); \ |
77 |
|
cp_gtk_remove_state_slot (env, obj, native_graphics_global_ref_table); \ |
78 |
|
(*env)->DeleteGlobalRef (env, *globRefPtr); \ |
79 |
|
free (globRefPtr);} while (0) |
80 |
|
|
81 |
|
JNIEXPORT void JNICALL |
82 |
|
Java_gnu_java_awt_peer_gtk_GdkGraphics_initStaticState |
83 |
|
(JNIEnv *env, jclass clazz) |
84 |
|
{ |
85 |
|
gdk_threads_enter(); |
86 |
|
|
87 |
|
NSA_G_INIT (env, clazz); |
88 |
|
NSA_GLOBAL_G_INIT (env, clazz); |
89 |
|
|
90 |
|
gdk_threads_leave(); |
91 |
|
} |
92 |
|
|
93 |
#define GDK_STABLE_IS_PIXMAP(d) (GDK_IS_PIXMAP(d)) |
#define GDK_STABLE_IS_PIXMAP(d) (GDK_IS_PIXMAP(d)) |
94 |
|
|
95 |
static GdkPoint *translate_points (JNIEnv *env, jintArray xpoints, |
static GdkPoint *translate_points (JNIEnv *env, jintArray xpoints, |
107 |
gdk_threads_enter (); |
gdk_threads_enter (); |
108 |
|
|
109 |
g = (struct graphics *) g_malloc (sizeof (struct graphics)); |
g = (struct graphics *) g_malloc (sizeof (struct graphics)); |
110 |
g_old = (struct graphics *) NSA_GET_PTR (env, old); |
g_old = (struct graphics *) NSA_GET_G_PTR (env, old); |
111 |
|
|
112 |
*g = *g_old; |
*g = *g_old; |
113 |
|
|
121 |
|
|
122 |
gdk_colormap_ref (g->cm); |
gdk_colormap_ref (g->cm); |
123 |
|
|
124 |
NSA_SET_PTR (env, obj, g); |
NSA_SET_G_PTR (env, obj, g); |
125 |
|
|
126 |
gdk_threads_leave (); |
gdk_threads_leave (); |
127 |
} |
} |
143 |
gdk_colormap_ref (g->cm); |
gdk_colormap_ref (g->cm); |
144 |
g->gc = gdk_gc_new (g->drawable); |
g->gc = gdk_gc_new (g->drawable); |
145 |
|
|
146 |
NSA_SET_PTR (env, obj, g); |
NSA_SET_G_PTR (env, obj, g); |
147 |
|
|
148 |
gdk_threads_leave (); |
gdk_threads_leave (); |
149 |
} |
} |
170 |
gdk_colormap_ref (g->cm); |
gdk_colormap_ref (g->cm); |
171 |
g->gc = gdk_gc_new (g->drawable); |
g->gc = gdk_gc_new (g->drawable); |
172 |
|
|
173 |
NSA_SET_PTR (env, obj, g); |
NSA_SET_G_PTR (env, obj, g); |
174 |
|
|
175 |
gdk_threads_leave (); |
gdk_threads_leave (); |
176 |
} |
} |
203 |
gdk_gc_copy (g->gc, widget->style->fg_gc[GTK_STATE_NORMAL]); |
gdk_gc_copy (g->gc, widget->style->fg_gc[GTK_STATE_NORMAL]); |
204 |
color = widget->style->fg[GTK_STATE_NORMAL]; |
color = widget->style->fg[GTK_STATE_NORMAL]; |
205 |
|
|
206 |
NSA_SET_PTR (env, obj, g); |
NSA_SET_G_PTR (env, obj, g); |
207 |
|
|
208 |
gdk_threads_leave (); |
gdk_threads_leave (); |
209 |
} |
} |
217 |
|
|
218 |
gdk_threads_enter (); |
gdk_threads_enter (); |
219 |
|
|
220 |
NSA_SET_GLOBAL_REF (env, obj); |
NSA_SET_GLOBAL_G_REF (env, obj); |
221 |
gref = NSA_GET_GLOBAL_REF (env, obj); |
gref = NSA_GET_GLOBAL_G_REF (env, obj); |
222 |
|
|
223 |
ptr = NSA_GET_PTR (env, peer); |
ptr = NSA_GET_PTR (env, peer); |
224 |
|
|
236 |
|
|
237 |
gdk_threads_enter (); |
gdk_threads_enter (); |
238 |
|
|
239 |
g = (struct graphics *) NSA_DEL_PTR (env, obj); |
g = (struct graphics *) NSA_DEL_G_PTR (env, obj); |
240 |
|
|
241 |
/* check if dispose has been called already */ |
/* check if dispose has been called already */ |
242 |
if (!g) |
if (!g) |
269 |
|
|
270 |
gdk_threads_enter (); |
gdk_threads_enter (); |
271 |
|
|
272 |
g = (struct graphics *) NSA_GET_PTR (env, obj); |
g = (struct graphics *) NSA_GET_G_PTR (env, obj); |
273 |
|
|
274 |
g->x_offset += x; |
g->x_offset += x; |
275 |
g->y_offset += y; |
g->y_offset += y; |
289 |
|
|
290 |
gdk_threads_enter (); |
gdk_threads_enter (); |
291 |
|
|
292 |
g = (struct graphics *) NSA_GET_PTR (env, obj); |
g = (struct graphics *) NSA_GET_G_PTR (env, obj); |
293 |
g_assert (g != NULL); |
g_assert (g != NULL); |
294 |
|
|
295 |
pfont = (struct peerfont *)NSA_GET_FONT_PTR (env, font); |
pfont = (struct peerfont *)NSA_GET_FONT_PTR (env, font); |
326 |
|
|
327 |
gdk_threads_enter (); |
gdk_threads_enter (); |
328 |
|
|
329 |
g = (struct graphics *) NSA_GET_PTR (env, obj); |
g = (struct graphics *) NSA_GET_G_PTR (env, obj); |
330 |
|
|
331 |
gdk_draw_line (g->drawable, g->gc, |
gdk_draw_line (g->drawable, g->gc, |
332 |
x + g->x_offset, y + g->y_offset, |
x + g->x_offset, y + g->y_offset, |
344 |
|
|
345 |
gdk_threads_enter (); |
gdk_threads_enter (); |
346 |
|
|
347 |
g = (struct graphics *) NSA_GET_PTR (env, obj); |
g = (struct graphics *) NSA_GET_G_PTR (env, obj); |
348 |
|
|
349 |
gdk_draw_rectangle (g->drawable, g->gc, TRUE, |
gdk_draw_rectangle (g->drawable, g->gc, TRUE, |
350 |
x + g->x_offset, y + g->y_offset, width, height); |
x + g->x_offset, y + g->y_offset, width, height); |
361 |
|
|
362 |
gdk_threads_enter (); |
gdk_threads_enter (); |
363 |
|
|
364 |
g = (struct graphics *) NSA_GET_PTR (env, obj); |
g = (struct graphics *) NSA_GET_G_PTR (env, obj); |
365 |
|
|
366 |
gdk_draw_rectangle (g->drawable, g->gc, FALSE, |
gdk_draw_rectangle (g->drawable, g->gc, FALSE, |
367 |
x + g->x_offset, y + g->y_offset, width, height); |
x + g->x_offset, y + g->y_offset, width, height); |
379 |
|
|
380 |
gdk_threads_enter (); |
gdk_threads_enter (); |
381 |
|
|
382 |
g = (struct graphics *) NSA_GET_PTR (env, obj); |
g = (struct graphics *) NSA_GET_G_PTR (env, obj); |
383 |
|
|
384 |
gdk_window_copy_area ((GdkWindow *)g->drawable, |
gdk_window_copy_area ((GdkWindow *)g->drawable, |
385 |
g->gc, |
g->gc, |
403 |
|
|
404 |
gdk_threads_enter (); |
gdk_threads_enter (); |
405 |
|
|
406 |
g = (struct graphics *) NSA_GET_PTR (env, obj); |
g = (struct graphics *) NSA_GET_G_PTR (env, obj); |
407 |
|
|
408 |
if (!g) |
if (!g) |
409 |
{ |
{ |
442 |
|
|
443 |
gdk_threads_enter (); |
gdk_threads_enter (); |
444 |
|
|
445 |
g = (struct graphics *) NSA_GET_PTR (env, obj); |
g = (struct graphics *) NSA_GET_G_PTR (env, obj); |
446 |
|
|
447 |
gdk_gc_set_function (g->gc, func); |
gdk_gc_set_function (g->gc, func); |
448 |
|
|
463 |
color.green = green << 8; |
color.green = green << 8; |
464 |
color.blue = blue << 8; |
color.blue = blue << 8; |
465 |
|
|
466 |
g = (struct graphics *) NSA_GET_PTR (env, obj); |
g = (struct graphics *) NSA_GET_G_PTR (env, obj); |
467 |
|
|
468 |
gdk_color_alloc (g->cm, &color); |
gdk_color_alloc (g->cm, &color); |
469 |
gdk_gc_set_foreground (g->gc, &color); |
gdk_gc_set_foreground (g->gc, &color); |
480 |
|
|
481 |
gdk_threads_enter (); |
gdk_threads_enter (); |
482 |
|
|
483 |
g = (struct graphics *) NSA_GET_PTR (env, obj); |
g = (struct graphics *) NSA_GET_G_PTR (env, obj); |
484 |
|
|
485 |
gdk_draw_arc (g->drawable, g->gc, FALSE, |
gdk_draw_arc (g->drawable, g->gc, FALSE, |
486 |
x + g->x_offset, y + g->y_offset, |
x + g->x_offset, y + g->y_offset, |
527 |
|
|
528 |
gdk_threads_enter (); |
gdk_threads_enter (); |
529 |
|
|
530 |
g = (struct graphics *) NSA_GET_PTR (env, obj); |
g = (struct graphics *) NSA_GET_G_PTR (env, obj); |
531 |
points = translate_points (env, xpoints, ypoints, npoints, |
points = translate_points (env, xpoints, ypoints, npoints, |
532 |
g->x_offset, g->y_offset); |
g->x_offset, g->y_offset); |
533 |
|
|
549 |
|
|
550 |
gdk_threads_enter (); |
gdk_threads_enter (); |
551 |
|
|
552 |
g = (struct graphics *) NSA_GET_PTR (env, obj); |
g = (struct graphics *) NSA_GET_G_PTR (env, obj); |
553 |
points = translate_points (env, xpoints, ypoints, npoints, |
points = translate_points (env, xpoints, ypoints, npoints, |
554 |
g->x_offset, g->y_offset); |
g->x_offset, g->y_offset); |
555 |
|
|
576 |
|
|
577 |
gdk_threads_enter (); |
gdk_threads_enter (); |
578 |
|
|
579 |
g = (struct graphics *) NSA_GET_PTR (env, obj); |
g = (struct graphics *) NSA_GET_G_PTR (env, obj); |
580 |
points = translate_points (env, xpoints, ypoints, npoints, |
points = translate_points (env, xpoints, ypoints, npoints, |
581 |
g->x_offset, g->y_offset); |
g->x_offset, g->y_offset); |
582 |
gdk_draw_polygon (g->drawable, g->gc, TRUE, points, npoints); |
gdk_draw_polygon (g->drawable, g->gc, TRUE, points, npoints); |
596 |
|
|
597 |
gdk_threads_enter (); |
gdk_threads_enter (); |
598 |
|
|
599 |
g = (struct graphics *) NSA_GET_PTR (env, obj); |
g = (struct graphics *) NSA_GET_G_PTR (env, obj); |
600 |
|
|
601 |
gdk_draw_arc (g->drawable, g->gc, TRUE, |
gdk_draw_arc (g->drawable, g->gc, TRUE, |
602 |
x + g->x_offset, y + g->y_offset, |
x + g->x_offset, y + g->y_offset, |
614 |
|
|
615 |
gdk_threads_enter (); |
gdk_threads_enter (); |
616 |
|
|
617 |
g = (struct graphics *) NSA_GET_PTR (env, obj); |
g = (struct graphics *) NSA_GET_G_PTR (env, obj); |
618 |
|
|
619 |
gdk_draw_arc (g->drawable, g->gc, FALSE, |
gdk_draw_arc (g->drawable, g->gc, FALSE, |
620 |
x + g->x_offset, y + g->y_offset, |
x + g->x_offset, y + g->y_offset, |
632 |
|
|
633 |
gdk_threads_enter (); |
gdk_threads_enter (); |
634 |
|
|
635 |
g = (struct graphics *) NSA_GET_PTR (env, obj); |
g = (struct graphics *) NSA_GET_G_PTR (env, obj); |
636 |
|
|
637 |
gdk_draw_arc (g->drawable, g->gc, TRUE, |
gdk_draw_arc (g->drawable, g->gc, TRUE, |
638 |
x + g->x_offset, y + g->y_offset, |
x + g->x_offset, y + g->y_offset, |
651 |
|
|
652 |
gdk_threads_enter (); |
gdk_threads_enter (); |
653 |
|
|
654 |
g = (struct graphics *) NSA_GET_PTR (env, obj); |
g = (struct graphics *) NSA_GET_G_PTR (env, obj); |
655 |
|
|
656 |
rectangle.x = x + g->x_offset; |
rectangle.x = x + g->x_offset; |
657 |
rectangle.y = y + g->y_offset; |
rectangle.y = y + g->y_offset; |
670 |
|
|
671 |
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), jgraphics, initComponentGraphicsID); |
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), jgraphics, initComponentGraphicsID); |
672 |
|
|
673 |
NSA_DEL_GLOBAL_REF (cp_gtk_gdk_env(), jgraphics); |
NSA_DEL_GLOBAL_G_REF (cp_gtk_gdk_env(), jgraphics); |
674 |
|
|
675 |
gdk_threads_enter (); |
gdk_threads_enter (); |
676 |
} |
} |