1 |
774 |
jeremybenn |
/* gtkpeer.h -- Some global variables and #defines
|
2 |
|
|
Copyright (C) 1998, 1999, 2004, 2005, 2006 Free Software Foundation, Inc.
|
3 |
|
|
|
4 |
|
|
This file is part of GNU Classpath.
|
5 |
|
|
|
6 |
|
|
GNU Classpath is free software; you can redistribute it and/or modify
|
7 |
|
|
it under the terms of the GNU General Public License as published by
|
8 |
|
|
the Free Software Foundation; either version 2, or (at your option)
|
9 |
|
|
any later version.
|
10 |
|
|
|
11 |
|
|
GNU Classpath is distributed in the hope that it will be useful, but
|
12 |
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
|
|
General Public License for more details.
|
15 |
|
|
|
16 |
|
|
You should have received a copy of the GNU General Public License
|
17 |
|
|
along with GNU Classpath; see the file COPYING. If not, write to the
|
18 |
|
|
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 |
|
|
02110-1301 USA.
|
20 |
|
|
|
21 |
|
|
Linking this library statically or dynamically with other modules is
|
22 |
|
|
making a combined work based on this library. Thus, the terms and
|
23 |
|
|
conditions of the GNU General Public License cover the whole
|
24 |
|
|
combination.
|
25 |
|
|
|
26 |
|
|
As a special exception, the copyright holders of this library give you
|
27 |
|
|
permission to link this library with independent modules to produce an
|
28 |
|
|
executable, regardless of the license terms of these independent
|
29 |
|
|
modules, and to copy and distribute the resulting executable under
|
30 |
|
|
terms of your choice, provided that you also meet, for each linked
|
31 |
|
|
independent module, the terms and conditions of the license of that
|
32 |
|
|
module. An independent module is a module which is not derived from
|
33 |
|
|
or based on this library. If you modify this library, you may extend
|
34 |
|
|
this exception to your version of the library, but you are not
|
35 |
|
|
obligated to do so. If you do not wish to do so, delete this
|
36 |
|
|
exception statement from your version. */
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
#include <cairo.h>
|
40 |
|
|
#include <gtk/gtk.h>
|
41 |
|
|
#include <stdio.h>
|
42 |
|
|
#include <stdlib.h>
|
43 |
|
|
#include <string.h>
|
44 |
|
|
#include <config.h>
|
45 |
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
46 |
|
|
|
47 |
|
|
#include <jni.h>
|
48 |
|
|
|
49 |
|
|
#ifndef __GTKPEER_H__
|
50 |
|
|
#define __GTKPEER_H__
|
51 |
|
|
|
52 |
|
|
#ifndef __GNUC__
|
53 |
|
|
#define __attribute__(x) /* nothing */
|
54 |
|
|
#endif
|
55 |
|
|
|
56 |
|
|
/**
|
57 |
|
|
* Initializes the IDs of the Pointer* classes.
|
58 |
|
|
*
|
59 |
|
|
* @param env the JNI environment
|
60 |
|
|
*/
|
61 |
|
|
void gtkpeer_init_pointer_IDs(JNIEnv* env);
|
62 |
|
|
|
63 |
|
|
/**
|
64 |
|
|
* Initializes the field IDs for the widget reference.
|
65 |
|
|
*
|
66 |
|
|
* @param env the JNI environment
|
67 |
|
|
*/
|
68 |
|
|
void gtkpeer_init_widget_IDs(JNIEnv *env);
|
69 |
|
|
|
70 |
|
|
/**
|
71 |
|
|
* Stores the GTK widget reference in the GtkComponentPeer object.
|
72 |
|
|
*
|
73 |
|
|
* @param env the JNI environment
|
74 |
|
|
* @param peer the actual peer object
|
75 |
|
|
* @param widget the widget reference to store
|
76 |
|
|
*/
|
77 |
|
|
void gtkpeer_set_widget(JNIEnv *env, jobject peer, void *widget);
|
78 |
|
|
|
79 |
|
|
/**
|
80 |
|
|
* Retrieves the GTK widget reference from a GtkComponentPeer object.
|
81 |
|
|
*
|
82 |
|
|
* @param env the JNI environment
|
83 |
|
|
* @param peer the actual peer object
|
84 |
|
|
*
|
85 |
|
|
* @return the widget reference
|
86 |
|
|
*/
|
87 |
|
|
void* gtkpeer_get_widget(JNIEnv *env, jobject peer);
|
88 |
|
|
|
89 |
|
|
/**
|
90 |
|
|
* Stores the global JNI reference of a peer inside the peer.
|
91 |
|
|
*
|
92 |
|
|
* @param env the JNI environment
|
93 |
|
|
* @param peer the peer object
|
94 |
|
|
*/
|
95 |
|
|
void gtkpeer_set_global_ref(JNIEnv *env, jobject peer);
|
96 |
|
|
|
97 |
|
|
/**
|
98 |
|
|
* Retrieves the global reference from a peer.
|
99 |
|
|
*
|
100 |
|
|
* @param env the JNI environment
|
101 |
|
|
* @param peer the peer object
|
102 |
|
|
*
|
103 |
|
|
* @return the global reference
|
104 |
|
|
*/
|
105 |
|
|
void* gtkpeer_get_global_ref(JNIEnv *env, jobject peer);
|
106 |
|
|
|
107 |
|
|
/**
|
108 |
|
|
* Deletes the global reference of a peer. This is necessary in order to
|
109 |
|
|
* allow the peer to be garbage collected.
|
110 |
|
|
*
|
111 |
|
|
* @param env the JNI environment
|
112 |
|
|
* @param peer the peer object.
|
113 |
|
|
*/
|
114 |
|
|
void gtkpeer_del_global_ref(JNIEnv* env, jobject peer);
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
/**
|
118 |
|
|
* Initializes the fieldIDs for the display and screen fields.
|
119 |
|
|
*
|
120 |
|
|
* @param env the JNI environment
|
121 |
|
|
*/
|
122 |
|
|
void gtkpeer_init_display_IDs(JNIEnv* env);
|
123 |
|
|
|
124 |
|
|
/**
|
125 |
|
|
* Sets the native display pointer in the GdkGraphicsEnvironment object.
|
126 |
|
|
*
|
127 |
|
|
* @param env the JNI environment
|
128 |
|
|
* @param graphicsenv the GdkGraphicsEnvironment object
|
129 |
|
|
* @param display the native display pointer
|
130 |
|
|
*/
|
131 |
|
|
void gtkpeer_set_display(JNIEnv* env, jobject graphicsenv, void* display);
|
132 |
|
|
|
133 |
|
|
/**
|
134 |
|
|
* Fetches the native display pointer from the GdkGraphicsEnvironment object.
|
135 |
|
|
*
|
136 |
|
|
* @param env the JNI environment
|
137 |
|
|
* @param graphicsenv the GdkGraphicsEnvironment object
|
138 |
|
|
*
|
139 |
|
|
* @return the native display pointer
|
140 |
|
|
*/
|
141 |
|
|
void* gtkpeer_get_display(JNIEnv* env, jobject graphicsenv);
|
142 |
|
|
|
143 |
|
|
/**
|
144 |
|
|
* Initializes the fieldIDs for the screen field.
|
145 |
|
|
*
|
146 |
|
|
* @param env the JNI environment
|
147 |
|
|
*/
|
148 |
|
|
void gtkpeer_init_screen_IDs(JNIEnv* env);
|
149 |
|
|
|
150 |
|
|
/**
|
151 |
|
|
* Sets the native screen in the GdkScreenGraphicsDevice object.
|
152 |
|
|
*
|
153 |
|
|
* @param env the JNI environment
|
154 |
|
|
* @param screen_graphics_device the GdkScreenGraphicsDevice object
|
155 |
|
|
* @param ptr the native screen pointer
|
156 |
|
|
*/
|
157 |
|
|
void gtkpeer_set_screen(JNIEnv* env, jobject screen_graphics_device,
|
158 |
|
|
void* ptr);
|
159 |
|
|
|
160 |
|
|
/**
|
161 |
|
|
* Fetches the native screen pointer from the GdkScreenGraphicsDevice object.
|
162 |
|
|
*
|
163 |
|
|
* @param env the JNI environment
|
164 |
|
|
* @param screen_graphics_device the GdkScreenGraphicsDevice object
|
165 |
|
|
*
|
166 |
|
|
* @return the native screen pointer
|
167 |
|
|
*/
|
168 |
|
|
void* gtkpeer_get_screen(JNIEnv* env, jobject screen_graphics_device);
|
169 |
|
|
|
170 |
|
|
/**
|
171 |
|
|
* Initializes the field IDs for fonts.
|
172 |
|
|
*
|
173 |
|
|
* @param env the JNI environment
|
174 |
|
|
*/
|
175 |
|
|
void gtkpeer_init_font_IDs(JNIEnv* env);
|
176 |
|
|
|
177 |
|
|
/**
|
178 |
|
|
* Sets the native font in the nativeFont field in GdkFontPeer.
|
179 |
|
|
*
|
180 |
|
|
* @param env the JNI environment
|
181 |
|
|
* @param font_peer the font peer object
|
182 |
|
|
* @param font the actual native font reference
|
183 |
|
|
*/
|
184 |
|
|
void gtkpeer_set_font(JNIEnv* env, jobject font_peer, void* font);
|
185 |
|
|
|
186 |
|
|
/**
|
187 |
|
|
* Fetches the native font reference from the GdkFontPeer object.
|
188 |
|
|
*
|
189 |
|
|
* @param env the JNI environment
|
190 |
|
|
* @param font_peer the font peer object
|
191 |
|
|
*
|
192 |
|
|
* @return the native font structure
|
193 |
|
|
*/
|
194 |
|
|
void* gtkpeer_get_font(JNIEnv* env, jobject font_peer);
|
195 |
|
|
|
196 |
|
|
/**
|
197 |
|
|
* Initializes the field IDs for pixbuf decoder.
|
198 |
|
|
*
|
199 |
|
|
* @param env the JNI environment
|
200 |
|
|
*/
|
201 |
|
|
void gtkpeer_init_pixbuf_IDs(JNIEnv* env);
|
202 |
|
|
|
203 |
|
|
/**
|
204 |
|
|
* Sets the native font in the nativeFont field in GdkFontPeer.
|
205 |
|
|
*
|
206 |
|
|
* @param env the JNI environment
|
207 |
|
|
* @param pixbuf_dec the pixbuf decoder object
|
208 |
|
|
* @param pixbuf_loader the native pixbuf loader
|
209 |
|
|
*/
|
210 |
|
|
void gtkpeer_set_pixbuf_loader(JNIEnv* env, jobject pixbuf_dec,
|
211 |
|
|
void* pixbuf_loader);
|
212 |
|
|
|
213 |
|
|
/**
|
214 |
|
|
* Fetches the native pixbuf loader reference from the GdkPixbufDecoder object.
|
215 |
|
|
*
|
216 |
|
|
* @param env the JNI environment
|
217 |
|
|
* @param pixbuf_dec the pixbuf decoder object
|
218 |
|
|
*
|
219 |
|
|
* @return the native pixbuf loader
|
220 |
|
|
*/
|
221 |
|
|
void* gtkpeer_get_pixbuf_loader(JNIEnv* env, jobject pixbuf_dec);
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
#define SWAPU32(w) \
|
225 |
|
|
(((w) << 24) | (((w) & 0xff00) << 8) | (((w) >> 8) & 0xff00) | ((w) >> 24))
|
226 |
|
|
|
227 |
|
|
/* New-style event masks. */
|
228 |
|
|
#define AWT_BUTTON1_DOWN_MASK (1 << 10)
|
229 |
|
|
#define AWT_BUTTON2_DOWN_MASK (1 << 11)
|
230 |
|
|
#define AWT_BUTTON3_DOWN_MASK (1 << 12)
|
231 |
|
|
|
232 |
|
|
#define AWT_SHIFT_DOWN_MASK (1 << 6)
|
233 |
|
|
#define AWT_CTRL_DOWN_MASK (1 << 7)
|
234 |
|
|
#define AWT_META_DOWN_MASK (1 << 8)
|
235 |
|
|
#define AWT_ALT_DOWN_MASK (1 << 9)
|
236 |
|
|
|
237 |
|
|
/* Old-style event masks. */
|
238 |
|
|
#define AWT_BUTTON1_MASK (1 << 4)
|
239 |
|
|
#define AWT_BUTTON2_MASK (1 << 3)
|
240 |
|
|
#define AWT_BUTTON3_MASK (1 << 2)
|
241 |
|
|
|
242 |
|
|
#define AWT_SHIFT_MASK (1 << 0)
|
243 |
|
|
#define AWT_CTRL_MASK (1 << 1)
|
244 |
|
|
#define AWT_META_MASK (1 << 2)
|
245 |
|
|
#define AWT_ALT_MASK (1 << 3)
|
246 |
|
|
|
247 |
|
|
#define AWT_ITEM_SELECTED 1
|
248 |
|
|
#define AWT_ITEM_DESELECTED 2
|
249 |
|
|
|
250 |
|
|
#define AWT_KEY_TYPED 400
|
251 |
|
|
#define AWT_KEY_PRESSED 401
|
252 |
|
|
#define AWT_KEY_RELEASED 402
|
253 |
|
|
|
254 |
|
|
#define AWT_KEY_LOCATION_UNKNOWN 0
|
255 |
|
|
#define AWT_KEY_LOCATION_STANDARD 1
|
256 |
|
|
#define AWT_KEY_LOCATION_LEFT 2
|
257 |
|
|
#define AWT_KEY_LOCATION_RIGHT 3
|
258 |
|
|
#define AWT_KEY_LOCATION_NUMPAD 4
|
259 |
|
|
|
260 |
|
|
#define AWT_STYLE_PLAIN 0
|
261 |
|
|
#define AWT_STYLE_BOLD 1
|
262 |
|
|
#define AWT_STYLE_ITALIC 2
|
263 |
|
|
|
264 |
|
|
/* Used in GtkComponentPeer and GtkWindowPeer */
|
265 |
|
|
#define VK_NUMPAD0 96
|
266 |
|
|
#define VK_NUMPAD1 97
|
267 |
|
|
#define VK_NUMPAD2 98
|
268 |
|
|
#define VK_NUMPAD3 99
|
269 |
|
|
#define VK_NUMPAD4 100
|
270 |
|
|
#define VK_NUMPAD5 101
|
271 |
|
|
#define VK_NUMPAD6 102
|
272 |
|
|
#define VK_NUMPAD7 103
|
273 |
|
|
#define VK_NUMPAD8 104
|
274 |
|
|
#define VK_NUMPAD9 105
|
275 |
|
|
#define VK_DECIMAL 110
|
276 |
|
|
|
277 |
|
|
JNIEnv *cp_gtk_gdk_env(void);
|
278 |
|
|
|
279 |
|
|
/* Global variables */
|
280 |
|
|
extern double cp_gtk_dpi_conversion_factor;
|
281 |
|
|
extern GtkWindowGroup *cp_gtk_global_window_group;
|
282 |
|
|
|
283 |
|
|
/* Shared global clipboard and selection for GtkClipboard and GtkSelection. */
|
284 |
|
|
extern GtkClipboard *cp_gtk_clipboard;
|
285 |
|
|
extern GtkClipboard *cp_gtk_selection;
|
286 |
|
|
|
287 |
|
|
extern jobject cp_gtk_clipboard_instance;
|
288 |
|
|
extern jobject cp_gtk_selection_instance;
|
289 |
|
|
|
290 |
|
|
/* Standard target (strings) for GtkClipboard and GtkSelection. */
|
291 |
|
|
extern jstring cp_gtk_stringTarget;
|
292 |
|
|
extern jstring cp_gtk_imageTarget;
|
293 |
|
|
extern jstring cp_gtk_filesTarget;
|
294 |
|
|
|
295 |
|
|
/* Union used for type punning. */
|
296 |
|
|
union widget_union
|
297 |
|
|
{
|
298 |
|
|
void **void_widget;
|
299 |
|
|
GtkWidget **widget;
|
300 |
|
|
};
|
301 |
|
|
|
302 |
|
|
/* Constant conversion helpers */
|
303 |
|
|
guint cp_gtk_awt_keycode_to_keysym (jint keyCode, jint keyLocation);
|
304 |
|
|
jint cp_gtk_state_to_awt_mods (guint state);
|
305 |
|
|
|
306 |
|
|
/* Image helpers */
|
307 |
|
|
GdkPixbuf *cp_gtk_image_get_pixbuf (JNIEnv *env, jobject obj);
|
308 |
|
|
|
309 |
|
|
/* Component Graphics helpers */
|
310 |
|
|
void cp_gtk_grab_current_drawable(GtkWidget *widget, GdkDrawable **draw,
|
311 |
|
|
GdkWindow **win);
|
312 |
|
|
|
313 |
|
|
/* JNI initialization functions */
|
314 |
|
|
void cp_gtk_button_init_jni (JNIEnv*);
|
315 |
|
|
void cp_gtk_checkbox_init_jni (void);
|
316 |
|
|
void cp_gtk_choice_init_jni (void);
|
317 |
|
|
void cp_gtk_component_init_jni (void);
|
318 |
|
|
void cp_gtk_filedialog_init_jni (void);
|
319 |
|
|
void cp_gtk_list_init_jni (void);
|
320 |
|
|
void cp_gtk_menuitem_init_jni (void);
|
321 |
|
|
void cp_gtk_scrollbar_init_jni (void);
|
322 |
|
|
void cp_gtk_textcomponent_init_jni (void);
|
323 |
|
|
void cp_gtk_window_init_jni (void);
|
324 |
|
|
|
325 |
|
|
/* Signal connection convience functions */
|
326 |
|
|
void cp_gtk_component_connect_expose_signals (GObject *ptr, jobject gref);
|
327 |
|
|
void cp_gtk_component_connect_focus_signals (GObject *ptr, jobject gref);
|
328 |
|
|
void cp_gtk_component_connect_mouse_signals (GObject *ptr, jobject gref);
|
329 |
|
|
void cp_gtk_component_connect_signals (GObject *ptr, jobject gref);
|
330 |
|
|
void cp_gtk_textcomponent_connect_signals (GObject *ptr, jobject gref);
|
331 |
|
|
|
332 |
|
|
/* Debugging */
|
333 |
|
|
void cp_gtk_print_current_thread (void);
|
334 |
|
|
|
335 |
|
|
GdkPixmap *cp_gtk_get_pixmap( JNIEnv *env, jobject obj);
|
336 |
|
|
|
337 |
|
|
#define SYNCHRONIZE_GDK 0
|
338 |
|
|
|
339 |
|
|
#define DEBUG_LOCKING 0
|
340 |
|
|
|
341 |
|
|
#if DEBUG_LOCKING
|
342 |
|
|
#define gdk_threads_enter() \
|
343 |
|
|
{ \
|
344 |
|
|
g_print ("locking: %s, %d\n", __FILE__, __LINE__); \
|
345 |
|
|
cp_gtk_print_current_thread (); \
|
346 |
|
|
gdk_threads_enter (); \
|
347 |
|
|
g_print ("locked: %s, %d\n", __FILE__, __LINE__); \
|
348 |
|
|
cp_gtk_print_current_thread (); \
|
349 |
|
|
}
|
350 |
|
|
#define gdk_threads_leave() \
|
351 |
|
|
{ \
|
352 |
|
|
g_print ("unlocking: %s, %d\n", __FILE__, __LINE__); \
|
353 |
|
|
cp_gtk_print_current_thread (); \
|
354 |
|
|
gdk_threads_leave (); \
|
355 |
|
|
g_print ("unlocked: %s, %d\n", __FILE__, __LINE__); \
|
356 |
|
|
cp_gtk_print_current_thread (); \
|
357 |
|
|
}
|
358 |
|
|
#endif
|
359 |
|
|
|
360 |
|
|
#endif /* __GTKPEER_H */
|