guile-elisp bootstrap (lisp)
[bpt/emacs.git] / src / gtkutil.h
1 /* Definitions and headers for GTK widgets.
2
3 Copyright (C) 2003-2014 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
10 (at 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 <http://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 #include "frame.h"
29 #include "xterm.h"
30
31 /* Minimum and maximum values used for GTK scroll bars */
32
33 #define XG_SB_MIN 1
34 #define XG_SB_MAX 10000000
35 #define XG_SB_RANGE (XG_SB_MAX-XG_SB_MIN)
36
37 /* Key for data that is valid for menus and scroll bars in a frame */
38 #define XG_FRAME_DATA "emacs_frame"
39
40 /* Key for data that menu items hold. */
41 #define XG_ITEM_DATA "emacs_menuitem"
42
43 /* This is a list node in a generic list implementation. */
44 typedef 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. */
55 typedef struct xg_menu_cb_data_
56 {
57 xg_list_node ptrs;
58
59 struct frame *f;
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. */
67 typedef struct xg_menu_item_cb_data_
68 {
69 xg_list_node ptrs;
70
71 gulong select_id;
72 Lisp_Object help;
73 gpointer call_data;
74 xg_menu_cb_data *cl_data;
75
76 } xg_menu_item_cb_data;
77
78 extern bool xg_uses_old_file_dialog (void) ATTRIBUTE_CONST;
79
80 extern char *xg_get_file_name (struct frame *f,
81 char *prompt,
82 char *default_filename,
83 bool mustmatch_p,
84 bool only_dir_p);
85
86 extern Lisp_Object xg_get_font (struct frame *f, const char *);
87
88 extern GtkWidget *xg_create_widget (const char *type,
89 const char *name,
90 struct frame *f,
91 struct _widget_value *val,
92 GCallback select_cb,
93 GCallback deactivate_cb,
94 GCallback highlight_cb);
95
96 extern void xg_modify_menubar_widgets (GtkWidget *menubar,
97 struct frame *f,
98 struct _widget_value *val,
99 bool deep_p,
100 GCallback select_cb,
101 GCallback deactivate_cb,
102 GCallback highlight_cb);
103
104 extern void xg_update_frame_menubar (struct frame *f);
105
106 extern bool xg_event_is_for_menubar (struct frame *, const XEvent *);
107
108 extern bool xg_have_tear_offs (struct frame *f);
109
110 extern ptrdiff_t xg_get_scroll_id_for_window (Display *dpy, Window wid);
111
112 extern void xg_create_scroll_bar (struct frame *f,
113 struct scroll_bar *bar,
114 GCallback scroll_callback,
115 GCallback end_callback,
116 const char *scroll_bar_name);
117 extern void xg_remove_scroll_bar (struct frame *f, ptrdiff_t scrollbar_id);
118
119 extern void xg_update_scrollbar_pos (struct frame *f,
120 ptrdiff_t scrollbar_id,
121 int top,
122 int left,
123 int width,
124 int height);
125
126 extern void xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar,
127 int portion,
128 int position,
129 int whole);
130 extern bool xg_event_is_for_scrollbar (struct frame *, const XEvent *);
131 extern int xg_get_default_scrollbar_width (void);
132
133 extern void update_frame_tool_bar (struct frame *f);
134 extern void free_frame_tool_bar (struct frame *f);
135 extern void xg_change_toolbar_position (struct frame *f, Lisp_Object pos);
136
137 extern void xg_frame_resized (struct frame *f,
138 int pixelwidth,
139 int pixelheight);
140 extern void xg_frame_set_char_size (struct frame *f, int width, int height);
141 extern GtkWidget * xg_win_to_widget (Display *dpy, Window wdesc);
142
143 extern void xg_display_open (char *display_name, Display **dpy);
144 extern void xg_display_close (Display *dpy);
145 extern GdkCursor * xg_create_default_cursor (Display *dpy);
146
147 extern bool xg_create_frame_widgets (struct frame *f);
148 extern void xg_free_frame_widgets (struct frame *f);
149 extern void xg_set_background_color (struct frame *f, unsigned long bg);
150 extern bool xg_check_special_colors (struct frame *f,
151 const char *color_name,
152 XColor *color);
153
154 extern void xg_set_frame_icon (struct frame *f,
155 Pixmap icon_pixmap,
156 Pixmap icon_mask);
157
158 extern bool xg_prepare_tooltip (struct frame *f,
159 Lisp_Object string,
160 int *width,
161 int *height);
162 extern void xg_show_tooltip (struct frame *f, int root_x, int root_y);
163 extern bool xg_hide_tooltip (struct frame *f);
164
165
166 /* Mark all callback data that are Lisp_object:s during GC. */
167 extern void xg_mark_data (void);
168
169 /* Initialize GTK specific parts. */
170 extern void xg_initialize (void);
171
172 /* Setting scrollbar values invokes the callback. Use this variable
173 to indicate that the callback should do nothing. */
174 extern bool xg_ignore_gtk_scrollbar;
175
176 #endif /* USE_GTK */
177 #endif /* GTKUTIL_H */