]> code.delx.au - gnu-emacs/blob - src/xwidget.h
Rework C source files to avoid ^(
[gnu-emacs] / src / xwidget.h
1 /* Support for embedding graphical components in a buffer.
2
3 Copyright (C) 2011-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 XWIDGET_H_INCLUDED
21 #define XWIDGET_H_INCLUDED
22
23 #include "lisp.h"
24
25 struct glyph_matrix;
26 struct glyph_string;
27 struct xwidget;
28 struct xwidget_view;
29 struct window;
30
31 #ifdef HAVE_XWIDGETS
32 # include <gtk/gtk.h>
33
34 struct xwidget
35 {
36 struct vectorlike_header header;
37
38 /* Auxiliary data. */
39 Lisp_Object plist;
40
41 /* The widget type. */
42 Lisp_Object type;
43
44 /* The buffer where the xwidget lives. */
45 Lisp_Object buffer;
46
47 /* A title used for button labels, for instance. */
48 Lisp_Object title;
49
50 /* Here ends the Lisp part. "height" is the marker field. */
51
52 int height;
53 int width;
54
55 /* For offscreen widgets, unused if not osr. */
56 GtkWidget *widget_osr;
57 GtkWidget *widgetwindow_osr;
58
59 /* Used if the widget (webkit) is to be wrapped in a scrolled window. */
60 GtkWidget *widgetscrolledwindow_osr;
61
62 /* Kill silently if Emacs is exited. */
63 bool_bf kill_without_query : 1;
64 };
65
66 struct xwidget_view
67 {
68 struct vectorlike_header header;
69 Lisp_Object model;
70 Lisp_Object w;
71
72 /* Here ends the lisp part. "redisplayed" is the marker field. */
73
74 /* If touched by redisplay. */
75 bool redisplayed;
76
77 /* The "live" instance isn't drawn. */
78 bool hidden;
79
80 GtkWidget *widget;
81 GtkWidget *widgetwindow;
82 GtkWidget *emacswindow;
83 int x;
84 int y;
85 int clip_right;
86 int clip_bottom;
87 int clip_top;
88 int clip_left;
89
90 long handler_id;
91 };
92 #endif
93
94 /* Test for xwidget pseudovector. */
95 #define XWIDGETP(x) PSEUDOVECTORP (x, PVEC_XWIDGET)
96 #define XXWIDGET(a) (eassert (XWIDGETP (a)), \
97 (struct xwidget *) XUNTAG (a, Lisp_Vectorlike))
98
99 #define CHECK_XWIDGET(x) \
100 CHECK_TYPE (XWIDGETP (x), Qxwidgetp, x)
101
102 /* Test for xwidget_view pseudovector. */
103 #define XWIDGET_VIEW_P(x) PSEUDOVECTORP (x, PVEC_XWIDGET_VIEW)
104 #define XXWIDGET_VIEW(a) (eassert (XWIDGET_VIEW_P (a)), \
105 (struct xwidget_view *) XUNTAG (a, Lisp_Vectorlike))
106
107 #define CHECK_XWIDGET_VIEW(x) \
108 CHECK_TYPE (XWIDGET_VIEW_P (x), Qxwidget_view_p, x)
109
110 #define XG_XWIDGET "emacs_xwidget"
111 #define XG_XWIDGET_VIEW "emacs_xwidget_view"
112
113 #ifdef HAVE_XWIDGETS
114 void syms_of_xwidget (void);
115 bool valid_xwidget_spec_p (Lisp_Object);
116 void xwidget_view_delete_all_in_window (struct window *);
117 void x_draw_xwidget_glyph_string (struct glyph_string *);
118 struct xwidget *lookup_xwidget (Lisp_Object spec);
119 void xwidget_end_redisplay (struct window *, struct glyph_matrix *);
120 void kill_buffer_xwidgets (Lisp_Object);
121 #else
122 INLINE_HEADER_BEGIN
123 INLINE void syms_of_xwidget (void) {}
124 INLINE bool valid_xwidget_spec_p (Lisp_Object obj) { return false; }
125 INLINE void xwidget_view_delete_all_in_window (struct window *w) {}
126 INLINE void x_draw_xwidget_glyph_string (struct glyph_string *s) { eassume (0); }
127 INLINE struct xwidget *lookup_xwidget (Lisp_Object obj) { eassume (0); }
128 INLINE void xwidget_end_redisplay (struct window *w, struct glyph_matrix *m) {}
129 INLINE void kill_buffer_xwidgets (Lisp_Object buf) {}
130 INLINE_HEADER_END
131 #endif
132
133 #endif /* XWIDGET_H_INCLUDED */