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