Merge from origin/emacs-25
[emacs.git] / src / xwidget.h
blobd43b40179652fd70c66572704b3f696e6725dfb4
1 /* Support for embedding graphical components in a buffer.
3 Copyright (C) 2011-2017 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
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.
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.
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/>. */
20 #ifndef XWIDGET_H_INCLUDED
21 #define XWIDGET_H_INCLUDED
23 #include "lisp.h"
25 struct glyph_matrix;
26 struct glyph_string;
27 struct xwidget;
28 struct xwidget_view;
29 struct window;
31 #ifdef HAVE_XWIDGETS
32 # include <gtk/gtk.h>
34 struct xwidget
36 struct vectorlike_header header;
38 /* Auxiliary data. */
39 Lisp_Object plist;
41 /* The widget type. */
42 Lisp_Object type;
44 /* The buffer where the xwidget lives. */
45 Lisp_Object buffer;
47 /* A title used for button labels, for instance. */
48 Lisp_Object title;
50 /* Here ends the Lisp part. "height" is the marker field. */
52 int height;
53 int width;
55 /* For offscreen widgets, unused if not osr. */
56 GtkWidget *widget_osr;
57 GtkWidget *widgetwindow_osr;
59 /* Kill silently if Emacs is exited. */
60 bool_bf kill_without_query : 1;
63 struct xwidget_view
65 struct vectorlike_header header;
66 Lisp_Object model;
67 Lisp_Object w;
69 /* Here ends the lisp part. "redisplayed" is the marker field. */
71 /* If touched by redisplay. */
72 bool redisplayed;
74 /* The "live" instance isn't drawn. */
75 bool hidden;
77 GtkWidget *widget;
78 GtkWidget *widgetwindow;
79 GtkWidget *emacswindow;
80 int x;
81 int y;
82 int clip_right;
83 int clip_bottom;
84 int clip_top;
85 int clip_left;
87 long handler_id;
89 #endif
91 /* Test for xwidget pseudovector. */
92 #define XWIDGETP(x) PSEUDOVECTORP (x, PVEC_XWIDGET)
93 #define XXWIDGET(a) (eassert (XWIDGETP (a)), \
94 (struct xwidget *) XUNTAG (a, Lisp_Vectorlike))
96 #define CHECK_XWIDGET(x) \
97 CHECK_TYPE (XWIDGETP (x), Qxwidgetp, x)
99 /* Test for xwidget_view pseudovector. */
100 #define XWIDGET_VIEW_P(x) PSEUDOVECTORP (x, PVEC_XWIDGET_VIEW)
101 #define XXWIDGET_VIEW(a) (eassert (XWIDGET_VIEW_P (a)), \
102 (struct xwidget_view *) XUNTAG (a, Lisp_Vectorlike))
104 #define CHECK_XWIDGET_VIEW(x) \
105 CHECK_TYPE (XWIDGET_VIEW_P (x), Qxwidget_view_p, x)
107 #define XG_XWIDGET "emacs_xwidget"
108 #define XG_XWIDGET_VIEW "emacs_xwidget_view"
110 #ifdef HAVE_XWIDGETS
111 void syms_of_xwidget (void);
112 bool valid_xwidget_spec_p (Lisp_Object);
113 void xwidget_view_delete_all_in_window (struct window *);
114 void x_draw_xwidget_glyph_string (struct glyph_string *);
115 struct xwidget *lookup_xwidget (Lisp_Object spec);
116 void xwidget_end_redisplay (struct window *, struct glyph_matrix *);
117 void kill_buffer_xwidgets (Lisp_Object);
118 #else
119 INLINE_HEADER_BEGIN
120 INLINE void syms_of_xwidget (void) {}
121 INLINE bool valid_xwidget_spec_p (Lisp_Object obj) { return false; }
122 INLINE void xwidget_view_delete_all_in_window (struct window *w) {}
123 INLINE void x_draw_xwidget_glyph_string (struct glyph_string *s) { eassume (0); }
124 INLINE struct xwidget *lookup_xwidget (Lisp_Object obj) { eassume (0); }
125 INLINE void xwidget_end_redisplay (struct window *w, struct glyph_matrix *m) {}
126 INLINE void kill_buffer_xwidgets (Lisp_Object buf) {}
127 INLINE_HEADER_END
128 #endif
130 #endif /* XWIDGET_H_INCLUDED */