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