gtkutil.h 7.49 KB
Newer Older
Jan Djärv's avatar
Jan Djärv committed
1
/* Definitions and headers for GTK widgets.
2

Paul Eggert's avatar
Paul Eggert committed
3
Copyright (C) 2003-2019 Free Software Foundation, Inc.
Jan Djärv's avatar
Jan Djärv committed
4 5 6

This file is part of GNU Emacs.

7
GNU Emacs is free software: you can redistribute it and/or modify
Jan Djärv's avatar
Jan Djärv committed
8
it under the terms of the GNU General Public License as published by
9 10
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
Jan Djärv's avatar
Jan Djärv committed
11 12 13 14 15 16 17

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
18
along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
Jan Djärv's avatar
Jan Djärv committed
19 20 21 22 23 24 25 26

#ifndef GTKUTIL_H
#define GTKUTIL_H


#ifdef USE_GTK

#include <gtk/gtk.h>
27
#include "../lwlib/lwlib-widget.h"
28
#include "xterm.h"
Jan Djärv's avatar
Jan Djärv committed
29 30 31

/* Minimum and maximum values used for GTK scroll bars  */

32
#define XG_SB_MIN 1
Jan Djärv's avatar
Jan Djärv committed
33
#define XG_SB_MAX 10000000
34
#define XG_SB_RANGE (XG_SB_MAX-XG_SB_MIN)
35 36 37
#define YG_SB_MIN 1
#define YG_SB_MAX 10000000
#define YG_SB_RANGE (YG_SB_MAX-YG_SB_MIN)
Jan Djärv's avatar
Jan Djärv committed
38

39
/* Key for data that is valid for menus and scroll bars in a frame  */
Jan Djärv's avatar
Jan Djärv committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
#define XG_FRAME_DATA "emacs_frame"

/* Key for data that menu items hold.  */
#define XG_ITEM_DATA "emacs_menuitem"

/* This is a list node in a generic list implementation.  */
typedef struct xg_list_node_
{
  struct xg_list_node_ *prev;
  struct xg_list_node_ *next;
} xg_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 xg_menu_cb_data_
{
  xg_list_node  ptrs;
60

Dmitry Antipov's avatar
Dmitry Antipov committed
61
  struct frame  *f;
Jan Djärv's avatar
Jan Djärv committed
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
  Lisp_Object   menu_bar_vector;
  int           menu_bar_items_used;
  GCallback     highlight_cb;
  int           ref_count;
} xg_menu_cb_data;

/* This structure holds callback information for each individual menu item.  */
typedef struct xg_menu_item_cb_data_
{
  xg_list_node  ptrs;

  gulong        select_id;
  Lisp_Object   help;
  gpointer	call_data;
  xg_menu_cb_data *cl_data;
77

Jan Djärv's avatar
Jan Djärv committed
78 79
} xg_menu_item_cb_data;

80
extern bool xg_uses_old_file_dialog (void);
Jan D's avatar
Jan D committed
81

Dmitry Antipov's avatar
Dmitry Antipov committed
82
extern char *xg_get_file_name (struct frame *f,
Jan D's avatar
Jan D committed
83 84
                               char *prompt,
                               char *default_filename,
85 86
                               bool mustmatch_p,
                               bool only_dir_p);
Jan D's avatar
Jan D committed
87

Dmitry Antipov's avatar
Dmitry Antipov committed
88
extern Lisp_Object xg_get_font (struct frame *f, const char *);
Jan D's avatar
Jan D committed
89

90 91
extern GtkWidget *xg_create_widget (const char *type,
                                    const char *name,
Dmitry Antipov's avatar
Dmitry Antipov committed
92
                                    struct frame *f,
93
                                    struct _widget_value *val,
Jan D's avatar
Jan D committed
94 95
                                    GCallback select_cb,
                                    GCallback deactivate_cb,
Paul Eggert's avatar
Paul Eggert committed
96
                                    GCallback highlight_cb);
Jan D's avatar
Jan D committed
97 98

extern void xg_modify_menubar_widgets (GtkWidget *menubar,
Dmitry Antipov's avatar
Dmitry Antipov committed
99
                                       struct frame *f,
100
                                       struct _widget_value *val,
101
                                       bool deep_p,
Jan D's avatar
Jan D committed
102 103
                                       GCallback select_cb,
                                       GCallback deactivate_cb,
Paul Eggert's avatar
Paul Eggert committed
104
                                       GCallback highlight_cb);
Jan D's avatar
Jan D committed
105

Dmitry Antipov's avatar
Dmitry Antipov committed
106
extern void xg_update_frame_menubar (struct frame *f);
Jan D's avatar
Jan D committed
107

108
extern bool xg_event_is_for_menubar (struct frame *, const XEvent *);
109

110
extern ptrdiff_t xg_get_scroll_id_for_window (Display *dpy, Window wid);
Jan D's avatar
Jan D committed
111

Dmitry Antipov's avatar
Dmitry Antipov committed
112
extern void xg_create_scroll_bar (struct frame *f,
Jan D's avatar
Jan D committed
113 114 115
                                  struct scroll_bar *bar,
                                  GCallback scroll_callback,
                                  GCallback end_callback,
116
                                  const char *scroll_bar_name);
117 118 119 120 121
extern void xg_create_horizontal_scroll_bar (struct frame *f,
					     struct scroll_bar *bar,
					     GCallback scroll_callback,
					     GCallback end_callback,
					     const char *scroll_bar_name);
Dmitry Antipov's avatar
Dmitry Antipov committed
122
extern void xg_remove_scroll_bar (struct frame *f, ptrdiff_t scrollbar_id);
Jan D's avatar
Jan D committed
123

Dmitry Antipov's avatar
Dmitry Antipov committed
124
extern void xg_update_scrollbar_pos (struct frame *f,
125
                                     ptrdiff_t scrollbar_id,
Jan D's avatar
Jan D committed
126 127 128 129
                                     int top,
                                     int left,
                                     int width,
                                     int height);
130 131 132 133 134 135
extern void xg_update_horizontal_scrollbar_pos (struct frame *f,
						ptrdiff_t scrollbar_id,
						int top,
						int left,
						int width,
						int height);
Jan D's avatar
Jan D committed
136 137 138 139 140

extern void xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar,
                                             int portion,
                                             int position,
                                             int whole);
141 142 143 144
extern void xg_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar,
							int portion,
							int position,
							int whole);
145
extern bool xg_event_is_for_scrollbar (struct frame *, const XEvent *);
146 147
extern int xg_get_default_scrollbar_width (struct frame *f);
extern int xg_get_default_scrollbar_height (struct frame *f);
Jan D's avatar
Jan D committed
148

Dmitry Antipov's avatar
Dmitry Antipov committed
149 150 151
extern void update_frame_tool_bar (struct frame *f);
extern void free_frame_tool_bar (struct frame *f);
extern void xg_change_toolbar_position (struct frame *f, Lisp_Object pos);
Jan D's avatar
Jan D committed
152

Dmitry Antipov's avatar
Dmitry Antipov committed
153
extern void xg_frame_resized (struct frame *f,
Jan D's avatar
Jan D committed
154 155
                              int pixelwidth,
                              int pixelheight);
156
extern void xg_frame_set_char_size (struct frame *f, int width, int height);
Jan D's avatar
Jan D committed
157 158
extern GtkWidget * xg_win_to_widget (Display *dpy, Window wdesc);

159
extern int xg_get_scale (struct frame *f);
Jan D's avatar
Jan D committed
160 161 162 163
extern void xg_display_open (char *display_name, Display **dpy);
extern void xg_display_close (Display *dpy);
extern GdkCursor * xg_create_default_cursor (Display *dpy);

Dmitry Antipov's avatar
Dmitry Antipov committed
164 165 166
extern bool xg_create_frame_widgets (struct frame *f);
extern void xg_free_frame_widgets (struct frame *f);
extern void xg_set_background_color (struct frame *f, unsigned long bg);
167 168
extern bool xg_check_special_colors (struct frame *f,
				     const char *color_name,
169
				     Emacs_Color *color);
Jan D's avatar
Jan D committed
170

Dmitry Antipov's avatar
Dmitry Antipov committed
171
extern void xg_set_frame_icon (struct frame *f,
Jan D's avatar
Jan D committed
172 173
                               Pixmap icon_pixmap,
                               Pixmap icon_mask);
174

175 176 177 178 179 180 181
extern void xg_set_undecorated (struct frame *f, Lisp_Object undecorated);
extern void xg_frame_restack (struct frame *f1, struct frame *f2, bool above);
extern void xg_set_skip_taskbar (struct frame *f, Lisp_Object skip_taskbar);
extern void xg_set_no_focus_on_map (struct frame *f, Lisp_Object no_focus_on_map);
extern void xg_set_no_accept_focus (struct frame *f, Lisp_Object no_accept_focus);
extern void xg_set_override_redirect (struct frame *f, Lisp_Object override_redirect);

Dmitry Antipov's avatar
Dmitry Antipov committed
182
extern bool xg_prepare_tooltip (struct frame *f,
183 184 185
				Lisp_Object string,
				int *width,
				int *height);
Dmitry Antipov's avatar
Dmitry Antipov committed
186 187
extern void xg_show_tooltip (struct frame *f, int root_x, int root_y);
extern bool xg_hide_tooltip (struct frame *f);
188

Jan D's avatar
Jan D committed
189 190 191 192 193 194
#ifdef USE_CAIRO
extern void xg_page_setup_dialog (void);
extern Lisp_Object xg_get_page_setup (void);
extern void xg_print_frames_dialog (Lisp_Object);
#endif

Jan Djärv's avatar
Jan Djärv committed
195
/* Mark all callback data that are Lisp_object:s during GC.  */
Jan D's avatar
Jan D committed
196
extern void xg_mark_data (void);
Jan Djärv's avatar
Jan Djärv committed
197 198

/* Initialize GTK specific parts.  */
Jan D's avatar
Jan D committed
199
extern void xg_initialize (void);
Jan Djärv's avatar
Jan Djärv committed
200 201 202

/* Setting scrollbar values invokes the callback.  Use this variable
   to indicate that the callback should do nothing.  */
203
extern bool xg_ignore_gtk_scrollbar;
Jan Djärv's avatar
Jan Djärv committed
204

205
extern bool xg_gtk_initialized;
Jan Djärv's avatar
Jan Djärv committed
206 207
#endif /* USE_GTK */
#endif /* GTKUTIL_H */