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