declare smobs in alloc.c
[bpt/emacs.git] / src / gtkutil.h
CommitLineData
f392e843 1/* Definitions and headers for GTK widgets.
95df8112 2
ba318903 3Copyright (C) 2003-2014 Free Software Foundation, Inc.
f392e843
JD
4
5This file is part of GNU Emacs.
6
b9b1cc14 7GNU Emacs is free software: you can redistribute it and/or modify
f392e843 8it under the terms of the GNU General Public License as published by
b9b1cc14
GM
9the Free Software Foundation, either version 3 of the License, or
10(at your option) any later version.
f392e843
JD
11
12GNU Emacs is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
b9b1cc14 18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
f392e843
JD
19
20#ifndef GTKUTIL_H
21#define GTKUTIL_H
22
23
24#ifdef USE_GTK
25
26#include <gtk/gtk.h>
181f08a7 27#include "../lwlib/lwlib-widget.h"
f392e843 28#include "frame.h"
17a2cbbd 29#include "xterm.h"
f392e843
JD
30
31/* Minimum and maximum values used for GTK scroll bars */
32
7863d625 33#define XG_SB_MIN 1
f392e843 34#define XG_SB_MAX 10000000
7863d625 35#define XG_SB_RANGE (XG_SB_MAX-XG_SB_MIN)
f392e843 36
e5f0bc9a 37/* Key for data that is valid for menus and scroll bars in a frame */
f392e843
JD
38#define XG_FRAME_DATA "emacs_frame"
39
f392e843
JD
40/* Key for data that menu items hold. */
41#define XG_ITEM_DATA "emacs_menuitem"
42
f392e843
JD
43/* This is a list node in a generic list implementation. */
44typedef struct xg_list_node_
45{
46 struct xg_list_node_ *prev;
47 struct xg_list_node_ *next;
48} xg_list_node;
49
50/* This structure is the callback data that is shared for menu items.
51 We need to keep it separate from the frame structure due to
52 detachable menus. The data in the frame structure is only valid while
53 the menu is popped up. This structure is kept around as long as
54 the menu is. */
55typedef struct xg_menu_cb_data_
56{
57 xg_list_node ptrs;
177c0ea7 58
a10c8269 59 struct frame *f;
f392e843
JD
60 Lisp_Object menu_bar_vector;
61 int menu_bar_items_used;
62 GCallback highlight_cb;
63 int ref_count;
64} xg_menu_cb_data;
65
66/* This structure holds callback information for each individual menu item. */
67typedef struct xg_menu_item_cb_data_
68{
69 xg_list_node ptrs;
70
f392e843
JD
71 gulong select_id;
72 Lisp_Object help;
73 gpointer call_data;
74 xg_menu_cb_data *cl_data;
177c0ea7 75
f392e843
JD
76} xg_menu_item_cb_data;
77
18e27ea8 78extern bool xg_uses_old_file_dialog (void) ATTRIBUTE_CONST;
383e0970 79
a10c8269 80extern char *xg_get_file_name (struct frame *f,
383e0970
J
81 char *prompt,
82 char *default_filename,
18e27ea8
PE
83 bool mustmatch_p,
84 bool only_dir_p);
383e0970 85
a10c8269 86extern Lisp_Object xg_get_font (struct frame *f, const char *);
383e0970 87
675e2c69
DN
88extern GtkWidget *xg_create_widget (const char *type,
89 const char *name,
a10c8269 90 struct frame *f,
42ca4633 91 struct _widget_value *val,
383e0970
J
92 GCallback select_cb,
93 GCallback deactivate_cb,
e4769531 94 GCallback highlight_cb);
383e0970
J
95
96extern void xg_modify_menubar_widgets (GtkWidget *menubar,
a10c8269 97 struct frame *f,
42ca4633 98 struct _widget_value *val,
18e27ea8 99 bool deep_p,
383e0970
J
100 GCallback select_cb,
101 GCallback deactivate_cb,
e4769531 102 GCallback highlight_cb);
383e0970 103
a10c8269 104extern void xg_update_frame_menubar (struct frame *f);
383e0970 105
b7ad2f74 106extern bool xg_event_is_for_menubar (struct frame *, const XEvent *);
fea9cabd 107
7a1b473c 108extern bool xg_have_tear_offs (struct frame *f);
383e0970 109
0eb0f318 110extern ptrdiff_t xg_get_scroll_id_for_window (Display *dpy, Window wid);
383e0970 111
a10c8269 112extern void xg_create_scroll_bar (struct frame *f,
383e0970
J
113 struct scroll_bar *bar,
114 GCallback scroll_callback,
115 GCallback end_callback,
675e2c69 116 const char *scroll_bar_name);
a10c8269 117extern void xg_remove_scroll_bar (struct frame *f, ptrdiff_t scrollbar_id);
383e0970 118
a10c8269 119extern void xg_update_scrollbar_pos (struct frame *f,
0eb0f318 120 ptrdiff_t scrollbar_id,
383e0970
J
121 int top,
122 int left,
123 int width,
124 int height);
125
126extern void xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar,
127 int portion,
128 int position,
129 int whole);
b7ad2f74 130extern bool xg_event_is_for_scrollbar (struct frame *, const XEvent *);
c195f2de 131extern int xg_get_default_scrollbar_width (void);
383e0970 132
a10c8269
DA
133extern void update_frame_tool_bar (struct frame *f);
134extern void free_frame_tool_bar (struct frame *f);
135extern void xg_change_toolbar_position (struct frame *f, Lisp_Object pos);
383e0970 136
a10c8269 137extern void xg_frame_resized (struct frame *f,
383e0970
J
138 int pixelwidth,
139 int pixelheight);
7303a0ae 140extern void xg_frame_set_char_size (struct frame *f, int width, int height);
383e0970
J
141extern GtkWidget * xg_win_to_widget (Display *dpy, Window wdesc);
142
143extern void xg_display_open (char *display_name, Display **dpy);
144extern void xg_display_close (Display *dpy);
145extern GdkCursor * xg_create_default_cursor (Display *dpy);
146
a10c8269
DA
147extern bool xg_create_frame_widgets (struct frame *f);
148extern void xg_free_frame_widgets (struct frame *f);
149extern void xg_set_background_color (struct frame *f, unsigned long bg);
18e27ea8
PE
150extern bool xg_check_special_colors (struct frame *f,
151 const char *color_name,
152 XColor *color);
383e0970 153
a10c8269 154extern void xg_set_frame_icon (struct frame *f,
383e0970
J
155 Pixmap icon_pixmap,
156 Pixmap icon_mask);
5d91377a 157
a10c8269 158extern bool xg_prepare_tooltip (struct frame *f,
18e27ea8
PE
159 Lisp_Object string,
160 int *width,
161 int *height);
a10c8269
DA
162extern void xg_show_tooltip (struct frame *f, int root_x, int root_y);
163extern bool xg_hide_tooltip (struct frame *f);
aa1859f5
J
164
165
f392e843 166/* Mark all callback data that are Lisp_object:s during GC. */
383e0970 167extern void xg_mark_data (void);
f392e843
JD
168
169/* Initialize GTK specific parts. */
383e0970 170extern void xg_initialize (void);
f392e843
JD
171
172/* Setting scrollbar values invokes the callback. Use this variable
173 to indicate that the callback should do nothing. */
18e27ea8 174extern bool xg_ignore_gtk_scrollbar;
f392e843 175
f392e843
JD
176#endif /* USE_GTK */
177#endif /* GTKUTIL_H */