]> code.delx.au - gnu-emacs/blob - src/gtkutil.h
Cleanup tooltips
[gnu-emacs] / src / gtkutil.h
1 /* Definitions and headers for GTK widgets.
2
3 Copyright (C) 2003-2016 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 <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 "xterm.h"
29
30 /* Minimum and maximum values used for GTK scroll bars */
31
32 #define XG_SB_MIN 1
33 #define XG_SB_MAX 10000000
34 #define XG_SB_RANGE (XG_SB_MAX-XG_SB_MIN)
35 #define YG_SB_MIN 1
36 #define YG_SB_MAX 10000000
37 #define YG_SB_RANGE (YG_SB_MAX-YG_SB_MIN)
38
39 /* Key for data that is valid for menus and scroll bars in a frame */
40 #define XG_FRAME_DATA "emacs_frame"
41
42 /* Key for data that menu items hold. */
43 #define XG_ITEM_DATA "emacs_menuitem"
44
45 /* This is a list node in a generic list implementation. */
46 typedef struct xg_list_node_
47 {
48 struct xg_list_node_ *prev;
49 struct xg_list_node_ *next;
50 } xg_list_node;
51
52 /* This structure is the callback data that is shared for menu items.
53 We need to keep it separate from the frame structure due to
54 detachable menus. The data in the frame structure is only valid while
55 the menu is popped up. This structure is kept around as long as
56 the menu is. */
57 typedef struct xg_menu_cb_data_
58 {
59 xg_list_node ptrs;
60
61 struct frame *f;
62 Lisp_Object menu_bar_vector;
63 int menu_bar_items_used;
64 GCallback highlight_cb;
65 int ref_count;
66 } xg_menu_cb_data;
67
68 /* This structure holds callback information for each individual menu item. */
69 typedef struct xg_menu_item_cb_data_
70 {
71 xg_list_node ptrs;
72
73 gulong select_id;
74 Lisp_Object help;
75 gpointer call_data;
76 xg_menu_cb_data *cl_data;
77
78 } xg_menu_item_cb_data;
79
80 extern bool xg_uses_old_file_dialog (void);
81
82 extern char *xg_get_file_name (struct frame *f,
83 char *prompt,
84 char *default_filename,
85 bool mustmatch_p,
86 bool only_dir_p);
87
88 extern Lisp_Object xg_get_font (struct frame *f, const char *);
89
90 extern GtkWidget *xg_create_widget (const char *type,
91 const char *name,
92 struct frame *f,
93 struct _widget_value *val,
94 GCallback select_cb,
95 GCallback deactivate_cb,
96 GCallback highlight_cb);
97
98 extern void xg_modify_menubar_widgets (GtkWidget *menubar,
99 struct frame *f,
100 struct _widget_value *val,
101 bool deep_p,
102 GCallback select_cb,
103 GCallback deactivate_cb,
104 GCallback highlight_cb);
105
106 extern void xg_update_frame_menubar (struct frame *f);
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);
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_create_horizontal_scroll_bar (struct frame *f,
118 struct scroll_bar *bar,
119 GCallback scroll_callback,
120 GCallback end_callback,
121 const char *scroll_bar_name);
122 extern void xg_remove_scroll_bar (struct frame *f, ptrdiff_t scrollbar_id);
123
124 extern void xg_update_scrollbar_pos (struct frame *f,
125 ptrdiff_t scrollbar_id,
126 int top,
127 int left,
128 int width,
129 int height);
130 extern void xg_update_horizontal_scrollbar_pos (struct frame *f,
131 ptrdiff_t scrollbar_id,
132 int top,
133 int left,
134 int width,
135 int height);
136
137 extern void xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar,
138 int portion,
139 int position,
140 int whole);
141 extern void xg_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar,
142 int portion,
143 int position,
144 int whole);
145 extern bool xg_event_is_for_scrollbar (struct frame *, const XEvent *);
146 extern int xg_get_default_scrollbar_width (void);
147 extern int xg_get_default_scrollbar_height (void);
148
149 extern void update_frame_tool_bar (struct frame *f);
150 extern void free_frame_tool_bar (struct frame *f);
151 extern void xg_change_toolbar_position (struct frame *f, Lisp_Object pos);
152
153 extern void xg_clear_under_internal_border (struct frame *f);
154 extern void xg_frame_resized (struct frame *f,
155 int pixelwidth,
156 int pixelheight);
157 extern void xg_frame_set_char_size (struct frame *f, int width, int height);
158 extern GtkWidget * xg_win_to_widget (Display *dpy, Window wdesc);
159
160 extern void xg_display_open (char *display_name, Display **dpy);
161 extern void xg_display_close (Display *dpy);
162 extern GdkCursor * xg_create_default_cursor (Display *dpy);
163
164 extern bool xg_create_frame_widgets (struct frame *f);
165 extern void xg_free_frame_widgets (struct frame *f);
166 extern void xg_set_background_color (struct frame *f, unsigned long bg);
167 extern bool xg_check_special_colors (struct frame *f,
168 const char *color_name,
169 XColor *color);
170
171 extern void xg_set_frame_icon (struct frame *f,
172 Pixmap icon_pixmap,
173 Pixmap icon_mask);
174
175 extern bool xg_prepare_tooltip (struct frame *f,
176 Lisp_Object string,
177 int *width,
178 int *height);
179 extern void xg_show_tooltip (struct frame *f, int root_x, int root_y);
180 extern bool xg_hide_tooltip (struct frame *f);
181 extern gboolean xg_hide_tip (gpointer data);
182
183 #ifdef USE_CAIRO
184 extern void xg_page_setup_dialog (void);
185 extern Lisp_Object xg_get_page_setup (void);
186 extern void xg_print_frames_dialog (Lisp_Object);
187 #endif
188
189 /* Mark all callback data that are Lisp_object:s during GC. */
190 extern void xg_mark_data (void);
191
192 /* Initialize GTK specific parts. */
193 extern void xg_initialize (void);
194
195 /* Setting scrollbar values invokes the callback. Use this variable
196 to indicate that the callback should do nothing. */
197 extern bool xg_ignore_gtk_scrollbar;
198
199 #endif /* USE_GTK */
200 #endif /* GTKUTIL_H */