1 /******************************************************************************* 2 * Copyright (c) 2000, 2018 IBM Corporation and others. All rights reserved. 3 * The contents of this file are made available under the terms 4 * of the GNU Lesser General Public License (LGPL) Version 2.1 that 5 * accompanies this distribution (lgpl-v21.txt). The LGPL is also 6 * available at http://www.gnu.org/licenses/lgpl.html. If the version 7 * of the LGPL at http://www.gnu.org is different to the version of 8 * the LGPL accompanying this distribution and there is any conflict 9 * between the two license versions, the terms of the LGPL accompanying 10 * this distribution shall govern. 11 * 12 * Contributors: 13 * IBM Corporation - initial API and implementation 14 *******************************************************************************/ 15 16 /* Include guard */ 17 #ifndef ORG_ECLIPSE_SWT_GTK_OS_CUSTOM_H 18 #define ORG_ECLIPSE_SWT_GTK_OS_CUSTOM_H 19 20 /* Special sizeof's */ 21 #define GPollFD_sizeof() sizeof(GPollFD) 22 #define GtkCellRendererText_sizeof() sizeof(GtkCellRendererText) 23 #define GtkCellRendererTextClass_sizeof() sizeof(GtkCellRendererTextClass) 24 #if !defined(GTK4) 25 #define GtkCellRendererPixbuf_sizeof() sizeof(GtkCellRendererPixbuf) 26 #define GtkCellRendererPixbufClass_sizeof() sizeof(GtkCellRendererPixbufClass) 27 #define GtkCellRendererToggle_sizeof() sizeof(GtkCellRendererToggle) 28 #define GtkCellRendererToggleClass_sizeof() sizeof(GtkCellRendererToggleClass) 29 #endif 30 #define GtkTextIter_sizeof() sizeof(GtkTextIter) 31 #define GtkTreeIter_sizeof() sizeof(GtkTreeIter) 32 33 #ifdef _WIN32 34 #define LIB_GTK "libgtk-3-0.dll" 35 #define LIB_GDK "libgdk-3-0.dll" 36 #define LIB_GTHREAD "libgthread-2.0-0.dll" 37 #define LIB_GLIB "libglib-2.0-0.dll" 38 #define LIB_ATK "libatk-1.0-0.dll" 39 #define LIB_FONTCONFIG "libfontconfig-1.dll" 40 #else 41 #if defined(GTK4) 42 #define LIB_GTK "libgtk-4.so.1" 43 // Point GDK to GTK for GTK4 44 #define LIB_GDK "libgtk-4.so.1" 45 #else 46 #define LIB_GTK "libgtk-3.so.0" 47 #define LIB_GDK "libgdk-3.so.0" 48 #endif 49 #define LIB_GTHREAD "libgthread-2.0.so.0" 50 #define LIB_GLIB "libglib-2.0.so.0" 51 #define LIB_ATK "libatk-1.0.so.0" 52 #define LIB_FONTCONFIG "libfontconfig.so.1" 53 #endif 54 55 /* Libraries for dynamic loaded functions */ 56 57 #define ubuntu_menu_proxy_get_LIB LIB_GTK 58 #define FcConfigAppFontAddFile_LIB LIB_FONTCONFIG 59 60 /* Field accessors */ 61 #define G_OBJECT_CLASS_CONSTRUCTOR(arg0) (arg0)->constructor 62 #define G_OBJECT_CLASS_SET_CONSTRUCTOR(arg0, arg1) (arg0)->constructor = (GObject* (*) (GType, guint, GObjectConstructParam *))arg1 63 #define GDK_EVENT_TYPE(arg0) (arg0)->type 64 #define GDK_EVENT_WINDOW(arg0) (arg0)->window 65 #define X_EVENT_TYPE(arg0) (arg0)->type 66 #define X_EVENT_WINDOW(arg0) (arg0)->window 67 #define g_error_get_message(arg0) (arg0)->message 68 #define g_list_data(arg0) (arg0)->data 69 #define g_slist_data(arg0) (arg0)->data 70 #define g_list_set_next(arg0, arg1) (arg0)->next = arg1 71 #define g_list_set_previous(arg0, arg1) (arg0)->prev = arg1 72 #define localeconv_decimal_point() localeconv()->decimal_point 73 74 // Mechanism to get function pointers of C/gtk functions back to java. 75 // Idea is that you substitute the return value with the function pointer. 76 // NOTE: functions like gtk_false need to be linked to a lib. Eg see gtk_false_LIB above. 77 #define GET_FUNCTION_POINTER_gtk_false() 0; \ 78 GTK_LOAD_FUNCTION(fp, gtk_false) \ 79 rc = (jlong)fp; 80 81 #define gtk_status_icon_position_menu_func() 0; \ 82 GTK_LOAD_FUNCTION(fp, gtk_status_icon_position_menu) \ 83 rc = (jlong)fp; 84 85 glong g_utf16_pointer_to_offset(const gchar*, const gchar*); 86 gchar* g_utf16_offset_to_pointer(const gchar*, glong); 87 glong g_utf16_strlen(const gchar*, glong max); 88 glong g_utf16_offset_to_utf8_offset(const gchar*, glong); 89 glong g_utf8_offset_to_utf16_offset(const gchar*, glong); 90 91 #define SWT_TYPE_FIXED (swt_fixed_get_type ()) 92 #define SWT_FIXED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWT_TYPE_FIXED, SwtFixed)) 93 #define SWT_FIXED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWT_TYPE_FIXED, SwtFixedClass)) 94 #define SWT_IS_FIXED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWT_TYPE_FIXED)) 95 #define SWT_IS_FIXED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWT_TYPE_FIXED)) 96 #define SWT_FIXED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWT_TYPE_FIXED, SwtFixedClass)) 97 98 99 typedef struct _SwtFixed SwtFixed; 100 typedef struct _SwtFixedPrivate SwtFixedPrivate; 101 typedef struct _SwtFixedClass SwtFixedClass; 102 103 #if defined(GTK4) 104 struct _SwtFixed 105 { 106 GtkWidget container; 107 }; 108 109 struct _SwtFixedClass 110 { 111 GtkWidgetClass parent_class; 112 }; 113 #else 114 struct _SwtFixed 115 { 116 GtkContainer container; 117 118 /*< private >*/ 119 SwtFixedPrivate *priv; 120 121 /* Accessibility */ 122 AtkObject *accessible; 123 }; 124 125 struct _SwtFixedClass 126 { 127 GtkContainerClass parent_class; 128 }; 129 #endif 130 131 GType swt_fixed_get_type (void) G_GNUC_CONST; 132 133 #if defined(GTK4) 134 void swt_fixed_add(SwtFixed* fixed, GtkWidget* widget); 135 void swt_fixed_remove(SwtFixed* fixed, GtkWidget* widget); 136 #endif 137 void swt_fixed_restack(SwtFixed *fixed, GtkWidget *widget, GtkWidget *sibling, gboolean above); 138 void swt_fixed_move(SwtFixed *fixed, GtkWidget *widget, gint x, gint y); 139 void swt_fixed_resize(SwtFixed *fixed, GtkWidget *widget, gint width, gint height); 140 141 #if !defined(GTK4) 142 #include <gtk/gtk-a11y.h> 143 #endif 144 145 #define SWT_TYPE_FIXED_ACCESSIBLE (swt_fixed_accessible_get_type ()) 146 #define SWT_FIXED_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWT_TYPE_FIXED_ACCESSIBLE, SwtFixedAccessible)) 147 #define SWT_IS_FIXED_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWT_TYPE_FIXED_ACCESSIBLE)) 148 149 typedef struct _SwtFixedAccessible SwtFixedAccessible; 150 typedef struct _SwtFixedAccessiblePrivate SwtFixedAccessiblePrivate; 151 typedef struct _SwtFixedAccessibleClass SwtFixedAccessibleClass; 152 153 #if defined(GTK4) 154 struct _SwtFixedAccessible 155 { 156 SwtFixedAccessiblePrivate *priv; 157 }; 158 159 struct _SwtFixedAccessibleClass 160 { 161 }; 162 #else 163 struct _SwtFixedAccessible 164 { 165 GtkContainerAccessible parent; 166 167 SwtFixedAccessiblePrivate *priv; 168 }; 169 170 struct _SwtFixedAccessibleClass 171 { 172 GtkContainerAccessibleClass parent_class; 173 }; 174 #endif 175 176 GType swt_fixed_accessible_get_type (void) G_GNUC_CONST; 177 #if !defined(GTK4) 178 AtkObject *swt_fixed_accessible_new (GtkWidget *widget); 179 void swt_fixed_accessible_register_accessible (AtkObject *obj, gboolean is_native, GtkWidget *to_map); 180 #endif 181 jlong call_accessible_object_function (const char *method_name, const char *method_signature,...); 182 183 void swt_set_lock_functions(); 184 void swt_debug_on_fatal_warnings() ; 185 186 #endif /* ORG_ECLIPSE_SWT_GTK_OS_CUSTOM_H (include guard, this should be the last line) */ 187