Mercurial > hg > xemacs-beta
annotate src/redisplay-gtk.c @ 4882:eab9498ecc0e
merge most of rest of redisplay-x.c and redisplay-gtk.c into redisplay-xlike-inc.c
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2010-01-18 Ben Wing <ben@xemacs.org>
* redisplay-gtk.c:
* redisplay-gtk.c (gtk_bevel_area):
* redisplay-x.c:
* redisplay-x.c (THIS_IS_X):
* redisplay-xlike-inc.c:
* redisplay-xlike-inc.c (XLIKE_text_width_single_run):
* redisplay-xlike-inc.c (XLIKE_text_width):
* redisplay-xlike-inc.c (XLIKE_output_display_block):
* redisplay-xlike-inc.c (XLIKE_get_gc):
* redisplay-xlike-inc.c (XLIKE_output_string):
* 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_output_blank):
* redisplay-xlike-inc.c (XLIKE_output_horizontal_line):
* redisplay-xlike-inc.c (XLIKE_clear_region):
* redisplay-xlike-inc.c (XLIKE_output_eol_cursor):
* redisplay-xlike-inc.c (XLIKE_clear_frame_window):
* redisplay-xlike-inc.c (XLIKE_clear_frame):
* redisplay-xlike-inc.c (XLIKE_flash):
* redisplay-xlike-inc.c (console_type_create_redisplay_XLIKE):
Move lots more code into redisplay-xlike-inc.c. Use macros to
isolate the code that differs among X vs. GTK, to reduce the need
for ifdefs in the middle of the code. Now, redisplay-x.c and
redisplay-gtk.c only contain a few functions whose implementation
is completely different from one to the other, or which are not
present at all in one of them.
GTK code not currently tested, but it has bitrotted somewhat
any. Doing this will help keep it less bitrotty.
* depend: Regenerate.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Mon, 18 Jan 2010 08:44:49 -0600 |
parents | a4322ac49e37 |
children | b3ce27ca7647 |
rev | line source |
---|---|
714 | 1 /* GTK output and frame manipulation routines. |
462 | 2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. |
3 Copyright (C) 1994 Lucid, Inc. | |
4 Copyright (C) 1995 Sun Microsystems, Inc. | |
1318 | 5 Copyright (C) 2002, 2003 Ben Wing. |
462 | 6 |
7 This file is part of XEmacs. | |
8 | |
9 XEmacs is free software; you can redistribute it and/or modify it | |
10 under the terms of the GNU General Public License as published by the | |
11 Free Software Foundation; either version 2, or (at your option) any | |
12 later version. | |
13 | |
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
17 for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
20 along with XEmacs; see the file COPYING. If not, write to | |
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 Boston, MA 02111-1307, USA. */ | |
23 | |
24 /* Synched up with: Not in FSF. */ | |
25 | |
4881
a4322ac49e37
break out common separate-into-runs routines into redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
3479
diff
changeset
|
26 #include "redisplay-xlike-inc.c" |
462 | 27 |
28 /***************************************************************************** | |
29 gtk_bevel_modeline | |
30 | |
31 Draw a 3d border around the modeline on window W. | |
32 ****************************************************************************/ | |
33 static void | |
34 gtk_bevel_modeline (struct window *w, struct display_line *dl) | |
35 { | |
36 struct frame *f = XFRAME (w->frame); | |
37 int shadow_thickness = MODELINE_SHADOW_THICKNESS (w); | |
38 int x,y, width, height; | |
39 | |
40 x = WINDOW_MODELINE_LEFT (w); | |
41 width = WINDOW_MODELINE_RIGHT (w) - x; | |
42 y = dl->ypos - dl->ascent - shadow_thickness; | |
43 height = dl->ascent + dl->descent + 2 * shadow_thickness; | |
44 | |
45 gtk_output_shadows (f, x, y, width, height, shadow_thickness); | |
46 } | |
47 | |
48 /***************************************************************************** | |
49 gtk_output_shadows | |
50 | |
51 Draw a shadow around the given area using the standard theme engine routines. | |
52 ****************************************************************************/ | |
53 void | |
54 gtk_output_shadows (struct frame *f, int x, int y, int width, int height, | |
55 int shadow_thickness) | |
56 { | |
57 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f)); | |
58 GtkStyle *style = FRAME_GTK_TEXT_WIDGET (f)->style; | |
59 GtkShadowType stype = GTK_SHADOW_OUT; | |
60 | |
61 if (shadow_thickness < 0) | |
62 { | |
63 stype = GTK_SHADOW_IN; | |
64 } | |
65 else if (shadow_thickness == 0) | |
66 { | |
67 stype = GTK_SHADOW_NONE; | |
68 } | |
69 | |
70 /* Do we want to have some magic constants to set | |
71 GTK_SHADOW_ETCHED_IN or GTK_SHADOW_ETCHED_OUT? */ | |
72 | |
73 gtk_paint_shadow (style, x_win, GTK_STATE_NORMAL, stype, NULL, | |
74 FRAME_GTK_TEXT_WIDGET (f), "modeline", | |
75 x, y, width, height); | |
76 } | |
77 | |
78 static void | |
2286 | 79 gtk_bevel_area (struct window *w, face_index UNUSED (findex), |
462 | 80 int x, int y, int width, int height, |
2286 | 81 int shadow_thickness, int UNUSED (edges), |
82 enum edge_style UNUSED (style)) | |
462 | 83 { |
84 struct frame *f = XFRAME (w->frame); | |
85 | |
86 gtk_output_shadows (f, x, y, width, height, shadow_thickness); | |
87 } | |
88 | |
89 | |
90 | |
91 /* Make audible bell. */ | |
92 static void | |
2286 | 93 gtk_ring_bell (struct device *UNUSED (d), int volume, int UNUSED (pitch), |
94 int UNUSED (duration)) | |
462 | 95 { |
714 | 96 /* Gdk does not allow us to control the duration / pitch / volume */ |
97 if (volume > 0) | |
98 { | |
99 gdk_beep (); | |
100 } | |
462 | 101 } |
102 | |
103 | |
104 /* This makes me feel incredibly dirty... but there is no other way to | |
105 get this done right other than calling clear_area before every | |
106 single $#!%@ing piece of text, which I do NOT want to do. */ | |
107 #define USE_X_SPECIFIC_DRAW_ROUTINES 1 | |
108 | |
109 #include <gdk/gdkx.h> | |
110 | |
714 | 111 static |
112 void gdk_draw_text_image (GdkDrawable *drawable, | |
113 GdkFont *font, | |
114 GdkGC *gc, | |
115 gint x, | |
116 gint y, | |
117 const gchar *text, | |
118 gint text_length) | |
462 | 119 { |
120 #if !USE_X_SPECIFIC_DRAW_ROUTINES | |
121 int width = gdk_text_measure (font, text, text_length); | |
122 int height = gdk_text_height (font, text, text_length); | |
123 | |
124 gdk_draw_rectangle (drawable, gc, TRUE, x, y, width, height); | |
125 gdk_draw_text (drawable, font, gc, x, y, text, text_length); | |
126 #else | |
127 GdkWindowPrivate *drawable_private; | |
128 GdkFontPrivate *font_private; | |
129 GdkGCPrivate *gc_private; | |
130 | |
131 g_return_if_fail (drawable != NULL); | |
132 g_return_if_fail (font != NULL); | |
133 g_return_if_fail (gc != NULL); | |
134 g_return_if_fail (text != NULL); | |
135 | |
136 drawable_private = (GdkWindowPrivate*) drawable; | |
137 if (drawable_private->destroyed) | |
138 return; | |
139 gc_private = (GdkGCPrivate*) gc; | |
140 font_private = (GdkFontPrivate*) font; | |
141 | |
142 if (font->type == GDK_FONT_FONT) | |
143 { | |
144 XFontStruct *xfont = (XFontStruct *) font_private->xfont; | |
145 XSetFont(drawable_private->xdisplay, gc_private->xgc, xfont->fid); | |
146 if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0)) | |
147 { | |
148 XDrawImageString (drawable_private->xdisplay, drawable_private->xwindow, | |
149 gc_private->xgc, x, y, text, text_length); | |
150 } | |
151 else | |
152 { | |
153 XDrawImageString16 (drawable_private->xdisplay, drawable_private->xwindow, | |
154 gc_private->xgc, x, y, (XChar2b *) text, text_length / 2); | |
155 } | |
156 } | |
157 else if (font->type == GDK_FONT_FONTSET) | |
158 { | |
159 XFontSet fontset = (XFontSet) font_private->xfont; | |
160 XmbDrawImageString (drawable_private->xdisplay, drawable_private->xwindow, | |
161 fontset, gc_private->xgc, x, y, text, text_length); | |
162 } | |
163 else | |
164 g_error("undefined font type\n"); | |
165 #endif | |
166 } | |
167 | |
168 static void | |
169 our_draw_bitmap (GdkDrawable *drawable, | |
170 GdkGC *gc, | |
171 GdkPixmap *src, | |
172 gint xsrc, | |
173 gint ysrc, | |
174 gint xdest, | |
175 gint ydest, | |
176 gint width, | |
177 gint height) | |
178 { | |
179 GdkWindowPrivate *drawable_private; | |
180 GdkWindowPrivate *src_private; | |
181 GdkGCPrivate *gc_private; | |
182 | |
183 g_return_if_fail (drawable != NULL); | |
184 g_return_if_fail (src != NULL); | |
185 g_return_if_fail (gc != NULL); | |
186 | |
187 drawable_private = (GdkWindowPrivate*) drawable; | |
188 src_private = (GdkWindowPrivate*) src; | |
189 if (drawable_private->destroyed || src_private->destroyed) | |
190 return; | |
191 gc_private = (GdkGCPrivate*) gc; | |
192 | |
193 if (width == -1) | |
194 width = src_private->width; | |
195 if (height == -1) | |
196 height = src_private->height; | |
197 | |
198 XCopyPlane (drawable_private->xdisplay, | |
199 src_private->xwindow, | |
200 drawable_private->xwindow, | |
201 gc_private->xgc, | |
202 xsrc, ysrc, | |
203 width, height, | |
204 xdest, ydest, 1L); | |
205 } |