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