Mercurial > hg > xemacs-beta
annotate src/redisplay-gtk.c @ 5437:002cb5224e4f
Merge with 21.5 trunk.
| author | Mats Lidell <matsl@xemacs.org> |
|---|---|
| date | Mon, 15 Nov 2010 22:33:52 +0100 |
| parents | 308d34e9f07d |
| children | 574f0cded429 |
| 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 | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4908
diff
changeset
|
9 XEmacs is free software: you can redistribute it and/or modify it |
| 462 | 10 under the terms of the GNU General Public License as published by the |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4908
diff
changeset
|
11 Free Software Foundation, either version 3 of the License, or (at your |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4908
diff
changeset
|
12 option) any later version. |
| 462 | 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 | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4908
diff
changeset
|
20 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 462 | 21 |
| 22 /* Synched up with: Not in FSF. */ | |
| 23 | |
|
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
24 #define THIS_IS_GTK |
|
4881
a4322ac49e37
break out common separate-into-runs routines into redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
3479
diff
changeset
|
25 #include "redisplay-xlike-inc.c" |
| 462 | 26 |
| 27 /***************************************************************************** | |
|
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
28 Draw a shadow around the given area using the standard theme engine routines. |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
29 ****************************************************************************/ |
| 462 | 30 |
| 31 static void | |
|
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
32 XLIKE_bevel_area (struct window *w, face_index UNUSED (findex), |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
33 int x, int y, int width, int height, |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
34 int shadow_thickness, int UNUSED (edges), |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
35 enum edge_style style) |
| 462 | 36 { |
| 37 struct frame *f = XFRAME (w->frame); | |
|
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
38 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f)); |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
39 GtkStyle *gstyle = FRAME_GTK_TEXT_WIDGET (f)->style; |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
40 GtkShadowType stype; |
| 462 | 41 |
|
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
42 if (shadow_thickness == 0) |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
43 stype = GTK_SHADOW_NONE; |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
44 else |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
45 switch (style) |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
46 { |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
47 case EDGE_BEVEL_IN: style = GTK_SHADOW_IN; break; |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
48 case EDGE_BEVEL_OUT: style = GTK_SHADOW_OUT; break; |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
49 case EDGE_ETCHED_IN: style = GTK_SHADOW_ETCHED_IN; break; |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
50 case EDGE_ETCHED_OUT: style = GTK_SHADOW_ETCHED_OUT; break; |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
51 default: ABORT (); style = GTK_SHADOW_OUT; |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
52 } |
| 462 | 53 |
| 54 /* Do we want to have some magic constants to set | |
| 55 GTK_SHADOW_ETCHED_IN or GTK_SHADOW_ETCHED_OUT? */ | |
| 56 | |
|
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
57 gtk_paint_shadow (gstyle, x_win, GTK_STATE_NORMAL, stype, NULL, |
| 462 | 58 FRAME_GTK_TEXT_WIDGET (f), "modeline", |
| 59 x, y, width, height); | |
| 60 } | |
| 61 | |
| 62 | |
| 63 | |
| 64 /* Make audible bell. */ | |
| 65 static void | |
|
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
66 XLIKE_ring_bell (struct device *UNUSED (d), int volume, int UNUSED (pitch), |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
67 int UNUSED (duration)) |
| 462 | 68 { |
| 714 | 69 /* Gdk does not allow us to control the duration / pitch / volume */ |
| 70 if (volume > 0) | |
| 71 { | |
| 72 gdk_beep (); | |
| 73 } | |
| 462 | 74 } |
| 75 | |
| 76 | |
| 77 /* This makes me feel incredibly dirty... but there is no other way to | |
| 78 get this done right other than calling clear_area before every | |
| 79 single $#!%@ing piece of text, which I do NOT want to do. */ | |
| 80 #define USE_X_SPECIFIC_DRAW_ROUTINES 1 | |
| 81 | |
|
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
82 #include "sysgdkx.h" |
| 462 | 83 |
|
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
84 static void |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
85 gdk_draw_text_image (GdkDrawable *drawable, |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
86 GdkFont *font, |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
87 GdkGC *gc, |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
88 gint x, |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
89 gint y, |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
90 const gchar *text, |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4882
diff
changeset
|
91 gint text_length) |
| 462 | 92 { |
| 93 #if !USE_X_SPECIFIC_DRAW_ROUTINES | |
| 94 int width = gdk_text_measure (font, text, text_length); | |
| 95 int height = gdk_text_height (font, text, text_length); | |
| 96 | |
| 97 gdk_draw_rectangle (drawable, gc, TRUE, x, y, width, height); | |
| 98 gdk_draw_text (drawable, font, gc, x, y, text, text_length); | |
| 99 #else | |
| 100 GdkWindowPrivate *drawable_private; | |
| 101 GdkFontPrivate *font_private; | |
| 102 GdkGCPrivate *gc_private; | |
| 103 | |
| 104 g_return_if_fail (drawable != NULL); | |
| 105 g_return_if_fail (font != NULL); | |
| 106 g_return_if_fail (gc != NULL); | |
| 107 g_return_if_fail (text != NULL); | |
| 108 | |
| 109 drawable_private = (GdkWindowPrivate*) drawable; | |
| 110 if (drawable_private->destroyed) | |
| 111 return; | |
| 112 gc_private = (GdkGCPrivate*) gc; | |
| 113 font_private = (GdkFontPrivate*) font; | |
| 114 | |
| 115 if (font->type == GDK_FONT_FONT) | |
| 116 { | |
| 117 XFontStruct *xfont = (XFontStruct *) font_private->xfont; | |
| 118 XSetFont(drawable_private->xdisplay, gc_private->xgc, xfont->fid); | |
| 119 if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0)) | |
| 120 { | |
| 121 XDrawImageString (drawable_private->xdisplay, drawable_private->xwindow, | |
| 122 gc_private->xgc, x, y, text, text_length); | |
| 123 } | |
| 124 else | |
| 125 { | |
| 126 XDrawImageString16 (drawable_private->xdisplay, drawable_private->xwindow, | |
| 127 gc_private->xgc, x, y, (XChar2b *) text, text_length / 2); | |
| 128 } | |
| 129 } | |
| 130 else if (font->type == GDK_FONT_FONTSET) | |
| 131 { | |
| 132 XFontSet fontset = (XFontSet) font_private->xfont; | |
| 133 XmbDrawImageString (drawable_private->xdisplay, drawable_private->xwindow, | |
| 134 fontset, gc_private->xgc, x, y, text, text_length); | |
| 135 } | |
| 136 else | |
| 137 g_error("undefined font type\n"); | |
| 138 #endif | |
| 139 } | |
| 140 | |
| 141 static void | |
| 142 our_draw_bitmap (GdkDrawable *drawable, | |
| 143 GdkGC *gc, | |
| 144 GdkPixmap *src, | |
| 145 gint xsrc, | |
| 146 gint ysrc, | |
| 147 gint xdest, | |
| 148 gint ydest, | |
| 149 gint width, | |
| 150 gint height) | |
| 151 { | |
| 152 GdkWindowPrivate *drawable_private; | |
| 153 GdkWindowPrivate *src_private; | |
| 154 GdkGCPrivate *gc_private; | |
| 155 | |
| 156 g_return_if_fail (drawable != NULL); | |
| 157 g_return_if_fail (src != NULL); | |
| 158 g_return_if_fail (gc != NULL); | |
| 159 | |
| 160 drawable_private = (GdkWindowPrivate*) drawable; | |
| 161 src_private = (GdkWindowPrivate*) src; | |
| 162 if (drawable_private->destroyed || src_private->destroyed) | |
| 163 return; | |
| 164 gc_private = (GdkGCPrivate*) gc; | |
| 165 | |
| 166 if (width == -1) | |
| 167 width = src_private->width; | |
| 168 if (height == -1) | |
| 169 height = src_private->height; | |
| 170 | |
| 171 XCopyPlane (drawable_private->xdisplay, | |
| 172 src_private->xwindow, | |
| 173 drawable_private->xwindow, | |
| 174 gc_private->xgc, | |
| 175 xsrc, ysrc, | |
| 176 width, height, | |
| 177 xdest, ydest, 1L); | |
| 178 } |
