213
|
1 /* mswindows output and frame manipulation routines.
|
|
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
|
|
3 Copyright (C) 1994 Lucid, Inc.
|
|
4 Copyright (C) 1995 Sun Microsystems, Inc.
|
|
5
|
|
6 This file is part of XEmacs.
|
|
7
|
|
8 XEmacs is free software; you can redistribute it and/or modify it
|
|
9 under the terms of the GNU General Public License as published by the
|
|
10 Free Software Foundation; either version 2, or (at your option) any
|
|
11 later version.
|
|
12
|
|
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
16 for more details.
|
|
17
|
|
18 You should have received a copy of the GNU General Public License
|
|
19 along with XEmacs; see the file COPYING. If not, write to
|
|
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
21 Boston, MA 02111-1307, USA. */
|
|
22
|
|
23 /* Synched up with: Not in FSF. */
|
|
24
|
|
25 /* Authorship:
|
|
26
|
|
27 Chuck Thompson
|
|
28 Lots of work done by Ben Wing for Mule
|
|
29 Partially rewritten for mswindows by Jonathan Harris, November 1997 for 20.4.
|
|
30 */
|
|
31
|
|
32 #include <config.h>
|
|
33 #include "lisp.h"
|
|
34
|
|
35 #include "console-msw.h"
|
|
36 #include "objects-msw.h"
|
|
37
|
|
38 #include "buffer.h"
|
|
39 #include "debug.h"
|
|
40 #include "events.h"
|
|
41 #include "faces.h"
|
|
42 #include "frame.h"
|
|
43 #include "glyphs.h" /* XXX FIXME: Should be glyphs-mswindows when we make one */
|
|
44 #include "redisplay.h"
|
|
45 #include "sysdep.h"
|
|
46 #include "window.h"
|
|
47
|
|
48 #include "windows.h"
|
|
49
|
|
50 /* MSWINDOWS_DIVIDER_LINE_WIDTH is the width of the line drawn in the gutter.
|
|
51 MSWINDOWS_DIVIDER_SPACING is the amount of blank space on each side of the line.
|
|
52 MSWINDOWS_DIVIDER_WIDTH = MSWINDOWS_DIVIDER_LINE_WIDTH + 2*MSWINDOWS_DIVIDER_SPACING
|
|
53 */
|
|
54 #define MSWINDOWS_DIVIDER_LINE_WIDTH 7
|
|
55 #define MSWINDOWS_DIVIDER_SPACING 0
|
|
56 #define MSWINDOWS_DIVIDER_WIDTH (MSWINDOWS_DIVIDER_LINE_WIDTH + 2 * MSWINDOWS_DIVIDER_SPACING)
|
|
57
|
|
58 #define MSWINDOWS_EOL_CURSOR_WIDTH 5
|
|
59
|
|
60 /*
|
|
61 * Random forward delarations
|
|
62 */
|
|
63 static void mswindows_clear_region (Lisp_Object locale, face_index findex,
|
|
64 int x, int y, int width, int height);
|
|
65 static void mswindows_output_vertical_divider (struct window *w, int clear);
|
|
66 static void mswindows_redraw_exposed_windows (Lisp_Object window, int x,
|
|
67 int y, int width, int height);
|
|
68
|
|
69
|
|
70
|
|
71 typedef struct textual_run
|
|
72 {
|
|
73 Lisp_Object charset;
|
|
74 unsigned char *ptr;
|
|
75 int len;
|
|
76 int dimension;
|
|
77 } textual_run;
|
|
78
|
|
79 /* Separate out the text in DYN into a series of textual runs of a
|
|
80 particular charset. Also convert the characters as necessary into
|
|
81 the format needed by XDrawImageString(), XDrawImageString16(), et
|
|
82 al. (This means converting to one or two byte format, possibly
|
|
83 tweaking the high bits, and possibly running a CCL program.) You
|
|
84 must pre-allocate the space used and pass it in. (This is done so
|
|
85 you can alloca() the space.) You need to allocate (2 * len) bytes
|
|
86 of TEXT_STORAGE and (len * sizeof (textual_run)) bytes of
|
|
87 RUN_STORAGE, where LEN is the length of the dynarr.
|
|
88
|
|
89 Returns the number of runs actually used. */
|
|
90
|
|
91 static int
|
|
92 separate_textual_runs (unsigned char *text_storage,
|
|
93 textual_run *run_storage,
|
|
94 CONST Emchar *str, Charcount len)
|
|
95 {
|
|
96 Lisp_Object prev_charset = Qunbound; /* not Qnil because that is a
|
|
97 possible valid charset when
|
|
98 MULE is not defined */
|
|
99 int runs_so_far = 0;
|
|
100 int i;
|
|
101 #ifdef MULE
|
|
102 struct ccl_program char_converter;
|
|
103 int need_ccl_conversion = 0;
|
|
104 #endif
|
|
105
|
|
106 for (i = 0; i < len; i++)
|
|
107 {
|
|
108 Emchar ch = str[i];
|
|
109 Lisp_Object charset;
|
|
110 int byte1, byte2;
|
|
111 int dimension;
|
|
112 int graphic;
|
|
113
|
|
114 BREAKUP_CHAR (ch, charset, byte1, byte2);
|
|
115 dimension = XCHARSET_DIMENSION (charset);
|
|
116 graphic = XCHARSET_GRAPHIC (charset);
|
|
117
|
|
118 if (!EQ (charset, prev_charset))
|
|
119 {
|
|
120 run_storage[runs_so_far].ptr = text_storage;
|
|
121 run_storage[runs_so_far].charset = charset;
|
|
122 run_storage[runs_so_far].dimension = dimension;
|
|
123
|
|
124 if (runs_so_far)
|
|
125 {
|
|
126 run_storage[runs_so_far - 1].len =
|
|
127 text_storage - run_storage[runs_so_far - 1].ptr;
|
|
128 if (run_storage[runs_so_far - 1].dimension == 2)
|
|
129 run_storage[runs_so_far - 1].len >>= 1;
|
|
130 }
|
|
131 runs_so_far++;
|
|
132 prev_charset = charset;
|
|
133 #ifdef MULE
|
|
134 {
|
|
135 Lisp_Object ccl_prog = XCHARSET_CCL_PROGRAM (charset);
|
|
136 need_ccl_conversion = !NILP (ccl_prog);
|
|
137 if (need_ccl_conversion)
|
|
138 setup_ccl_program (&char_converter, ccl_prog);
|
|
139 }
|
|
140 #endif
|
|
141 }
|
|
142
|
|
143 if (graphic == 0)
|
|
144 {
|
|
145 byte1 &= 0x7F;
|
|
146 byte2 &= 0x7F;
|
|
147 }
|
|
148 else if (graphic == 1)
|
|
149 {
|
|
150 byte1 |= 0x80;
|
|
151 byte2 |= 0x80;
|
|
152 }
|
|
153 #ifdef MULE
|
|
154 if (need_ccl_conversion)
|
|
155 {
|
|
156 char_converter.reg[0] = XCHARSET_ID (charset);
|
|
157 char_converter.reg[1] = byte1;
|
|
158 char_converter.reg[2] = byte2;
|
|
159 char_converter.ic = 0; /* start at beginning each time */
|
|
160 ccl_driver (&char_converter, 0, 0, 0, 0);
|
|
161 byte1 = char_converter.reg[1];
|
|
162 byte2 = char_converter.reg[2];
|
|
163 }
|
|
164 #endif
|
|
165 *text_storage++ = (unsigned char) byte1;
|
|
166 if (dimension == 2)
|
|
167 *text_storage++ = (unsigned char) byte2;
|
|
168 }
|
|
169
|
|
170 if (runs_so_far)
|
|
171 {
|
|
172 run_storage[runs_so_far - 1].len =
|
|
173 text_storage - run_storage[runs_so_far - 1].ptr;
|
|
174 if (run_storage[runs_so_far - 1].dimension == 2)
|
|
175 run_storage[runs_so_far - 1].len >>= 1;
|
|
176 }
|
|
177
|
|
178 return runs_so_far;
|
|
179 }
|
|
180
|
|
181
|
|
182 static int
|
|
183 mswindows_text_width_single_run (HDC hdc, struct face_cachel *cachel,
|
|
184 textual_run *run)
|
|
185 {
|
|
186 Lisp_Object font_inst = FACE_CACHEL_FONT (cachel, run->charset);
|
|
187 struct Lisp_Font_Instance *fi = XFONT_INSTANCE (font_inst);
|
|
188 SIZE size;
|
|
189
|
|
190 #if 0 /* XXX HACK: mswindows_text_width is broken and will pass in a NULL hdc */
|
|
191 if (!fi->proportional_p)
|
|
192 #else
|
|
193 if (!fi->proportional_p || !hdc)
|
|
194 #endif
|
|
195 return (fi->width * run->len);
|
|
196 else
|
|
197 {
|
|
198 assert(run->dimension == 1); /* XXX FIXME! */
|
|
199 GetTextExtentPoint32(hdc, run->ptr, run->len, &size);
|
|
200 return(size.cx);
|
|
201 }
|
|
202 }
|
|
203
|
|
204
|
|
205 /*****************************************************************************
|
|
206 mswindows_update_gc
|
|
207
|
|
208 Given a number of parameters munge the GC so it has those properties.
|
|
209 ****************************************************************************/
|
|
210 static void
|
|
211 mswindows_update_gc (HDC hdc, Lisp_Object font, Lisp_Object fg, Lisp_Object bg,
|
|
212 Lisp_Object bg_pmap, Lisp_Object lwidth)
|
|
213 {
|
|
214 if (!NILP (font))
|
|
215 SelectObject(hdc, (XFONT_INSTANCE (font))->data);
|
|
216
|
|
217 /* evil kludge! - XXX do we need this? */
|
|
218 if (!NILP (fg) && !COLOR_INSTANCEP (fg))
|
|
219 {
|
|
220 fprintf (stderr, "Help! mswindows_update_gc got a bogus fg value! fg = ");
|
|
221 debug_print (fg);
|
|
222 fg = Qnil;
|
|
223 }
|
|
224
|
|
225 if (!NILP (fg))
|
|
226 SetTextColor (hdc, COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (fg)));
|
|
227
|
|
228 if (!NILP (bg))
|
|
229 SetBkColor (hdc, COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (bg)));
|
|
230
|
|
231 #if 0 /* XXX Implement me */
|
|
232 /* I expect that the Lisp_Image_Instance's data will point to a brush */
|
|
233 if (IMAGE_INSTANCEP (bg_pmap)
|
|
234 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
|
|
235 {
|
|
236 if (XIMAGE_INSTANCE_PIXMAP_DEPTH (bg_pmap) == 0)
|
|
237 {
|
|
238 gcv.fill_style = FillOpaqueStippled;
|
|
239 gcv.stipple = XIMAGE_INSTANCE_X_PIXMAP (bg_pmap);
|
|
240 mask |= (GCStipple | GCFillStyle);
|
|
241 }
|
|
242 else
|
|
243 {
|
|
244 gcv.fill_style = FillTiled;
|
|
245 gcv.tile = XIMAGE_INSTANCE_X_PIXMAP (bg_pmap);
|
|
246 mask |= (GCTile | GCFillStyle);
|
|
247 }
|
|
248 }
|
|
249 #endif
|
|
250
|
|
251 #if 0 /* XXX FIXME */
|
|
252 if (!NILP (lwidth))
|
|
253 {
|
|
254 gcv.line_width = XINT (lwidth);
|
|
255 mask |= GCLineWidth;
|
|
256 }
|
|
257 #endif
|
|
258 }
|
|
259
|
|
260
|
|
261 /*****************************************************************************
|
|
262 mswindows_output_hline
|
|
263
|
|
264 Output a horizontal line in the foreground of its face.
|
|
265 ****************************************************************************/
|
|
266 static void
|
|
267 mswindows_output_hline (struct window *w, struct display_line *dl, struct rune *rb)
|
|
268 { /* XXX Implement me */
|
|
269 }
|
|
270
|
|
271
|
|
272 /*****************************************************************************
|
|
273 mswindows_output_blank
|
|
274
|
|
275 Output a blank by clearing the area it covers in the background color
|
|
276 of its face.
|
|
277 ****************************************************************************/
|
|
278 static void
|
|
279 mswindows_output_blank (struct window *w, struct display_line *dl, struct rune *rb)
|
|
280 {
|
|
281 struct frame *f = XFRAME (w->frame);
|
|
282 RECT rect = { rb->xpos, dl->ypos-dl->ascent,
|
|
283 rb->xpos+rb->width, dl->ypos+dl->descent-dl->clip };
|
|
284 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, rb->findex);
|
|
285
|
|
286 Lisp_Object bg_pmap = WINDOW_FACE_CACHEL_BACKGROUND_PIXMAP (w, rb->findex);
|
|
287
|
|
288 if (!IMAGE_INSTANCEP (bg_pmap)
|
|
289 || !IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
|
|
290 bg_pmap = Qnil;
|
|
291
|
227
|
292 /* #### This deals only with solid colors */
|
|
293 mswindows_update_gc (FRAME_MSWINDOWS_DC (f), Qnil, Qnil,
|
|
294 cachel->background, Qnil, Qnil);
|
|
295 ExtTextOut (FRAME_MSWINDOWS_DC (f), 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
|
213
|
296 }
|
|
297
|
|
298
|
|
299 /*****************************************************************************
|
|
300 mswindows_output_cursor
|
|
301
|
|
302 Draw a normal or end-of-line cursor. The end-of-line cursor is
|
|
303 narrower than the normal cursor.
|
|
304 ****************************************************************************/
|
|
305 static void
|
|
306 mswindows_output_cursor (struct window *w, struct display_line *dl, int xpos,
|
|
307 int width, struct rune *rb)
|
|
308 {
|
|
309 struct frame *f = XFRAME (w->frame);
|
|
310 struct device *d = XDEVICE (f->device);
|
|
311 struct face_cachel *cachel;
|
227
|
312 Lisp_Object font = Qnil;
|
213
|
313 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
|
|
314 HDC hdc = FRAME_MSWINDOWS_DC (f);
|
|
315 int real_char_p = (rb->type == RUNE_CHAR && rb->object.chr.ch != '\n');
|
227
|
316 char *p_char = NULL;
|
|
317 int n_char = 0;
|
213
|
318 RECT rect = { xpos,
|
|
319 dl->ypos - dl->ascent,
|
|
320 xpos + width,
|
|
321 dl->ypos + dl->descent - dl->clip};
|
|
322
|
239
|
323 Lisp_Object bar = symbol_value_in_buffer (Qbar_cursor,
|
|
324 WINDOW_BUFFER (w));
|
|
325 int bar_p = !NILP (bar);
|
213
|
326
|
|
327 if (real_char_p)
|
|
328 {
|
|
329 /* Use the font from the underlying character */
|
|
330 cachel = WINDOW_FACE_CACHEL (w, rb->findex);
|
|
331
|
|
332 /* XXX MULE: Need to know the charset! */
|
|
333 font = FACE_CACHEL_FONT (cachel, Vcharset_ascii);
|
|
334 }
|
|
335
|
239
|
336 if ((focus || bar_p) && real_char_p)
|
227
|
337 {
|
|
338 p_char = (char*) &rb->object.chr.ch;
|
|
339 n_char = 1;
|
|
340 }
|
|
341
|
239
|
342 /* Use cursor fg/bg for block cursor, or character fg/bg for the bar.
|
|
343 Output nothing at eol if bar cursor */
|
227
|
344 cachel = WINDOW_FACE_CACHEL (w,
|
239
|
345 (bar_p
|
|
346 ? rb->findex
|
|
347 : get_builtin_face_cache_index (w, Vtext_cursor_face)));
|
227
|
348 mswindows_update_gc (hdc, font, cachel->foreground,
|
|
349 cachel->background, Qnil, Qnil);
|
|
350 ExtTextOut (FRAME_MSWINDOWS_DC (f), xpos, dl->ypos, ETO_OPAQUE,
|
|
351 &rect, p_char, n_char, NULL);
|
213
|
352
|
239
|
353 if (focus && bar_p)
|
|
354 {
|
|
355 rect.right = rect.left + (EQ (bar, Qt) ? 1 : 2);
|
|
356 cachel = WINDOW_FACE_CACHEL (w,
|
|
357 get_builtin_face_cache_index (w, Vtext_cursor_face));
|
|
358 mswindows_update_gc (hdc, Qnil, Qnil,
|
|
359 cachel->background, Qnil, Qnil);
|
|
360 ExtTextOut (FRAME_MSWINDOWS_DC (f), xpos, dl->ypos, ETO_OPAQUE,
|
|
361 &rect, NULL, 0, NULL);
|
|
362 }
|
|
363 else if (!focus)
|
213
|
364 {
|
239
|
365 /* Now have real character drawn in its own color. We defalte
|
|
366 the rectangle so character cell will be bounded by the
|
|
367 previously drawn cursor shape */
|
|
368 InflateRect (&rect, -1, -1);
|
213
|
369
|
239
|
370 if (real_char_p)
|
|
371 {
|
|
372 p_char = (char*) &rb->object.chr.ch;
|
|
373 n_char = 1;
|
|
374 }
|
|
375
|
|
376 cachel = WINDOW_FACE_CACHEL (w, (real_char_p ? rb->findex
|
|
377 : get_builtin_face_cache_index (w, Vdefault_face)));
|
|
378 mswindows_update_gc (hdc, Qnil, cachel->foreground,
|
|
379 cachel->background, Qnil, Qnil);
|
|
380 ExtTextOut (FRAME_MSWINDOWS_DC (f), xpos, dl->ypos, ETO_OPAQUE | ETO_CLIPPED,
|
|
381 &rect, p_char, n_char, NULL);
|
|
382 }
|
213
|
383 }
|
|
384
|
|
385
|
|
386 /*****************************************************************************
|
|
387 mswindows_output_string
|
|
388
|
|
389 Given a string and a starting position, output that string in the
|
|
390 given face.
|
|
391 Correctly handles multiple charsets in the string.
|
|
392
|
|
393 The meaning of the parameters is something like this:
|
|
394
|
|
395 W Window that the text is to be displayed in.
|
|
396 DL Display line that this text is on. The values in the
|
|
397 structure are used to determine the vertical position and
|
|
398 clipping range of the text.
|
|
399 BUF Dynamic array of Emchars specifying what is actually to be
|
|
400 drawn.
|
|
401 XPOS X position in pixels where the text should start being drawn.
|
|
402 XOFFSET Number of pixels to be chopped off the left side of the
|
|
403 text. The effect is as if the text were shifted to the
|
|
404 left this many pixels and clipped at XPOS.
|
|
405 CLIP_START Clip everything left of this X position.
|
|
406 WIDTH Clip everything right of XPOS + WIDTH.
|
|
407 FINDEX Index for the face cache element describing how to display
|
|
408 the text.
|
|
409 ****************************************************************************/
|
|
410 void
|
|
411 mswindows_output_string (struct window *w, struct display_line *dl,
|
|
412 Emchar_dynarr *buf, int xpos, int xoffset, int clip_start,
|
|
413 int width, face_index findex)
|
|
414 {
|
|
415 struct frame *f = XFRAME (w->frame);
|
|
416 struct device *d = XDEVICE (f->device);
|
|
417 Lisp_Object window = Qnil;
|
|
418 HDC hdc;
|
|
419 int clip_end;
|
|
420 Lisp_Object bg_pmap;
|
|
421 int len = Dynarr_length (buf);
|
|
422 unsigned char *text_storage = (unsigned char *) alloca (2 * len);
|
|
423 textual_run *runs = alloca_array (textual_run, len);
|
|
424 int nruns;
|
|
425 int i;
|
|
426 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, findex);
|
|
427
|
|
428 XSETWINDOW (window, w);
|
|
429 hdc = FRAME_MSWINDOWS_DC(f);
|
|
430
|
|
431 #if 0 /* XXX: FIXME? */
|
|
432 /* We can't work out the width before we've set the font in the DC */
|
|
433 if (width < 0)
|
|
434 width = mswindows_text_width (cachel, Dynarr_atp (buf, 0), Dynarr_length (buf));
|
|
435 #else
|
|
436 assert(width>=0);
|
|
437 #endif
|
|
438
|
|
439 /* Regularize the variables passed in. */
|
|
440 if (clip_start < xpos)
|
|
441 clip_start = xpos;
|
|
442 clip_end = xpos + width;
|
|
443 if (clip_start >= clip_end)
|
|
444 /* It's all clipped out. */
|
|
445 return;
|
|
446
|
|
447 xpos -= xoffset;
|
|
448
|
|
449 nruns = separate_textual_runs (text_storage, runs, Dynarr_atp (buf, 0),
|
|
450 Dynarr_length (buf));
|
|
451
|
|
452 bg_pmap = cachel->background_pixmap;
|
|
453 if (!IMAGE_INSTANCEP (bg_pmap)
|
|
454 || !IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
|
|
455 bg_pmap = Qnil;
|
|
456
|
|
457 for (i = 0; i < nruns; i++)
|
|
458 {
|
|
459 Lisp_Object font = FACE_CACHEL_FONT (cachel, runs[i].charset);
|
|
460 struct Lisp_Font_Instance *fi = XFONT_INSTANCE (font);
|
|
461 int this_width;
|
|
462 RECT rect = { clip_start, dl->ypos - dl->ascent,
|
|
463 clip_end, dl->ypos + dl->descent - dl->clip };
|
|
464
|
|
465 if (EQ (font, Vthe_null_font_instance))
|
|
466 continue;
|
|
467
|
|
468 mswindows_update_gc (hdc, font, cachel->foreground,
|
227
|
469 NILP(bg_pmap) ? cachel->background : Qnil,
|
|
470 Qnil, Qnil);
|
213
|
471
|
|
472 this_width = mswindows_text_width_single_run (hdc, cachel, runs + i);
|
|
473
|
227
|
474 /* #### bg_pmap should be output here */
|
213
|
475
|
|
476 assert (runs[i].dimension == 1); /* XXX FIXME */
|
227
|
477 ExtTextOut (hdc, xpos, dl->ypos,
|
|
478 NILP(bg_pmap) ? ETO_CLIPPED | ETO_OPAQUE : ETO_CLIPPED,
|
|
479 &rect, (char *) runs[i].ptr, runs[i].len, NULL);
|
213
|
480
|
|
481 /* XXX FIXME? X does underline/strikethrough here
|
|
482 we will do it as part of face's font */
|
|
483
|
|
484 xpos += this_width;
|
|
485 }
|
|
486 }
|
|
487
|
227
|
488
|
|
489 #ifdef HAVE_SCROLLBARS
|
|
490 /*
|
|
491 * This function paints window's deadbox, a rectangle between window
|
|
492 * borders and two short edges of both scrollbars.
|
|
493 *
|
|
494 * Function checks whether deadbox intersects with the rectangle pointed
|
|
495 * to by PRC, and paints only the intersection
|
|
496 */
|
|
497 static void
|
239
|
498 mswindows_redisplay_deadbox_maybe (struct window *w,
|
|
499 CONST RECT* prc)
|
227
|
500 {
|
|
501 int sbh = window_scrollbar_height (w);
|
|
502 int sbw = window_scrollbar_width (w);
|
|
503 RECT rect_dead, rect_paint;
|
|
504 struct frame *f;
|
|
505 if (sbh == 0 || sbw == 0)
|
|
506 return;
|
|
507
|
|
508 f = XFRAME (WINDOW_FRAME (w));
|
|
509 if (f->scrollbar_on_left)
|
|
510 {
|
|
511 rect_dead.left = WINDOW_LEFT (w);
|
|
512 rect_dead.right = WINDOW_LEFT (w) + sbw;
|
|
513 }
|
|
514 else
|
|
515 {
|
|
516 rect_dead.left = WINDOW_RIGHT (w) - sbw;
|
|
517 rect_dead.right = WINDOW_RIGHT (w);
|
|
518 }
|
|
519
|
|
520 if (f->scrollbar_on_top)
|
|
521 {
|
|
522 rect_dead.top = WINDOW_TOP (w);
|
|
523 rect_dead.bottom = WINDOW_TOP (w) + sbh;
|
|
524 }
|
|
525 else
|
|
526 {
|
|
527 int modh = window_modeline_height (w);
|
|
528 rect_dead.top = WINDOW_BOTTOM (w) - modh - sbh;
|
|
529 rect_dead.bottom = WINDOW_BOTTOM (w) - modh;
|
|
530 }
|
|
531
|
|
532 if (IntersectRect (&rect_paint, &rect_dead, prc))
|
|
533 FillRect (FRAME_MSWINDOWS_DC (f), &rect_paint,
|
|
534 (HBRUSH)GetClassLong (FRAME_MSWINDOWS_HANDLE(f), GCL_HBRBACKGROUND));
|
|
535 }
|
|
536
|
|
537 #endif /* HAVE_SCROLLBARS */
|
|
538
|
213
|
539 /*****************************************************************************
|
|
540 mswindows_redraw_exposed_window
|
|
541
|
|
542 Given a bounding box for an area that needs to be redrawn, determine
|
|
543 what parts of what lines are contained within and re-output their
|
|
544 contents.
|
|
545 Copied from redisplay-x.c
|
|
546 ****************************************************************************/
|
|
547 static void
|
|
548 mswindows_redraw_exposed_window (struct window *w, int x, int y, int width,
|
|
549 int height)
|
|
550 {
|
|
551 struct frame *f = XFRAME (w->frame);
|
|
552 int line;
|
|
553 int orig_windows_structure_changed;
|
227
|
554 RECT rect_window = { WINDOW_LEFT (w), WINDOW_TOP (w),
|
|
555 WINDOW_RIGHT (w), WINDOW_BOTTOM (w) };
|
|
556 RECT rect_expose = { x, y, x + width, y + height };
|
|
557 RECT rect_draw;
|
213
|
558
|
|
559 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
560
|
|
561 if (!NILP (w->vchild))
|
|
562 {
|
|
563 mswindows_redraw_exposed_windows (w->vchild, x, y, width, height);
|
|
564 return;
|
|
565 }
|
|
566 else if (!NILP (w->hchild))
|
|
567 {
|
|
568 mswindows_redraw_exposed_windows (w->hchild, x, y, width, height);
|
|
569 return;
|
|
570 }
|
|
571
|
|
572 /* If the window doesn't intersect the exposed region, we're done here. */
|
227
|
573 if (!IntersectRect (&rect_draw, &rect_window, &rect_expose))
|
213
|
574 return;
|
|
575
|
227
|
576 /* We do this to make sure that the 3D modelines get redrawn if
|
|
577 they are in the exposed region. */
|
|
578 orig_windows_structure_changed = f->windows_structure_changed;
|
|
579 f->windows_structure_changed = 1;
|
213
|
580
|
|
581 if (window_needs_vertical_divider (w))
|
|
582 {
|
|
583 mswindows_output_vertical_divider (w, 0);
|
|
584 }
|
|
585
|
|
586 for (line = 0; line < Dynarr_length (cdla); line++)
|
|
587 {
|
|
588 struct display_line *cdl = Dynarr_atp (cdla, line);
|
|
589 int top_y = cdl->ypos - cdl->ascent;
|
|
590 int bottom_y = cdl->ypos + cdl->descent;
|
|
591
|
227
|
592 if (bottom_y >= rect_draw.top)
|
213
|
593 {
|
227
|
594 if (top_y > rect_draw.bottom)
|
213
|
595 {
|
|
596 if (line == 0)
|
|
597 continue;
|
|
598 else
|
|
599 break;
|
|
600 }
|
|
601 else
|
|
602 {
|
227
|
603 output_display_line (w, 0, cdla, line,
|
|
604 rect_draw.left, rect_draw.right);
|
213
|
605 }
|
|
606 }
|
|
607 }
|
|
608
|
|
609 f->windows_structure_changed = orig_windows_structure_changed;
|
|
610
|
|
611 /* If there have never been any face cache_elements created, then this
|
|
612 expose event doesn't actually have anything to do. */
|
|
613 if (Dynarr_largest (w->face_cachels))
|
227
|
614 redisplay_clear_bottom_of_window (w, cdla, rect_draw.top, rect_draw.bottom);
|
|
615
|
|
616 #ifdef HAVE_SCROLLBARS
|
|
617 mswindows_redisplay_deadbox_maybe (w, &rect_expose);
|
|
618 #endif
|
213
|
619 }
|
|
620
|
|
621 /*****************************************************************************
|
|
622 mswindows_redraw_exposed_windows
|
|
623
|
|
624 For each window beneath the given window in the window hierarchy,
|
|
625 ensure that it is redrawn if necessary after an Expose event.
|
|
626 ****************************************************************************/
|
|
627 static void
|
|
628 mswindows_redraw_exposed_windows (Lisp_Object window, int x, int y, int width,
|
|
629 int height)
|
|
630 {
|
|
631 for (; !NILP (window); window = XWINDOW (window)->next)
|
|
632 mswindows_redraw_exposed_window (XWINDOW (window), x, y, width, height);
|
|
633 }
|
|
634
|
|
635 /*****************************************************************************
|
|
636 mswindows_redraw_exposed_area
|
|
637
|
|
638 For each window on the given frame, ensure that any area in the
|
|
639 Exposed area is redrawn.
|
|
640 ****************************************************************************/
|
|
641 void
|
|
642 mswindows_redraw_exposed_area (struct frame *f, int x, int y, int width, int height)
|
|
643 {
|
|
644 /* If any window on the frame has had its face cache reset then the
|
|
645 redisplay structures are effectively invalid. If we attempt to
|
|
646 use them we'll blow up. We mark the frame as changed to ensure
|
|
647 that redisplay will do a full update. This probably isn't
|
|
648 necessary but it can't hurt. */
|
|
649
|
|
650 if (!f->window_face_cache_reset)
|
215
|
651 {
|
|
652 mswindows_redraw_exposed_windows (f->root_window, x, y, width, height);
|
|
653 GdiFlush();
|
|
654 }
|
213
|
655 else
|
|
656 MARK_FRAME_CHANGED (f);
|
|
657 }
|
|
658
|
|
659
|
|
660 /*****************************************************************************
|
|
661 mswindows_bevel_modeline
|
|
662
|
|
663 Draw a 3d border around the modeline on window W.
|
|
664 ****************************************************************************/
|
|
665 static void
|
|
666 mswindows_bevel_modeline (struct window *w, struct display_line *dl)
|
|
667 {
|
|
668 struct frame *f = XFRAME (w->frame);
|
|
669 Lisp_Object color;
|
|
670 int shadow_width = MODELINE_SHADOW_THICKNESS (w);
|
|
671 RECT rect = { WINDOW_MODELINE_LEFT (w),
|
|
672 dl->ypos - dl->ascent - shadow_width,
|
|
673 WINDOW_MODELINE_RIGHT (w),
|
|
674 dl->ypos + dl->descent + shadow_width};
|
239
|
675 UINT edge;
|
213
|
676
|
|
677 color = WINDOW_FACE_CACHEL_BACKGROUND (w, MODELINE_INDEX);
|
|
678 mswindows_update_gc(FRAME_MSWINDOWS_DC(f), Qnil, Qnil, color, Qnil, Qnil);
|
|
679
|
239
|
680 if (XINT (w->modeline_shadow_thickness) < 0)
|
|
681 shadow_width = -shadow_width;
|
213
|
682
|
239
|
683 if (shadow_width < -1)
|
|
684 edge = EDGE_SUNKEN;
|
|
685 else if (shadow_width < 0)
|
|
686 edge = BDR_SUNKENINNER;
|
|
687 else if (shadow_width == 1)
|
|
688 edge = BDR_RAISEDINNER;
|
|
689 else
|
|
690 edge = EDGE_RAISED;
|
|
691
|
|
692 DrawEdge (FRAME_MSWINDOWS_DC(f), &rect, edge, BF_RECT);
|
213
|
693 }
|
|
694
|
|
695
|
|
696 /*****************************************************************************
|
|
697 #### Display methods
|
|
698 /*****************************************************************************
|
|
699
|
|
700 /*****************************************************************************
|
|
701 mswindows_divider_width
|
|
702
|
|
703 Return the width of the vertical divider.
|
|
704 ****************************************************************************/
|
|
705 static int
|
|
706 mswindows_divider_width (void)
|
|
707 {
|
|
708 return MSWINDOWS_DIVIDER_WIDTH;
|
|
709 }
|
|
710
|
|
711 /*****************************************************************************
|
|
712 mswindows_divider_height
|
|
713
|
|
714 Return the height of the horizontal divider.
|
|
715 ****************************************************************************/
|
|
716 static int
|
|
717 mswindows_divider_height (void)
|
|
718 {
|
|
719 return 1; /* XXX Copied from redisplay-X.c. What is this? */
|
|
720 }
|
|
721
|
|
722 /*****************************************************************************
|
|
723 mswindows_eol_cursor_width
|
|
724
|
|
725 Return the width of the end-of-line cursor.
|
|
726 ****************************************************************************/
|
|
727 static int
|
|
728 mswindows_eol_cursor_width (void)
|
|
729 {
|
|
730 return MSWINDOWS_EOL_CURSOR_WIDTH;
|
|
731 }
|
|
732
|
|
733 /*****************************************************************************
|
|
734 mswindows_output_begin
|
|
735
|
|
736 Perform any necessary initialization prior to an update.
|
|
737 ****************************************************************************/
|
|
738 static void
|
|
739 mswindows_output_begin (struct device *d)
|
|
740 {
|
|
741 }
|
|
742
|
|
743 /*****************************************************************************
|
|
744 mswindows_output_end
|
|
745
|
|
746 Perform any necessary flushing of queues when an update has completed.
|
|
747 ****************************************************************************/
|
|
748 static void
|
|
749 mswindows_output_end (struct device *d)
|
|
750 {
|
215
|
751 GdiFlush();
|
213
|
752 }
|
|
753
|
|
754 static int
|
|
755 mswindows_flash (struct device *d)
|
|
756 {
|
|
757 struct frame *f = device_selected_frame (d);
|
239
|
758 RECT rc;
|
213
|
759
|
239
|
760 GetClientRect (FRAME_MSWINDOWS_HANDLE (f), &rc);
|
|
761 InvertRect (FRAME_MSWINDOWS_DC (f), &rc);
|
|
762 GdiFlush ();
|
|
763 Sleep (25);
|
|
764 InvertRect (FRAME_MSWINDOWS_DC (f), &rc);
|
|
765
|
|
766 return 1;
|
213
|
767 }
|
|
768
|
|
769 static void
|
|
770 mswindows_ring_bell (struct device *d, int volume, int pitch, int duration)
|
|
771 {
|
223
|
772 /* Beep does not work at all, anyways! -kkm */
|
|
773 MessageBeep (MB_OK);
|
213
|
774 }
|
|
775
|
|
776 /*****************************************************************************
|
|
777 mswindows_output_display_block
|
|
778
|
|
779 Given a display line, a block number for that start line, output all
|
|
780 runes between start and end in the specified display block.
|
|
781 Ripped off with mininmal thought from the corresponding X routine.
|
|
782 ****************************************************************************/
|
|
783 static void
|
|
784 mswindows_output_display_block (struct window *w, struct display_line *dl, int block,
|
|
785 int start, int end, int start_pixpos, int cursor_start,
|
|
786 int cursor_width, int cursor_height)
|
|
787 {
|
|
788 struct frame *f = XFRAME (w->frame);
|
|
789 Emchar_dynarr *buf = Dynarr_new (Emchar);
|
|
790 Lisp_Object window;
|
|
791
|
|
792 struct display_block *db = Dynarr_atp (dl->display_blocks, block);
|
|
793 rune_dynarr *rba = db->runes;
|
|
794 struct rune *rb;
|
|
795
|
|
796 int elt = start;
|
|
797 face_index findex;
|
|
798 int xpos, width;
|
|
799 Lisp_Object charset = Qunbound; /* Qnil is a valid charset when
|
|
800 MULE is not defined */
|
|
801 XSETWINDOW (window, w);
|
|
802 rb = Dynarr_atp (rba, start);
|
|
803
|
|
804 if (!rb)
|
|
805 {
|
|
806 /* Nothing to do so don't do anything. */
|
|
807 return;
|
|
808 }
|
|
809 else
|
|
810 {
|
|
811 findex = rb->findex;
|
|
812 xpos = rb->xpos;
|
|
813 width = 0;
|
|
814 if (rb->type == RUNE_CHAR)
|
|
815 charset = CHAR_CHARSET (rb->object.chr.ch);
|
|
816 }
|
|
817
|
|
818 if (end < 0)
|
|
819 end = Dynarr_length (rba);
|
|
820 Dynarr_reset (buf);
|
|
821
|
|
822 while (elt < end)
|
|
823 {
|
|
824 rb = Dynarr_atp (rba, elt);
|
|
825
|
|
826 if (rb->findex == findex && rb->type == RUNE_CHAR
|
|
827 && rb->object.chr.ch != '\n' && rb->cursor_type != CURSOR_ON
|
|
828 && EQ (charset, CHAR_CHARSET (rb->object.chr.ch)))
|
|
829 {
|
|
830 Dynarr_add (buf, rb->object.chr.ch);
|
|
831 width += rb->width;
|
|
832 elt++;
|
|
833 }
|
|
834 else
|
|
835 {
|
|
836 if (Dynarr_length (buf))
|
|
837 {
|
|
838 mswindows_output_string (w, dl, buf, xpos, 0, start_pixpos, width,
|
|
839 findex);
|
|
840 xpos = rb->xpos;
|
|
841 width = 0;
|
|
842 }
|
|
843 Dynarr_reset (buf);
|
|
844 width = 0;
|
|
845
|
|
846 if (rb->type == RUNE_CHAR)
|
|
847 {
|
|
848 findex = rb->findex;
|
|
849 xpos = rb->xpos;
|
|
850 charset = CHAR_CHARSET (rb->object.chr.ch);
|
|
851
|
|
852 if (rb->cursor_type == CURSOR_ON)
|
|
853 {
|
|
854 if (rb->object.chr.ch == '\n')
|
|
855 {
|
|
856 mswindows_output_cursor (w, dl, xpos, cursor_width, rb);
|
|
857 }
|
|
858 else
|
|
859 {
|
|
860 Dynarr_add (buf, rb->object.chr.ch);
|
|
861 #if 0
|
|
862 mswindows_output_string (w, dl, buf, xpos, 0, start_pixpos,
|
|
863 rb->width, findex, 1,
|
|
864 cursor_start, cursor_width,
|
|
865 cursor_height);
|
|
866 #else
|
|
867 mswindows_output_cursor (w, dl, xpos, cursor_width, rb);
|
|
868 #endif
|
|
869 Dynarr_reset (buf);
|
|
870 }
|
|
871
|
|
872 xpos += rb->width;
|
|
873 elt++;
|
|
874 }
|
|
875 else if (rb->object.chr.ch == '\n')
|
|
876 {
|
|
877 /* Clear in case a cursor was formerly here. */
|
|
878 int height = dl->ascent + dl->descent - dl->clip;
|
|
879
|
|
880 mswindows_clear_region (window, findex, xpos, dl->ypos - dl->ascent,
|
|
881 rb->width, height);
|
|
882 elt++;
|
|
883 }
|
|
884 }
|
|
885 else if (rb->type == RUNE_BLANK || rb->type == RUNE_HLINE)
|
|
886 {
|
|
887 if (rb->type == RUNE_BLANK)
|
|
888 mswindows_output_blank (w, dl, rb);
|
|
889 else
|
|
890 {
|
|
891 /* #### Our flagging of when we need to redraw the
|
|
892 modeline shadows sucks. Since RUNE_HLINE is only used
|
|
893 by the modeline at the moment it is a good bet
|
|
894 that if it gets redrawn then we should also
|
|
895 redraw the shadows. This won't be true forever.
|
|
896 We borrow the shadow_thickness_changed flag for
|
|
897 now. */
|
|
898 w->shadow_thickness_changed = 1;
|
|
899 mswindows_output_hline (w, dl, rb);
|
|
900 }
|
|
901
|
|
902 if (rb->cursor_type == CURSOR_ON)
|
|
903 mswindows_output_cursor (w, dl, xpos, cursor_width, rb);
|
|
904
|
|
905 elt++;
|
|
906 if (elt < end)
|
|
907 {
|
|
908 rb = Dynarr_atp (rba, elt);
|
|
909
|
|
910 findex = rb->findex;
|
|
911 xpos = rb->xpos;
|
|
912 }
|
|
913 }
|
|
914 else if (rb->type == RUNE_DGLYPH)
|
|
915 {
|
|
916 Lisp_Object instance;
|
|
917
|
|
918 XSETWINDOW (window, w);
|
|
919 instance = glyph_image_instance (rb->object.dglyph.glyph,
|
|
920 window, ERROR_ME_NOT, 1);
|
|
921 findex = rb->findex;
|
|
922
|
|
923 if (IMAGE_INSTANCEP (instance))
|
|
924 switch (XIMAGE_INSTANCE_TYPE (instance))
|
|
925 {
|
|
926 case IMAGE_TEXT:
|
|
927 {
|
|
928 /* #### This is way losing. See the comment in
|
|
929 add_glyph_rune(). */
|
|
930 Lisp_Object string =
|
|
931 XIMAGE_INSTANCE_TEXT_STRING (instance);
|
|
932 convert_bufbyte_string_into_emchar_dynarr
|
|
933 (XSTRING_DATA (string), XSTRING_LENGTH (string), buf);
|
|
934
|
|
935 if (rb->cursor_type == CURSOR_ON)
|
|
936 mswindows_output_cursor (w, dl, xpos, cursor_width, rb);
|
|
937 else
|
|
938 mswindows_output_string (w, dl, buf, xpos,
|
|
939 rb->object.dglyph.xoffset,
|
|
940 start_pixpos, -1, findex);
|
|
941 Dynarr_reset (buf);
|
|
942 }
|
|
943 break;
|
|
944
|
|
945 case IMAGE_MONO_PIXMAP:
|
|
946 case IMAGE_COLOR_PIXMAP:
|
|
947 #if 0
|
|
948 mswindows_output_pixmap (w, dl, instance, xpos,
|
|
949 rb->object.dglyph.xoffset, start_pixpos,
|
|
950 rb->width, findex, cursor_start,
|
|
951 cursor_width, cursor_height);
|
|
952 #endif
|
|
953 break;
|
|
954
|
|
955 case IMAGE_POINTER:
|
|
956 abort ();
|
|
957
|
|
958 case IMAGE_SUBWINDOW:
|
|
959 /* #### implement me */
|
|
960 break;
|
|
961
|
|
962 case IMAGE_NOTHING:
|
|
963 /* nothing is as nothing does */
|
|
964 break;
|
|
965
|
|
966 default:
|
|
967 abort ();
|
|
968 }
|
|
969
|
|
970 xpos += rb->width;
|
|
971 elt++;
|
|
972 }
|
|
973 else
|
|
974 abort ();
|
|
975 }
|
|
976 }
|
|
977
|
|
978 if (Dynarr_length (buf))
|
|
979 mswindows_output_string (w, dl, buf, xpos, 0, start_pixpos, width, findex);
|
|
980
|
|
981 if (dl->modeline
|
|
982 && !EQ (Qzero, w->modeline_shadow_thickness)
|
|
983 && (f->clear
|
|
984 || f->windows_structure_changed
|
|
985 || w->shadow_thickness_changed))
|
|
986 mswindows_bevel_modeline (w, dl);
|
|
987
|
|
988 Dynarr_free (buf);
|
|
989
|
|
990 }
|
|
991
|
|
992
|
|
993 /*****************************************************************************
|
|
994 mswindows_output_vertical_divider
|
|
995
|
|
996 Draw a vertical divider down the left side of the given window.
|
|
997 ****************************************************************************/
|
|
998 static void
|
|
999 mswindows_output_vertical_divider (struct window *w, int clear)
|
|
1000 {
|
|
1001 struct frame *f = XFRAME (w->frame);
|
|
1002 Lisp_Object color;
|
|
1003 RECT rect;
|
|
1004 int shadow_width = MODELINE_SHADOW_THICKNESS (w);
|
|
1005
|
|
1006 /* We don't use the normal gutter measurements here because the
|
|
1007 horizontal scrollbars and toolbars do not stretch completely over
|
|
1008 to the right edge of the window. Only the modeline does. */
|
|
1009 int modeline_height = window_modeline_height (w);
|
|
1010
|
|
1011 assert(!MSWINDOWS_DIVIDER_SPACING); /* This code doesn't handle this */
|
|
1012
|
|
1013 /* XXX Not sure about this */
|
|
1014 #ifdef HAVE_SCROLLBARS
|
|
1015 if (f->scrollbar_on_left)
|
|
1016 rect.left = WINDOW_LEFT (w);
|
|
1017 else
|
|
1018 rect.left = WINDOW_RIGHT (w) - MSWINDOWS_DIVIDER_WIDTH;
|
|
1019 #else
|
|
1020 rect.left = WINDOW_LEFT (w);
|
|
1021 #endif
|
|
1022 rect.right = rect.left + MSWINDOWS_DIVIDER_WIDTH;
|
|
1023
|
|
1024 #ifdef HAVE_SCROLLBARS
|
|
1025 if (f->scrollbar_on_top)
|
|
1026 rect.top = WINDOW_TOP (w);
|
|
1027 else
|
|
1028 #endif
|
|
1029 rect.top = WINDOW_TEXT_TOP (w);
|
|
1030 rect.bottom = WINDOW_BOTTOM (w) - modeline_height;
|
|
1031
|
|
1032 /* Draw the divider line */
|
|
1033 color = WINDOW_FACE_CACHEL_BACKGROUND (w, MODELINE_INDEX);
|
|
1034 mswindows_update_gc(FRAME_MSWINDOWS_DC(f), Qnil, Qnil, color, Qnil, Qnil);
|
227
|
1035 ExtTextOut (FRAME_MSWINDOWS_DC(f), 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
|
213
|
1036 if (shadow_width)
|
|
1037 DrawEdge (FRAME_MSWINDOWS_DC(f), &rect,
|
|
1038 shadow_width==1 ? BDR_RAISEDINNER : EDGE_RAISED,
|
|
1039 BF_TOP|BF_RIGHT|BF_LEFT);
|
|
1040 }
|
|
1041
|
|
1042
|
|
1043 /****************************************************************************
|
|
1044 mswindows_text_width
|
|
1045
|
|
1046 Given a string and a face, return the string's length in pixels when
|
|
1047 displayed in the font associated with the face.
|
|
1048 XXX FIXME: get redisplay_text_width_emchar_string() etc to pass in the
|
|
1049 window so we can get hold of the window's frame's gc
|
|
1050 ****************************************************************************/
|
|
1051 static int
|
|
1052 mswindows_text_width (struct face_cachel *cachel, CONST Emchar *str,
|
|
1053 Charcount len)
|
|
1054 {
|
|
1055 int width_so_far = 0;
|
|
1056 unsigned char *text_storage = (unsigned char *) alloca (2 * len);
|
|
1057 textual_run *runs = alloca_array (textual_run, len);
|
|
1058 int nruns;
|
|
1059 int i;
|
|
1060 HDC hdc=NULL; /* XXXXX FIXME! only works for non-proportional fonts! */
|
|
1061
|
|
1062 nruns = separate_textual_runs (text_storage, runs, str, len);
|
|
1063
|
|
1064 for (i = 0; i < nruns; i++)
|
|
1065 width_so_far += mswindows_text_width_single_run (hdc, cachel, runs + i);
|
|
1066
|
|
1067 return width_so_far;
|
|
1068 }
|
|
1069
|
|
1070
|
|
1071 /****************************************************************************
|
|
1072 mswindows_clear_region
|
|
1073
|
|
1074 Clear the area in the box defined by the given parameters using the
|
|
1075 given face.
|
|
1076 ****************************************************************************/
|
|
1077 static void
|
|
1078 mswindows_clear_region (Lisp_Object locale, face_index findex, int x, int y,
|
|
1079 int width, int height)
|
|
1080 {
|
|
1081 struct window *w;
|
|
1082 struct frame *f;
|
|
1083 Lisp_Object background_pixmap = Qunbound;
|
|
1084 Lisp_Object temp;
|
|
1085 RECT rect = { x, y, x+width, y+height };
|
|
1086 HBRUSH brush;
|
|
1087
|
|
1088 if (!(width && height)) /* We often seem to get called with width==0 */
|
|
1089 return;
|
|
1090
|
|
1091 if (WINDOWP (locale))
|
|
1092 {
|
|
1093 w = XWINDOW (locale);
|
|
1094 f = XFRAME (w->frame);
|
|
1095 }
|
|
1096 else if (FRAMEP (locale))
|
|
1097 {
|
|
1098 w = NULL;
|
|
1099 f = XFRAME (locale);
|
|
1100 }
|
|
1101 else
|
|
1102 abort ();
|
|
1103
|
|
1104 if (w)
|
|
1105 {
|
|
1106 temp = WINDOW_FACE_CACHEL_BACKGROUND_PIXMAP (w, findex);
|
|
1107
|
|
1108 if (IMAGE_INSTANCEP (temp)
|
|
1109 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (temp)))
|
|
1110 {
|
|
1111 /* #### maybe we could implement such that a string
|
|
1112 can be a background pixmap? */
|
|
1113 background_pixmap = temp;
|
|
1114 }
|
|
1115 }
|
|
1116 else
|
|
1117 {
|
|
1118 temp = FACE_BACKGROUND_PIXMAP (Vdefault_face, locale);
|
|
1119
|
|
1120 if (IMAGE_INSTANCEP (temp)
|
|
1121 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (temp)))
|
|
1122 {
|
|
1123 background_pixmap = temp;
|
|
1124 }
|
|
1125 }
|
|
1126
|
|
1127 if (!UNBOUNDP (background_pixmap))
|
|
1128 {
|
|
1129 if (XIMAGE_INSTANCE_PIXMAP_DEPTH (background_pixmap) == 0)
|
|
1130 {
|
|
1131 Lisp_Object fcolor, bcolor;
|
|
1132
|
|
1133 if (w)
|
|
1134 {
|
|
1135 fcolor = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
|
|
1136 bcolor = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
|
|
1137 }
|
|
1138 else
|
|
1139 {
|
|
1140 fcolor = FACE_FOREGROUND (Vdefault_face, locale);
|
|
1141 bcolor = FACE_BACKGROUND (Vdefault_face, locale);
|
|
1142 }
|
|
1143
|
|
1144 mswindows_update_gc (FRAME_MSWINDOWS_DC(f), Qnil, fcolor, bcolor, background_pixmap, Qnil);
|
|
1145 }
|
|
1146
|
|
1147 /* XX FIXME: Get brush from background_pixmap here */
|
|
1148 assert(0);
|
227
|
1149 FillRect (FRAME_MSWINDOWS_DC(f), &rect, brush);
|
213
|
1150 }
|
|
1151 else
|
|
1152 {
|
|
1153 Lisp_Object color = (w ? WINDOW_FACE_CACHEL_BACKGROUND (w, findex) :
|
|
1154 FACE_BACKGROUND (Vdefault_face, locale));
|
227
|
1155 mswindows_update_gc(FRAME_MSWINDOWS_DC(f), Qnil, Qnil, color, Qnil, Qnil);
|
|
1156 ExtTextOut (FRAME_MSWINDOWS_DC(f), 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
|
213
|
1157 }
|
|
1158
|
227
|
1159 #ifdef HAVE_SCROLLBARS
|
|
1160 if (WINDOWP (locale))
|
|
1161 mswindows_redisplay_deadbox_maybe (w, &rect);
|
|
1162 #endif
|
213
|
1163 }
|
|
1164
|
|
1165 /*****************************************************************************
|
|
1166 mswindows_clear_to_window_end
|
|
1167
|
|
1168 Clear the area between ypos1 and ypos2. Each margin area and the
|
|
1169 text area is handled separately since they may each have their own
|
|
1170 background color.
|
|
1171 ****************************************************************************/
|
|
1172 static void
|
|
1173 mswindows_clear_to_window_end (struct window *w, int ypos1, int ypos2)
|
|
1174 {
|
|
1175 int height = ypos2 - ypos1;
|
|
1176
|
|
1177 if (height)
|
|
1178 {
|
|
1179 struct frame *f = XFRAME (w->frame);
|
|
1180 Lisp_Object window;
|
|
1181 int bflag = (window_needs_vertical_divider (w) ? 0 : 1);
|
|
1182 layout_bounds bounds;
|
|
1183
|
|
1184 bounds = calculate_display_line_boundaries (w, bflag);
|
|
1185 XSETWINDOW (window, w);
|
|
1186
|
|
1187 if (window_is_leftmost (w))
|
|
1188 mswindows_clear_region (window, DEFAULT_INDEX, FRAME_LEFT_BORDER_START (f),
|
|
1189 ypos1, FRAME_BORDER_WIDTH (f), height);
|
|
1190
|
|
1191 if (bounds.left_in - bounds.left_out > 0)
|
|
1192 mswindows_clear_region (window,
|
|
1193 get_builtin_face_cache_index (w, Vleft_margin_face),
|
|
1194 bounds.left_out, ypos1,
|
|
1195 bounds.left_in - bounds.left_out, height);
|
|
1196
|
|
1197 if (bounds.right_in - bounds.left_in > 0)
|
|
1198 mswindows_clear_region (window, DEFAULT_INDEX, bounds.left_in, ypos1,
|
|
1199 bounds.right_in - bounds.left_in, height);
|
|
1200
|
|
1201 if (bounds.right_out - bounds.right_in > 0)
|
|
1202 mswindows_clear_region (window,
|
|
1203 get_builtin_face_cache_index (w, Vright_margin_face),
|
|
1204 bounds.right_in, ypos1,
|
|
1205 bounds.right_out - bounds.right_in, height);
|
|
1206
|
|
1207 if (window_is_rightmost (w))
|
|
1208 mswindows_clear_region (window, DEFAULT_INDEX, FRAME_RIGHT_BORDER_START (f),
|
|
1209 ypos1, FRAME_BORDER_WIDTH (f), height);
|
|
1210 }
|
|
1211
|
|
1212 }
|
|
1213
|
|
1214
|
215
|
1215 /* XXX Implement me! */
|
213
|
1216 static void
|
|
1217 mswindows_clear_frame (struct frame *f)
|
|
1218 {
|
215
|
1219 GdiFlush();
|
213
|
1220 }
|
|
1221
|
|
1222
|
|
1223
|
|
1224
|
|
1225 /************************************************************************/
|
|
1226 /* initialization */
|
|
1227 /************************************************************************/
|
|
1228
|
|
1229 void
|
|
1230 console_type_create_redisplay_mswindows (void)
|
|
1231 {
|
|
1232 /* redisplay methods */
|
|
1233 CONSOLE_HAS_METHOD (mswindows, text_width);
|
|
1234 CONSOLE_HAS_METHOD (mswindows, output_display_block);
|
|
1235 CONSOLE_HAS_METHOD (mswindows, divider_width);
|
|
1236 CONSOLE_HAS_METHOD (mswindows, divider_height);
|
|
1237 CONSOLE_HAS_METHOD (mswindows, eol_cursor_width);
|
|
1238 CONSOLE_HAS_METHOD (mswindows, output_vertical_divider);
|
|
1239 CONSOLE_HAS_METHOD (mswindows, clear_to_window_end);
|
|
1240 CONSOLE_HAS_METHOD (mswindows, clear_region);
|
|
1241 CONSOLE_HAS_METHOD (mswindows, clear_frame);
|
|
1242 CONSOLE_HAS_METHOD (mswindows, output_begin);
|
|
1243 CONSOLE_HAS_METHOD (mswindows, output_end);
|
|
1244 CONSOLE_HAS_METHOD (mswindows, flash);
|
|
1245 CONSOLE_HAS_METHOD (mswindows, ring_bell);
|
|
1246 }
|