Path: blob/master/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.h
41155 views
/*1* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#ifdef HEADLESS26#error This file should not be included in headless library27#endif2829#ifndef _GTK2_INTERFACE_H30#define _GTK2_INTERFACE_H3132#include <stdlib.h>33#include <jni.h>34#include <X11/X.h>35#include "gtk_interface.h"3637#define GTK_HAS_FOCUS (1 << 12)38#define GTK_HAS_DEFAULT (1 << 14)3940typedef enum41{42GTK_WINDOW_TOPLEVEL,43GTK_WINDOW_POPUP44} GtkWindowType;4546typedef enum47{48G_PARAM_READABLE = 1 << 0,49G_PARAM_WRITABLE = 1 << 1,50G_PARAM_CONSTRUCT = 1 << 2,51G_PARAM_CONSTRUCT_ONLY = 1 << 3,52G_PARAM_LAX_VALIDATION = 1 << 4,53G_PARAM_PRIVATE = 1 << 554} GParamFlags;5556/* We define all structure pointers to be void* */57typedef void GMainContext;58typedef void GVfs;5960typedef void GdkColormap;61typedef void GdkDrawable;62typedef void GdkGC;63typedef void GdkPixbuf;64typedef void GdkPixmap;6566typedef void GtkFixed;67typedef void GtkMenuItem;68typedef void GtkMenuShell;69typedef void GtkWidgetClass;70typedef void PangoFontDescription;71typedef void GtkSettings;7273/* Some real structures */74typedef struct75{76guint32 pixel;77guint16 red;78guint16 green;79guint16 blue;80} GdkColor;8182typedef struct {83gint fd;84gushort events;85gushort revents;86} GPollFD;8788typedef struct {89gint x;90gint y;91gint width;92gint height;93} GdkRectangle;9495typedef struct {96gint x;97gint y;98gint width;99gint height;100} GtkAllocation;101102typedef struct {103gint width;104gint height;105} GtkRequisition;106107typedef struct {108GtkWidgetClass *g_class;109} GTypeInstance;110111typedef struct {112gint left;113gint right;114gint top;115gint bottom;116} GtkBorder;117118/******************************************************119* FIXME: it is more safe to include gtk headers for120* the precise type definition of GType and other121* structures. This is a place where getting rid of gtk122* headers may be dangerous.123******************************************************/124125typedef struct126{127GType g_type;128129union {130gint v_int;131guint v_uint;132glong v_long;133gulong v_ulong;134gint64 v_int64;135guint64 v_uint64;136gfloat v_float;137gdouble v_double;138gpointer v_pointer;139} data[2];140} GValue;141142typedef struct143{144GTypeInstance g_type_instance;145146gchar *name;147GParamFlags flags;148GType value_type;149GType owner_type;150} GParamSpec;151152typedef struct {153GTypeInstance g_type_instance;154guint ref_count;155void *qdata;156} GObject;157158typedef struct {159GObject parent_instance;160guint32 flags;161} GtkObject;162163typedef struct164{165GObject parent_instance;166167GdkColor fg[5];168GdkColor bg[5];169GdkColor light[5];170GdkColor dark[5];171GdkColor mid[5];172GdkColor text[5];173GdkColor base[5];174GdkColor text_aa[5]; /* Halfway between text/base */175176GdkColor black;177GdkColor white;178PangoFontDescription *font_desc;179180gint xthickness;181gint ythickness;182183GdkGC *fg_gc[5];184GdkGC *bg_gc[5];185GdkGC *light_gc[5];186GdkGC *dark_gc[5];187GdkGC *mid_gc[5];188GdkGC *text_gc[5];189GdkGC *base_gc[5];190GdkGC *text_aa_gc[5];191GdkGC *black_gc;192GdkGC *white_gc;193194GdkPixmap *bg_pixmap[5];195} GtkStyle;196197typedef struct _GtkWidget GtkWidget;198struct _GtkWidget199{200GtkObject object;201guint16 private_flags;202guint8 state;203guint8 saved_state;204gchar *name;205GtkStyle *style;206GtkRequisition requisition;207GtkAllocation allocation;208GdkWindow *window;209GtkWidget *parent;210};211212typedef struct213{214GtkWidget widget;215216gfloat xalign;217gfloat yalign;218219guint16 xpad;220guint16 ypad;221} GtkMisc;222223typedef struct {224GtkWidget widget;225GtkWidget *focus_child;226guint border_width : 16;227guint need_resize : 1;228guint resize_mode : 2;229guint reallocate_redraws : 1;230guint has_focus_chain : 1;231} GtkContainer;232233typedef struct {234GtkContainer container;235GtkWidget *child;236} GtkBin;237238typedef struct {239GtkBin bin;240GdkWindow *event_window;241gchar *label_text;242guint activate_timeout;243guint constructed : 1;244guint in_button : 1;245guint button_down : 1;246guint relief : 2;247guint use_underline : 1;248guint use_stock : 1;249guint depressed : 1;250guint depress_on_activate : 1;251guint focus_on_click : 1;252} GtkButton;253254typedef struct {255GtkButton button;256guint active : 1;257guint draw_indicator : 1;258guint inconsistent : 1;259} GtkToggleButton;260261typedef struct _GtkAdjustment GtkAdjustment;262struct _GtkAdjustment263{264GtkObject parent_instance;265266gdouble lower;267gdouble upper;268gdouble value;269gdouble step_increment;270gdouble page_increment;271gdouble page_size;272};273274typedef enum275{276GTK_UPDATE_CONTINUOUS,277GTK_UPDATE_DISCONTINUOUS,278GTK_UPDATE_DELAYED279} GtkUpdateType;280281typedef struct _GtkRange GtkRange;282struct _GtkRange283{284GtkWidget widget;285GtkAdjustment *adjustment;286GtkUpdateType update_policy;287guint inverted : 1;288/*< protected >*/289guint flippable : 1;290guint has_stepper_a : 1;291guint has_stepper_b : 1;292guint has_stepper_c : 1;293guint has_stepper_d : 1;294guint need_recalc : 1;295guint slider_size_fixed : 1;296gint min_slider_size;297GtkOrientation orientation;298GdkRectangle range_rect;299gint slider_start, slider_end;300gint round_digits;301/*< private >*/302guint trough_click_forward : 1;303guint update_pending : 1;304/*GtkRangeLayout * */ void *layout;305/*GtkRangeStepTimer * */ void* timer;306gint slide_initial_slider_position;307gint slide_initial_coordinate;308guint update_timeout_id;309GdkWindow *event_window;310};311312typedef struct _GtkProgressBar GtkProgressBar;313314typedef enum315{316GTK_PROGRESS_CONTINUOUS,317GTK_PROGRESS_DISCRETE318} GtkProgressBarStyle;319320typedef enum321{322GTK_PROGRESS_LEFT_TO_RIGHT,323GTK_PROGRESS_RIGHT_TO_LEFT,324GTK_PROGRESS_BOTTOM_TO_TOP,325GTK_PROGRESS_TOP_TO_BOTTOM326} GtkProgressBarOrientation;327328typedef struct _GtkProgress GtkProgress;329330struct _GtkProgress331{332GtkWidget widget;333GtkAdjustment *adjustment;334GdkPixmap *offscreen_pixmap;335gchar *format;336gfloat x_align;337gfloat y_align;338guint show_text : 1;339guint activity_mode : 1;340guint use_text_format : 1;341};342343struct _GtkProgressBar344{345GtkProgress progress;346GtkProgressBarStyle bar_style;347GtkProgressBarOrientation orientation;348guint blocks;349gint in_block;350gint activity_pos;351guint activity_step;352guint activity_blocks;353gdouble pulse_fraction;354guint activity_dir : 1;355guint ellipsize : 3;356};357358/**359* Returns :360* NULL if the GLib library is compatible with the given version, or a string361* describing the version mismatch.362* Please note that the glib_check_version() is available since 2.6,363* so you should use GLIB_CHECK_VERSION macro instead.364*/365static gchar* (*fp_glib_check_version)(guint required_major, guint required_minor,366guint required_micro);367368/**369* Returns :370* TRUE if the GLib library is compatible with the given version371*/372#define GLIB_CHECK_VERSION(major, minor, micro) \373(fp_glib_check_version && fp_glib_check_version(major, minor, micro) == NULL)374375/**376* Returns :377* NULL if the GTK+ library is compatible with the given version, or a string378* describing the version mismatch.379*/380static gchar* (*fp_gtk_check_version)(guint required_major, guint required_minor,381guint required_micro);382383static void gtk2_init(GtkApi* gtk);384385static void (*fp_g_free)(gpointer mem);386static void (*fp_g_object_unref)(gpointer object);387static GdkWindow *(*fp_gdk_get_default_root_window) (void);388389static int (*fp_gdk_pixbuf_get_bits_per_sample)(const GdkPixbuf *pixbuf);390static guchar *(*fp_gdk_pixbuf_get_pixels)(const GdkPixbuf *pixbuf);391static gboolean (*fp_gdk_pixbuf_get_has_alpha)(const GdkPixbuf *pixbuf);392static int (*fp_gdk_pixbuf_get_height)(const GdkPixbuf *pixbuf);393static int (*fp_gdk_pixbuf_get_n_channels)(const GdkPixbuf *pixbuf);394static int (*fp_gdk_pixbuf_get_rowstride)(const GdkPixbuf *pixbuf);395static int (*fp_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf);396static GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename, GError **error);397static GdkColorspace (*fp_gdk_pixbuf_get_colorspace)(const GdkPixbuf *pixbuf);398399static GdkPixbuf *(*fp_gdk_pixbuf_get_from_drawable)(GdkPixbuf *dest,400GdkDrawable *src, GdkColormap *cmap, int src_x, int src_y,401int dest_x, int dest_y, int width, int height);402static GdkPixbuf *(*fp_gdk_pixbuf_scale_simple)(GdkPixbuf *src,403int dest_width, int dest_heigh, GdkInterpType interp_type);404405406static void (*fp_gtk_widget_destroy)(void *widget);407static void (*fp_gtk_window_present)(GtkWindow *window);408static void (*fp_gtk_window_move)(GtkWindow *window, gint x, gint y);409static void (*fp_gtk_window_resize)(GtkWindow *window, gint width, gint height);410411/**412* Function Pointers for GtkFileChooser413*/414static gchar* (*fp_gtk_file_chooser_get_filename)(GtkFileChooser *chooser);415static void (*fp_gtk_widget_hide)(void *widget);416static void (*fp_gtk_main_quit)(void);417static void* (*fp_gtk_file_chooser_dialog_new)(const gchar *title,418GtkWindow *parent, GtkFileChooserAction action,419const gchar *first_button_text, ...);420static gboolean (*fp_gtk_file_chooser_set_current_folder)(GtkFileChooser *chooser,421const gchar *filename);422static gboolean (*fp_gtk_file_chooser_set_filename)(GtkFileChooser *chooser,423const char *filename);424static void (*fp_gtk_file_chooser_set_current_name)(GtkFileChooser *chooser,425const gchar *name);426static void (*fp_gtk_file_filter_add_custom)(GtkFileFilter *filter,427GtkFileFilterFlags needed, GtkFileFilterFunc func, gpointer data,428GDestroyNotify notify);429static void (*fp_gtk_file_chooser_set_filter)(GtkFileChooser *chooser,430GtkFileFilter *filter);431static GType (*fp_gtk_file_chooser_get_type)(void);432static GtkFileFilter* (*fp_gtk_file_filter_new)(void);433static void (*fp_gtk_file_chooser_set_do_overwrite_confirmation)(434GtkFileChooser *chooser, gboolean do_overwrite_confirmation);435static void (*fp_gtk_file_chooser_set_select_multiple)(436GtkFileChooser *chooser, gboolean select_multiple);437static gchar* (*fp_gtk_file_chooser_get_current_folder)(GtkFileChooser *chooser);438static GSList* (*fp_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser);439static guint (*fp_gtk_g_slist_length)(GSList *list);440static gulong (*fp_g_signal_connect_data)(gpointer instance,441const gchar *detailed_signal, GCallback c_handler, gpointer data,442GClosureNotify destroy_data, GConnectFlags connect_flags);443static void (*fp_gtk_widget_show)(void *widget);444static void (*fp_gtk_main)(void);445static guint (*fp_gtk_main_level)(void);446static gchar* (*fp_g_path_get_dirname) (const gchar *file_name);447static XID (*fp_gdk_x11_drawable_get_xid) (GdkWindow *drawable);448449static GList* (*fp_g_list_append) (GList *list, gpointer data);450static void (*fp_g_list_free) (GList *list);451static void (*fp_g_list_free_full) (GList *list, GDestroyNotify free_func);452453static gboolean (*fp_gtk_show_uri)(GdkScreen *screen, const gchar *uri,454guint32 timestamp, GError **error);455456#endif /* !_GTK2_INTERFACE_H */457458459