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
|
|
26 /* Author: Chuck Thompson */
|
|
27 /* Gtk flavor by William Perry */
|
|
28
|
|
29 /* Lots of work done by Ben Wing for Mule */
|
|
30
|
|
31 #include <config.h>
|
|
32 #include "lisp.h"
|
|
33
|
|
34 #include "buffer.h"
|
|
35 #include "debug.h"
|
872
|
36 #include "device-impl.h"
|
462
|
37 #include "faces.h"
|
872
|
38 #include "file-coding.h"
|
|
39 #include "frame-impl.h"
|
462
|
40 #include "gutter.h"
|
|
41 #include "redisplay.h"
|
|
42 #include "sysdep.h"
|
|
43 #include "window.h"
|
872
|
44
|
|
45 #include "console-gtk-impl.h"
|
|
46 #include "gccache-gtk.h"
|
|
47 #include "glyphs-gtk.h"
|
|
48 #include "objects-gtk-impl.h"
|
462
|
49
|
|
50 #include "sysproc.h" /* for select() */
|
|
51
|
|
52 #ifdef MULE
|
|
53 #include "mule-ccl.h"
|
|
54 #endif
|
|
55
|
|
56 #define CONST const
|
|
57
|
|
58 #define EOL_CURSOR_WIDTH 5
|
|
59
|
714
|
60 static void gtk_output_pixmap (struct window *w,
|
|
61 Lisp_Object image_instance,
|
|
62 struct display_box *db,
|
|
63 struct display_glyph_area *dga,
|
|
64 face_index findex,
|
|
65 int cursor_start,
|
|
66 int cursor_width,
|
|
67 int cursor_height,
|
|
68 int bgpixmap);
|
462
|
69 static void gtk_output_vertical_divider (struct window *w, int clear);
|
|
70 static void gtk_output_blank (struct window *w, struct display_line *dl,
|
|
71 struct rune *rb, int start_pixpos,
|
|
72 int cursor_start, int cursor_width);
|
714
|
73 static void gtk_output_horizontal_line (struct window *w,
|
|
74 struct display_line *dl,
|
|
75 struct rune *rb);
|
462
|
76 static void gtk_clear_region (Lisp_Object locale, struct device* d, struct frame* f,
|
|
77 face_index findex, int x, int y,
|
|
78 int width, int height, Lisp_Object fcolor, Lisp_Object bcolor,
|
|
79 Lisp_Object background_pixmap);
|
|
80 static void gtk_output_eol_cursor (struct window *w, struct display_line *dl,
|
|
81 int xpos, face_index findex);
|
|
82 static void gtk_clear_frame (struct frame *f);
|
|
83 static void gtk_clear_frame_windows (Lisp_Object window);
|
|
84 static void gtk_bevel_modeline (struct window *w, struct display_line *dl);
|
|
85
|
|
86 #if 0
|
|
87 static void __describe_gc (GdkGC *);
|
|
88 #endif
|
|
89
|
|
90 struct textual_run
|
|
91 {
|
|
92 Lisp_Object charset;
|
|
93 unsigned char *ptr;
|
|
94 int len;
|
|
95 int dimension;
|
|
96 };
|
|
97
|
|
98 /* Separate out the text in DYN into a series of textual runs of a
|
|
99 particular charset. Also convert the characters as necessary into
|
|
100 the format needed by XDrawImageString(), XDrawImageString16(), et
|
|
101 al. (This means converting to one or two byte format, possibly
|
|
102 tweaking the high bits, and possibly running a CCL program.) You
|
|
103 must pre-allocate the space used and pass it in. (This is done so
|
851
|
104 you can ALLOCA () the space.) You need to allocate (2 * len) bytes
|
462
|
105 of TEXT_STORAGE and (len * sizeof (struct textual_run)) bytes of
|
|
106 RUN_STORAGE, where LEN is the length of the dynarr.
|
|
107
|
|
108 Returns the number of runs actually used. */
|
|
109
|
|
110 static int
|
|
111 separate_textual_runs (unsigned char *text_storage,
|
|
112 struct textual_run *run_storage,
|
867
|
113 CONST Ichar *str, Charcount len)
|
462
|
114 {
|
|
115 Lisp_Object prev_charset = Qunbound; /* not Qnil because that is a
|
|
116 possible valid charset when
|
|
117 MULE is not defined */
|
|
118 int runs_so_far = 0;
|
|
119 int i;
|
|
120 #ifdef MULE
|
|
121 struct ccl_program char_converter;
|
|
122 int need_ccl_conversion = 0;
|
|
123 #endif
|
|
124
|
|
125 for (i = 0; i < len; i++)
|
|
126 {
|
867
|
127 Ichar ch = str[i];
|
462
|
128 Lisp_Object charset;
|
|
129 int byte1, byte2;
|
|
130 int dimension;
|
|
131 int graphic;
|
|
132
|
867
|
133 BREAKUP_ICHAR (ch, charset, byte1, byte2);
|
462
|
134 dimension = XCHARSET_DIMENSION (charset);
|
|
135 graphic = XCHARSET_GRAPHIC (charset);
|
|
136
|
|
137 if (!EQ (charset, prev_charset))
|
|
138 {
|
|
139 run_storage[runs_so_far].ptr = text_storage;
|
|
140 run_storage[runs_so_far].charset = charset;
|
|
141 run_storage[runs_so_far].dimension = dimension;
|
|
142
|
|
143 if (runs_so_far)
|
|
144 {
|
|
145 run_storage[runs_so_far - 1].len =
|
|
146 text_storage - run_storage[runs_so_far - 1].ptr;
|
|
147 if (run_storage[runs_so_far - 1].dimension == 2)
|
|
148 run_storage[runs_so_far - 1].len >>= 1;
|
|
149 }
|
|
150 runs_so_far++;
|
|
151 prev_charset = charset;
|
|
152 #ifdef MULE
|
|
153 {
|
|
154 Lisp_Object ccl_prog = XCHARSET_CCL_PROGRAM (charset);
|
|
155 need_ccl_conversion = !NILP (ccl_prog);
|
|
156 if (need_ccl_conversion)
|
|
157 setup_ccl_program (&char_converter, ccl_prog);
|
|
158 }
|
|
159 #endif
|
|
160 }
|
|
161
|
|
162 if (graphic == 0)
|
|
163 {
|
|
164 byte1 &= 0x7F;
|
|
165 byte2 &= 0x7F;
|
|
166 }
|
|
167 else if (graphic == 1)
|
|
168 {
|
|
169 byte1 |= 0x80;
|
|
170 byte2 |= 0x80;
|
|
171 }
|
|
172 #ifdef MULE
|
|
173 if (need_ccl_conversion)
|
|
174 {
|
|
175 char_converter.reg[0] = XCHARSET_ID (charset);
|
|
176 char_converter.reg[1] = byte1;
|
|
177 char_converter.reg[2] = byte2;
|
|
178 ccl_driver (&char_converter, 0, 0, 0, 0, CCL_MODE_ENCODING);
|
|
179 byte1 = char_converter.reg[1];
|
|
180 byte2 = char_converter.reg[2];
|
|
181 }
|
|
182 #endif
|
|
183 *text_storage++ = (unsigned char) byte1;
|
|
184 if (dimension == 2)
|
|
185 *text_storage++ = (unsigned char) byte2;
|
|
186 }
|
|
187
|
|
188 if (runs_so_far)
|
|
189 {
|
|
190 run_storage[runs_so_far - 1].len =
|
|
191 text_storage - run_storage[runs_so_far - 1].ptr;
|
|
192 if (run_storage[runs_so_far - 1].dimension == 2)
|
|
193 run_storage[runs_so_far - 1].len >>= 1;
|
|
194 }
|
|
195
|
|
196 return runs_so_far;
|
|
197 }
|
|
198
|
|
199 /****************************************************************************/
|
|
200 /* */
|
|
201 /* Gtk output routines */
|
|
202 /* */
|
|
203 /****************************************************************************/
|
|
204
|
|
205 static int
|
|
206 gtk_text_width_single_run (struct face_cachel *cachel, struct textual_run *run)
|
|
207 {
|
|
208 Lisp_Object font_inst = FACE_CACHEL_FONT (cachel, run->charset);
|
|
209 struct Lisp_Font_Instance *fi = XFONT_INSTANCE (font_inst);
|
|
210
|
|
211 if (!fi->proportional_p)
|
|
212 {
|
|
213 return fi->width * run->len;
|
|
214 }
|
|
215 else
|
|
216 {
|
|
217 if (run->dimension == 2)
|
|
218 {
|
|
219 stderr_out ("Measuring wide characters\n");
|
|
220 return gdk_text_width_wc (FONT_INSTANCE_GTK_FONT (fi),
|
|
221 (GdkWChar *) run->ptr, run->len);
|
|
222 }
|
|
223 else
|
|
224 {
|
|
225 return gdk_text_width (FONT_INSTANCE_GTK_FONT (fi),
|
|
226 (char *) run->ptr, run->len);
|
|
227 }
|
|
228 }
|
|
229 }
|
|
230
|
|
231 /*
|
|
232 gtk_text_width
|
|
233
|
|
234 Given a string and a face, return the string's length in pixels when
|
|
235 displayed in the font associated with the face.
|
|
236 */
|
|
237
|
|
238 static int
|
867
|
239 gtk_text_width (struct frame *f, struct face_cachel *cachel, CONST Ichar *str,
|
462
|
240 Charcount len)
|
|
241 {
|
|
242 int width_so_far = 0;
|
851
|
243 unsigned char *text_storage = (unsigned char *) ALLOCA (2 * len);
|
462
|
244 struct textual_run *runs = alloca_array (struct textual_run, len);
|
|
245 int nruns;
|
|
246 int i;
|
|
247
|
|
248 nruns = separate_textual_runs (text_storage, runs, str, len);
|
|
249
|
|
250 for (i = 0; i < nruns; i++)
|
|
251 width_so_far += gtk_text_width_single_run (cachel, runs + i);
|
|
252
|
|
253 return width_so_far;
|
|
254 }
|
|
255
|
|
256 /*****************************************************************************
|
|
257 gtk_divider_height
|
|
258
|
|
259 Return the height of the horizontal divider. This is a function because
|
|
260 divider_height is a device method.
|
|
261
|
|
262 #### If we add etched horizontal divider lines this will have to get
|
|
263 smarter.
|
|
264 ****************************************************************************/
|
|
265 static int
|
|
266 gtk_divider_height (void)
|
|
267 {
|
|
268 return 2;
|
|
269 }
|
|
270
|
|
271 /*****************************************************************************
|
|
272 gtk_eol_cursor_width
|
|
273
|
|
274 Return the width of the end-of-line cursor. This is a function
|
|
275 because eol_cursor_width is a device method.
|
|
276 ****************************************************************************/
|
|
277 static int
|
|
278 gtk_eol_cursor_width (void)
|
|
279 {
|
|
280 return EOL_CURSOR_WIDTH;
|
|
281 }
|
|
282
|
|
283 /*****************************************************************************
|
|
284 gtk_output_display_block
|
|
285
|
|
286 Given a display line, a block number for that start line, output all
|
|
287 runes between start and end in the specified display block.
|
|
288 ****************************************************************************/
|
|
289 static void
|
|
290 gtk_output_display_block (struct window *w, struct display_line *dl, int block,
|
|
291 int start, int end, int start_pixpos, int cursor_start,
|
|
292 int cursor_width, int cursor_height)
|
|
293 {
|
|
294 struct frame *f = XFRAME (w->frame);
|
867
|
295 Ichar_dynarr *buf = Dynarr_new (Ichar);
|
462
|
296 Lisp_Object window;
|
|
297
|
|
298 struct display_block *db = Dynarr_atp (dl->display_blocks, block);
|
|
299 rune_dynarr *rba = db->runes;
|
|
300 struct rune *rb;
|
|
301
|
|
302 int elt = start;
|
|
303 face_index findex;
|
|
304 int xpos, width;
|
|
305 Lisp_Object charset = Qunbound; /* Qnil is a valid charset when
|
|
306 MULE is not defined */
|
|
307
|
793
|
308 window = wrap_window (w);
|
462
|
309 rb = Dynarr_atp (rba, start);
|
|
310
|
|
311 if (!rb)
|
|
312 {
|
|
313 /* Nothing to do so don't do anything. */
|
|
314 return;
|
|
315 }
|
|
316 else
|
|
317 {
|
|
318 findex = rb->findex;
|
|
319 xpos = rb->xpos;
|
|
320 width = 0;
|
|
321 if (rb->type == RUNE_CHAR)
|
867
|
322 charset = ichar_charset (rb->object.chr.ch);
|
462
|
323 }
|
|
324
|
|
325 if (end < 0)
|
|
326 end = Dynarr_length (rba);
|
|
327 Dynarr_reset (buf);
|
|
328
|
|
329 while (elt < end)
|
|
330 {
|
|
331 rb = Dynarr_atp (rba, elt);
|
|
332
|
|
333 if (rb->findex == findex && rb->type == RUNE_CHAR
|
|
334 && rb->object.chr.ch != '\n' && rb->cursor_type != CURSOR_ON
|
867
|
335 && EQ (charset, ichar_charset (rb->object.chr.ch)))
|
462
|
336 {
|
|
337 Dynarr_add (buf, rb->object.chr.ch);
|
|
338 width += rb->width;
|
|
339 elt++;
|
|
340 }
|
|
341 else
|
|
342 {
|
|
343 if (Dynarr_length (buf))
|
|
344 {
|
|
345 gtk_output_string (w, dl, buf, xpos, 0, start_pixpos, width,
|
|
346 findex, 0, cursor_start, cursor_width,
|
|
347 cursor_height);
|
|
348 xpos = rb->xpos;
|
|
349 width = 0;
|
|
350 }
|
|
351 Dynarr_reset (buf);
|
|
352 width = 0;
|
|
353
|
|
354 if (rb->type == RUNE_CHAR)
|
|
355 {
|
|
356 findex = rb->findex;
|
|
357 xpos = rb->xpos;
|
867
|
358 charset = ichar_charset (rb->object.chr.ch);
|
462
|
359
|
|
360 if (rb->cursor_type == CURSOR_ON)
|
|
361 {
|
|
362 if (rb->object.chr.ch == '\n')
|
|
363 {
|
|
364 gtk_output_eol_cursor (w, dl, xpos, findex);
|
|
365 }
|
|
366 else
|
|
367 {
|
|
368 Dynarr_add (buf, rb->object.chr.ch);
|
|
369 gtk_output_string (w, dl, buf, xpos, 0, start_pixpos,
|
|
370 rb->width, findex, 1,
|
|
371 cursor_start, cursor_width,
|
|
372 cursor_height);
|
|
373 Dynarr_reset (buf);
|
|
374 }
|
|
375
|
|
376 xpos += rb->width;
|
|
377 elt++;
|
|
378 }
|
|
379 else if (rb->object.chr.ch == '\n')
|
|
380 {
|
|
381 /* Clear in case a cursor was formerly here. */
|
|
382 int height = dl->ascent + dl->descent - dl->clip;
|
|
383
|
|
384 redisplay_clear_region (window, findex, xpos, dl->ypos - dl->ascent,
|
|
385 rb->width, height);
|
|
386 elt++;
|
|
387 }
|
|
388 }
|
|
389 else if (rb->type == RUNE_BLANK || rb->type == RUNE_HLINE)
|
|
390 {
|
|
391 if (rb->type == RUNE_BLANK)
|
|
392 gtk_output_blank (w, dl, rb, start_pixpos, cursor_start,
|
|
393 cursor_width);
|
|
394 else
|
|
395 {
|
|
396 /* #### Our flagging of when we need to redraw the
|
|
397 modeline shadows sucks. Since RUNE_HLINE is only used
|
|
398 by the modeline at the moment it is a good bet
|
|
399 that if it gets redrawn then we should also
|
|
400 redraw the shadows. This won't be true forever.
|
|
401 We borrow the shadow_thickness_changed flag for
|
|
402 now. */
|
|
403 w->shadow_thickness_changed = 1;
|
714
|
404 gtk_output_horizontal_line (w, dl, rb);
|
462
|
405 }
|
|
406
|
|
407 elt++;
|
|
408 if (elt < end)
|
|
409 {
|
|
410 rb = Dynarr_atp (rba, elt);
|
|
411
|
|
412 findex = rb->findex;
|
|
413 xpos = rb->xpos;
|
|
414 }
|
|
415 }
|
|
416 else if (rb->type == RUNE_DGLYPH)
|
|
417 {
|
|
418 Lisp_Object instance;
|
|
419 struct display_box dbox;
|
|
420 struct display_glyph_area dga;
|
|
421 redisplay_calculate_display_boxes (dl, rb->xpos, rb->object.dglyph.xoffset,
|
819
|
422 rb->object.dglyph.yoffset ,start_pixpos,
|
|
423 rb->width, &dbox, &dga);
|
462
|
424
|
793
|
425 window = wrap_window (w);
|
462
|
426 instance = glyph_image_instance (rb->object.dglyph.glyph,
|
793
|
427 window, ERROR_ME_DEBUG_WARN, 1);
|
462
|
428 findex = rb->findex;
|
|
429
|
|
430 if (IMAGE_INSTANCEP (instance))
|
|
431 switch (XIMAGE_INSTANCE_TYPE (instance))
|
|
432 {
|
|
433 case IMAGE_TEXT:
|
|
434 {
|
|
435 /* #### This is way losing. See the comment in
|
|
436 add_glyph_rune(). */
|
|
437 Lisp_Object string =
|
|
438 XIMAGE_INSTANCE_TEXT_STRING (instance);
|
867
|
439 convert_ibyte_string_into_ichar_dynarr
|
462
|
440 (XSTRING_DATA (string), XSTRING_LENGTH (string), buf);
|
|
441
|
|
442 gtk_output_string (w, dl, buf, xpos,
|
|
443 rb->object.dglyph.xoffset,
|
|
444 start_pixpos, -1, findex,
|
|
445 (rb->cursor_type == CURSOR_ON),
|
|
446 cursor_start, cursor_width,
|
|
447 cursor_height);
|
|
448 Dynarr_reset (buf);
|
|
449 }
|
|
450 break;
|
|
451
|
|
452 case IMAGE_MONO_PIXMAP:
|
|
453 case IMAGE_COLOR_PIXMAP:
|
714
|
454 redisplay_output_pixmap (w, instance, &dbox, &dga,
|
|
455 findex,cursor_start,
|
|
456 cursor_width, cursor_height, 0);
|
462
|
457 break;
|
|
458
|
|
459 case IMAGE_POINTER:
|
|
460 abort ();
|
|
461
|
|
462 case IMAGE_WIDGET:
|
|
463 if (EQ (XIMAGE_INSTANCE_WIDGET_TYPE (instance),
|
|
464 Qlayout))
|
|
465 {
|
|
466 redisplay_output_layout (window, instance, &dbox,
|
|
467 &dga, findex,
|
|
468 cursor_start, cursor_width,
|
|
469 cursor_height);
|
|
470 break;
|
|
471 }
|
|
472
|
|
473 case IMAGE_SUBWINDOW:
|
|
474 redisplay_output_subwindow (w, instance, &dbox, &dga,
|
|
475 findex, cursor_start,
|
|
476 cursor_width, cursor_height);
|
|
477 break;
|
|
478
|
|
479 case IMAGE_NOTHING:
|
|
480 /* nothing is as nothing does */
|
|
481 break;
|
|
482
|
|
483 default:
|
|
484 abort ();
|
|
485 }
|
|
486
|
|
487 xpos += rb->width;
|
|
488 elt++;
|
|
489 }
|
|
490 else
|
|
491 abort ();
|
|
492 }
|
|
493 }
|
|
494
|
|
495 if (Dynarr_length (buf))
|
|
496 gtk_output_string (w, dl, buf, xpos, 0, start_pixpos, width, findex,
|
|
497 0, cursor_start, cursor_width, cursor_height);
|
|
498
|
|
499 /* #### This is really conditionalized well for optimized
|
|
500 performance. */
|
|
501 if (dl->modeline
|
|
502 && !EQ (Qzero, w->modeline_shadow_thickness)
|
|
503 && (f->clear
|
|
504 || f->windows_structure_changed
|
|
505 || w->shadow_thickness_changed))
|
|
506 gtk_bevel_modeline (w, dl);
|
|
507
|
|
508 Dynarr_free (buf);
|
|
509 }
|
|
510
|
|
511 /*****************************************************************************
|
|
512 gtk_bevel_modeline
|
|
513
|
|
514 Draw a 3d border around the modeline on window W.
|
|
515 ****************************************************************************/
|
|
516 static void
|
|
517 gtk_bevel_modeline (struct window *w, struct display_line *dl)
|
|
518 {
|
|
519 struct frame *f = XFRAME (w->frame);
|
|
520 int shadow_thickness = MODELINE_SHADOW_THICKNESS (w);
|
|
521 int x,y, width, height;
|
|
522
|
|
523 x = WINDOW_MODELINE_LEFT (w);
|
|
524 width = WINDOW_MODELINE_RIGHT (w) - x;
|
|
525 y = dl->ypos - dl->ascent - shadow_thickness;
|
|
526 height = dl->ascent + dl->descent + 2 * shadow_thickness;
|
|
527
|
|
528 gtk_output_shadows (f, x, y, width, height, shadow_thickness);
|
|
529 }
|
|
530
|
|
531 /*****************************************************************************
|
|
532 gtk_get_gc
|
|
533
|
|
534 Given a number of parameters return a GC with those properties.
|
|
535 ****************************************************************************/
|
|
536 GdkGC *
|
|
537 gtk_get_gc (struct device *d, Lisp_Object font, Lisp_Object fg, Lisp_Object bg,
|
|
538 Lisp_Object bg_pmap, Lisp_Object lwidth)
|
|
539 {
|
|
540 GdkGCValues gcv;
|
|
541 unsigned long mask;
|
|
542
|
|
543 memset (&gcv, ~0, sizeof (gcv));
|
|
544 gcv.graphics_exposures = FALSE;
|
|
545 /* Make absolutely sure that we don't pick up a clipping region in
|
|
546 the GC returned by this function. */
|
|
547 gcv.clip_mask = 0;
|
|
548 gcv.clip_x_origin = 0;
|
|
549 gcv.clip_y_origin = 0;
|
|
550 gcv.fill = GDK_SOLID;
|
|
551 mask = GDK_GC_EXPOSURES | GDK_GC_CLIP_MASK | GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN;
|
|
552 mask |= GDK_GC_FILL;
|
|
553
|
|
554 if (!NILP (font))
|
|
555 {
|
|
556 gcv.font = FONT_INSTANCE_GTK_FONT (XFONT_INSTANCE (font));
|
|
557 mask |= GDK_GC_FONT;
|
|
558 }
|
|
559
|
|
560 /* evil kludge! */
|
|
561 if (!NILP (fg) && !COLOR_INSTANCEP (fg) && !INTP (fg))
|
|
562 {
|
|
563 /* #### I fixed once case where this was getting it. It was a
|
|
564 bad macro expansion (compiler bug). */
|
|
565 fprintf (stderr, "Help! gtk_get_gc got a bogus fg value! fg = ");
|
|
566 debug_print (fg);
|
|
567 fg = Qnil;
|
|
568 }
|
|
569
|
|
570 if (!NILP (fg))
|
|
571 {
|
|
572 if (COLOR_INSTANCEP (fg))
|
|
573 gcv.foreground = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (fg));
|
|
574 else
|
|
575 gcv.foreground.pixel = XINT (fg);
|
|
576 mask |= GDK_GC_FOREGROUND;
|
|
577 }
|
|
578
|
|
579 if (!NILP (bg))
|
|
580 {
|
|
581 if (COLOR_INSTANCEP (bg))
|
|
582 gcv.background = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (bg));
|
|
583 else
|
|
584 gcv.background.pixel = XINT (fg);
|
|
585 mask |= GDK_GC_BACKGROUND;
|
|
586 }
|
|
587
|
|
588 if (IMAGE_INSTANCEP (bg_pmap)
|
|
589 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
|
|
590 {
|
|
591 if (XIMAGE_INSTANCE_PIXMAP_DEPTH (bg_pmap) == 0)
|
|
592 {
|
|
593 gcv.fill = GDK_OPAQUE_STIPPLED;
|
|
594 gcv.stipple = XIMAGE_INSTANCE_GTK_PIXMAP (bg_pmap);
|
|
595 mask |= (GDK_GC_STIPPLE | GDK_GC_FILL);
|
|
596 }
|
|
597 else
|
|
598 {
|
|
599 gcv.fill = GDK_TILED;
|
|
600 gcv.tile = XIMAGE_INSTANCE_GTK_PIXMAP (bg_pmap);
|
|
601 mask |= (GDK_GC_TILE | GDK_GC_FILL);
|
|
602 }
|
|
603 }
|
|
604
|
|
605 if (!NILP (lwidth))
|
|
606 {
|
|
607 gcv.line_width = XINT (lwidth);
|
|
608 mask |= GDK_GC_LINE_WIDTH;
|
|
609 }
|
|
610
|
|
611 return gc_cache_lookup (DEVICE_GTK_GC_CACHE (d), &gcv, mask);
|
|
612 }
|
|
613
|
|
614 /*****************************************************************************
|
|
615 gtk_output_string
|
|
616
|
|
617 Given a string and a starting position, output that string in the
|
|
618 given face. If cursor is true, draw a cursor around the string.
|
|
619 Correctly handles multiple charsets in the string.
|
|
620
|
|
621 The meaning of the parameters is something like this:
|
|
622
|
|
623 W Window that the text is to be displayed in.
|
|
624 DL Display line that this text is on. The values in the
|
|
625 structure are used to determine the vertical position and
|
|
626 clipping range of the text.
|
867
|
627 BUF Dynamic array of Ichars specifying what is actually to be
|
462
|
628 drawn.
|
|
629 XPOS X position in pixels where the text should start being drawn.
|
|
630 XOFFSET Number of pixels to be chopped off the left side of the
|
|
631 text. The effect is as if the text were shifted to the
|
|
632 left this many pixels and clipped at XPOS.
|
|
633 CLIP_START Clip everything left of this X position.
|
|
634 WIDTH Clip everything right of XPOS + WIDTH.
|
|
635 FINDEX Index for the face cache element describing how to display
|
|
636 the text.
|
|
637 CURSOR #### I don't understand this. There's something
|
|
638 strange and overcomplexified with this variable.
|
|
639 Chuck, explain please?
|
|
640 CURSOR_START Starting X position of cursor.
|
|
641 CURSOR_WIDTH Width of cursor in pixels.
|
|
642 CURSOR_HEIGHT Height of cursor in pixels.
|
|
643
|
|
644 Starting Y position of cursor is the top of the text line.
|
|
645 The cursor is drawn sometimes whether or not CURSOR is set. ???
|
|
646 ****************************************************************************/
|
714
|
647 static
|
|
648 void gdk_draw_text_image (GdkDrawable *drawable,
|
|
649 GdkFont *font,
|
|
650 GdkGC *gc,
|
|
651 gint x,
|
|
652 gint y,
|
|
653 const gchar *text,
|
|
654 gint text_length);
|
462
|
655
|
|
656 void
|
|
657 gtk_output_string (struct window *w, struct display_line *dl,
|
867
|
658 Ichar_dynarr *buf, int xpos, int xoffset, int clip_start,
|
462
|
659 int width, face_index findex, int cursor,
|
|
660 int cursor_start, int cursor_width, int cursor_height)
|
|
661 {
|
|
662 /* General variables */
|
|
663 struct frame *f = XFRAME (w->frame);
|
|
664 struct device *d = XDEVICE (f->device);
|
|
665 Lisp_Object device;
|
|
666 Lisp_Object window;
|
|
667 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
668
|
|
669 int clip_end;
|
|
670
|
|
671 /* Cursor-related variables */
|
|
672 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
|
|
673 int cursor_clip;
|
|
674 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor,
|
|
675 WINDOW_BUFFER (w));
|
|
676 struct face_cachel *cursor_cachel = 0;
|
|
677
|
|
678 /* Text-related variables */
|
|
679 Lisp_Object bg_pmap;
|
|
680 GdkGC *bgc, *gc;
|
|
681 int height;
|
|
682 int len = Dynarr_length (buf);
|
851
|
683 unsigned char *text_storage = (unsigned char *) ALLOCA (2 * len);
|
462
|
684 struct textual_run *runs = alloca_array (struct textual_run, len);
|
|
685 int nruns;
|
|
686 int i;
|
|
687 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, findex);
|
|
688
|
793
|
689 device = wrap_device (d);
|
|
690 window = wrap_window (w);
|
462
|
691
|
|
692 if (width < 0)
|
|
693 width = gtk_text_width (f, cachel, Dynarr_atp (buf, 0), Dynarr_length (buf));
|
|
694 height = dl->ascent + dl->descent - dl->clip;
|
|
695
|
|
696 /* Regularize the variables passed in. */
|
|
697
|
|
698 if (clip_start < xpos)
|
|
699 clip_start = xpos;
|
|
700 clip_end = xpos + width;
|
|
701 if (clip_start >= clip_end)
|
|
702 /* It's all clipped out. */
|
|
703 return;
|
|
704
|
|
705 xpos -= xoffset;
|
|
706
|
|
707 nruns = separate_textual_runs (text_storage, runs, Dynarr_atp (buf, 0),
|
|
708 Dynarr_length (buf));
|
|
709
|
|
710 cursor_clip = (cursor_start >= clip_start &&
|
|
711 cursor_start < clip_end);
|
|
712
|
|
713 /* This cursor code is really a mess. */
|
|
714 if (!NILP (w->text_cursor_visible_p)
|
|
715 && (cursor
|
|
716 || cursor_clip
|
|
717 || (cursor_width
|
|
718 && (cursor_start + cursor_width >= clip_start)
|
|
719 && !NILP (bar_cursor_value))))
|
|
720 {
|
|
721 /* These have to be in separate statements in order to avoid a
|
|
722 compiler bug. */
|
|
723 face_index sucks = get_builtin_face_cache_index (w, Vtext_cursor_face);
|
|
724 cursor_cachel = WINDOW_FACE_CACHEL (w, sucks);
|
|
725
|
|
726 /* We have to reset this since any call to WINDOW_FACE_CACHEL
|
|
727 may cause the cache to resize and any pointers to it to
|
|
728 become invalid. */
|
|
729 cachel = WINDOW_FACE_CACHEL (w, findex);
|
|
730 }
|
|
731
|
|
732 bg_pmap = cachel->background_pixmap;
|
|
733 if (!IMAGE_INSTANCEP (bg_pmap)
|
|
734 || !IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
|
|
735 bg_pmap = Qnil;
|
|
736
|
|
737 if ((cursor && focus && NILP (bar_cursor_value)
|
|
738 && !NILP (w->text_cursor_visible_p)) || NILP (bg_pmap))
|
|
739 bgc = 0;
|
|
740 else
|
|
741 bgc = gtk_get_gc (d, Qnil, cachel->foreground, cachel->background,
|
|
742 bg_pmap, Qnil);
|
|
743
|
|
744 if (bgc)
|
|
745 gdk_draw_rectangle (GDK_DRAWABLE (x_win), bgc, TRUE, clip_start,
|
|
746 dl->ypos - dl->ascent, clip_end - clip_start,
|
|
747 height);
|
|
748
|
|
749 for (i = 0; i < nruns; i++)
|
|
750 {
|
|
751 Lisp_Object font = FACE_CACHEL_FONT (cachel, runs[i].charset);
|
|
752 struct Lisp_Font_Instance *fi = XFONT_INSTANCE (font);
|
|
753 GdkFont *gdk_font = FONT_INSTANCE_GTK_FONT (fi);
|
|
754 int this_width;
|
|
755 int need_clipping;
|
|
756
|
|
757 if (EQ (font, Vthe_null_font_instance))
|
|
758 continue;
|
|
759
|
|
760 this_width = gtk_text_width_single_run (cachel, runs + i);
|
|
761 need_clipping = (dl->clip || clip_start > xpos ||
|
|
762 clip_end < xpos + this_width);
|
|
763
|
|
764 /* XDrawImageString only clears the area equal to the height of
|
|
765 the given font. It is possible that a font is being displayed
|
|
766 on a line taller than it is, so this would cause us to fail to
|
|
767 clear some areas. */
|
|
768 if ((int) fi->height < (int) (height + dl->clip))
|
|
769 {
|
|
770 int clear_start = max (xpos, clip_start);
|
|
771 int clear_end = min (xpos + this_width, clip_end);
|
|
772
|
|
773 if (cursor)
|
|
774 {
|
|
775 int ypos1_line, ypos1_string, ypos2_line, ypos2_string;
|
|
776
|
|
777 ypos1_string = dl->ypos - fi->ascent;
|
|
778 ypos2_string = dl->ypos + fi->descent;
|
|
779 ypos1_line = dl->ypos - dl->ascent;
|
|
780 ypos2_line = dl->ypos + dl->descent - dl->clip;
|
|
781
|
|
782 /* Make sure we don't clear below the real bottom of the
|
|
783 line. */
|
|
784 if (ypos1_string > ypos2_line)
|
|
785 ypos1_string = ypos2_line;
|
|
786 if (ypos2_string > ypos2_line)
|
|
787 ypos2_string = ypos2_line;
|
|
788
|
|
789 if (ypos1_line < ypos1_string)
|
|
790 {
|
|
791 redisplay_clear_region (window, findex, clear_start, ypos1_line,
|
|
792 clear_end - clear_start,
|
|
793 ypos1_string - ypos1_line);
|
|
794 }
|
|
795
|
|
796 if (ypos2_line > ypos2_string)
|
|
797 {
|
|
798 redisplay_clear_region (window, findex, clear_start, ypos2_string,
|
|
799 clear_end - clear_start,
|
|
800 ypos2_line - ypos2_string);
|
|
801 }
|
|
802 }
|
|
803 else
|
|
804 {
|
|
805 redisplay_clear_region (window, findex, clear_start,
|
|
806 dl->ypos - dl->ascent, clear_end - clear_start,
|
|
807 height);
|
|
808 }
|
|
809 }
|
|
810
|
|
811 if (cursor && cursor_cachel && focus && NILP (bar_cursor_value))
|
|
812 {
|
|
813 gc = gtk_get_gc (d, font, cursor_cachel->foreground,
|
|
814 cursor_cachel->background, Qnil, Qnil);
|
|
815 }
|
|
816 else
|
|
817 {
|
|
818 gc = gtk_get_gc (d, font, cachel->foreground, cachel->background,
|
|
819 Qnil, Qnil);
|
|
820 }
|
|
821
|
|
822 if (need_clipping)
|
|
823 {
|
|
824 GdkRectangle clip_box;
|
|
825
|
|
826 clip_box.x = 0;
|
|
827 clip_box.y = 0;
|
|
828 clip_box.width = clip_end - clip_start;
|
|
829 clip_box.height = height;
|
|
830
|
|
831 gdk_gc_set_clip_rectangle (gc, &clip_box);
|
|
832 gdk_gc_set_clip_origin (gc, clip_start, dl->ypos - dl->ascent);
|
|
833 }
|
|
834
|
|
835 /* The X specific called different functions (XDraw*String
|
|
836 vs. XDraw*String16), but apparently gdk_draw_text takes care
|
|
837 of that for us.
|
|
838
|
|
839 BUT, gdk_draw_text also does too much, by dividing the length
|
|
840 by 2. So we fake them out my multiplying the length by the
|
|
841 dimension of the text. This will do the right thing for
|
|
842 single-dimension runs as well of course.
|
|
843 */
|
|
844 (bgc ? gdk_draw_text : gdk_draw_text_image) (GDK_DRAWABLE (x_win), gdk_font, gc, xpos,
|
|
845 dl->ypos, (char *) runs[i].ptr,
|
|
846 runs[i].len * runs[i].dimension);
|
|
847
|
|
848 /* We draw underlines in the same color as the text. */
|
|
849 if (cachel->underline)
|
|
850 {
|
|
851 unsigned long upos, uthick;
|
|
852
|
|
853 /* Cannot get at font properties in Gtk, so we resort to
|
|
854 guessing */
|
|
855 upos = dl->descent / 2;
|
|
856 uthick = 1;
|
|
857
|
778
|
858 if ((dl->ypos + upos) < (dl->ypos + dl->descent - dl->clip))
|
462
|
859 {
|
|
860 if (dl->ypos + upos + uthick > dl->ypos + dl->descent - dl->clip)
|
|
861 uthick = dl->descent - dl->clip - upos;
|
|
862
|
|
863 if (uthick == 1)
|
|
864 {
|
|
865 gdk_draw_line (GDK_DRAWABLE (x_win), gc, xpos, dl->ypos + upos,
|
|
866 xpos + this_width, dl->ypos + upos);
|
|
867 }
|
|
868 else if (uthick > 1)
|
|
869 {
|
|
870 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, TRUE, xpos,
|
|
871 dl->ypos + upos, this_width, uthick);
|
|
872 }
|
|
873 }
|
|
874 }
|
|
875
|
|
876 if (cachel->strikethru) {
|
|
877 unsigned long ascent,descent,upos, uthick;
|
|
878 GdkFont *gfont = FONT_INSTANCE_GTK_FONT (XFONT_INSTANCE (font));
|
|
879
|
|
880 /* Cannot get at font properties in Gtk, so we resort to
|
|
881 guessing */
|
|
882
|
|
883 ascent = gfont->ascent;
|
|
884 descent = gfont->descent;
|
|
885 uthick = 1;
|
|
886
|
|
887 upos = ascent - ((ascent + descent) / 2) + 1;
|
|
888
|
|
889 /* Generally, upos will be positive (above the baseline),so subtract */
|
|
890 if (dl->ypos - upos < dl->ypos + dl->descent - dl->clip)
|
|
891 {
|
|
892 if (dl->ypos - upos + uthick > dl->ypos + dl->descent - dl->clip)
|
|
893 uthick = dl->descent - dl->clip + upos;
|
|
894
|
|
895 if (uthick == 1)
|
|
896 {
|
|
897 gdk_draw_line (GDK_DRAWABLE (x_win), gc, xpos, dl->ypos - upos,
|
|
898 xpos + this_width, dl->ypos - upos);
|
|
899 }
|
|
900 else if (uthick > 1)
|
|
901 {
|
|
902 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, TRUE, xpos, dl->ypos + upos,
|
|
903 this_width, uthick);
|
|
904 }
|
|
905 }
|
|
906 }
|
|
907
|
|
908 /* Restore the GC */
|
|
909 if (need_clipping)
|
|
910 {
|
|
911 gdk_gc_set_clip_rectangle (gc, NULL);
|
|
912 gdk_gc_set_clip_origin (gc, 0, 0);
|
|
913 }
|
|
914
|
|
915 /* If we are actually superimposing the cursor then redraw with just
|
|
916 the appropriate section highlighted. */
|
|
917 if (cursor_clip && !cursor && focus && cursor_cachel)
|
|
918 {
|
|
919 GdkGC *cgc;
|
|
920 GdkRectangle clip_box;
|
|
921
|
|
922 cgc = gtk_get_gc (d, font, cursor_cachel->foreground,
|
|
923 cursor_cachel->background, Qnil, Qnil);
|
|
924
|
|
925 clip_box.x = 0;
|
|
926 clip_box.y = 0;
|
|
927 clip_box.width = cursor_width;
|
|
928 clip_box.height = height;
|
|
929
|
|
930 gdk_gc_set_clip_rectangle (cgc, &clip_box);
|
|
931 gdk_gc_set_clip_origin (cgc, cursor_start, dl->ypos - dl->ascent);
|
|
932
|
|
933 /* The X specific called different functions (XDraw*String
|
|
934 vs. XDraw*String16), but apparently gdk_draw_text takes care
|
|
935 of that for us.
|
|
936
|
|
937 BUT, gdk_draw_text also does too much, by dividing the
|
|
938 length by 2. So we fake them out my multiplying the
|
|
939 length by the dimension of the text. This will do the
|
|
940 right thing for single-dimension runs as well of course.
|
|
941 */
|
|
942 gdk_draw_text_image (GDK_DRAWABLE (x_win), gdk_font, cgc, xpos,
|
|
943 dl->ypos, (char *) runs[i].ptr,
|
|
944 runs[i].len * runs[i].dimension);
|
|
945
|
|
946 gdk_gc_set_clip_rectangle (cgc, NULL);
|
|
947 gdk_gc_set_clip_origin (cgc, 0, 0);
|
|
948 }
|
|
949
|
|
950 xpos += this_width;
|
|
951 }
|
|
952
|
|
953 /* Draw the non-focus box or bar-cursor as needed. */
|
|
954 /* Can't this logic be simplified? */
|
|
955 if (cursor_cachel
|
|
956 && ((cursor && !focus && NILP (bar_cursor_value))
|
|
957 || (cursor_width
|
|
958 && (cursor_start + cursor_width >= clip_start)
|
|
959 && !NILP (bar_cursor_value))))
|
|
960 {
|
|
961 int tmp_height, tmp_y;
|
|
962 int bar_width = EQ (bar_cursor_value, Qt) ? 1 : 2;
|
|
963 int need_clipping = (cursor_start < clip_start
|
|
964 || clip_end < cursor_start + cursor_width);
|
|
965
|
|
966 /* #### This value is correct (as far as I know) because
|
|
967 all of the times we need to draw this cursor, we will
|
|
968 be called with exactly one character, so we know we
|
|
969 can always use runs[0].
|
|
970
|
|
971 This is bogus as all hell, however. The cursor handling in
|
|
972 this function is way bogus and desperately needs to be
|
|
973 cleaned up. (In particular, the drawing of the cursor should
|
|
974 really really be separated out of this function. This may be
|
|
975 a bit tricky now because this function itself does way too
|
|
976 much stuff, a lot of which needs to be moved into
|
|
977 redisplay.c) This is the only way to be able to easily add
|
|
978 new cursor types or (e.g.) make the bar cursor be able to
|
|
979 span two characters instead of overlaying just one. */
|
|
980 int bogusly_obtained_ascent_value =
|
|
981 XFONT_INSTANCE (FACE_CACHEL_FONT (cachel, runs[0].charset))->ascent;
|
|
982
|
|
983 if (!NILP (bar_cursor_value))
|
|
984 {
|
|
985 gc = gtk_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil,
|
|
986 make_int (bar_width));
|
|
987 }
|
|
988 else
|
|
989 {
|
|
990 gc = gtk_get_gc (d, Qnil, cursor_cachel->background,
|
|
991 Qnil, Qnil, Qnil);
|
|
992 }
|
|
993
|
|
994 tmp_y = dl->ypos - bogusly_obtained_ascent_value;
|
|
995 tmp_height = cursor_height;
|
|
996 if (tmp_y + tmp_height > (int) (dl->ypos - dl->ascent + height))
|
|
997 {
|
|
998 tmp_y = dl->ypos - dl->ascent + height - tmp_height;
|
|
999 if (tmp_y < (int) (dl->ypos - dl->ascent))
|
|
1000 tmp_y = dl->ypos - dl->ascent;
|
|
1001 tmp_height = dl->ypos - dl->ascent + height - tmp_y;
|
|
1002 }
|
|
1003
|
|
1004 if (need_clipping)
|
|
1005 {
|
|
1006 GdkRectangle clip_box;
|
|
1007 clip_box.x = 0;
|
|
1008 clip_box.y = 0;
|
|
1009 clip_box.width = clip_end - clip_start;
|
|
1010 clip_box.height = tmp_height;
|
|
1011
|
|
1012 gdk_gc_set_clip_rectangle (gc, &clip_box);
|
|
1013 gdk_gc_set_clip_origin (gc, clip_start, tmp_y);
|
|
1014 }
|
|
1015
|
|
1016 if (!focus && NILP (bar_cursor_value))
|
|
1017 {
|
|
1018 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, FALSE,
|
|
1019 cursor_start, tmp_y,
|
|
1020 cursor_width - 1, tmp_height - 1);
|
|
1021 }
|
|
1022 else if (focus && !NILP (bar_cursor_value))
|
|
1023 {
|
|
1024 gdk_draw_line (GDK_DRAWABLE (x_win), gc,
|
|
1025 cursor_start + bar_width - 1, tmp_y,
|
|
1026 cursor_start + bar_width - 1, tmp_y + tmp_height - 1);
|
|
1027 }
|
|
1028
|
|
1029 /* Restore the GC */
|
|
1030 if (need_clipping)
|
|
1031 {
|
|
1032 gdk_gc_set_clip_rectangle (gc, NULL);
|
|
1033 gdk_gc_set_clip_origin (gc, 0, 0);
|
|
1034 }
|
|
1035 }
|
|
1036 }
|
|
1037
|
|
1038 static void
|
|
1039 our_draw_bitmap (GdkDrawable *drawable,
|
|
1040 GdkGC *gc,
|
|
1041 GdkPixmap *src,
|
|
1042 gint xsrc,
|
|
1043 gint ysrc,
|
|
1044 gint xdest,
|
|
1045 gint ydest,
|
|
1046 gint width,
|
|
1047 gint height);
|
|
1048
|
714
|
1049 static void
|
462
|
1050 gtk_output_gdk_pixmap (struct frame *f, struct Lisp_Image_Instance *p, int x,
|
714
|
1051 int y, int xoffset, int yoffset,
|
|
1052 int width, int height,
|
462
|
1053 GdkColor *fg, GdkColor *bg, GdkGC *override_gc)
|
|
1054 {
|
|
1055 struct device *d = XDEVICE (f->device);
|
|
1056 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
1057
|
|
1058 GdkGC *gc;
|
|
1059 GdkGCValues gcv;
|
|
1060 unsigned long pixmap_mask;
|
|
1061
|
|
1062 if (!override_gc)
|
|
1063 {
|
|
1064 memset (&gcv, ~0, sizeof (gcv));
|
|
1065 gcv.graphics_exposures = FALSE;
|
|
1066 gcv.foreground = *fg;
|
|
1067 gcv.background = *bg;
|
|
1068 pixmap_mask = GDK_GC_FOREGROUND | GDK_GC_BACKGROUND | GDK_GC_EXPOSURES;
|
|
1069
|
|
1070 if (IMAGE_INSTANCE_GTK_MASK (p))
|
|
1071 {
|
|
1072 gcv.function = GDK_COPY;
|
|
1073 gcv.clip_mask = IMAGE_INSTANCE_GTK_MASK (p);
|
714
|
1074 gcv.clip_x_origin = x - xoffset;
|
|
1075 gcv.clip_y_origin = y - yoffset;
|
462
|
1076 pixmap_mask |= (GDK_GC_FUNCTION | GDK_GC_CLIP_MASK | GDK_GC_CLIP_X_ORIGIN |
|
|
1077 GDK_GC_CLIP_Y_ORIGIN);
|
|
1078 /* Can't set a clip rectangle below because we already have a mask.
|
|
1079 We could conceivably create a new clipmask by zeroing out
|
|
1080 everything outside the clip region. Is it worth it?
|
|
1081 Is it possible to get an equivalent effect by changing the
|
|
1082 args to XCopyArea below rather than messing with a clip box?
|
714
|
1083 - dkindred@cs.cmu.edu
|
|
1084 Yes. We don't clip at all now - andy@xemacs.org
|
|
1085 */
|
462
|
1086 }
|
|
1087
|
|
1088 gc = gc_cache_lookup (DEVICE_GTK_GC_CACHE (d), &gcv, pixmap_mask);
|
|
1089 }
|
|
1090 else
|
|
1091 {
|
|
1092 gc = override_gc;
|
|
1093 /* override_gc might have a mask already--we don't want to nuke it.
|
|
1094 Maybe we can insist that override_gc have no mask, or use
|
|
1095 one of the suggestions above. */
|
|
1096 }
|
|
1097
|
|
1098 if (IMAGE_INSTANCE_PIXMAP_DEPTH (p) > 0)
|
|
1099 {
|
|
1100 gdk_draw_pixmap (GDK_DRAWABLE (x_win), gc,
|
|
1101 IMAGE_INSTANCE_GTK_PIXMAP (p),
|
714
|
1102 xoffset, yoffset, x, y, width, height);
|
462
|
1103 }
|
|
1104 else
|
|
1105 {
|
|
1106 our_draw_bitmap (GDK_DRAWABLE (x_win), gc,
|
|
1107 IMAGE_INSTANCE_GTK_PIXMAP (p),
|
714
|
1108 xoffset, yoffset, x, y, width, height);
|
462
|
1109 }
|
|
1110 }
|
|
1111
|
|
1112 static void
|
714
|
1113 gtk_output_pixmap (struct window *w,
|
|
1114 Lisp_Object image_instance,
|
|
1115 struct display_box *db,
|
|
1116 struct display_glyph_area *dga,
|
|
1117 face_index findex,
|
|
1118 int cursor_start,
|
|
1119 int cursor_width,
|
|
1120 int cursor_height,
|
|
1121 int bg_pixmap)
|
462
|
1122 {
|
|
1123 struct frame *f = XFRAME (w->frame);
|
|
1124 struct device *d = XDEVICE (f->device);
|
|
1125 struct Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
|
|
1126 Lisp_Object window;
|
|
1127
|
|
1128 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
1129
|
793
|
1130 window = wrap_window (w);
|
462
|
1131
|
|
1132 /* Output the pixmap. */
|
|
1133 {
|
|
1134 Lisp_Object tmp_pixel;
|
|
1135 GdkColor *tmp_bcolor, *tmp_fcolor;
|
|
1136
|
|
1137 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
|
|
1138 tmp_fcolor = COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (tmp_pixel));
|
|
1139 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
|
|
1140 tmp_bcolor = COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (tmp_pixel));
|
|
1141
|
714
|
1142 gtk_output_gdk_pixmap (f, p, db->xpos, db->ypos,
|
|
1143 dga->xoffset, dga->yoffset,
|
|
1144 dga->width, dga->height,
|
|
1145 tmp_fcolor, tmp_bcolor, NULL);
|
462
|
1146 }
|
|
1147
|
|
1148 /* Draw a cursor over top of the pixmap. */
|
714
|
1149 if (cursor_width && cursor_height && (cursor_start >= db->xpos)
|
462
|
1150 && !NILP (w->text_cursor_visible_p)
|
714
|
1151 && (cursor_start < (db->xpos + dga->width)))
|
462
|
1152 {
|
|
1153 GdkGC *gc;
|
|
1154 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
|
|
1155 struct face_cachel *cursor_cachel =
|
|
1156 WINDOW_FACE_CACHEL (w,
|
|
1157 get_builtin_face_cache_index
|
|
1158 (w, Vtext_cursor_face));
|
|
1159
|
|
1160 gc = gtk_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil);
|
|
1161
|
714
|
1162 if (cursor_width > db->xpos + dga->width - cursor_start)
|
|
1163 cursor_width = db->xpos + dga->width - cursor_start;
|
462
|
1164
|
|
1165 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, focus ? TRUE : FALSE,
|
714
|
1166 cursor_start, db->ypos, cursor_width,
|
462
|
1167 cursor_height);
|
|
1168 }
|
|
1169 }
|
|
1170
|
|
1171 /*****************************************************************************
|
|
1172 gtk_output_vertical_divider
|
|
1173
|
|
1174 Draw a vertical divider down the right side of the given window.
|
|
1175 ****************************************************************************/
|
|
1176 static void
|
|
1177 gtk_output_vertical_divider (struct window *w, int clear)
|
|
1178 {
|
|
1179 struct frame *f = XFRAME (w->frame);
|
|
1180 struct device *d = XDEVICE (f->device);
|
|
1181 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
1182 GdkGC *background_gc;
|
|
1183 Lisp_Object tmp_pixel;
|
|
1184 GdkGCValues gcv;
|
|
1185 unsigned long mask;
|
|
1186 int x, y1, y2, width, shadow_thickness, spacing, line_width;
|
|
1187 face_index div_face = get_builtin_face_cache_index (w, Vvertical_divider_face);
|
|
1188
|
|
1189 width = window_divider_width (w);
|
|
1190 shadow_thickness = XINT (w->vertical_divider_shadow_thickness);
|
|
1191 spacing = XINT (w->vertical_divider_spacing);
|
|
1192 line_width = XINT (w->vertical_divider_line_width);
|
|
1193 x = WINDOW_RIGHT (w) - width;
|
|
1194 y1 = WINDOW_TOP (w);
|
|
1195 y2 = WINDOW_BOTTOM (w);
|
|
1196
|
|
1197 memset (&gcv, ~0, sizeof (gcv));
|
|
1198
|
|
1199 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, div_face);
|
|
1200
|
|
1201 gcv.background = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (tmp_pixel));
|
|
1202 gcv.foreground = gcv.background;
|
|
1203 gcv.graphics_exposures = FALSE;
|
|
1204 mask = GDK_GC_FOREGROUND | GDK_GC_BACKGROUND | GDK_GC_EXPOSURES;
|
|
1205
|
|
1206 background_gc = gc_cache_lookup (DEVICE_GTK_GC_CACHE (d), &gcv, mask);
|
|
1207
|
|
1208 /* Clear the divider area first. This needs to be done when a
|
|
1209 window split occurs. */
|
|
1210 /* if (clear) */
|
|
1211 gdk_draw_rectangle (GDK_DRAWABLE (x_win), background_gc, TRUE,
|
|
1212 x, y1, width, y2 - y1);
|
|
1213
|
|
1214 #if 0
|
|
1215 /* Draw the divider line. */
|
|
1216 gdk_draw_rectangle (GDK_DRAWABLE (x_win), background_gc, TRUE,
|
|
1217 x + spacing + shadow_thickness, y1,
|
|
1218 line_width, y2 - y1);
|
|
1219 #endif
|
|
1220
|
|
1221 /* Draw the shadows around the divider line */
|
|
1222 gtk_output_shadows (f, x + spacing, y1,
|
|
1223 width - 2 * spacing, y2 - y1,
|
|
1224 shadow_thickness);
|
|
1225 }
|
|
1226
|
|
1227 /*****************************************************************************
|
|
1228 gtk_output_blank
|
|
1229
|
|
1230 Output a blank by clearing the area it covers in the foreground color
|
|
1231 of its face.
|
|
1232 ****************************************************************************/
|
|
1233 static void
|
|
1234 gtk_output_blank (struct window *w, struct display_line *dl, struct rune *rb,
|
|
1235 int start_pixpos, int cursor_start, int cursor_width)
|
|
1236 {
|
|
1237 struct frame *f = XFRAME (w->frame);
|
|
1238 struct device *d = XDEVICE (f->device);
|
|
1239
|
|
1240 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
1241 GdkGC *gc;
|
|
1242 struct face_cachel *cursor_cachel =
|
|
1243 WINDOW_FACE_CACHEL (w,
|
|
1244 get_builtin_face_cache_index
|
|
1245 (w, Vtext_cursor_face));
|
|
1246 Lisp_Object bg_pmap;
|
|
1247 Lisp_Object buffer = WINDOW_BUFFER (w);
|
|
1248 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor,
|
|
1249 buffer);
|
|
1250
|
|
1251 int x = rb->xpos;
|
|
1252 int y = dl->ypos - dl->ascent;
|
|
1253 int width = rb->width;
|
|
1254 int height = dl->ascent + dl->descent - dl->clip;
|
|
1255
|
|
1256 if (start_pixpos > x)
|
|
1257 {
|
|
1258 if (start_pixpos >= (x + width))
|
|
1259 return;
|
|
1260 else
|
|
1261 {
|
|
1262 width -= (start_pixpos - x);
|
|
1263 x = start_pixpos;
|
|
1264 }
|
|
1265 }
|
|
1266
|
|
1267 bg_pmap = WINDOW_FACE_CACHEL_BACKGROUND_PIXMAP (w, rb->findex);
|
|
1268 if (!IMAGE_INSTANCEP (bg_pmap)
|
|
1269 || !IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
|
|
1270 bg_pmap = Qnil;
|
|
1271
|
|
1272 if (NILP (bg_pmap))
|
|
1273 gc = gtk_get_gc (d, Qnil, WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex),
|
|
1274 Qnil, Qnil, Qnil);
|
|
1275 else
|
|
1276 gc = gtk_get_gc (d, Qnil, WINDOW_FACE_CACHEL_FOREGROUND (w, rb->findex),
|
|
1277 WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex), bg_pmap,
|
|
1278 Qnil);
|
|
1279
|
|
1280 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, TRUE, x, y, width, height);
|
|
1281
|
|
1282 /* If this rune is marked as having the cursor, then it is actually
|
|
1283 representing a tab. */
|
|
1284 if (!NILP (w->text_cursor_visible_p)
|
|
1285 && (rb->cursor_type == CURSOR_ON
|
|
1286 || (cursor_width
|
|
1287 && (cursor_start + cursor_width > x)
|
|
1288 && cursor_start < (x + width))))
|
|
1289 {
|
|
1290 int cursor_height, cursor_y;
|
|
1291 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
|
|
1292 struct Lisp_Font_Instance *fi;
|
|
1293
|
|
1294 fi = XFONT_INSTANCE (FACE_CACHEL_FONT
|
|
1295 (WINDOW_FACE_CACHEL (w, rb->findex),
|
|
1296 Vcharset_ascii));
|
|
1297
|
|
1298 gc = gtk_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil);
|
|
1299
|
|
1300 cursor_y = dl->ypos - fi->ascent;
|
|
1301 cursor_height = fi->height;
|
|
1302 if (cursor_y + cursor_height > y + height)
|
|
1303 cursor_height = y + height - cursor_y;
|
|
1304
|
|
1305 if (focus)
|
|
1306 {
|
|
1307 if (NILP (bar_cursor_value))
|
|
1308 {
|
|
1309 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, TRUE,
|
|
1310 cursor_start, cursor_y,
|
|
1311 fi->width, cursor_height);
|
|
1312 }
|
|
1313 else
|
|
1314 {
|
|
1315 int bar_width = EQ (bar_cursor_value, Qt) ? 1 : 2;
|
|
1316
|
|
1317 gc = gtk_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil,
|
|
1318 make_int (bar_width));
|
|
1319 gdk_draw_line (GDK_DRAWABLE (x_win), gc, cursor_start + bar_width - 1,
|
|
1320 cursor_y, cursor_start + bar_width - 1,
|
|
1321 cursor_y + cursor_height - 1);
|
|
1322 }
|
|
1323 }
|
|
1324 else if (NILP (bar_cursor_value))
|
|
1325 {
|
|
1326 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, FALSE,
|
|
1327 cursor_start, cursor_y,
|
|
1328 fi->width - 1, cursor_height - 1);
|
|
1329 }
|
|
1330 }
|
|
1331 }
|
|
1332
|
|
1333 /*****************************************************************************
|
714
|
1334 gtk_output_horizontal_line
|
462
|
1335
|
|
1336 Output a horizontal line in the foreground of its face.
|
|
1337 ****************************************************************************/
|
|
1338 static void
|
714
|
1339 gtk_output_horizontal_line (struct window *w,
|
|
1340 struct display_line *dl,
|
|
1341 struct rune *rb)
|
462
|
1342 {
|
|
1343 struct frame *f = XFRAME (w->frame);
|
|
1344 struct device *d = XDEVICE (f->device);
|
|
1345 GtkStyle *style = FRAME_GTK_TEXT_WIDGET (f)->style;
|
|
1346
|
|
1347 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
1348 GdkGC *gc;
|
|
1349
|
|
1350 int x = rb->xpos;
|
|
1351 int width = rb->width;
|
|
1352 int height = dl->ascent + dl->descent - dl->clip;
|
|
1353
|
|
1354 int ypos1, ypos2, ypos3, ypos4;
|
|
1355
|
|
1356 ypos1 = dl->ypos - dl->ascent;
|
|
1357 ypos2 = ypos1 + rb->object.hline.yoffset;
|
|
1358 ypos3 = ypos2 + rb->object.hline.thickness;
|
|
1359 ypos4 = dl->ypos + dl->descent - dl->clip;
|
|
1360
|
|
1361 /* First clear the area not covered by the line. */
|
|
1362 if (height - rb->object.hline.thickness > 0)
|
|
1363 {
|
|
1364 gc = gtk_get_gc (d, Qnil, WINDOW_FACE_CACHEL_FOREGROUND (w, rb->findex),
|
|
1365 Qnil, Qnil, Qnil);
|
|
1366
|
|
1367 if (ypos2 - ypos1 > 0)
|
|
1368 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, TRUE, x, ypos1, width, ypos2 - ypos1);
|
|
1369 if (ypos4 - ypos3 > 0)
|
|
1370 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, TRUE, x, ypos1, width, ypos2 - ypos1);
|
|
1371 }
|
|
1372
|
|
1373 gtk_paint_hline (style, x_win, GTK_STATE_NORMAL, NULL, FRAME_GTK_TEXT_WIDGET (f),
|
|
1374 "hline", x, x + width, ypos2);
|
|
1375 #if 0
|
|
1376 /* Now draw the line. */
|
|
1377 gc = gtk_get_gc (d, Qnil, WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex),
|
|
1378 Qnil, Qnil, Qnil);
|
|
1379
|
|
1380 if (ypos2 < ypos1)
|
|
1381 ypos2 = ypos1;
|
|
1382 if (ypos3 > ypos4)
|
|
1383 ypos3 = ypos4;
|
|
1384
|
|
1385 if (ypos3 - ypos2 > 0)
|
|
1386 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, TRUE, x, ypos2, width, ypos3 - ypos2);
|
|
1387 #endif
|
|
1388 }
|
|
1389
|
|
1390 /*****************************************************************************
|
|
1391 gtk_output_shadows
|
|
1392
|
|
1393 Draw a shadow around the given area using the standard theme engine routines.
|
|
1394 ****************************************************************************/
|
|
1395 void
|
|
1396 gtk_output_shadows (struct frame *f, int x, int y, int width, int height,
|
|
1397 int shadow_thickness)
|
|
1398 {
|
|
1399 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
1400 GtkStyle *style = FRAME_GTK_TEXT_WIDGET (f)->style;
|
|
1401 GtkShadowType stype = GTK_SHADOW_OUT;
|
|
1402
|
|
1403 if (shadow_thickness < 0)
|
|
1404 {
|
|
1405 stype = GTK_SHADOW_IN;
|
|
1406 }
|
|
1407 else if (shadow_thickness == 0)
|
|
1408 {
|
|
1409 stype = GTK_SHADOW_NONE;
|
|
1410 }
|
|
1411
|
|
1412 /* Do we want to have some magic constants to set
|
|
1413 GTK_SHADOW_ETCHED_IN or GTK_SHADOW_ETCHED_OUT? */
|
|
1414
|
|
1415 gtk_paint_shadow (style, x_win, GTK_STATE_NORMAL, stype, NULL,
|
|
1416 FRAME_GTK_TEXT_WIDGET (f), "modeline",
|
|
1417 x, y, width, height);
|
|
1418 }
|
|
1419
|
|
1420 /*****************************************************************************
|
|
1421 gtk_clear_to_window_end
|
|
1422
|
|
1423 Clear the area between ypos1 and ypos2. Each margin area and the
|
|
1424 text area is handled separately since they may each have their own
|
|
1425 background color.
|
|
1426 ****************************************************************************/
|
|
1427 static void
|
|
1428 gtk_clear_to_window_end (struct window *w, int ypos1, int ypos2)
|
|
1429 {
|
|
1430 int height = ypos2 - ypos1;
|
|
1431
|
|
1432 if (height)
|
|
1433 {
|
|
1434 struct frame *f = XFRAME (w->frame);
|
|
1435 Lisp_Object window;
|
|
1436 int bflag = (window_needs_vertical_divider (w) ? 0 : 1);
|
|
1437 layout_bounds bounds;
|
|
1438
|
|
1439 bounds = calculate_display_line_boundaries (w, bflag);
|
793
|
1440 window = wrap_window (w);
|
462
|
1441
|
|
1442 if (window_is_leftmost (w))
|
|
1443 redisplay_clear_region (window, DEFAULT_INDEX, FRAME_LEFT_BORDER_START (f),
|
|
1444 ypos1, FRAME_BORDER_WIDTH (f), height);
|
|
1445
|
|
1446 if (bounds.left_in - bounds.left_out > 0)
|
|
1447 redisplay_clear_region (window,
|
|
1448 get_builtin_face_cache_index (w, Vleft_margin_face),
|
|
1449 bounds.left_out, ypos1,
|
|
1450 bounds.left_in - bounds.left_out, height);
|
|
1451
|
|
1452 if (bounds.right_in - bounds.left_in > 0)
|
|
1453 redisplay_clear_region (window, DEFAULT_INDEX, bounds.left_in, ypos1,
|
|
1454 bounds.right_in - bounds.left_in, height);
|
|
1455
|
|
1456 if (bounds.right_out - bounds.right_in > 0)
|
|
1457 redisplay_clear_region (window,
|
|
1458 get_builtin_face_cache_index (w, Vright_margin_face),
|
|
1459 bounds.right_in, ypos1,
|
|
1460 bounds.right_out - bounds.right_in, height);
|
|
1461
|
|
1462 if (window_is_rightmost (w))
|
|
1463 redisplay_clear_region (window, DEFAULT_INDEX, FRAME_RIGHT_BORDER_START (f),
|
|
1464 ypos1, FRAME_BORDER_WIDTH (f), height);
|
|
1465 }
|
|
1466 }
|
|
1467
|
|
1468 /****************************************************************************
|
|
1469 gtk_clear_region
|
|
1470
|
|
1471 Clear the area in the box defined by the given parameters using the
|
|
1472 given face.
|
|
1473 ****************************************************************************/
|
|
1474 static void
|
|
1475 gtk_clear_region (Lisp_Object locale, struct device* d, struct frame* f, face_index findex,
|
|
1476 int x, int y,
|
|
1477 int width, int height, Lisp_Object fcolor, Lisp_Object bcolor,
|
|
1478 Lisp_Object background_pixmap)
|
|
1479 {
|
|
1480 GdkWindow *x_win;
|
|
1481 GdkGC *gc = NULL;
|
|
1482
|
|
1483 x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
1484
|
|
1485 if (!UNBOUNDP (background_pixmap))
|
|
1486 {
|
|
1487 gc = gtk_get_gc (d, Qnil, fcolor, bcolor, background_pixmap, Qnil);
|
|
1488 }
|
|
1489
|
|
1490 if (gc)
|
|
1491 {
|
|
1492 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc,TRUE,
|
|
1493 x, y, width, height);
|
|
1494 }
|
|
1495 else
|
|
1496 {
|
|
1497 gdk_window_clear_area (x_win, x, y, width, height);
|
|
1498 }
|
|
1499 }
|
|
1500
|
|
1501 /*****************************************************************************
|
|
1502 gtk_output_eol_cursor
|
|
1503
|
|
1504 Draw a cursor at the end of a line. The end-of-line cursor is
|
|
1505 narrower than the normal cursor.
|
|
1506 ****************************************************************************/
|
|
1507 static void
|
|
1508 gtk_output_eol_cursor (struct window *w, struct display_line *dl, int xpos,
|
|
1509 face_index findex)
|
|
1510 {
|
|
1511 struct frame *f = XFRAME (w->frame);
|
|
1512 struct device *d = XDEVICE (f->device);
|
|
1513 Lisp_Object window;
|
|
1514
|
|
1515 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
1516 GdkGC *gc;
|
|
1517 face_index elt = get_builtin_face_cache_index (w, Vtext_cursor_face);
|
|
1518 struct face_cachel *cursor_cachel = WINDOW_FACE_CACHEL (w, elt);
|
|
1519
|
|
1520 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
|
|
1521 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor,
|
|
1522 WINDOW_BUFFER (w));
|
|
1523
|
|
1524 int x = xpos;
|
|
1525 int y = dl->ypos - dl->ascent;
|
|
1526 int width = EOL_CURSOR_WIDTH;
|
|
1527 int height = dl->ascent + dl->descent - dl->clip;
|
|
1528 int cursor_height, cursor_y;
|
|
1529 int defheight, defascent;
|
|
1530
|
793
|
1531 window = wrap_window (w);
|
462
|
1532 redisplay_clear_region (window, findex, x, y, width, height);
|
|
1533
|
|
1534 if (NILP (w->text_cursor_visible_p))
|
|
1535 return;
|
|
1536
|
|
1537 gc = gtk_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil);
|
|
1538
|
|
1539 default_face_font_info (window, &defascent, 0, &defheight, 0, 0);
|
|
1540
|
|
1541 /* make sure the cursor is entirely contained between y and y+height */
|
|
1542 cursor_height = min (defheight, height);
|
|
1543 cursor_y = max (y, min (y + height - cursor_height,
|
|
1544 dl->ypos - defascent));
|
|
1545
|
|
1546 if (focus)
|
|
1547 {
|
|
1548 if (NILP (bar_cursor_value))
|
|
1549 {
|
|
1550 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, TRUE, x, cursor_y, width, cursor_height);
|
|
1551 }
|
|
1552 else
|
|
1553 {
|
|
1554 int bar_width = EQ (bar_cursor_value, Qt) ? 1 : 2;
|
|
1555
|
|
1556 gc = gtk_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil,
|
|
1557 make_int (bar_width));
|
|
1558 gdk_draw_line (GDK_DRAWABLE (x_win), gc, x + bar_width - 1, cursor_y,
|
|
1559 x + bar_width - 1, cursor_y + cursor_height - 1);
|
|
1560 }
|
|
1561 }
|
|
1562 else if (NILP (bar_cursor_value))
|
|
1563 {
|
|
1564 gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, FALSE, x, cursor_y, width - 1,
|
|
1565 cursor_height - 1);
|
|
1566 }
|
|
1567 }
|
|
1568
|
|
1569 static void
|
|
1570 gtk_clear_frame_window (Lisp_Object window)
|
|
1571 {
|
|
1572 struct window *w = XWINDOW (window);
|
|
1573
|
|
1574 if (!NILP (w->vchild))
|
|
1575 {
|
|
1576 gtk_clear_frame_windows (w->vchild);
|
|
1577 return;
|
|
1578 }
|
|
1579
|
|
1580 if (!NILP (w->hchild))
|
|
1581 {
|
|
1582 gtk_clear_frame_windows (w->hchild);
|
|
1583 return;
|
|
1584 }
|
|
1585
|
|
1586 gtk_clear_to_window_end (w, WINDOW_TEXT_TOP (w), WINDOW_TEXT_BOTTOM (w));
|
|
1587 }
|
|
1588
|
|
1589 static void
|
|
1590 gtk_clear_frame_windows (Lisp_Object window)
|
|
1591 {
|
|
1592 for (; !NILP (window); window = XWINDOW (window)->next)
|
|
1593 gtk_clear_frame_window (window);
|
|
1594 }
|
|
1595
|
|
1596 static void
|
|
1597 gtk_clear_frame (struct frame *f)
|
|
1598 {
|
|
1599 GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
|
|
1600 int x, y, width, height;
|
|
1601 Lisp_Object frame;
|
|
1602
|
|
1603 x = FRAME_LEFT_BORDER_START (f);
|
|
1604 width = (FRAME_PIXWIDTH (f) - FRAME_REAL_LEFT_TOOLBAR_WIDTH (f) -
|
|
1605 FRAME_REAL_RIGHT_TOOLBAR_WIDTH (f) -
|
|
1606 2 * FRAME_REAL_LEFT_TOOLBAR_BORDER_WIDTH (f) -
|
|
1607 2 * FRAME_REAL_RIGHT_TOOLBAR_BORDER_WIDTH (f));
|
|
1608 /* #### This adjustment by 1 should be being done in the macros.
|
|
1609 There is some small differences between when the menubar is on
|
|
1610 and off that we still need to deal with. */
|
|
1611 y = FRAME_TOP_BORDER_START (f) - 1;
|
|
1612 height = (FRAME_PIXHEIGHT (f) - FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) -
|
|
1613 FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f) -
|
|
1614 2 * FRAME_REAL_TOP_TOOLBAR_BORDER_WIDTH (f) -
|
|
1615 2 * FRAME_REAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f)) + 1;
|
|
1616
|
|
1617 gdk_window_clear_area (x_win, x, y, width, height);
|
|
1618
|
793
|
1619 frame = wrap_frame (f);
|
462
|
1620
|
|
1621 if (!UNBOUNDP (FACE_BACKGROUND_PIXMAP (Vdefault_face, frame))
|
|
1622 || !UNBOUNDP (FACE_BACKGROUND_PIXMAP (Vleft_margin_face, frame))
|
|
1623 || !UNBOUNDP (FACE_BACKGROUND_PIXMAP (Vright_margin_face, frame)))
|
|
1624 {
|
|
1625 gtk_clear_frame_windows (f->root_window);
|
|
1626 }
|
|
1627 }
|
|
1628
|
|
1629 static int
|
|
1630 gtk_flash (struct device *d)
|
|
1631 {
|
|
1632 GdkGCValues gcv;
|
|
1633 GdkGC *gc;
|
|
1634 GdkColor tmp_fcolor, tmp_bcolor;
|
|
1635 Lisp_Object tmp_pixel, frame;
|
|
1636 struct frame *f = device_selected_frame (d);
|
|
1637 struct window *w = XWINDOW (FRAME_ROOT_WINDOW (f));
|
|
1638
|
793
|
1639 frame = wrap_frame (f);
|
462
|
1640
|
|
1641 tmp_pixel = FACE_FOREGROUND (Vdefault_face, frame);
|
|
1642 tmp_fcolor = * (COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (tmp_pixel)));
|
|
1643 tmp_pixel = FACE_BACKGROUND (Vdefault_face, frame);
|
|
1644 tmp_bcolor = * (COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (tmp_pixel)));
|
|
1645
|
|
1646 memset (&gcv, ~0, sizeof (gcv)); /* initialize all slots to ~0 */
|
|
1647 gcv.foreground.pixel = (tmp_fcolor.pixel ^ tmp_bcolor.pixel);
|
|
1648 gcv.function = GDK_XOR;
|
|
1649 gcv.graphics_exposures = FALSE;
|
|
1650 gc = gc_cache_lookup (DEVICE_GTK_GC_CACHE (XDEVICE (f->device)), &gcv,
|
|
1651 GDK_GC_FOREGROUND | GDK_GC_FUNCTION | GDK_GC_EXPOSURES);
|
|
1652
|
|
1653 gdk_draw_rectangle (GDK_DRAWABLE (GET_GTK_WIDGET_WINDOW (FRAME_GTK_SHELL_WIDGET (f))),
|
|
1654 gc, TRUE, w->pixel_left, w->pixel_top,
|
|
1655 w->pixel_width, w->pixel_height);
|
|
1656
|
|
1657 gdk_flush ();
|
|
1658
|
|
1659 #ifdef HAVE_SELECT
|
|
1660 {
|
|
1661 int usecs = 100000;
|
|
1662 struct timeval tv;
|
|
1663 tv.tv_sec = usecs / 1000000L;
|
|
1664 tv.tv_usec = usecs % 1000000L;
|
|
1665 /* I'm sure someone is going to complain about this... */
|
|
1666 select (0, 0, 0, 0, &tv);
|
|
1667 }
|
|
1668 #else
|
778
|
1669 #ifdef HAVE_POLL
|
|
1670 poll (0, 0, 100);
|
|
1671 #else
|
462
|
1672 bite me
|
778
|
1673 #endif
|
|
1674 #endif
|
462
|
1675
|
|
1676 gdk_draw_rectangle (GDK_DRAWABLE (GET_GTK_WIDGET_WINDOW (FRAME_GTK_SHELL_WIDGET (f))),
|
|
1677 gc, TRUE, w->pixel_left, w->pixel_top,
|
|
1678 w->pixel_width, w->pixel_height);
|
|
1679
|
|
1680 gdk_flush ();
|
|
1681
|
|
1682 return 1;
|
|
1683 }
|
|
1684
|
|
1685 static void
|
|
1686 gtk_bevel_area (struct window *w, face_index findex,
|
|
1687 int x, int y, int width, int height,
|
|
1688 int shadow_thickness, int edges, enum edge_style style)
|
|
1689 {
|
|
1690 struct frame *f = XFRAME (w->frame);
|
|
1691
|
|
1692 gtk_output_shadows (f, x, y, width, height, shadow_thickness);
|
|
1693 }
|
|
1694
|
|
1695
|
|
1696
|
|
1697 /* Make audible bell. */
|
|
1698 static void
|
|
1699 gtk_ring_bell (struct device *d, int volume, int pitch, int duration)
|
|
1700 {
|
714
|
1701 /* Gdk does not allow us to control the duration / pitch / volume */
|
|
1702 if (volume > 0)
|
|
1703 {
|
|
1704 gdk_beep ();
|
|
1705 }
|
462
|
1706 }
|
|
1707
|
|
1708
|
|
1709 /************************************************************************/
|
|
1710 /* initialization */
|
|
1711 /************************************************************************/
|
|
1712
|
|
1713 void
|
|
1714 console_type_create_redisplay_gtk (void)
|
|
1715 {
|
|
1716 /* redisplay methods */
|
|
1717 CONSOLE_HAS_METHOD (gtk, text_width);
|
|
1718 CONSOLE_HAS_METHOD (gtk, output_display_block);
|
|
1719 CONSOLE_HAS_METHOD (gtk, divider_height);
|
|
1720 CONSOLE_HAS_METHOD (gtk, eol_cursor_width);
|
|
1721 CONSOLE_HAS_METHOD (gtk, output_vertical_divider);
|
|
1722 CONSOLE_HAS_METHOD (gtk, clear_to_window_end);
|
|
1723 CONSOLE_HAS_METHOD (gtk, clear_region);
|
|
1724 CONSOLE_HAS_METHOD (gtk, clear_frame);
|
|
1725 CONSOLE_HAS_METHOD (gtk, flash);
|
|
1726 CONSOLE_HAS_METHOD (gtk, ring_bell);
|
|
1727 CONSOLE_HAS_METHOD (gtk, bevel_area);
|
|
1728 CONSOLE_HAS_METHOD (gtk, output_string);
|
714
|
1729 CONSOLE_HAS_METHOD (gtk, output_pixmap);
|
462
|
1730 }
|
|
1731
|
|
1732 /* This makes me feel incredibly dirty... but there is no other way to
|
|
1733 get this done right other than calling clear_area before every
|
|
1734 single $#!%@ing piece of text, which I do NOT want to do. */
|
|
1735 #define USE_X_SPECIFIC_DRAW_ROUTINES 1
|
|
1736
|
|
1737 #include <gdk/gdkx.h>
|
|
1738
|
714
|
1739 static
|
|
1740 void gdk_draw_text_image (GdkDrawable *drawable,
|
|
1741 GdkFont *font,
|
|
1742 GdkGC *gc,
|
|
1743 gint x,
|
|
1744 gint y,
|
|
1745 const gchar *text,
|
|
1746 gint text_length)
|
462
|
1747 {
|
|
1748 #if !USE_X_SPECIFIC_DRAW_ROUTINES
|
|
1749 int width = gdk_text_measure (font, text, text_length);
|
|
1750 int height = gdk_text_height (font, text, text_length);
|
|
1751
|
|
1752 gdk_draw_rectangle (drawable, gc, TRUE, x, y, width, height);
|
|
1753 gdk_draw_text (drawable, font, gc, x, y, text, text_length);
|
|
1754 #else
|
|
1755 GdkWindowPrivate *drawable_private;
|
|
1756 GdkFontPrivate *font_private;
|
|
1757 GdkGCPrivate *gc_private;
|
|
1758
|
|
1759 g_return_if_fail (drawable != NULL);
|
|
1760 g_return_if_fail (font != NULL);
|
|
1761 g_return_if_fail (gc != NULL);
|
|
1762 g_return_if_fail (text != NULL);
|
|
1763
|
|
1764 drawable_private = (GdkWindowPrivate*) drawable;
|
|
1765 if (drawable_private->destroyed)
|
|
1766 return;
|
|
1767 gc_private = (GdkGCPrivate*) gc;
|
|
1768 font_private = (GdkFontPrivate*) font;
|
|
1769
|
|
1770 if (font->type == GDK_FONT_FONT)
|
|
1771 {
|
|
1772 XFontStruct *xfont = (XFontStruct *) font_private->xfont;
|
|
1773 XSetFont(drawable_private->xdisplay, gc_private->xgc, xfont->fid);
|
|
1774 if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
|
|
1775 {
|
|
1776 XDrawImageString (drawable_private->xdisplay, drawable_private->xwindow,
|
|
1777 gc_private->xgc, x, y, text, text_length);
|
|
1778 }
|
|
1779 else
|
|
1780 {
|
|
1781 XDrawImageString16 (drawable_private->xdisplay, drawable_private->xwindow,
|
|
1782 gc_private->xgc, x, y, (XChar2b *) text, text_length / 2);
|
|
1783 }
|
|
1784 }
|
|
1785 else if (font->type == GDK_FONT_FONTSET)
|
|
1786 {
|
|
1787 XFontSet fontset = (XFontSet) font_private->xfont;
|
|
1788 XmbDrawImageString (drawable_private->xdisplay, drawable_private->xwindow,
|
|
1789 fontset, gc_private->xgc, x, y, text, text_length);
|
|
1790 }
|
|
1791 else
|
|
1792 g_error("undefined font type\n");
|
|
1793 #endif
|
|
1794 }
|
|
1795
|
|
1796 static void
|
|
1797 our_draw_bitmap (GdkDrawable *drawable,
|
|
1798 GdkGC *gc,
|
|
1799 GdkPixmap *src,
|
|
1800 gint xsrc,
|
|
1801 gint ysrc,
|
|
1802 gint xdest,
|
|
1803 gint ydest,
|
|
1804 gint width,
|
|
1805 gint height)
|
|
1806 {
|
|
1807 GdkWindowPrivate *drawable_private;
|
|
1808 GdkWindowPrivate *src_private;
|
|
1809 GdkGCPrivate *gc_private;
|
|
1810
|
|
1811 g_return_if_fail (drawable != NULL);
|
|
1812 g_return_if_fail (src != NULL);
|
|
1813 g_return_if_fail (gc != NULL);
|
|
1814
|
|
1815 drawable_private = (GdkWindowPrivate*) drawable;
|
|
1816 src_private = (GdkWindowPrivate*) src;
|
|
1817 if (drawable_private->destroyed || src_private->destroyed)
|
|
1818 return;
|
|
1819 gc_private = (GdkGCPrivate*) gc;
|
|
1820
|
|
1821 if (width == -1)
|
|
1822 width = src_private->width;
|
|
1823 if (height == -1)
|
|
1824 height = src_private->height;
|
|
1825
|
|
1826 XCopyPlane (drawable_private->xdisplay,
|
|
1827 src_private->xwindow,
|
|
1828 drawable_private->xwindow,
|
|
1829 gc_private->xgc,
|
|
1830 xsrc, ysrc,
|
|
1831 width, height,
|
|
1832 xdest, ydest, 1L);
|
|
1833 }
|