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 HBRUSH brush;
|
|
315 HDC hdc = FRAME_MSWINDOWS_DC (f);
|
|
316 int real_char_p = (rb->type == RUNE_CHAR && rb->object.chr.ch != '\n');
|
227
|
317 char *p_char = NULL;
|
|
318 int n_char = 0;
|
213
|
319 RECT rect = { xpos,
|
|
320 dl->ypos - dl->ascent,
|
|
321 xpos + width,
|
|
322 dl->ypos + dl->descent - dl->clip};
|
|
323
|
|
324 #if 0 /* XXX FIXME: Whar about the bar_cursor? */
|
|
325 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor,
|
|
326 WINDOW_BUFFER (w));
|
|
327 #endif
|
|
328
|
|
329 if (real_char_p)
|
|
330 {
|
|
331 /* Use the font from the underlying character */
|
|
332 cachel = WINDOW_FACE_CACHEL (w, rb->findex);
|
|
333
|
|
334 /* XXX MULE: Need to know the charset! */
|
|
335 font = FACE_CACHEL_FONT (cachel, Vcharset_ascii);
|
|
336 }
|
|
337
|
227
|
338
|
|
339 if (focus && real_char_p)
|
|
340 {
|
|
341 p_char = (char*) &rb->object.chr.ch;
|
|
342 n_char = 1;
|
|
343 }
|
|
344
|
|
345 cachel = WINDOW_FACE_CACHEL (w,
|
213
|
346 get_builtin_face_cache_index (w, Vtext_cursor_face));
|
227
|
347 mswindows_update_gc (hdc, font, cachel->foreground,
|
|
348 cachel->background, Qnil, Qnil);
|
|
349 ExtTextOut (FRAME_MSWINDOWS_DC (f), xpos, dl->ypos, ETO_OPAQUE,
|
|
350 &rect, p_char, n_char, NULL);
|
213
|
351
|
227
|
352 if (focus)
|
|
353 return;
|
|
354
|
|
355 InflateRect (&rect, -1, -1);
|
213
|
356
|
|
357 if (real_char_p)
|
|
358 {
|
227
|
359 p_char = (char*) &rb->object.chr.ch;
|
|
360 n_char = 1;
|
213
|
361 }
|
|
362
|
227
|
363 cachel = WINDOW_FACE_CACHEL (w, (real_char_p ? rb->findex
|
|
364 : get_builtin_face_cache_index (w, Vdefault_face)));
|
|
365 mswindows_update_gc (hdc, Qnil, cachel->foreground,
|
|
366 cachel->background, Qnil, Qnil);
|
|
367 ExtTextOut (FRAME_MSWINDOWS_DC (f), xpos, dl->ypos, ETO_OPAQUE | ETO_CLIPPED,
|
|
368 &rect, p_char, n_char, NULL);
|
213
|
369 }
|
|
370
|
|
371
|
|
372 /*****************************************************************************
|
|
373 mswindows_output_string
|
|
374
|
|
375 Given a string and a starting position, output that string in the
|
|
376 given face.
|
|
377 Correctly handles multiple charsets in the string.
|
|
378
|
|
379 The meaning of the parameters is something like this:
|
|
380
|
|
381 W Window that the text is to be displayed in.
|
|
382 DL Display line that this text is on. The values in the
|
|
383 structure are used to determine the vertical position and
|
|
384 clipping range of the text.
|
|
385 BUF Dynamic array of Emchars specifying what is actually to be
|
|
386 drawn.
|
|
387 XPOS X position in pixels where the text should start being drawn.
|
|
388 XOFFSET Number of pixels to be chopped off the left side of the
|
|
389 text. The effect is as if the text were shifted to the
|
|
390 left this many pixels and clipped at XPOS.
|
|
391 CLIP_START Clip everything left of this X position.
|
|
392 WIDTH Clip everything right of XPOS + WIDTH.
|
|
393 FINDEX Index for the face cache element describing how to display
|
|
394 the text.
|
|
395 ****************************************************************************/
|
|
396 void
|
|
397 mswindows_output_string (struct window *w, struct display_line *dl,
|
|
398 Emchar_dynarr *buf, int xpos, int xoffset, int clip_start,
|
|
399 int width, face_index findex)
|
|
400 {
|
|
401 struct frame *f = XFRAME (w->frame);
|
|
402 struct device *d = XDEVICE (f->device);
|
|
403 Lisp_Object window = Qnil;
|
|
404 HDC hdc;
|
|
405 int clip_end;
|
|
406 Lisp_Object bg_pmap;
|
|
407 int len = Dynarr_length (buf);
|
|
408 unsigned char *text_storage = (unsigned char *) alloca (2 * len);
|
|
409 textual_run *runs = alloca_array (textual_run, len);
|
|
410 int nruns;
|
|
411 int i;
|
|
412 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, findex);
|
|
413
|
|
414 XSETWINDOW (window, w);
|
|
415 hdc = FRAME_MSWINDOWS_DC(f);
|
|
416
|
|
417 #if 0 /* XXX: FIXME? */
|
|
418 /* We can't work out the width before we've set the font in the DC */
|
|
419 if (width < 0)
|
|
420 width = mswindows_text_width (cachel, Dynarr_atp (buf, 0), Dynarr_length (buf));
|
|
421 #else
|
|
422 assert(width>=0);
|
|
423 #endif
|
|
424
|
|
425 /* Regularize the variables passed in. */
|
|
426 if (clip_start < xpos)
|
|
427 clip_start = xpos;
|
|
428 clip_end = xpos + width;
|
|
429 if (clip_start >= clip_end)
|
|
430 /* It's all clipped out. */
|
|
431 return;
|
|
432
|
|
433 xpos -= xoffset;
|
|
434
|
|
435 nruns = separate_textual_runs (text_storage, runs, Dynarr_atp (buf, 0),
|
|
436 Dynarr_length (buf));
|
|
437
|
|
438 bg_pmap = cachel->background_pixmap;
|
|
439 if (!IMAGE_INSTANCEP (bg_pmap)
|
|
440 || !IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
|
|
441 bg_pmap = Qnil;
|
|
442
|
|
443 for (i = 0; i < nruns; i++)
|
|
444 {
|
|
445 Lisp_Object font = FACE_CACHEL_FONT (cachel, runs[i].charset);
|
|
446 struct Lisp_Font_Instance *fi = XFONT_INSTANCE (font);
|
|
447 int this_width;
|
|
448 RECT rect = { clip_start, dl->ypos - dl->ascent,
|
|
449 clip_end, dl->ypos + dl->descent - dl->clip };
|
|
450
|
|
451 if (EQ (font, Vthe_null_font_instance))
|
|
452 continue;
|
|
453
|
|
454 mswindows_update_gc (hdc, font, cachel->foreground,
|
227
|
455 NILP(bg_pmap) ? cachel->background : Qnil,
|
|
456 Qnil, Qnil);
|
213
|
457
|
|
458 this_width = mswindows_text_width_single_run (hdc, cachel, runs + i);
|
|
459
|
227
|
460 /* #### bg_pmap should be output here */
|
213
|
461
|
|
462 assert (runs[i].dimension == 1); /* XXX FIXME */
|
227
|
463 ExtTextOut (hdc, xpos, dl->ypos,
|
|
464 NILP(bg_pmap) ? ETO_CLIPPED | ETO_OPAQUE : ETO_CLIPPED,
|
|
465 &rect, (char *) runs[i].ptr, runs[i].len, NULL);
|
213
|
466
|
|
467 /* XXX FIXME? X does underline/strikethrough here
|
|
468 we will do it as part of face's font */
|
|
469
|
|
470 xpos += this_width;
|
|
471 }
|
|
472 }
|
|
473
|
227
|
474
|
|
475 #ifdef HAVE_SCROLLBARS
|
|
476 /*
|
|
477 * This function paints window's deadbox, a rectangle between window
|
|
478 * borders and two short edges of both scrollbars.
|
|
479 *
|
|
480 * Function checks whether deadbox intersects with the rectangle pointed
|
|
481 * to by PRC, and paints only the intersection
|
|
482 */
|
|
483 static void
|
|
484 mswindows_redisplay_deadbox_maybe (CONST struct window *w,
|
|
485 CONST RECT* prc)
|
|
486 {
|
|
487 int sbh = window_scrollbar_height (w);
|
|
488 int sbw = window_scrollbar_width (w);
|
|
489 RECT rect_dead, rect_paint;
|
|
490 struct frame *f;
|
|
491 if (sbh == 0 || sbw == 0)
|
|
492 return;
|
|
493
|
|
494 f = XFRAME (WINDOW_FRAME (w));
|
|
495 if (f->scrollbar_on_left)
|
|
496 {
|
|
497 rect_dead.left = WINDOW_LEFT (w);
|
|
498 rect_dead.right = WINDOW_LEFT (w) + sbw;
|
|
499 }
|
|
500 else
|
|
501 {
|
|
502 rect_dead.left = WINDOW_RIGHT (w) - sbw;
|
|
503 rect_dead.right = WINDOW_RIGHT (w);
|
|
504 }
|
|
505
|
|
506 if (f->scrollbar_on_top)
|
|
507 {
|
|
508 rect_dead.top = WINDOW_TOP (w);
|
|
509 rect_dead.bottom = WINDOW_TOP (w) + sbh;
|
|
510 }
|
|
511 else
|
|
512 {
|
|
513 int modh = window_modeline_height (w);
|
|
514 rect_dead.top = WINDOW_BOTTOM (w) - modh - sbh;
|
|
515 rect_dead.bottom = WINDOW_BOTTOM (w) - modh;
|
|
516 }
|
|
517
|
|
518 if (IntersectRect (&rect_paint, &rect_dead, prc))
|
|
519 FillRect (FRAME_MSWINDOWS_DC (f), &rect_paint,
|
|
520 (HBRUSH)GetClassLong (FRAME_MSWINDOWS_HANDLE(f), GCL_HBRBACKGROUND));
|
|
521 }
|
|
522
|
|
523 #endif /* HAVE_SCROLLBARS */
|
|
524
|
213
|
525 /*****************************************************************************
|
|
526 mswindows_redraw_exposed_window
|
|
527
|
|
528 Given a bounding box for an area that needs to be redrawn, determine
|
|
529 what parts of what lines are contained within and re-output their
|
|
530 contents.
|
|
531 Copied from redisplay-x.c
|
|
532 ****************************************************************************/
|
|
533 static void
|
|
534 mswindows_redraw_exposed_window (struct window *w, int x, int y, int width,
|
|
535 int height)
|
|
536 {
|
|
537 struct frame *f = XFRAME (w->frame);
|
|
538 int line;
|
|
539 int orig_windows_structure_changed;
|
227
|
540 RECT rect_window = { WINDOW_LEFT (w), WINDOW_TOP (w),
|
|
541 WINDOW_RIGHT (w), WINDOW_BOTTOM (w) };
|
|
542 RECT rect_expose = { x, y, x + width, y + height };
|
|
543 RECT rect_draw;
|
213
|
544
|
|
545 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
546
|
|
547 if (!NILP (w->vchild))
|
|
548 {
|
|
549 mswindows_redraw_exposed_windows (w->vchild, x, y, width, height);
|
|
550 return;
|
|
551 }
|
|
552 else if (!NILP (w->hchild))
|
|
553 {
|
|
554 mswindows_redraw_exposed_windows (w->hchild, x, y, width, height);
|
|
555 return;
|
|
556 }
|
|
557
|
|
558 /* If the window doesn't intersect the exposed region, we're done here. */
|
227
|
559 if (!IntersectRect (&rect_draw, &rect_window, &rect_expose))
|
213
|
560 return;
|
|
561
|
227
|
562 /* We do this to make sure that the 3D modelines get redrawn if
|
|
563 they are in the exposed region. */
|
|
564 orig_windows_structure_changed = f->windows_structure_changed;
|
|
565 f->windows_structure_changed = 1;
|
213
|
566
|
|
567 if (window_needs_vertical_divider (w))
|
|
568 {
|
|
569 mswindows_output_vertical_divider (w, 0);
|
|
570 }
|
|
571
|
|
572 for (line = 0; line < Dynarr_length (cdla); line++)
|
|
573 {
|
|
574 struct display_line *cdl = Dynarr_atp (cdla, line);
|
|
575 int top_y = cdl->ypos - cdl->ascent;
|
|
576 int bottom_y = cdl->ypos + cdl->descent;
|
|
577
|
227
|
578 if (bottom_y >= rect_draw.top)
|
213
|
579 {
|
227
|
580 if (top_y > rect_draw.bottom)
|
213
|
581 {
|
|
582 if (line == 0)
|
|
583 continue;
|
|
584 else
|
|
585 break;
|
|
586 }
|
|
587 else
|
|
588 {
|
227
|
589 output_display_line (w, 0, cdla, line,
|
|
590 rect_draw.left, rect_draw.right);
|
213
|
591 }
|
|
592 }
|
|
593 }
|
|
594
|
|
595 f->windows_structure_changed = orig_windows_structure_changed;
|
|
596
|
|
597 /* If there have never been any face cache_elements created, then this
|
|
598 expose event doesn't actually have anything to do. */
|
|
599 if (Dynarr_largest (w->face_cachels))
|
227
|
600 redisplay_clear_bottom_of_window (w, cdla, rect_draw.top, rect_draw.bottom);
|
|
601
|
|
602 #ifdef HAVE_SCROLLBARS
|
|
603 mswindows_redisplay_deadbox_maybe (w, &rect_expose);
|
|
604 #endif
|
213
|
605 }
|
|
606
|
|
607 /*****************************************************************************
|
|
608 mswindows_redraw_exposed_windows
|
|
609
|
|
610 For each window beneath the given window in the window hierarchy,
|
|
611 ensure that it is redrawn if necessary after an Expose event.
|
|
612 ****************************************************************************/
|
|
613 static void
|
|
614 mswindows_redraw_exposed_windows (Lisp_Object window, int x, int y, int width,
|
|
615 int height)
|
|
616 {
|
|
617 for (; !NILP (window); window = XWINDOW (window)->next)
|
|
618 mswindows_redraw_exposed_window (XWINDOW (window), x, y, width, height);
|
|
619 }
|
|
620
|
|
621 /*****************************************************************************
|
|
622 mswindows_redraw_exposed_area
|
|
623
|
|
624 For each window on the given frame, ensure that any area in the
|
|
625 Exposed area is redrawn.
|
|
626 ****************************************************************************/
|
|
627 void
|
|
628 mswindows_redraw_exposed_area (struct frame *f, int x, int y, int width, int height)
|
|
629 {
|
|
630 /* If any window on the frame has had its face cache reset then the
|
|
631 redisplay structures are effectively invalid. If we attempt to
|
|
632 use them we'll blow up. We mark the frame as changed to ensure
|
|
633 that redisplay will do a full update. This probably isn't
|
|
634 necessary but it can't hurt. */
|
|
635
|
|
636 if (!f->window_face_cache_reset)
|
215
|
637 {
|
|
638 mswindows_redraw_exposed_windows (f->root_window, x, y, width, height);
|
|
639 GdiFlush();
|
|
640 }
|
213
|
641 else
|
|
642 MARK_FRAME_CHANGED (f);
|
|
643 }
|
|
644
|
|
645
|
|
646 /*****************************************************************************
|
|
647 mswindows_bevel_modeline
|
|
648
|
|
649 Draw a 3d border around the modeline on window W.
|
|
650 ****************************************************************************/
|
|
651 static void
|
|
652 mswindows_bevel_modeline (struct window *w, struct display_line *dl)
|
|
653 {
|
|
654 struct frame *f = XFRAME (w->frame);
|
|
655 Lisp_Object color;
|
|
656 int shadow_width = MODELINE_SHADOW_THICKNESS (w);
|
|
657 RECT rect = { WINDOW_MODELINE_LEFT (w),
|
|
658 dl->ypos - dl->ascent - shadow_width,
|
|
659 WINDOW_MODELINE_RIGHT (w),
|
|
660 dl->ypos + dl->descent + shadow_width};
|
|
661
|
|
662
|
|
663 color = WINDOW_FACE_CACHEL_BACKGROUND (w, MODELINE_INDEX);
|
|
664 mswindows_update_gc(FRAME_MSWINDOWS_DC(f), Qnil, Qnil, color, Qnil, Qnil);
|
|
665
|
|
666 #if 0 /* XXX Eh? */
|
|
667 if (shadow_width < 0)
|
|
668 {
|
|
669 GC temp;
|
|
670
|
|
671 temp = top_shadow_gc;
|
|
672 top_shadow_gc = bottom_shadow_gc;
|
|
673 bottom_shadow_gc = temp;
|
|
674 }
|
|
675 #endif
|
|
676
|
|
677 DrawEdge (FRAME_MSWINDOWS_DC(f), &rect, shadow_width==1 ? BDR_RAISEDINNER :
|
|
678 EDGE_RAISED, BF_RECT);
|
|
679 }
|
|
680
|
|
681
|
|
682 /*****************************************************************************
|
|
683 #### Display methods
|
|
684 /*****************************************************************************
|
|
685
|
|
686 /*****************************************************************************
|
|
687 mswindows_divider_width
|
|
688
|
|
689 Return the width of the vertical divider.
|
|
690 ****************************************************************************/
|
|
691 static int
|
|
692 mswindows_divider_width (void)
|
|
693 {
|
|
694 return MSWINDOWS_DIVIDER_WIDTH;
|
|
695 }
|
|
696
|
|
697 /*****************************************************************************
|
|
698 mswindows_divider_height
|
|
699
|
|
700 Return the height of the horizontal divider.
|
|
701 ****************************************************************************/
|
|
702 static int
|
|
703 mswindows_divider_height (void)
|
|
704 {
|
|
705 return 1; /* XXX Copied from redisplay-X.c. What is this? */
|
|
706 }
|
|
707
|
|
708 /*****************************************************************************
|
|
709 mswindows_eol_cursor_width
|
|
710
|
|
711 Return the width of the end-of-line cursor.
|
|
712 ****************************************************************************/
|
|
713 static int
|
|
714 mswindows_eol_cursor_width (void)
|
|
715 {
|
|
716 return MSWINDOWS_EOL_CURSOR_WIDTH;
|
|
717 }
|
|
718
|
|
719 /*****************************************************************************
|
|
720 mswindows_output_begin
|
|
721
|
|
722 Perform any necessary initialization prior to an update.
|
|
723 ****************************************************************************/
|
|
724 static void
|
|
725 mswindows_output_begin (struct device *d)
|
|
726 {
|
|
727 }
|
|
728
|
|
729 /*****************************************************************************
|
|
730 mswindows_output_end
|
|
731
|
|
732 Perform any necessary flushing of queues when an update has completed.
|
|
733 ****************************************************************************/
|
|
734 static void
|
|
735 mswindows_output_end (struct device *d)
|
|
736 {
|
215
|
737 GdiFlush();
|
213
|
738 }
|
|
739
|
|
740 static int
|
|
741 mswindows_flash (struct device *d)
|
|
742 {
|
|
743 struct frame *f = device_selected_frame (d);
|
|
744
|
|
745 /* XXX FIXME: Do something more visible here, maybe involving a timer */
|
|
746 FlashWindow (FRAME_MSWINDOWS_HANDLE (f), TRUE);
|
|
747 FlashWindow (FRAME_MSWINDOWS_HANDLE (f), FALSE);
|
|
748 }
|
|
749
|
|
750 static void
|
|
751 mswindows_ring_bell (struct device *d, int volume, int pitch, int duration)
|
|
752 {
|
223
|
753 /* Beep does not work at all, anyways! -kkm */
|
|
754 MessageBeep (MB_OK);
|
213
|
755 }
|
|
756
|
|
757 /*****************************************************************************
|
|
758 mswindows_output_display_block
|
|
759
|
|
760 Given a display line, a block number for that start line, output all
|
|
761 runes between start and end in the specified display block.
|
|
762 Ripped off with mininmal thought from the corresponding X routine.
|
|
763 ****************************************************************************/
|
|
764 static void
|
|
765 mswindows_output_display_block (struct window *w, struct display_line *dl, int block,
|
|
766 int start, int end, int start_pixpos, int cursor_start,
|
|
767 int cursor_width, int cursor_height)
|
|
768 {
|
|
769 struct frame *f = XFRAME (w->frame);
|
|
770 Emchar_dynarr *buf = Dynarr_new (Emchar);
|
|
771 Lisp_Object window;
|
|
772
|
|
773 struct display_block *db = Dynarr_atp (dl->display_blocks, block);
|
|
774 rune_dynarr *rba = db->runes;
|
|
775 struct rune *rb;
|
|
776
|
|
777 int elt = start;
|
|
778 face_index findex;
|
|
779 int xpos, width;
|
|
780 Lisp_Object charset = Qunbound; /* Qnil is a valid charset when
|
|
781 MULE is not defined */
|
|
782 XSETWINDOW (window, w);
|
|
783 rb = Dynarr_atp (rba, start);
|
|
784
|
|
785 if (!rb)
|
|
786 {
|
|
787 /* Nothing to do so don't do anything. */
|
|
788 return;
|
|
789 }
|
|
790 else
|
|
791 {
|
|
792 findex = rb->findex;
|
|
793 xpos = rb->xpos;
|
|
794 width = 0;
|
|
795 if (rb->type == RUNE_CHAR)
|
|
796 charset = CHAR_CHARSET (rb->object.chr.ch);
|
|
797 }
|
|
798
|
|
799 if (end < 0)
|
|
800 end = Dynarr_length (rba);
|
|
801 Dynarr_reset (buf);
|
|
802
|
|
803 while (elt < end)
|
|
804 {
|
|
805 rb = Dynarr_atp (rba, elt);
|
|
806
|
|
807 if (rb->findex == findex && rb->type == RUNE_CHAR
|
|
808 && rb->object.chr.ch != '\n' && rb->cursor_type != CURSOR_ON
|
|
809 && EQ (charset, CHAR_CHARSET (rb->object.chr.ch)))
|
|
810 {
|
|
811 Dynarr_add (buf, rb->object.chr.ch);
|
|
812 width += rb->width;
|
|
813 elt++;
|
|
814 }
|
|
815 else
|
|
816 {
|
|
817 if (Dynarr_length (buf))
|
|
818 {
|
|
819 mswindows_output_string (w, dl, buf, xpos, 0, start_pixpos, width,
|
|
820 findex);
|
|
821 xpos = rb->xpos;
|
|
822 width = 0;
|
|
823 }
|
|
824 Dynarr_reset (buf);
|
|
825 width = 0;
|
|
826
|
|
827 if (rb->type == RUNE_CHAR)
|
|
828 {
|
|
829 findex = rb->findex;
|
|
830 xpos = rb->xpos;
|
|
831 charset = CHAR_CHARSET (rb->object.chr.ch);
|
|
832
|
|
833 if (rb->cursor_type == CURSOR_ON)
|
|
834 {
|
|
835 if (rb->object.chr.ch == '\n')
|
|
836 {
|
|
837 mswindows_output_cursor (w, dl, xpos, cursor_width, rb);
|
|
838 }
|
|
839 else
|
|
840 {
|
|
841 Dynarr_add (buf, rb->object.chr.ch);
|
|
842 #if 0
|
|
843 mswindows_output_string (w, dl, buf, xpos, 0, start_pixpos,
|
|
844 rb->width, findex, 1,
|
|
845 cursor_start, cursor_width,
|
|
846 cursor_height);
|
|
847 #else
|
|
848 mswindows_output_cursor (w, dl, xpos, cursor_width, rb);
|
|
849 #endif
|
|
850 Dynarr_reset (buf);
|
|
851 }
|
|
852
|
|
853 xpos += rb->width;
|
|
854 elt++;
|
|
855 }
|
|
856 else if (rb->object.chr.ch == '\n')
|
|
857 {
|
|
858 /* Clear in case a cursor was formerly here. */
|
|
859 int height = dl->ascent + dl->descent - dl->clip;
|
|
860
|
|
861 mswindows_clear_region (window, findex, xpos, dl->ypos - dl->ascent,
|
|
862 rb->width, height);
|
|
863 elt++;
|
|
864 }
|
|
865 }
|
|
866 else if (rb->type == RUNE_BLANK || rb->type == RUNE_HLINE)
|
|
867 {
|
|
868 if (rb->type == RUNE_BLANK)
|
|
869 mswindows_output_blank (w, dl, rb);
|
|
870 else
|
|
871 {
|
|
872 /* #### Our flagging of when we need to redraw the
|
|
873 modeline shadows sucks. Since RUNE_HLINE is only used
|
|
874 by the modeline at the moment it is a good bet
|
|
875 that if it gets redrawn then we should also
|
|
876 redraw the shadows. This won't be true forever.
|
|
877 We borrow the shadow_thickness_changed flag for
|
|
878 now. */
|
|
879 w->shadow_thickness_changed = 1;
|
|
880 mswindows_output_hline (w, dl, rb);
|
|
881 }
|
|
882
|
|
883 if (rb->cursor_type == CURSOR_ON)
|
|
884 mswindows_output_cursor (w, dl, xpos, cursor_width, rb);
|
|
885
|
|
886 elt++;
|
|
887 if (elt < end)
|
|
888 {
|
|
889 rb = Dynarr_atp (rba, elt);
|
|
890
|
|
891 findex = rb->findex;
|
|
892 xpos = rb->xpos;
|
|
893 }
|
|
894 }
|
|
895 else if (rb->type == RUNE_DGLYPH)
|
|
896 {
|
|
897 Lisp_Object instance;
|
|
898
|
|
899 XSETWINDOW (window, w);
|
|
900 instance = glyph_image_instance (rb->object.dglyph.glyph,
|
|
901 window, ERROR_ME_NOT, 1);
|
|
902 findex = rb->findex;
|
|
903
|
|
904 if (IMAGE_INSTANCEP (instance))
|
|
905 switch (XIMAGE_INSTANCE_TYPE (instance))
|
|
906 {
|
|
907 case IMAGE_TEXT:
|
|
908 {
|
|
909 /* #### This is way losing. See the comment in
|
|
910 add_glyph_rune(). */
|
|
911 Lisp_Object string =
|
|
912 XIMAGE_INSTANCE_TEXT_STRING (instance);
|
|
913 convert_bufbyte_string_into_emchar_dynarr
|
|
914 (XSTRING_DATA (string), XSTRING_LENGTH (string), buf);
|
|
915
|
|
916 if (rb->cursor_type == CURSOR_ON)
|
|
917 mswindows_output_cursor (w, dl, xpos, cursor_width, rb);
|
|
918 else
|
|
919 mswindows_output_string (w, dl, buf, xpos,
|
|
920 rb->object.dglyph.xoffset,
|
|
921 start_pixpos, -1, findex);
|
|
922 Dynarr_reset (buf);
|
|
923 }
|
|
924 break;
|
|
925
|
|
926 case IMAGE_MONO_PIXMAP:
|
|
927 case IMAGE_COLOR_PIXMAP:
|
|
928 #if 0
|
|
929 mswindows_output_pixmap (w, dl, instance, xpos,
|
|
930 rb->object.dglyph.xoffset, start_pixpos,
|
|
931 rb->width, findex, cursor_start,
|
|
932 cursor_width, cursor_height);
|
|
933 #endif
|
|
934 break;
|
|
935
|
|
936 case IMAGE_POINTER:
|
|
937 abort ();
|
|
938
|
|
939 case IMAGE_SUBWINDOW:
|
|
940 /* #### implement me */
|
|
941 break;
|
|
942
|
|
943 case IMAGE_NOTHING:
|
|
944 /* nothing is as nothing does */
|
|
945 break;
|
|
946
|
|
947 default:
|
|
948 abort ();
|
|
949 }
|
|
950
|
|
951 xpos += rb->width;
|
|
952 elt++;
|
|
953 }
|
|
954 else
|
|
955 abort ();
|
|
956 }
|
|
957 }
|
|
958
|
|
959 if (Dynarr_length (buf))
|
|
960 mswindows_output_string (w, dl, buf, xpos, 0, start_pixpos, width, findex);
|
|
961
|
|
962 if (dl->modeline
|
|
963 && !EQ (Qzero, w->modeline_shadow_thickness)
|
|
964 && (f->clear
|
|
965 || f->windows_structure_changed
|
|
966 || w->shadow_thickness_changed))
|
|
967 mswindows_bevel_modeline (w, dl);
|
|
968
|
|
969 Dynarr_free (buf);
|
|
970
|
|
971 }
|
|
972
|
|
973
|
|
974 /*****************************************************************************
|
|
975 mswindows_output_vertical_divider
|
|
976
|
|
977 Draw a vertical divider down the left side of the given window.
|
|
978 ****************************************************************************/
|
|
979 static void
|
|
980 mswindows_output_vertical_divider (struct window *w, int clear)
|
|
981 {
|
|
982 struct frame *f = XFRAME (w->frame);
|
|
983 Lisp_Object color;
|
|
984 RECT rect;
|
|
985 HBRUSH brush;
|
|
986 int shadow_width = MODELINE_SHADOW_THICKNESS (w);
|
|
987
|
|
988 /* We don't use the normal gutter measurements here because the
|
|
989 horizontal scrollbars and toolbars do not stretch completely over
|
|
990 to the right edge of the window. Only the modeline does. */
|
|
991 int modeline_height = window_modeline_height (w);
|
|
992
|
|
993 assert(!MSWINDOWS_DIVIDER_SPACING); /* This code doesn't handle this */
|
|
994
|
|
995 /* XXX Not sure about this */
|
|
996 #ifdef HAVE_SCROLLBARS
|
|
997 if (f->scrollbar_on_left)
|
|
998 rect.left = WINDOW_LEFT (w);
|
|
999 else
|
|
1000 rect.left = WINDOW_RIGHT (w) - MSWINDOWS_DIVIDER_WIDTH;
|
|
1001 #else
|
|
1002 rect.left = WINDOW_LEFT (w);
|
|
1003 #endif
|
|
1004 rect.right = rect.left + MSWINDOWS_DIVIDER_WIDTH;
|
|
1005
|
|
1006 #ifdef HAVE_SCROLLBARS
|
|
1007 if (f->scrollbar_on_top)
|
|
1008 rect.top = WINDOW_TOP (w);
|
|
1009 else
|
|
1010 #endif
|
|
1011 rect.top = WINDOW_TEXT_TOP (w);
|
|
1012 rect.bottom = WINDOW_BOTTOM (w) - modeline_height;
|
|
1013
|
|
1014 /* Draw the divider line */
|
|
1015 color = WINDOW_FACE_CACHEL_BACKGROUND (w, MODELINE_INDEX);
|
|
1016 mswindows_update_gc(FRAME_MSWINDOWS_DC(f), Qnil, Qnil, color, Qnil, Qnil);
|
227
|
1017 ExtTextOut (FRAME_MSWINDOWS_DC(f), 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
|
213
|
1018 if (shadow_width)
|
|
1019 DrawEdge (FRAME_MSWINDOWS_DC(f), &rect,
|
|
1020 shadow_width==1 ? BDR_RAISEDINNER : EDGE_RAISED,
|
|
1021 BF_TOP|BF_RIGHT|BF_LEFT);
|
|
1022 }
|
|
1023
|
|
1024
|
|
1025 /****************************************************************************
|
|
1026 mswindows_text_width
|
|
1027
|
|
1028 Given a string and a face, return the string's length in pixels when
|
|
1029 displayed in the font associated with the face.
|
|
1030 XXX FIXME: get redisplay_text_width_emchar_string() etc to pass in the
|
|
1031 window so we can get hold of the window's frame's gc
|
|
1032 ****************************************************************************/
|
|
1033 static int
|
|
1034 mswindows_text_width (struct face_cachel *cachel, CONST Emchar *str,
|
|
1035 Charcount len)
|
|
1036 {
|
|
1037 int width_so_far = 0;
|
|
1038 unsigned char *text_storage = (unsigned char *) alloca (2 * len);
|
|
1039 textual_run *runs = alloca_array (textual_run, len);
|
|
1040 int nruns;
|
|
1041 int i;
|
|
1042 HDC hdc=NULL; /* XXXXX FIXME! only works for non-proportional fonts! */
|
|
1043
|
|
1044 nruns = separate_textual_runs (text_storage, runs, str, len);
|
|
1045
|
|
1046 for (i = 0; i < nruns; i++)
|
|
1047 width_so_far += mswindows_text_width_single_run (hdc, cachel, runs + i);
|
|
1048
|
|
1049 return width_so_far;
|
|
1050 }
|
|
1051
|
|
1052
|
|
1053 /****************************************************************************
|
|
1054 mswindows_clear_region
|
|
1055
|
|
1056 Clear the area in the box defined by the given parameters using the
|
|
1057 given face.
|
|
1058 ****************************************************************************/
|
|
1059 static void
|
|
1060 mswindows_clear_region (Lisp_Object locale, face_index findex, int x, int y,
|
|
1061 int width, int height)
|
|
1062 {
|
|
1063 struct window *w;
|
|
1064 struct frame *f;
|
|
1065 Lisp_Object background_pixmap = Qunbound;
|
|
1066 Lisp_Object temp;
|
|
1067 RECT rect = { x, y, x+width, y+height };
|
|
1068 HBRUSH brush;
|
|
1069
|
|
1070 if (!(width && height)) /* We often seem to get called with width==0 */
|
|
1071 return;
|
|
1072
|
|
1073 if (WINDOWP (locale))
|
|
1074 {
|
|
1075 w = XWINDOW (locale);
|
|
1076 f = XFRAME (w->frame);
|
|
1077 }
|
|
1078 else if (FRAMEP (locale))
|
|
1079 {
|
|
1080 w = NULL;
|
|
1081 f = XFRAME (locale);
|
|
1082 }
|
|
1083 else
|
|
1084 abort ();
|
|
1085
|
|
1086 if (w)
|
|
1087 {
|
|
1088 temp = WINDOW_FACE_CACHEL_BACKGROUND_PIXMAP (w, findex);
|
|
1089
|
|
1090 if (IMAGE_INSTANCEP (temp)
|
|
1091 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (temp)))
|
|
1092 {
|
|
1093 /* #### maybe we could implement such that a string
|
|
1094 can be a background pixmap? */
|
|
1095 background_pixmap = temp;
|
|
1096 }
|
|
1097 }
|
|
1098 else
|
|
1099 {
|
|
1100 temp = FACE_BACKGROUND_PIXMAP (Vdefault_face, locale);
|
|
1101
|
|
1102 if (IMAGE_INSTANCEP (temp)
|
|
1103 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (temp)))
|
|
1104 {
|
|
1105 background_pixmap = temp;
|
|
1106 }
|
|
1107 }
|
|
1108
|
|
1109 if (!UNBOUNDP (background_pixmap))
|
|
1110 {
|
|
1111 if (XIMAGE_INSTANCE_PIXMAP_DEPTH (background_pixmap) == 0)
|
|
1112 {
|
|
1113 Lisp_Object fcolor, bcolor;
|
|
1114
|
|
1115 if (w)
|
|
1116 {
|
|
1117 fcolor = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
|
|
1118 bcolor = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
|
|
1119 }
|
|
1120 else
|
|
1121 {
|
|
1122 fcolor = FACE_FOREGROUND (Vdefault_face, locale);
|
|
1123 bcolor = FACE_BACKGROUND (Vdefault_face, locale);
|
|
1124 }
|
|
1125
|
|
1126 mswindows_update_gc (FRAME_MSWINDOWS_DC(f), Qnil, fcolor, bcolor, background_pixmap, Qnil);
|
|
1127 }
|
|
1128
|
|
1129 /* XX FIXME: Get brush from background_pixmap here */
|
|
1130 assert(0);
|
227
|
1131 FillRect (FRAME_MSWINDOWS_DC(f), &rect, brush);
|
213
|
1132 }
|
|
1133 else
|
|
1134 {
|
|
1135 Lisp_Object color = (w ? WINDOW_FACE_CACHEL_BACKGROUND (w, findex) :
|
|
1136 FACE_BACKGROUND (Vdefault_face, locale));
|
227
|
1137 mswindows_update_gc(FRAME_MSWINDOWS_DC(f), Qnil, Qnil, color, Qnil, Qnil);
|
|
1138 ExtTextOut (FRAME_MSWINDOWS_DC(f), 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
|
213
|
1139 }
|
|
1140
|
227
|
1141 #ifdef HAVE_SCROLLBARS
|
|
1142 if (WINDOWP (locale))
|
|
1143 mswindows_redisplay_deadbox_maybe (w, &rect);
|
|
1144 #endif
|
213
|
1145 }
|
|
1146
|
|
1147 /*****************************************************************************
|
|
1148 mswindows_clear_to_window_end
|
|
1149
|
|
1150 Clear the area between ypos1 and ypos2. Each margin area and the
|
|
1151 text area is handled separately since they may each have their own
|
|
1152 background color.
|
|
1153 ****************************************************************************/
|
|
1154 static void
|
|
1155 mswindows_clear_to_window_end (struct window *w, int ypos1, int ypos2)
|
|
1156 {
|
|
1157 int height = ypos2 - ypos1;
|
|
1158
|
|
1159 if (height)
|
|
1160 {
|
|
1161 struct frame *f = XFRAME (w->frame);
|
|
1162 Lisp_Object window;
|
|
1163 int bflag = (window_needs_vertical_divider (w) ? 0 : 1);
|
|
1164 layout_bounds bounds;
|
|
1165
|
|
1166 bounds = calculate_display_line_boundaries (w, bflag);
|
|
1167 XSETWINDOW (window, w);
|
|
1168
|
|
1169 if (window_is_leftmost (w))
|
|
1170 mswindows_clear_region (window, DEFAULT_INDEX, FRAME_LEFT_BORDER_START (f),
|
|
1171 ypos1, FRAME_BORDER_WIDTH (f), height);
|
|
1172
|
|
1173 if (bounds.left_in - bounds.left_out > 0)
|
|
1174 mswindows_clear_region (window,
|
|
1175 get_builtin_face_cache_index (w, Vleft_margin_face),
|
|
1176 bounds.left_out, ypos1,
|
|
1177 bounds.left_in - bounds.left_out, height);
|
|
1178
|
|
1179 if (bounds.right_in - bounds.left_in > 0)
|
|
1180 mswindows_clear_region (window, DEFAULT_INDEX, bounds.left_in, ypos1,
|
|
1181 bounds.right_in - bounds.left_in, height);
|
|
1182
|
|
1183 if (bounds.right_out - bounds.right_in > 0)
|
|
1184 mswindows_clear_region (window,
|
|
1185 get_builtin_face_cache_index (w, Vright_margin_face),
|
|
1186 bounds.right_in, ypos1,
|
|
1187 bounds.right_out - bounds.right_in, height);
|
|
1188
|
|
1189 if (window_is_rightmost (w))
|
|
1190 mswindows_clear_region (window, DEFAULT_INDEX, FRAME_RIGHT_BORDER_START (f),
|
|
1191 ypos1, FRAME_BORDER_WIDTH (f), height);
|
|
1192 }
|
|
1193
|
|
1194 }
|
|
1195
|
|
1196
|
215
|
1197 /* XXX Implement me! */
|
213
|
1198 static void
|
|
1199 mswindows_clear_frame (struct frame *f)
|
|
1200 {
|
215
|
1201 GdiFlush();
|
213
|
1202 }
|
|
1203
|
|
1204
|
|
1205
|
|
1206
|
|
1207 /************************************************************************/
|
|
1208 /* initialization */
|
|
1209 /************************************************************************/
|
|
1210
|
|
1211 void
|
|
1212 console_type_create_redisplay_mswindows (void)
|
|
1213 {
|
|
1214 /* redisplay methods */
|
|
1215 CONSOLE_HAS_METHOD (mswindows, text_width);
|
|
1216 CONSOLE_HAS_METHOD (mswindows, output_display_block);
|
|
1217 CONSOLE_HAS_METHOD (mswindows, divider_width);
|
|
1218 CONSOLE_HAS_METHOD (mswindows, divider_height);
|
|
1219 CONSOLE_HAS_METHOD (mswindows, eol_cursor_width);
|
|
1220 CONSOLE_HAS_METHOD (mswindows, output_vertical_divider);
|
|
1221 CONSOLE_HAS_METHOD (mswindows, clear_to_window_end);
|
|
1222 CONSOLE_HAS_METHOD (mswindows, clear_region);
|
|
1223 CONSOLE_HAS_METHOD (mswindows, clear_frame);
|
|
1224 CONSOLE_HAS_METHOD (mswindows, output_begin);
|
|
1225 CONSOLE_HAS_METHOD (mswindows, output_end);
|
|
1226 CONSOLE_HAS_METHOD (mswindows, flash);
|
|
1227 CONSOLE_HAS_METHOD (mswindows, ring_bell);
|
|
1228 }
|