root/src/gtkutil.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


     1 /* Definitions and headers for GTK widgets.
     2 
     3 Copyright (C) 2003-2023 Free Software Foundation, Inc.
     4 
     5 This file is part of GNU Emacs.
     6 
     7 GNU Emacs is free software: you can redistribute it and/or modify
     8 it under the terms of the GNU General Public License as published by
     9 the Free Software Foundation, either version 3 of the License, or (at
    10 your option) any later version.
    11 
    12 GNU Emacs is distributed in the hope that it will be useful,
    13 but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 GNU General Public License for more details.
    16 
    17 You should have received a copy of the GNU General Public License
    18 along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
    19 
    20 #ifndef GTKUTIL_H
    21 #define GTKUTIL_H
    22 
    23 
    24 #ifdef USE_GTK
    25 
    26 #include <gtk/gtk.h>
    27 #include "../lwlib/lwlib-widget.h"
    28 #ifdef HAVE_PGTK
    29 #include "pgtkterm.h"
    30 #define EVENT GdkEvent
    31 #else
    32 #include "xterm.h"
    33 #define EVENT XEvent
    34 #endif
    35 
    36 /* Minimum and maximum values used for GTK scroll bars  */
    37 
    38 #define XG_SB_MIN 1
    39 #define XG_SB_MAX 10000000
    40 #define XG_SB_RANGE (XG_SB_MAX-XG_SB_MIN)
    41 #define YG_SB_MIN 1
    42 #define YG_SB_MAX 10000000
    43 #define YG_SB_RANGE (YG_SB_MAX-YG_SB_MIN)
    44 
    45 /* Key for data that is valid for menus and scroll bars in a frame  */
    46 #define XG_FRAME_DATA "emacs_frame"
    47 
    48 /* Key for data that menu items hold.  */
    49 #define XG_ITEM_DATA "emacs_menuitem"
    50 
    51 /* This is a list node in a generic list implementation.  */
    52 typedef struct xg_list_node_
    53 {
    54   struct xg_list_node_ *prev;
    55   struct xg_list_node_ *next;
    56 } xg_list_node;
    57 
    58 /* This structure is the callback data that is shared for menu items.
    59    We need to keep it separate from the frame structure due to
    60    detachable menus.  The data in the frame structure is only valid while
    61    the menu is popped up.  This structure is kept around as long as
    62    the menu is.  */
    63 typedef struct xg_menu_cb_data_
    64 {
    65   xg_list_node  ptrs;
    66 
    67   struct frame  *f;
    68   Lisp_Object   menu_bar_vector;
    69   int           menu_bar_items_used;
    70   GCallback     highlight_cb;
    71   int           ref_count;
    72 } xg_menu_cb_data;
    73 
    74 /* This structure holds callback information for each individual menu item.  */
    75 typedef struct xg_menu_item_cb_data_
    76 {
    77   xg_list_node  ptrs;
    78 
    79   gulong        select_id;
    80   Lisp_Object   help;
    81   gpointer      call_data;
    82   xg_menu_cb_data *cl_data;
    83 
    84 } xg_menu_item_cb_data;
    85 
    86 extern bool xg_uses_old_file_dialog (void);
    87 
    88 extern char *xg_get_file_name (struct frame *f,
    89                                char *prompt,
    90                                char *default_filename,
    91                                bool mustmatch_p,
    92                                bool only_dir_p);
    93 
    94 extern Lisp_Object xg_get_font (struct frame *f, const char *);
    95 
    96 extern GtkWidget *xg_create_widget (const char *type,
    97                                     const char *name,
    98                                     struct frame *f,
    99                                     struct _widget_value *val,
   100                                     GCallback select_cb,
   101                                     GCallback deactivate_cb,
   102                                     GCallback highlight_cb);
   103 
   104 extern void xg_modify_menubar_widgets (GtkWidget *menubar,
   105                                        struct frame *f,
   106                                        struct _widget_value *val,
   107                                        bool deep_p,
   108                                        GCallback select_cb,
   109                                        GCallback deactivate_cb,
   110                                        GCallback highlight_cb);
   111 
   112 extern void xg_update_frame_menubar (struct frame *f);
   113 
   114 extern bool xg_event_is_for_menubar (struct frame *, const EVENT *);
   115 
   116 extern ptrdiff_t xg_get_scroll_id_for_window (Display *dpy, Window wid);
   117 
   118 extern void xg_create_scroll_bar (struct frame *f,
   119                                   struct scroll_bar *bar,
   120                                   GCallback scroll_callback,
   121                                   GCallback end_callback,
   122                                   const char *scroll_bar_name);
   123 extern void xg_create_horizontal_scroll_bar (struct frame *f,
   124                                              struct scroll_bar *bar,
   125                                              GCallback scroll_callback,
   126                                              GCallback end_callback,
   127                                              const char *scroll_bar_name);
   128 extern void xg_remove_scroll_bar (struct frame *f, ptrdiff_t scrollbar_id);
   129 
   130 extern void xg_update_scrollbar_pos (struct frame *f,
   131                                      ptrdiff_t scrollbar_id,
   132                                      int top,
   133                                      int left,
   134                                      int width,
   135                                      int height);
   136 extern void xg_update_horizontal_scrollbar_pos (struct frame *f,
   137                                                 ptrdiff_t scrollbar_id,
   138                                                 int top,
   139                                                 int left,
   140                                                 int width,
   141                                                 int height);
   142 
   143 extern void xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar,
   144                                              int portion,
   145                                              int position,
   146                                              int whole);
   147 extern void xg_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar,
   148                                                         int portion,
   149                                                         int position,
   150                                                         int whole);
   151 extern bool xg_event_is_for_scrollbar (struct frame *, const EVENT *,
   152                                        bool for_valuator);
   153 extern int xg_get_default_scrollbar_width (struct frame *f);
   154 extern int xg_get_default_scrollbar_height (struct frame *f);
   155 
   156 extern void xg_wm_set_size_hint (struct frame *, long int, bool);
   157 
   158 extern void update_frame_tool_bar (struct frame *f);
   159 extern void free_frame_tool_bar (struct frame *f);
   160 extern void xg_change_toolbar_position (struct frame *f, Lisp_Object pos);
   161 
   162 extern void xg_frame_resized (struct frame *f,
   163                               int pixelwidth,
   164                               int pixelheight);
   165 extern void xg_frame_set_char_size (struct frame *f, int width, int height);
   166 extern GtkWidget * xg_win_to_widget (Display *dpy, Window wdesc);
   167 
   168 extern int xg_get_scale (struct frame *f);
   169 #ifndef HAVE_PGTK
   170 extern void xg_display_open (char *display_name, Display **dpy);
   171 extern void xg_display_close (Display *dpy);
   172 extern GdkCursor * xg_create_default_cursor (Display *dpy);
   173 #else
   174 extern void xg_display_open (char *display_name, GdkDisplay **dpy);
   175 extern void xg_display_close (GdkDisplay *gdpy);
   176 extern GdkCursor * xg_create_default_cursor (GdkDisplay *gdpy);
   177 #endif
   178 
   179 extern bool xg_create_frame_widgets (struct frame *f);
   180 extern void xg_free_frame_widgets (struct frame *f);
   181 extern void xg_set_background_color (struct frame *f, unsigned long bg);
   182 extern bool xg_check_special_colors (struct frame *f,
   183                                      const char *color_name,
   184                                      Emacs_Color *color);
   185 #ifdef HAVE_PGTK
   186 extern void xg_create_frame_outer_widgets (struct frame *f);
   187 #endif
   188 
   189 #ifndef HAVE_PGTK
   190 extern void xg_set_frame_icon (struct frame *f,
   191                                Pixmap icon_pixmap,
   192                                Pixmap icon_mask);
   193 #endif
   194 
   195 extern void xg_set_undecorated (struct frame *f, Lisp_Object undecorated);
   196 extern void xg_frame_restack (struct frame *f1, struct frame *f2, bool above);
   197 extern void xg_set_skip_taskbar (struct frame *f, Lisp_Object skip_taskbar);
   198 extern void xg_set_no_focus_on_map (struct frame *f, Lisp_Object no_focus_on_map);
   199 extern void xg_set_no_accept_focus (struct frame *f, Lisp_Object no_accept_focus);
   200 extern void xg_set_override_redirect (struct frame *f, Lisp_Object override_redirect);
   201 
   202 extern bool xg_prepare_tooltip (struct frame *f,
   203                                 Lisp_Object string,
   204                                 int *width,
   205                                 int *height);
   206 #ifndef HAVE_PGTK
   207 extern void xg_show_tooltip (struct frame *f, int root_x, int root_y);
   208 #else
   209 extern void xg_show_tooltip (struct frame *f, Lisp_Object string);
   210 #endif
   211 extern bool xg_hide_tooltip (struct frame *f);
   212 
   213 #ifdef USE_CAIRO
   214 extern void xg_page_setup_dialog (void);
   215 extern Lisp_Object xg_get_page_setup (void);
   216 extern void xg_print_frames_dialog (Lisp_Object);
   217 #endif
   218 
   219 #if defined HAVE_GTK3 && defined HAVE_XINPUT2
   220 extern bool xg_is_menu_window (Display *dpy, Window);
   221 #endif
   222 
   223 #ifndef HAVE_PGTK
   224 extern bool xg_filter_key (struct frame *frame, XEvent *xkey);
   225 #endif
   226 
   227 /* Mark all callback data that are Lisp_Objects during GC.  */
   228 extern void xg_mark_data (void);
   229 
   230 /* Initialize GTK specific parts.  */
   231 extern void xg_initialize (void);
   232 
   233 /* Setting scrollbar values invokes the callback.  Use this variable
   234    to indicate that the callback should do nothing.  */
   235 extern bool xg_ignore_gtk_scrollbar;
   236 
   237 extern bool xg_gtk_initialized;
   238 
   239 #endif /* USE_GTK */
   240 #endif /* GTKUTIL_H */

/* [<][>][^][v][top][bottom][index][help] */