1 /* gtkpeer.h -- Some global variables and #defines
2 Copyright (C) 1998, 1999, 2004, 2005, 2006 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
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)
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.
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
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
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. */
45 #include "native_state.h"
46 #include <gdk-pixbuf/gdk-pixbuf.h>
54 #define __attribute__(x) /* nothing */
57 extern struct state_table
*cp_gtk_native_state_table
;
58 extern struct state_table
*cp_gtk_native_global_ref_table
;
59 extern struct state_table
*cp_gtk_native_graphics2d_state_table
;
61 #define NSA_INIT(env, clazz) \
62 do {cp_gtk_native_state_table = cp_gtk_init_state_table (env, clazz); \
63 cp_gtk_native_global_ref_table = cp_gtk_init_state_table (env, clazz);} while (0)
65 #define NSA_GET_PTR(env, obj) \
66 cp_gtk_get_state (env, obj, cp_gtk_native_state_table)
68 #define NSA_SET_PTR(env, obj, ptr) \
69 cp_gtk_set_state (env, obj, cp_gtk_native_state_table, (void *)ptr)
71 #define NSA_DEL_PTR(env, obj) \
72 cp_gtk_remove_state_slot (env, obj, cp_gtk_native_state_table)
74 #define NSA_GET_GLOBAL_REF(env, obj) \
75 cp_gtk_get_state (env, obj, cp_gtk_native_global_ref_table)
77 #define NSA_SET_GLOBAL_REF(env, obj) \
78 do {jobject *globRefPtr; \
79 globRefPtr = (jobject *) malloc (sizeof (jobject)); \
80 *globRefPtr = (*env)->NewGlobalRef (env, obj); \
81 cp_gtk_set_state (env, obj, cp_gtk_native_global_ref_table, (void *)globRefPtr);} while (0)
83 #define NSA_DEL_GLOBAL_REF(env, obj) \
84 do {jobject *globRefPtr = cp_gtk_get_state (env, obj, cp_gtk_native_global_ref_table); \
85 cp_gtk_remove_state_slot (env, obj, cp_gtk_native_global_ref_table); \
86 (*env)->DeleteGlobalRef (env, *globRefPtr); \
87 free (globRefPtr);} while (0)
89 #define NSA_G2D_INIT(env, clazz) \
90 cp_gtk_native_graphics2d_state_table = cp_gtk_init_state_table (env, clazz)
92 #define NSA_GET_G2D_PTR(env, obj) \
93 cp_gtk_get_state (env, obj, cp_gtk_native_graphics2d_state_table)
95 #define NSA_SET_G2D_PTR(env, obj, ptr) \
96 cp_gtk_set_state (env, obj, cp_gtk_native_graphics2d_state_table, (void *)ptr)
98 #define NSA_DEL_G2D_PTR(env, obj) \
99 cp_gtk_remove_state_slot (env, obj, cp_gtk_native_graphics2d_state_table)
102 (((w) << 24) | (((w) & 0xff00) << 8) | (((w) >> 8) & 0xff00) | ((w) >> 24))
104 /* New-style event masks. */
105 #define AWT_BUTTON1_DOWN_MASK (1 << 10)
106 #define AWT_BUTTON2_DOWN_MASK (1 << 11)
107 #define AWT_BUTTON3_DOWN_MASK (1 << 12)
109 #define AWT_SHIFT_DOWN_MASK (1 << 6)
110 #define AWT_CTRL_DOWN_MASK (1 << 7)
111 #define AWT_META_DOWN_MASK (1 << 8)
112 #define AWT_ALT_DOWN_MASK (1 << 9)
114 /* Old-style event masks. */
115 #define AWT_BUTTON1_MASK (1 << 4)
116 #define AWT_BUTTON2_MASK (1 << 3)
117 #define AWT_BUTTON3_MASK (1 << 2)
119 #define AWT_SHIFT_MASK (1 << 0)
120 #define AWT_CTRL_MASK (1 << 1)
121 #define AWT_META_MASK (1 << 2)
122 #define AWT_ALT_MASK (1 << 3)
124 #define AWT_ITEM_SELECTED 1
125 #define AWT_ITEM_DESELECTED 2
127 #define AWT_KEY_TYPED 400
128 #define AWT_KEY_PRESSED 401
129 #define AWT_KEY_RELEASED 402
131 #define AWT_KEY_LOCATION_UNKNOWN 0
132 #define AWT_KEY_LOCATION_STANDARD 1
133 #define AWT_KEY_LOCATION_LEFT 2
134 #define AWT_KEY_LOCATION_RIGHT 3
135 #define AWT_KEY_LOCATION_NUMPAD 4
137 #define AWT_STYLE_PLAIN 0
138 #define AWT_STYLE_BOLD 1
139 #define AWT_STYLE_ITALIC 2
141 /* Used in GtkComponentPeer and GtkWindowPeer */
142 #define VK_NUMPAD0 96
143 #define VK_NUMPAD1 97
144 #define VK_NUMPAD2 98
145 #define VK_NUMPAD3 99
146 #define VK_NUMPAD4 100
147 #define VK_NUMPAD5 101
148 #define VK_NUMPAD6 102
149 #define VK_NUMPAD7 103
150 #define VK_NUMPAD8 104
151 #define VK_NUMPAD9 105
152 #define VK_DECIMAL 110
154 JNIEnv
*cp_gtk_gdk_env(void);
156 /* Global variables */
157 extern double cp_gtk_dpi_conversion_factor
;
158 extern GtkWindowGroup
*cp_gtk_global_window_group
;
160 /* Shared global clipboard and selection for GtkClipboard and GtkSelection. */
161 extern GtkClipboard
*cp_gtk_clipboard
;
162 extern GtkClipboard
*cp_gtk_selection
;
164 extern jobject cp_gtk_clipboard_instance
;
165 extern jobject cp_gtk_selection_instance
;
167 /* Standard target (strings) for GtkClipboard and GtkSelection. */
168 extern jstring cp_gtk_stringTarget
;
169 extern jstring cp_gtk_imageTarget
;
170 extern jstring cp_gtk_filesTarget
;
172 /* Union used for type punning. */
179 /* Constant conversion helpers */
180 guint
cp_gtk_awt_keycode_to_keysym (jint keyCode
, jint keyLocation
);
181 jint
cp_gtk_state_to_awt_mods (guint state
);
184 GdkPixbuf
*cp_gtk_image_get_pixbuf (JNIEnv
*env
, jobject obj
);
186 /* Component Graphics helpers */
187 void cp_gtk_grab_current_drawable(GtkWidget
*widget
, GdkDrawable
**draw
,
190 /* JNI initialization functions */
191 void cp_gtk_button_init_jni (void);
192 void cp_gtk_checkbox_init_jni (void);
193 void cp_gtk_choice_init_jni (void);
194 void cp_gtk_component_init_jni (void);
195 void cp_gtk_filedialog_init_jni (void);
196 void cp_gtk_list_init_jni (void);
197 void cp_gtk_menuitem_init_jni (void);
198 void cp_gtk_scrollbar_init_jni (void);
199 void cp_gtk_textcomponent_init_jni (void);
200 void cp_gtk_window_init_jni (void);
202 /* Signal connection convience functions */
203 void cp_gtk_component_connect_expose_signals (GObject
*ptr
, jobject
*gref
);
204 void cp_gtk_component_connect_focus_signals (GObject
*ptr
, jobject
*gref
);
205 void cp_gtk_component_connect_mouse_signals (GObject
*ptr
, jobject
*gref
);
206 void cp_gtk_component_connect_signals (GObject
*ptr
, jobject
*gref
);
207 void cp_gtk_textcomponent_connect_signals (GObject
*ptr
, jobject
*gref
);
210 void cp_gtk_print_current_thread (void);
212 GdkPixmap
*cp_gtk_get_pixmap( JNIEnv
*env
, jobject obj
);
214 #define SYNCHRONIZE_GDK 0
216 #define DEBUG_LOCKING 0
219 #define gdk_threads_enter() \
221 g_print ("locking: %s, %d\n", __FILE__, __LINE__); \
222 cp_gtk_print_current_thread (); \
223 gdk_threads_enter (); \
224 g_print ("locked: %s, %d\n", __FILE__, __LINE__); \
225 cp_gtk_print_current_thread (); \
227 #define gdk_threads_leave() \
229 g_print ("unlocking: %s, %d\n", __FILE__, __LINE__); \
230 cp_gtk_print_current_thread (); \
231 gdk_threads_leave (); \
232 g_print ("unlocked: %s, %d\n", __FILE__, __LINE__); \
233 cp_gtk_print_current_thread (); \
237 #endif /* __GTKPEER_H */