/* Definitions and headers for GTK widgets. Copyright (C) 2003-2020 Free Software Foundation, Inc. This file is part of GNU Emacs. GNU Emacs is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. GNU Emacs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see . */ #ifndef PGTKSUBR_H #define PGTKSUBR_H #include "config.h" #ifdef USE_GTK #include #include "../lwlib/lwlib-widget.h" #include "pgtkterm.h" #include "menu.h" #define EVENT GdkEvent #include "gtkconfig.h" /* Minimum and maximum values used for GTK scroll bars */ #define XG_SB_MIN 1 #define XG_SB_MAX 100 #define XG_SB_RANGE (XG_SB_MAX - XG_SB_MIN) #define YG_SB_MIN 1 #define YG_SB_MAX 100 #define YG_SB_RANGE (YG_SB_MAX - YG_SB_MIN) /* Key for data that is valid for menus and scroll bars in a frame */ #define XG_FRAME_DATA "emacs_frame" /* Key for data that menu items hold. */ #define XG_ITEM_DATA "emacs_menuitem" #define EGTK_WIDGET_GET_WINDOW(widget) \ (gtk_native_get_surface (gtk_widget_get_native (widget))) #define EG_OVERLAY_ALLOC "eg-override-alloc" #define XG_TOOL_BAR_LAST_MODIFIER "tool-bar-last-mod" #define XG_TOOL_BAR_STOCK_NAME "tool-bar-stock-name" /* This is a list node in a generic list implementation. */ typedef struct egtk_list_node_ { struct egtk_list_node_ *prev; struct egtk_list_node_ *next; } egtk_list_node; /* This structure is the callback data that is shared for menu items. We need to keep it separate from the frame structure due to detachable menus. The data in the frame structure is only valid while the menu is popped up. This structure is kept around as long as the menu is. */ typedef struct egtk_menu_cb_data_ { egtk_list_node ptrs; struct frame *f; Lisp_Object menu_bar_vector; int menu_bar_items_used; GCallback highlight_cb; int ref_count; } egtk_menu_cb_data; /* This structure holds callback information for each individual menu item. */ typedef struct egtk_menu_item_cb_data_ { egtk_list_node ptrs; gulong select_id; Lisp_Object help; gpointer call_data; egtk_menu_cb_data *cl_data; } egtk_menu_item_cb_data; G_BEGIN_DECLS typedef struct _EmacsResizableDrawingArea { GtkDrawingArea parent_instance; GtkAccessible *accessible; GdkRGBA *background_color; GtkPopover *nrc_popover; GHashTable *action_map; GActionGroup *action_group; struct frame *f; } EmacsResizableDrawingArea; struct _EmacsResizableDrawingAreaClass { GtkDrawingAreaClass parent_class; }; extern GtkWidget *emacs_resizable_drawing_area_new (struct frame *f); extern void emacs_resizable_drawing_area_set_background (EmacsResizableDrawingArea *area, unsigned long color); G_END_DECLS extern void run_main_loop_iteration (void); extern char *egtk_get_file_name (struct frame *f, char *prompt, char *default_filename, bool mustmatch_p, bool only_dir_p); extern Lisp_Object egtk_get_font (struct frame *f, const char *); extern void egtk_create_scroll_bar (struct frame *f, struct scroll_bar *bar, GCallback scroll_callback, GCallback end_callback, const char *scroll_bar_name); extern void egtk_create_horizontal_scroll_bar (struct frame *f, struct scroll_bar *bar, GCallback scroll_callback, GCallback end_callback, const char *scroll_bar_name); extern void egtk_remove_scroll_bar (struct frame *f, ptrdiff_t scrollbar_id); extern void egtk_update_scrollbar_pos (struct frame *f, ptrdiff_t scrollbar_id, int top, int left, int width, int height); extern void egtk_update_horizontal_scrollbar_pos (struct frame *f, ptrdiff_t scrollbar_id, int top, int left, int width, int height); extern void egtk_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int position, int whole); extern void egtk_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar, int portion, int position, int whole); extern int egtk_get_default_scrollbar_width (struct frame *f); extern int egtk_get_default_scrollbar_height (struct frame *f); extern void update_frame_tool_bar (struct frame *f); extern void free_frame_tool_bar (struct frame *f); extern void egtk_change_toolbar_position (struct frame *f, Lisp_Object pos); extern void egtk_frame_resized (struct frame *f, int pixelwidth, int pixelheight); extern void egtk_frame_set_char_size (struct frame *f, int width, int height); extern int egtk_get_scale (struct frame *f); extern void egtk_display_open (char *display_name, GdkDisplay **dpy); extern void egtk_display_close (GdkDisplay *gdpy); extern GdkCursor *egtk_create_default_cursor (GdkDisplay *gdpy); extern bool egtk_create_frame_widgets (struct frame *f); extern void egtk_free_frame_widgets (struct frame *f); extern void egtk_set_background_color (struct frame *f, unsigned long bg); extern bool egtk_check_special_colors (struct frame *f, const char *color_name, Emacs_Color *color); extern void egtk_set_undecorated (struct frame *f, Lisp_Object undecorated); extern void egtk_frame_restack (struct frame *f1, struct frame *f2, bool above); extern void egtk_set_skip_taskbar (struct frame *f, Lisp_Object skip_taskbar); extern void egtk_set_no_focus_on_map (struct frame *f, Lisp_Object no_focus_on_map); extern void egtk_set_no_accept_focus (struct frame *f, Lisp_Object no_accept_focus); extern void egtk_set_override_redirect (struct frame *f, Lisp_Object override_redirect); extern bool egtk_prepare_tooltip (struct frame *f, Lisp_Object string, int *width, int *height); extern void egtk_show_tooltip (struct frame *f, int root_x, int root_y); extern bool egtk_hide_tooltip (struct frame *f); extern void egtk_page_setup_dialog (void); extern Lisp_Object egtk_get_page_setup (void); extern void egtk_print_frames_dialog (Lisp_Object); /* Mark all callback data that are Lisp_object:s during GC. */ extern void egtk_mark_data (void); /* Initialize GTK specific parts. */ extern void egtk_initialize (void); /* Setting scrollbar values invokes the callback. Use this variable to indicate that the callback should do nothing. */ extern bool egtk_ignore_gtk_scrollbar; extern bool egtk_gtk_initialized; extern GtkWidget *egtk_get_image_for_pixmap (struct frame *f, struct image *img, GtkWidget *widget, GtkImage *old_widget); extern void egtk_list_insert (egtk_list_node *list, egtk_list_node *node); extern double egtk_get_monitor_wdpi (GdkMonitor *monitor); extern double egtk_get_monitor_hdpi (GdkMonitor *monitor); extern GtkDialog * egtk_build_dialog (struct frame *f, widget_value *wv, GCallback select_cb, GCallback deactivate_cb); extern GtkPopover * build_mm_from_wv (widget_value *wv, struct frame *f, GCallback select_cb, GCallback deactivate_cb, GCallback highlight_cb, bool pop_up_p, bool menu_bar_p, egtk_menu_cb_data *cl_data, const char *name, GtkContainer *box, GtkPopover *popover, GdkRectangle *posrect); extern int calculate_child_frame_distance_x (struct frame *f); extern int calculate_child_frame_distance_y (struct frame *f); extern gboolean overlay_allocate_cb (GtkOverlay *overlay, GtkWidget *widget, GdkRectangle *allocation, gpointer user_data); egtk_menu_cb_data * make_cl_data (egtk_menu_cb_data *cl_data, struct frame *f, GCallback highlight_cb); GtkWidget * eg_get_widget_from_map (ptrdiff_t idx); void eg_notify_frame_header_bar_state_changed (struct frame *f); void eg_unparent_frame (struct frame *f); void emacs_resizable_drawing_area_show_selection_options (EmacsResizableDrawingArea *area); void unref_cl_data (egtk_menu_cb_data *cl_data); Lisp_Object eg_get_font_family (bool mono); Lisp_Object eg_get_caret_px_width (void); Lisp_Object eg_get_divider_width (void); GtkWidget * build_popover_menu_bar (widget_value *wv, egtk_menu_cb_data *cl_data, GCallback select_cb, GCallback deactivate_cb, GCallback highlight_cb, struct frame *f, GtkWidget *mbar); GtkWidget * xeg_child_frame_bin_new (void); void frame_activate_menu_bar (struct frame *f); #endif /* USE_GTK */ #endif /* PGTKSUBR_H */