comparison src/console-xlike-inc.h @ 4908:b3ce27ca7647

various fixes related to gtk, redisplay-xlike-inc.c -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2010-02-01 Ben Wing <ben@xemacs.org> * compiler.h: Create a USED() macro to force unused-var warnings to go away, in certain cases where it's inconvenient to do otherwise (e.g. when THIS_IS_GTK in redisplay-xlike-inc.c). * console-x.h: Remove unneeded decls, make some static. * redisplay-xlike-inc.c: * console-xlike-inc.h: New file. Include defns from redisplay-xlike-inc.c that may be useful in other XLIKE files. Correct the handling of colors and font-style setting functions in the xlike defns. Lots of fixes in the GTK-specific defns. * depend: Regenerate. * event-xlike-inc.c: * event-xlike-inc.c (USE_UNICODE_MAP): * event-xlike-inc.c (endif): * gccache-gtk.c: * gtk-glue.c (xemacs_list_to_gtklist): * gtk-glue.c (xemacs_gtklist_to_list): * gtk-glue.c (FROB): * gtk-glue.c (face_to_gc): * gtk-glue.c (face_to_style): * gtk-glue.c (gdk_event_to_emacs_event): * gtk-xemacs.h (struct _GtkXEmacs): * gtk-xemacs.h (struct _GtkXEmacsClass): * objects-xlike-inc.c: Cosmetic, comment fixes. * glyphs.c (pixmap_to_lisp_data): Unused var fixes. * gtk-glue.c: * gccache-gtk.c: * gtk-xemacs.c: * gtk-xemacs.h: * objects-xlike-inc.c: * ui-gtk.c: * ui-gtk.h: * xgccache.c: * xgccache.c (GC_CACHE_SIZE): * xgccache.h: Misc include-file fixes. * objects-xlike-inc.c (XFUN): * objects-xlike-inc.c (xlistfonts_checking_charset): Combine some ifdeffed stuff using defs in console-xlike-inc.h. * redisplay-gtk.c: * redisplay-gtk.c (THIS_IS_GTK): * redisplay-gtk.c (XLIKE_bevel_area): * redisplay-gtk.c (XLIKE_ring_bell): * redisplay-gtk.c (gdk_draw_text_image): Fix numerous compile problems. Delete gtk_output_shadows(), which mostly duplicates generic bevel_modeline(). Fix up gtk_bevel_modeline() into XLIKE_bevel_area() and make use of the style var properly to set the appropriate GTK constant. * redisplay-x.c: * redisplay-x.c (XLIKE_window_output_begin): * redisplay-x.c (XLIKE_window_output_end): * redisplay-x.c (XLIKE_bevel_area): * redisplay-x.c (x_output_shadows): * redisplay-x.c (XLIKE_ring_bell): Make x_output_shadows be static. Change the defn of various functions to look like XLIKE_foo() so it matches the calling convention elsewhere. * redisplay-xlike-inc.c: * redisplay-xlike-inc.c (NEED_GCCACHE_H): * redisplay-xlike-inc.c (XLIKE_text_width): * redisplay-xlike-inc.c (XLIKE_get_gc): * redisplay-xlike-inc.c (XLIKE_text_width_single_run): * redisplay-xlike-inc.c (XFT_FROB_LISP_COLOR): * redisplay-xlike-inc.c (XLIKE_output_xlike_pixmap): * redisplay-xlike-inc.c (XLIKE_output_pixmap): * redisplay-xlike-inc.c (XLIKE_output_vertical_divider): * redisplay-xlike-inc.c (XLIKE_flash): Lots of header fixes. Lots of stuff moved to console-xlike-inc.h. Use XFUN() to generate function names instead of directly calling XLIKE_PASTE(). Remove unnecessary prototypes. Unify calls to text_width funs. Make XLIKE_get_gc non-static since it's called from gtk. Change the color-function calls and fill-style-setting calls to match the changes in console-xlike-inc.h. Use USED() to avoid some warnings. * symsinit.h: Sort the prototypes, and add a fun `sort-symsinit' in a comment that does the sorting (using sort-regexp-fields). * symsinit.h (init_number): * sysgtk.h: New file, wraps the various GTK headers. * sysgdkx.h: New file, wraps <gtk/gdkx.h>. Keep this separate to * event-gtk.h: Delete. Combine stuff into console-gtk.h. help isolate X-specific code from GTK. * device-gtk.c: * event-gtk.c: * console-gtk.h: * frame-gtk.c: * gccache-gtk.c: * gccache-gtk.h: * glyphs-gtk.c (gtk_colorize_image_instance): * glyphs-gtk.h: * gtk-xemacs.h: * objects-gtk.c: * objects-gtk.c (MAX_FONT_COUNT): * ui-gtk.h: Use sysgtk.h or sysgdkx.h instead of directly including GTK headers. Don't include event-gtk.h.
author Ben Wing <ben@xemacs.org>
date Mon, 01 Feb 2010 02:15:28 -0600
parents
children a6c778975d7d
comparison
equal deleted inserted replaced
4907:9e7f5a77cc84 4908:b3ce27ca7647
1 /* Definitions for use in *-xlike-inc.c files.
2 Copyright (C) 2010 Ben Wing.
3
4 This file is part of XEmacs.
5
6 XEmacs is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
10
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with XEmacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21 /* Synched up with: Not in FSF. */
22
23 #ifndef INCLUDED_console_xlike_inc_h_
24 #define INCLUDED_console_xlike_inc_h_
25
26 /* X and GTK are quite similar, since GTK based its structure on Xlib.
27 However, there are many small differences. Creating two separate
28 versions of the code, as Bill Perry did originally, is easier to code
29 but hard to maintain and leads to bit rot. On the other hand, trying to
30 abstract out into device methods, as is done generally for different
31 window systems, gets very hairy very quickly because the differences are
32 on the level of individual library functions, constants and types, of
33 which there are large number. Abstracting them into device methods
34 would lead to a large number of very small functions and very
35 hard-to-read code.
36
37 Instead, we handle the situation by having only one copy, placed in a
38 file called *-xlike-inc.c (e.g. redisplay-xlike-inc.c) and
39 conditionalizing using ifdefs. Because we can compile with both X and
40 GTK at once, we include this file inside of the appropriate
41 device-specific file (e.g. redisplay-gtk.c or redisplay-x.c). The `inc'
42 in *-xlike-inc.c indicates that this is a file meant to be included in
43 another file, despite the fact that it is a .c file.
44
45 To signal which variety of "xlike" we are compiling for, either
46 THIS_IS_X or THIS_IS_GTK needs to be defined, prior to including the
47 *-xlike-inc.c file. */
48
49
50 /* About the representation of color below:
51
52 X has two ways of representing a color: (a) as an unsigned long
53 representing a color pixel value, i.e. the actual value stored in memory
54 or a file at a particular pixel location to indicate that the pixel
55 takes on a specific color; and (b) an XColor structure, which
56 encapsulates both the RGB components of a color and the associated color
57 pixel value.
58
59 We call the former type XLIKE_PIXEL and the latter XLIKE_COLOR, along
60 with routines to convert from one to the other. Differences between the
61 two in specific functions and structures should be abstracted using the
62 XLIKE_FOO() routines, e.g. XLIKE_SET_GC_COLOR(). */
63
64 #if defined (THIS_IS_X) && defined (THIS_IS_GTK)
65 #error "Exactly one of THIS_IS_X and THIS_IS_GTK may be defined."
66 #endif
67
68 #if !defined (THIS_IS_X) && !defined (THIS_IS_GTK)
69 #error "Either THIS_IS_X or THIS_IS_GTK must be defined."
70 #endif
71
72 #ifdef THIS_IS_X
73 # include "console-x-impl.h"
74 # ifdef NEED_GCCACHE_H
75 # include "xgccache.h"
76 # endif
77 # ifdef NEED_GLYPHS_H
78 # include "glyphs-x.h"
79 # endif
80 # ifdef NEED_OBJECTS_IMPL_H
81 # include "objects-x-impl.h"
82 # endif
83 #else /* THIS_IS_GTK */
84 # include "console-gtk-impl.h"
85 # ifdef NEED_GCCACHE_H
86 # include "gccache-gtk.h"
87 # endif
88 # ifdef NEED_GLYPHS_H
89 # include "glyphs-gtk.h"
90 # endif
91 # ifdef NEED_OBJECTS_IMPL_H
92 # include "objects-gtk-impl.h"
93 # endif
94 #endif /* THIS_IS_GTK */
95
96 /***************************************************************************/
97 /* Common definitions */
98 /***************************************************************************/
99
100 #define XLIKE_PASTE_1(a,b) a##_##b
101 #define XLIKE_PASTE(a,b) XLIKE_PASTE_1(a,b)
102 #define XFUN(name) XLIKE_PASTE (XLIKE_NAME, name)
103
104 #define XLIKE_CONSOLE_HAS_METHOD_1(xlike, name) CONSOLE_HAS_METHOD (xlike, name)
105 #define XLIKE_CONSOLE_HAS_METHOD(name) \
106 XLIKE_CONSOLE_HAS_METHOD_1 (XLIKE_NAME, name)
107
108 #define XCOLOR_INSTANCE_XLIKE_COLOR(x) \
109 COLOR_INSTANCE_XLIKE_COLOR (XCOLOR_INSTANCE (x))
110
111 #ifdef THIS_IS_X
112
113 /***************************************************************************/
114 /* Definitions implementing X flavor of XLIKE */
115 /***************************************************************************/
116
117 #define XLIKE_NAME x
118 #define USED_IF_X(var) var
119 #define USED_IF_GTK(var) UNUSED (var)
120
121 /* types */
122 typedef Display * XLIKE_DISPLAY;
123 typedef Window XLIKE_WINDOW;
124 typedef GC XLIKE_GC;
125 typedef XRectangle XLIKE_RECTANGLE;
126 typedef XGCValues XLIKE_GCVALUES;
127 typedef XColor XLIKE_COLOR;
128 typedef unsigned long XLIKE_PIXEL;
129
130 /* constants */
131 #define XLIKE_NONE None
132 #define XLIKE_FALSE False
133
134 #define XLIKE_GC_BACKGROUND GCBackground
135 #define XLIKE_GC_CLIP_MASK GCClipMask
136 #define XLIKE_GC_CLIP_X_ORIGIN GCClipXOrigin
137 #define XLIKE_GC_CLIP_Y_ORIGIN GCClipYOrigin
138 #define XLIKE_GC_EXPOSURES GCGraphicsExposures
139 #define XLIKE_GC_FILL GCFillStyle
140 #define XLIKE_GC_FONT GCFont
141 #define XLIKE_GC_FOREGROUND GCForeground
142 #define XLIKE_GC_FUNCTION GCFunction
143 #define XLIKE_GC_LINE_WIDTH GCLineWidth
144 #define XLIKE_GC_STIPPLE GCStipple
145 #define XLIKE_GC_TILE GCTile
146
147 #define XLIKE_GX_COPY GXcopy
148 #define XLIKE_GX_XOR GXxor
149
150 #define XLIKE_FILL_STIPPLED FillStippled
151 #define XLIKE_FILL_OPAQUE_STIPPLED FillOpaqueStippled
152 #define XLIKE_FILL_TILED FillTiled
153 #define XLIKE_FILL_SOLID FillSolid
154
155 /* functions */
156 #define GET_XLIKE_DISPLAY(d) DEVICE_X_DISPLAY (d)
157 #define GET_XLIKE_X_DISPLAY(d) DEVICE_X_DISPLAY (d)
158 #define GET_XLIKE_WINDOW(w) XtWindow (FRAME_X_TEXT_WIDGET (f))
159 #define XLIKE_FILL_RECTANGLE(dpy, x_win, gc, x, y, width, height) \
160 XFillRectangle (dpy, x_win, gc, x, y, width, height)
161 #define XLIKE_DRAW_RECTANGLE(dpy, x_win, gc, x, y, width, height) \
162 XDrawRectangle (dpy, x_win, gc, x, y, width, height)
163 #define XLIKE_DRAW_LINE(dpy, x_win, gc, x1, y1, x2, y2) \
164 XDrawLine (dpy, x_win, gc, x1, y1, x2, y2)
165 #define XLIKE_TEXT_WIDTH(fi, ptr, len) XTextWidth (fi, (char *) ptr, len)
166 #define XLIKE_TEXT_WIDTH_WIDE(fi, ptr, len) XTextWidth16 (fi, (XChar2b *) ptr, len)
167
168 #define XLIKE_DISPLAY_LINE_HEIGHT(dl) DISPLAY_LINE_HEIGHT (dl)
169 #define XLIKE_DISPLAY_LINE_YPOS(dl) DISPLAY_LINE_YPOS (dl)
170 #define XLIKE_DISPLAY_LINE_TOP_CLIP(dl) ((dl)->top_clip)
171 #define XLIKE_SET_CLIP_RECTANGLE(dpy, gc, xorig, yorig, prect) \
172 /* #### why not Unsorted? */ \
173 XSetClipRectangles (dpy, gc, xorig, yorig, prect, 1, YXBanded)
174 #define XLIKE_CLEAR_CLIP_MASK(dpy, gc) \
175 do \
176 { \
177 XSetClipMask (dpy, gc, None); \
178 XSetClipOrigin (dpy, gc, 0, 0); \
179 } \
180 while (0)
181 #define XLIKE_FLUSH(dpy) XSync (dpy, False)
182 #define XLIKE_CLEAR_AREA(dpy, win, x, y, width, height) \
183 XClearArea (dpy, win, x, y, width, height, False)
184
185 #define IMAGE_INSTANCE_XLIKE_MASK IMAGE_INSTANCE_X_MASK
186 #define XIMAGE_INSTANCE_XLIKE_PIXMAP XIMAGE_INSTANCE_X_PIXMAP
187 #define COLOR_INSTANCE_XLIKE_COLOR COLOR_INSTANCE_X_COLOR
188 #define FONT_INSTANCE_XLIKE_FONT FONT_INSTANCE_X_FONT
189 #define DEVICE_XLIKE_GC_CACHE DEVICE_X_GC_CACHE
190 #define DEVICE_XLIKE_GRAY_PIXMAP DEVICE_X_GRAY_PIXMAP
191 #define XLIKE_SET_GC_FILL(gc, style) ((gc).fill_style = (style))
192 #define XLIKE_COLOR_TO_PIXEL(c) ((c).pixel)
193 #define XLIKE_SET_GC_COLOR(lval, rval) ((lval) = (rval).pixel)
194 #define XLIKE_SET_GC_PIXEL(lval, rval) ((lval) = (rval))
195 #define XLIKE_FONT_NUM(val) ((val)->fid)
196
197 /************ End X flavor of XLIKE **********/
198
199
200 #else /* THIS_IS_GTK */
201
202 /***************************************************************************/
203 /* Definitions implementing GTK flavor of XLIKE */
204 /***************************************************************************/
205
206 #define XLIKE_NAME gtk
207 #define USED_IF_X(var) UNUSED (var)
208 #define USED_IF_GTK(var) var
209
210 /*types */
211 typedef void * XLIKE_DISPLAY;
212 typedef GdkWindow * XLIKE_WINDOW;
213 typedef GdkGC * XLIKE_GC;
214 typedef GdkRectangle XLIKE_RECTANGLE;
215 typedef GdkGCValues XLIKE_GCVALUES;
216 typedef GdkColor XLIKE_COLOR;
217 typedef gulong XLIKE_PIXEL;
218
219 /* constants */
220 #define XLIKE_NONE 0
221 #define XLIKE_FALSE FALSE
222
223 #define XLIKE_GC_BACKGROUND GDK_GC_BACKGROUND
224 #define XLIKE_GC_CLIP_MASK GDK_GC_CLIP_MASK
225 #define XLIKE_GC_CLIP_X_ORIGIN GDK_GC_CLIP_X_ORIGIN
226 #define XLIKE_GC_CLIP_Y_ORIGIN GDK_GC_CLIP_Y_ORIGIN
227 #define XLIKE_GC_EXPOSURES GDK_GC_EXPOSURES
228 #define XLIKE_GC_FILL GDK_GC_FILL
229 #define XLIKE_GC_FONT GDK_GC_FONT
230 #define XLIKE_GC_FOREGROUND GDK_GC_FOREGROUND
231 #define XLIKE_GC_FUNCTION GDK_GC_FUNCTION
232 #define XLIKE_GC_LINE_WIDTH GDK_GC_LINE_WIDTH
233 #define XLIKE_GC_STIPPLE GDK_GC_STIPPLE
234 #define XLIKE_GC_TILE GDK_GC_TILE
235
236 #define XLIKE_GX_COPY GDK_COPY
237 #define XLIKE_GX_XOR GDK_XOR
238
239 #define XLIKE_FILL_STIPPLED GDK_STIPPLED
240 #define XLIKE_FILL_OPAQUE_STIPPLED GDK_OPAQUE_STIPPLED
241 #define XLIKE_FILL_TILED GDK_TILED
242 #define XLIKE_FILL_SOLID GDK_SOLID
243
244 /* functions */
245
246 /* Avoid unused-variable warning involving D */
247 #define GET_XLIKE_DISPLAY(d) (USED (d), NULL)
248 #define GET_XLIKE_X_DISPLAY(d) (USED (d), GDK_DISPLAY ())
249 #define GET_XLIKE_WINDOW(w) GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (w))
250 #define XLIKE_FILL_RECTANGLE(dpy, x_win, gc, x, y, width, height) \
251 (USED (dpy), gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, TRUE, \
252 x, y, width, height))
253 #define XLIKE_DRAW_RECTANGLE(dpy, x_win, gc, x, y, width, height) \
254 (USED (dpy), gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, FALSE, \
255 x, y, width, height))
256 #define XLIKE_DRAW_LINE(dpy, x_win, gc, x1, y1, x2, y2) \
257 (USED (dpy), gdk_draw_line (GDK_DRAWABLE (x_win), gc, x1, y1, x2, y2))
258 #define XLIKE_TEXT_WIDTH(fi, ptr, len) \
259 gdk_text_width (fi, (char *) ptr, len)
260 #define XLIKE_TEXT_WIDTH_WIDE(fi, ptr, len) \
261 gdk_text_width_wc (fi, (GdkWChar *) ptr, len)
262
263 /* FIXME: This is totally bogus. It removes dl->top_clip from the
264 equations. If there is a bug involving this, fix it properly!
265 Or just ensure that top_clip is 0. */
266 #define XLIKE_DISPLAY_LINE_HEIGHT(dl) \
267 ((dl)->ascent + (dl)->descent - (dl)->clip)
268 #define XLIKE_DISPLAY_LINE_YPOS(dl) ((dl)->ypos - (dl)->ascent)
269 #define XLIKE_DISPLAY_LINE_TOP_CLIP(dl) (0)
270 #define XLIKE_SET_CLIP_RECTANGLE(dpy, gc, xorig, yorig, prect) \
271 do \
272 { \
273 USED (dpy); \
274 gdk_gc_set_clip_rectangle (gc, prect); \
275 gdk_gc_set_clip_origin (gc, xorig, yorig); \
276 } \
277 while (0)
278 #define XLIKE_CLEAR_CLIP_MASK(dpy, gc) \
279 do \
280 { \
281 USED (dpy); \
282 gdk_gc_set_clip_rectangle (gc, NULL); \
283 gdk_gc_set_clip_origin (gc, 0, 0); \
284 } \
285 while (0)
286 #define XLIKE_FLUSH(dpy) gdk_flush ()
287 #define XLIKE_CLEAR_AREA(dpy, win, x, y, width, height) \
288 (USED (dpy), gdk_window_clear_area (win, x, y, width, height))
289
290 #define IMAGE_INSTANCE_XLIKE_MASK IMAGE_INSTANCE_GTK_MASK
291 #define XIMAGE_INSTANCE_XLIKE_PIXMAP XIMAGE_INSTANCE_GTK_PIXMAP
292 #define COLOR_INSTANCE_XLIKE_COLOR(ci) (*COLOR_INSTANCE_GTK_COLOR (ci))
293 #define FONT_INSTANCE_XLIKE_FONT FONT_INSTANCE_GTK_FONT
294 #define DEVICE_XLIKE_GRAY_PIXMAP DEVICE_GTK_GRAY_PIXMAP
295 #define DEVICE_XLIKE_GC_CACHE DEVICE_GTK_GC_CACHE
296 #define XLIKE_SET_GC_FILL(gc, style) ((gc).fill = (style))
297 #define XLIKE_COLOR_TO_PIXEL(c) ((c).pixel)
298 #define XLIKE_SET_GC_COLOR(lval, rval) ((lval) = (rval))
299 #define XLIKE_SET_GC_PIXEL(lval, rval) ((lval).pixel = (rval))
300 #define XLIKE_FONT_NUM(val) (val)
301
302 /************ End GTK flavor of XLIKE **********/
303
304 #endif /* (not) THIS_IS_X */
305
306
307 #endif /* INCLUDED_console_xlike_inc_h_ */