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
|
272
|
29 Partially rewritten for mswindows by Jonathan Harris, November 1997 for 21.0.
|
213
|
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"
|
267
|
43 #include "glyphs-msw.h"
|
213
|
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 #define MSWINDOWS_EOL_CURSOR_WIDTH 5
|
|
55
|
|
56 /*
|
|
57 * Random forward delarations
|
|
58 */
|
251
|
59 static void mswindows_update_dc (HDC hdc, Lisp_Object font, Lisp_Object fg,
|
|
60 Lisp_Object bg, Lisp_Object bg_pmap);
|
213
|
61 static void mswindows_clear_region (Lisp_Object locale, face_index findex,
|
|
62 int x, int y, int width, int height);
|
|
63 static void mswindows_output_vertical_divider (struct window *w, int clear);
|
|
64 static void mswindows_redraw_exposed_windows (Lisp_Object window, int x,
|
|
65 int y, int width, int height);
|
284
|
66 static void mswindows_output_dibitmap (struct frame *f,
|
|
67 struct Lisp_Image_Instance *p,
|
|
68 int x, int y,
|
|
69 int clip_x, int clip_y,
|
|
70 int clip_width, int clip_height,
|
|
71 int width, int height,
|
|
72 int pixmap_offset,
|
|
73 int offset_bitmap);
|
280
|
74 static void mswindows_output_pixmap (struct window *w, struct display_line *dl,
|
|
75 Lisp_Object image_instance, int xpos,
|
|
76 int xoffset, int start_pixpos, int width,
|
|
77 face_index findex, int cursor_start,
|
284
|
78 int cursor_width, int cursor_height,
|
|
79 int offset_bitmap);
|
213
|
80
|
|
81 typedef struct textual_run
|
|
82 {
|
|
83 Lisp_Object charset;
|
|
84 unsigned char *ptr;
|
|
85 int len;
|
|
86 int dimension;
|
|
87 } textual_run;
|
|
88
|
|
89 /* Separate out the text in DYN into a series of textual runs of a
|
|
90 particular charset. Also convert the characters as necessary into
|
|
91 the format needed by XDrawImageString(), XDrawImageString16(), et
|
|
92 al. (This means converting to one or two byte format, possibly
|
|
93 tweaking the high bits, and possibly running a CCL program.) You
|
|
94 must pre-allocate the space used and pass it in. (This is done so
|
|
95 you can alloca() the space.) You need to allocate (2 * len) bytes
|
|
96 of TEXT_STORAGE and (len * sizeof (textual_run)) bytes of
|
|
97 RUN_STORAGE, where LEN is the length of the dynarr.
|
|
98
|
|
99 Returns the number of runs actually used. */
|
|
100
|
|
101 static int
|
|
102 separate_textual_runs (unsigned char *text_storage,
|
|
103 textual_run *run_storage,
|
|
104 CONST Emchar *str, Charcount len)
|
|
105 {
|
|
106 Lisp_Object prev_charset = Qunbound; /* not Qnil because that is a
|
|
107 possible valid charset when
|
|
108 MULE is not defined */
|
|
109 int runs_so_far = 0;
|
|
110 int i;
|
|
111 #ifdef MULE
|
|
112 struct ccl_program char_converter;
|
|
113 int need_ccl_conversion = 0;
|
|
114 #endif
|
|
115
|
|
116 for (i = 0; i < len; i++)
|
|
117 {
|
|
118 Emchar ch = str[i];
|
|
119 Lisp_Object charset;
|
|
120 int byte1, byte2;
|
|
121 int dimension;
|
|
122 int graphic;
|
|
123
|
|
124 BREAKUP_CHAR (ch, charset, byte1, byte2);
|
|
125 dimension = XCHARSET_DIMENSION (charset);
|
|
126 graphic = XCHARSET_GRAPHIC (charset);
|
|
127
|
|
128 if (!EQ (charset, prev_charset))
|
|
129 {
|
|
130 run_storage[runs_so_far].ptr = text_storage;
|
|
131 run_storage[runs_so_far].charset = charset;
|
|
132 run_storage[runs_so_far].dimension = dimension;
|
|
133
|
|
134 if (runs_so_far)
|
|
135 {
|
|
136 run_storage[runs_so_far - 1].len =
|
|
137 text_storage - run_storage[runs_so_far - 1].ptr;
|
|
138 if (run_storage[runs_so_far - 1].dimension == 2)
|
|
139 run_storage[runs_so_far - 1].len >>= 1;
|
|
140 }
|
|
141 runs_so_far++;
|
|
142 prev_charset = charset;
|
|
143 #ifdef MULE
|
|
144 {
|
|
145 Lisp_Object ccl_prog = XCHARSET_CCL_PROGRAM (charset);
|
|
146 need_ccl_conversion = !NILP (ccl_prog);
|
|
147 if (need_ccl_conversion)
|
|
148 setup_ccl_program (&char_converter, ccl_prog);
|
|
149 }
|
|
150 #endif
|
|
151 }
|
|
152
|
|
153 if (graphic == 0)
|
|
154 {
|
|
155 byte1 &= 0x7F;
|
|
156 byte2 &= 0x7F;
|
|
157 }
|
|
158 else if (graphic == 1)
|
|
159 {
|
|
160 byte1 |= 0x80;
|
|
161 byte2 |= 0x80;
|
|
162 }
|
|
163 #ifdef MULE
|
|
164 if (need_ccl_conversion)
|
|
165 {
|
|
166 char_converter.reg[0] = XCHARSET_ID (charset);
|
|
167 char_converter.reg[1] = byte1;
|
|
168 char_converter.reg[2] = byte2;
|
|
169 char_converter.ic = 0; /* start at beginning each time */
|
|
170 ccl_driver (&char_converter, 0, 0, 0, 0);
|
|
171 byte1 = char_converter.reg[1];
|
|
172 byte2 = char_converter.reg[2];
|
|
173 }
|
|
174 #endif
|
|
175 *text_storage++ = (unsigned char) byte1;
|
|
176 if (dimension == 2)
|
|
177 *text_storage++ = (unsigned char) byte2;
|
|
178 }
|
|
179
|
|
180 if (runs_so_far)
|
|
181 {
|
|
182 run_storage[runs_so_far - 1].len =
|
|
183 text_storage - run_storage[runs_so_far - 1].ptr;
|
|
184 if (run_storage[runs_so_far - 1].dimension == 2)
|
|
185 run_storage[runs_so_far - 1].len >>= 1;
|
|
186 }
|
|
187
|
|
188 return runs_so_far;
|
|
189 }
|
|
190
|
|
191
|
|
192 static int
|
|
193 mswindows_text_width_single_run (HDC hdc, struct face_cachel *cachel,
|
251
|
194 textual_run *run)
|
213
|
195 {
|
|
196 Lisp_Object font_inst = FACE_CACHEL_FONT (cachel, run->charset);
|
|
197 struct Lisp_Font_Instance *fi = XFONT_INSTANCE (font_inst);
|
|
198 SIZE size;
|
|
199
|
|
200 if (!fi->proportional_p || !hdc)
|
|
201 return (fi->width * run->len);
|
|
202 else
|
|
203 {
|
251
|
204 assert(run->dimension == 1); /* #### FIXME! */
|
|
205 mswindows_update_dc (hdc, font_inst, Qnil, Qnil, Qnil);
|
|
206 GetTextExtentPoint32 (hdc, run->ptr, run->len, &size);
|
213
|
207 return(size.cx);
|
|
208 }
|
|
209 }
|
|
210
|
|
211
|
|
212 /*****************************************************************************
|
251
|
213 mswindows_update_dc
|
213
|
214
|
251
|
215 Given a number of parameters munge the DC so it has those properties.
|
213
|
216 ****************************************************************************/
|
|
217 static void
|
251
|
218 mswindows_update_dc (HDC hdc, Lisp_Object font, Lisp_Object fg,
|
|
219 Lisp_Object bg, Lisp_Object bg_pmap)
|
213
|
220 {
|
|
221 if (!NILP (font))
|
251
|
222 SelectObject(hdc, FONT_INSTANCE_MSWINDOWS_HFONT (XFONT_INSTANCE (font)));
|
213
|
223
|
|
224
|
|
225 if (!NILP (fg))
|
284
|
226 {
|
|
227 SetTextColor (hdc, COLOR_INSTANCE_MSWINDOWS_COLOR
|
|
228 (XCOLOR_INSTANCE (fg)));
|
|
229 }
|
213
|
230 if (!NILP (bg))
|
284
|
231 {
|
|
232 SetBkMode (hdc, OPAQUE);
|
|
233 SetBkColor (hdc, COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (bg)));
|
|
234 }
|
|
235 else
|
|
236 {
|
|
237 SetBkMode (hdc, TRANSPARENT);
|
|
238 }
|
213
|
239 }
|
|
240
|
|
241
|
|
242 /*****************************************************************************
|
|
243 mswindows_output_hline
|
|
244
|
|
245 Output a horizontal line in the foreground of its face.
|
|
246 ****************************************************************************/
|
|
247 static void
|
|
248 mswindows_output_hline (struct window *w, struct display_line *dl, struct rune *rb)
|
|
249 { /* XXX Implement me */
|
|
250 }
|
|
251
|
|
252
|
|
253 /*****************************************************************************
|
|
254 mswindows_output_blank
|
|
255
|
|
256 Output a blank by clearing the area it covers in the background color
|
|
257 of its face.
|
|
258 ****************************************************************************/
|
|
259 static void
|
280
|
260 mswindows_output_blank (struct window *w, struct display_line *dl, struct rune *rb, int start_pixpos)
|
213
|
261 {
|
|
262 struct frame *f = XFRAME (w->frame);
|
|
263 RECT rect = { rb->xpos, dl->ypos-dl->ascent,
|
|
264 rb->xpos+rb->width, dl->ypos+dl->descent-dl->clip };
|
|
265 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, rb->findex);
|
|
266
|
|
267 Lisp_Object bg_pmap = WINDOW_FACE_CACHEL_BACKGROUND_PIXMAP (w, rb->findex);
|
|
268
|
|
269 if (!IMAGE_INSTANCEP (bg_pmap)
|
|
270 || !IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
|
|
271 bg_pmap = Qnil;
|
|
272
|
280
|
273 if (!NILP(bg_pmap))
|
|
274 {
|
284
|
275 /* blank the background in the appropriate color */
|
|
276 mswindows_update_dc (FRAME_MSWINDOWS_DC (f), Qnil, cachel->foreground,
|
|
277 cachel->background, Qnil);
|
|
278
|
280
|
279 mswindows_output_pixmap (w, dl, bg_pmap,
|
284
|
280 rb->xpos, 0 /*rb->object.dglyph.xoffset*/,
|
280
|
281 start_pixpos, rb->width, rb->findex,
|
284
|
282 0, 0, 0, TRUE);
|
280
|
283 }
|
|
284 else
|
|
285 {
|
|
286 mswindows_update_dc (FRAME_MSWINDOWS_DC (f), Qnil, Qnil,
|
|
287 cachel->background, Qnil);
|
|
288
|
|
289 ExtTextOut (FRAME_MSWINDOWS_DC (f), 0, 0, ETO_OPAQUE,
|
|
290 &rect, NULL, 0, NULL);
|
|
291 }
|
213
|
292 }
|
|
293
|
|
294
|
|
295 /*****************************************************************************
|
|
296 mswindows_output_cursor
|
|
297
|
|
298 Draw a normal or end-of-line cursor. The end-of-line cursor is
|
|
299 narrower than the normal cursor.
|
|
300 ****************************************************************************/
|
|
301 static void
|
|
302 mswindows_output_cursor (struct window *w, struct display_line *dl, int xpos,
|
269
|
303 int width, face_index findex, Emchar ch, int image_p)
|
213
|
304 {
|
|
305 struct frame *f = XFRAME (w->frame);
|
|
306 struct device *d = XDEVICE (f->device);
|
|
307 struct face_cachel *cachel;
|
227
|
308 Lisp_Object font = Qnil;
|
213
|
309 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
|
|
310 HDC hdc = FRAME_MSWINDOWS_DC (f);
|
263
|
311 unsigned int face_index=0;
|
227
|
312 char *p_char = NULL;
|
|
313 int n_char = 0;
|
213
|
314 RECT rect = { xpos,
|
|
315 dl->ypos - dl->ascent,
|
|
316 xpos + width,
|
|
317 dl->ypos + dl->descent - dl->clip};
|
239
|
318 Lisp_Object bar = symbol_value_in_buffer (Qbar_cursor,
|
|
319 WINDOW_BUFFER (w));
|
269
|
320 int bar_p = image_p || !NILP (bar);
|
|
321 int cursor_p = !NILP (w->text_cursor_visible_p);
|
|
322 int real_char_p = ch != 0;
|
213
|
323
|
|
324 if (real_char_p)
|
|
325 {
|
|
326 /* Use the font from the underlying character */
|
269
|
327 cachel = WINDOW_FACE_CACHEL (w, findex);
|
213
|
328
|
|
329 /* XXX MULE: Need to know the charset! */
|
|
330 font = FACE_CACHEL_FONT (cachel, Vcharset_ascii);
|
|
331 }
|
|
332
|
239
|
333 if ((focus || bar_p) && real_char_p)
|
227
|
334 {
|
269
|
335 p_char = (char*) &ch;
|
227
|
336 n_char = 1;
|
|
337 }
|
|
338
|
269
|
339 if (!image_p)
|
|
340 {
|
|
341 /* Use cursor fg/bg for block cursor, or character fg/bg for the bar
|
|
342 or when we need to erase the cursor. Output nothing at eol if bar
|
|
343 cursor */
|
|
344 face_index = get_builtin_face_cache_index (w, Vtext_cursor_face);
|
|
345 cachel = WINDOW_FACE_CACHEL (w, ((!cursor_p || bar_p)
|
|
346 ? findex : face_index));
|
|
347 mswindows_update_dc (hdc, font, cachel->foreground,
|
|
348 cachel->background, Qnil);
|
|
349 ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE|ETO_CLIPPED, &rect, p_char, n_char, NULL);
|
|
350 }
|
|
351
|
|
352 if (!cursor_p)
|
|
353 return;
|
213
|
354
|
239
|
355 if (focus && bar_p)
|
|
356 {
|
269
|
357 rect.right = rect.left + (EQ (bar, Qt) ? 1 : min (2, width));
|
263
|
358 face_index = get_builtin_face_cache_index (w, Vtext_cursor_face);
|
|
359 cachel = WINDOW_FACE_CACHEL (w, face_index);
|
251
|
360 mswindows_update_dc (hdc, Qnil, Qnil, cachel->background, Qnil);
|
|
361 ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE, &rect, NULL, 0, NULL);
|
239
|
362 }
|
|
363 else if (!focus)
|
213
|
364 {
|
239
|
365 /* Now have real character drawn in its own color. We defalte
|
|
366 the rectangle so character cell will be bounded by the
|
|
367 previously drawn cursor shape */
|
|
368 InflateRect (&rect, -1, -1);
|
213
|
369
|
239
|
370 if (real_char_p)
|
|
371 {
|
269
|
372 p_char = (char*) &ch;
|
239
|
373 n_char = 1;
|
|
374 }
|
|
375
|
263
|
376 face_index = get_builtin_face_cache_index (w, Vdefault_face);
|
269
|
377 cachel = WINDOW_FACE_CACHEL (w, (real_char_p ? findex : face_index));
|
251
|
378 mswindows_update_dc (hdc, Qnil, cachel->foreground,
|
|
379 cachel->background, Qnil);
|
|
380 ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE | ETO_CLIPPED,
|
239
|
381 &rect, p_char, n_char, NULL);
|
|
382 }
|
213
|
383 }
|
|
384
|
|
385
|
|
386 /*****************************************************************************
|
|
387 mswindows_output_string
|
|
388
|
|
389 Given a string and a starting position, output that string in the
|
|
390 given face.
|
|
391 Correctly handles multiple charsets in the string.
|
|
392
|
|
393 The meaning of the parameters is something like this:
|
|
394
|
|
395 W Window that the text is to be displayed in.
|
|
396 DL Display line that this text is on. The values in the
|
|
397 structure are used to determine the vertical position and
|
|
398 clipping range of the text.
|
|
399 BUF Dynamic array of Emchars specifying what is actually to be
|
|
400 drawn.
|
|
401 XPOS X position in pixels where the text should start being drawn.
|
|
402 XOFFSET Number of pixels to be chopped off the left side of the
|
|
403 text. The effect is as if the text were shifted to the
|
|
404 left this many pixels and clipped at XPOS.
|
|
405 CLIP_START Clip everything left of this X position.
|
|
406 WIDTH Clip everything right of XPOS + WIDTH.
|
|
407 FINDEX Index for the face cache element describing how to display
|
|
408 the text.
|
|
409 ****************************************************************************/
|
|
410 void
|
|
411 mswindows_output_string (struct window *w, struct display_line *dl,
|
|
412 Emchar_dynarr *buf, int xpos, int xoffset, int clip_start,
|
|
413 int width, face_index findex)
|
|
414 {
|
|
415 struct frame *f = XFRAME (w->frame);
|
245
|
416 /* struct device *d = XDEVICE (f->device);*/
|
272
|
417 Lisp_Object window;
|
251
|
418 HDC hdc = FRAME_MSWINDOWS_DC (f);
|
213
|
419 int clip_end;
|
|
420 Lisp_Object bg_pmap;
|
|
421 int len = Dynarr_length (buf);
|
|
422 unsigned char *text_storage = (unsigned char *) alloca (2 * len);
|
|
423 textual_run *runs = alloca_array (textual_run, len);
|
|
424 int nruns;
|
284
|
425 int i, height;
|
|
426 RECT rect;
|
213
|
427 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, findex);
|
|
428
|
|
429 XSETWINDOW (window, w);
|
|
430
|
|
431 #if 0 /* XXX: FIXME? */
|
|
432 /* We can't work out the width before we've set the font in the DC */
|
|
433 if (width < 0)
|
|
434 width = mswindows_text_width (cachel, Dynarr_atp (buf, 0), Dynarr_length (buf));
|
|
435 #else
|
|
436 assert(width>=0);
|
|
437 #endif
|
|
438
|
|
439 /* Regularize the variables passed in. */
|
|
440 if (clip_start < xpos)
|
|
441 clip_start = xpos;
|
|
442 clip_end = xpos + width;
|
|
443 if (clip_start >= clip_end)
|
|
444 /* It's all clipped out. */
|
|
445 return;
|
|
446
|
|
447 xpos -= xoffset;
|
|
448
|
284
|
449 /* sort out the destination rectangle */
|
|
450 height = dl->ascent + dl->descent - dl->clip;
|
|
451 rect.left = clip_start;
|
|
452 rect.top = dl->ypos - dl->ascent;
|
|
453 rect.right = clip_end;
|
|
454 rect.bottom = height + dl->ypos - dl->ascent;
|
213
|
455
|
284
|
456 /* output the background pixmap if there is one */
|
213
|
457 bg_pmap = cachel->background_pixmap;
|
|
458 if (!IMAGE_INSTANCEP (bg_pmap)
|
|
459 || !IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
|
|
460 bg_pmap = Qnil;
|
|
461
|
284
|
462 if (!NILP(bg_pmap))
|
|
463 {
|
|
464 /* blank the background in the appropriate color */
|
|
465 mswindows_update_dc (hdc, Qnil, cachel->foreground,
|
|
466 cachel->background, Qnil);
|
|
467
|
|
468 mswindows_output_pixmap (w, dl, bg_pmap,
|
|
469 xpos, xoffset,
|
|
470 clip_start, width, findex,
|
|
471 0, 0, 0, TRUE);
|
|
472 /* output pixmap calls this so we have to recall to get correct
|
|
473 references */
|
|
474 cachel = WINDOW_FACE_CACHEL (w, findex);
|
|
475 }
|
|
476
|
|
477 nruns = separate_textual_runs (text_storage, runs, Dynarr_atp (buf, 0),
|
|
478 Dynarr_length (buf));
|
|
479
|
213
|
480 for (i = 0; i < nruns; i++)
|
|
481 {
|
|
482 Lisp_Object font = FACE_CACHEL_FONT (cachel, runs[i].charset);
|
284
|
483 struct Lisp_Font_Instance *fi = XFONT_INSTANCE (font);
|
213
|
484 int this_width;
|
|
485
|
|
486 if (EQ (font, Vthe_null_font_instance))
|
|
487 continue;
|
|
488
|
251
|
489 mswindows_update_dc (hdc, font, cachel->foreground,
|
|
490 NILP(bg_pmap) ? cachel->background : Qnil, Qnil);
|
213
|
491
|
|
492 this_width = mswindows_text_width_single_run (hdc, cachel, runs + i);
|
284
|
493
|
|
494 /* cope with fonts taller than lines */
|
|
495 if ((int) fi->height < (int) (height + dl->clip))
|
280
|
496 {
|
284
|
497 int clear_start = max (xpos, clip_start);
|
|
498 int clear_end = min (xpos + this_width, clip_end);
|
|
499
|
|
500 {
|
|
501 mswindows_clear_region (window, findex, clear_start,
|
|
502 dl->ypos - dl->ascent,
|
|
503 clear_end - clear_start,
|
|
504 height);
|
|
505 /* output pixmap calls this so we have to recall to get correct
|
|
506 references */
|
|
507 cachel = WINDOW_FACE_CACHEL (w, findex);
|
|
508 }
|
280
|
509 }
|
284
|
510
|
213
|
511 assert (runs[i].dimension == 1); /* XXX FIXME */
|
227
|
512 ExtTextOut (hdc, xpos, dl->ypos,
|
|
513 NILP(bg_pmap) ? ETO_CLIPPED | ETO_OPAQUE : ETO_CLIPPED,
|
|
514 &rect, (char *) runs[i].ptr, runs[i].len, NULL);
|
213
|
515
|
|
516 /* XXX FIXME? X does underline/strikethrough here
|
|
517 we will do it as part of face's font */
|
|
518
|
|
519 xpos += this_width;
|
|
520 }
|
|
521 }
|
|
522
|
284
|
523 static void
|
267
|
524 mswindows_output_dibitmap (struct frame *f, struct Lisp_Image_Instance *p,
|
|
525 int x, int y,
|
|
526 int clip_x, int clip_y,
|
|
527 int clip_width, int clip_height,
|
284
|
528 int width, int height, int pixmap_offset,
|
|
529 int offset_bitmap)
|
267
|
530 {
|
|
531 HDC hdc = FRAME_MSWINDOWS_DC (f);
|
284
|
532 HGDIOBJ old=NULL;
|
|
533 COLORREF bgcolor = GetBkColor (hdc);
|
267
|
534 int need_clipping = (clip_x || clip_y);
|
284
|
535 int yoffset=0;
|
|
536 int xoffset=0;
|
|
537 /* do we need to offset the pixmap vertically? this is necessary
|
|
538 for background pixmaps. */
|
|
539 if (offset_bitmap)
|
|
540 {
|
|
541 yoffset = y % IMAGE_INSTANCE_PIXMAP_HEIGHT (p);
|
|
542 xoffset = x % IMAGE_INSTANCE_PIXMAP_WIDTH (p);
|
|
543 /* the width is handled by mswindows_output_pixmap_region */
|
|
544 }
|
267
|
545
|
|
546 if (need_clipping)
|
|
547 {
|
|
548 }
|
|
549
|
284
|
550 /* first blt the mask */
|
|
551 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
|
267
|
552 {
|
284
|
553 RGBQUAD col;
|
|
554 col.rgbBlue = GetBValue (bgcolor);
|
|
555 col.rgbRed = GetRValue (bgcolor);
|
|
556 col.rgbGreen = GetGValue (bgcolor);
|
|
557 col.rgbReserved = 0;
|
|
558
|
|
559 old = SelectObject (FRAME_MSWINDOWS_CDC (f),
|
|
560 IMAGE_INSTANCE_MSWINDOWS_MASK (p));
|
|
561
|
|
562 SetDIBColorTable (FRAME_MSWINDOWS_CDC (f), 1, 1, &col);
|
|
563
|
|
564 BitBlt (hdc,
|
|
565 x,y,
|
|
566 width, height,
|
|
567 FRAME_MSWINDOWS_CDC (f),
|
|
568 xoffset,yoffset,
|
|
569 SRCCOPY);
|
|
570
|
|
571 SelectObject (FRAME_MSWINDOWS_CDC (f), old);
|
267
|
572 }
|
284
|
573
|
|
574 /* now blt the bitmap itself. */
|
|
575 old = SelectObject (FRAME_MSWINDOWS_CDC (f),
|
|
576 IMAGE_INSTANCE_MSWINDOWS_BITMAP (p));
|
267
|
577
|
284
|
578 BitBlt (hdc,
|
|
579 x,y,
|
|
580 width, height,
|
|
581 FRAME_MSWINDOWS_CDC (f),
|
|
582 xoffset, yoffset,
|
|
583 IMAGE_INSTANCE_MSWINDOWS_MASK (p) ? SRCINVERT : SRCCOPY);
|
|
584
|
|
585 SelectObject (FRAME_MSWINDOWS_CDC (f),old);
|
|
586
|
267
|
587 if (need_clipping)
|
|
588 {
|
|
589 }
|
284
|
590 }
|
|
591
|
|
592 /*
|
|
593 * X gc's have this nice property that setting the bg pixmap will
|
|
594 * output it offset relative to the window. Windows doesn't have this
|
|
595 * feature so we have to emulate this by outputting multiple pixmaps
|
|
596 */
|
|
597 static void
|
|
598 mswindows_output_dibitmap_region (struct frame *f,
|
|
599 struct Lisp_Image_Instance *p,
|
|
600 int x, int y,
|
|
601 int clip_x, int clip_y,
|
|
602 int clip_width, int clip_height,
|
|
603 int width, int height, int pixmap_offset,
|
|
604 int offset_bitmap)
|
|
605 {
|
|
606 int pwidth = min (width, IMAGE_INSTANCE_PIXMAP_WIDTH (p));
|
|
607 int pheight = min (height, IMAGE_INSTANCE_PIXMAP_HEIGHT (p));
|
|
608 int pxoffset = 0, pyoffset = 0;
|
|
609
|
|
610 /* when doing a bg pixmap do a partial pixmap first so that we
|
|
611 blt whole pixmaps thereafter */
|
|
612
|
|
613 if (offset_bitmap)
|
|
614 {
|
|
615 pheight = min (pheight, IMAGE_INSTANCE_PIXMAP_HEIGHT (p) -
|
|
616 y % IMAGE_INSTANCE_PIXMAP_HEIGHT (p));
|
|
617 }
|
|
618
|
|
619 while (pheight > 0)
|
|
620 {
|
|
621 if (offset_bitmap)
|
|
622 {
|
|
623 pwidth = min (min (width, IMAGE_INSTANCE_PIXMAP_WIDTH (p)),
|
|
624 IMAGE_INSTANCE_PIXMAP_WIDTH (p) -
|
|
625 x % IMAGE_INSTANCE_PIXMAP_WIDTH (p));
|
|
626 pxoffset = 0;
|
|
627 }
|
|
628 while (pwidth > 0)
|
|
629 {
|
|
630 mswindows_output_dibitmap (f, p,
|
|
631 x + pxoffset, y + pyoffset,
|
|
632 clip_x, clip_y,
|
|
633 clip_width, clip_height,
|
|
634 pwidth, pheight, pixmap_offset,
|
|
635 offset_bitmap);
|
|
636 pxoffset += pwidth;
|
|
637 pwidth = min ((width-pxoffset),
|
|
638 IMAGE_INSTANCE_PIXMAP_WIDTH (p));
|
|
639 }
|
|
640 pyoffset += pheight;
|
|
641 pheight = min ((height-pyoffset),
|
|
642 IMAGE_INSTANCE_PIXMAP_HEIGHT (p));
|
|
643 }
|
267
|
644 }
|
|
645
|
|
646 static void
|
|
647 mswindows_output_pixmap (struct window *w, struct display_line *dl,
|
|
648 Lisp_Object image_instance, int xpos, int xoffset,
|
|
649 int start_pixpos, int width, face_index findex,
|
284
|
650 int cursor_start, int cursor_width, int cursor_height,
|
|
651 int offset_bitmap)
|
267
|
652 {
|
|
653 struct frame *f = XFRAME (w->frame);
|
|
654 HDC hdc = FRAME_MSWINDOWS_DC (f);
|
284
|
655
|
267
|
656 struct Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
|
|
657 Lisp_Object window;
|
|
658
|
|
659 int lheight = dl->ascent + dl->descent - dl->clip;
|
|
660 int pheight = ((int) IMAGE_INSTANCE_PIXMAP_HEIGHT (p) > lheight ? lheight :
|
|
661 IMAGE_INSTANCE_PIXMAP_HEIGHT (p));
|
|
662 int clip_x, clip_y, clip_width, clip_height;
|
|
663
|
|
664 /* The pixmap_offset is used to center the pixmap on lines which are
|
|
665 shorter than it is. This results in odd effects when scrolling
|
|
666 pixmaps off of the bottom. Let's try not using it. */
|
|
667 #if 0
|
|
668 int pixmap_offset = (int) (IMAGE_INSTANCE_PIXMAP_HEIGHT (p) - lheight) / 2;
|
|
669 #else
|
|
670 int pixmap_offset = 0;
|
|
671 #endif
|
|
672
|
|
673 XSETWINDOW (window, w);
|
|
674
|
|
675 if ((start_pixpos >= 0 && start_pixpos > xpos) || xoffset)
|
|
676 {
|
|
677 if (start_pixpos > xpos && start_pixpos > xpos + width)
|
|
678 return;
|
|
679
|
|
680 clip_x = xoffset;
|
|
681 clip_width = width;
|
|
682 if (start_pixpos > xpos)
|
|
683 {
|
|
684 clip_x += (start_pixpos - xpos);
|
|
685 clip_width -= (start_pixpos - xpos);
|
|
686 }
|
|
687 }
|
|
688 else
|
|
689 {
|
|
690 clip_x = 0;
|
|
691 clip_width = 0;
|
|
692 }
|
|
693
|
|
694 /* Place markers for possible future functionality (clipping the top
|
|
695 half instead of the bottom half; think pixel scrolling). */
|
|
696 clip_y = 0;
|
|
697 clip_height = pheight;
|
|
698
|
|
699 /* Clear the area the pixmap is going into. The pixmap itself will
|
|
700 always take care of the full width. We don't want to clear where
|
|
701 it is going to go in order to avoid flicker. So, all we have to
|
|
702 take care of is any area above or below the pixmap. */
|
|
703 /* #### We take a shortcut for now. We know that since we have
|
|
704 pixmap_offset hardwired to 0 that the pixmap is against the top
|
|
705 edge so all we have to worry about is below it. */
|
|
706 /* #### Unless the pixmap has a mask in which case we have to clear
|
|
707 the whole damn thing since we can't yet clear just the area not
|
|
708 included in the mask. */
|
|
709 if (((int) (dl->ypos - dl->ascent + pheight) <
|
|
710 (int) (dl->ypos + dl->descent - dl->clip))
|
|
711 || IMAGE_INSTANCE_MSWINDOWS_MASK (p))
|
|
712 {
|
|
713 int clear_x, clear_y, clear_width, clear_height;
|
|
714
|
|
715 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
|
|
716 {
|
|
717 clear_y = dl->ypos - dl->ascent;
|
|
718 clear_height = lheight;
|
|
719 }
|
|
720 else
|
|
721 {
|
|
722 clear_y = dl->ypos - dl->ascent + pheight;
|
|
723 clear_height = lheight - pheight;
|
|
724 }
|
|
725
|
|
726 if (start_pixpos >= 0 && start_pixpos > xpos)
|
|
727 {
|
|
728 clear_x = start_pixpos;
|
|
729 clear_width = xpos + width - start_pixpos;
|
|
730 }
|
|
731 else
|
|
732 {
|
|
733 clear_x = xpos;
|
|
734 clear_width = width;
|
|
735 }
|
|
736
|
284
|
737 if (!offset_bitmap) /* i.e. not a bg pixmap */
|
|
738 mswindows_clear_region (window, findex, clear_x, clear_y,
|
|
739 clear_width, clear_height);
|
267
|
740 }
|
|
741
|
284
|
742 /* Output the pixmap. Have to do this as many times as is required
|
|
743 to fill the given area */
|
|
744 mswindows_update_dc (hdc, Qnil,
|
|
745 WINDOW_FACE_CACHEL_FOREGROUND (w, findex),
|
|
746 WINDOW_FACE_CACHEL_BACKGROUND (w, findex), Qnil);
|
|
747
|
|
748 mswindows_output_dibitmap_region (f, p, xpos - xoffset,
|
|
749 dl->ypos - dl->ascent,
|
|
750 clip_x, clip_y, clip_width, clip_height,
|
|
751 width + xoffset, pheight, pixmap_offset,
|
|
752 offset_bitmap);
|
267
|
753 }
|
227
|
754
|
|
755 #ifdef HAVE_SCROLLBARS
|
|
756 /*
|
|
757 * This function paints window's deadbox, a rectangle between window
|
|
758 * borders and two short edges of both scrollbars.
|
|
759 *
|
|
760 * Function checks whether deadbox intersects with the rectangle pointed
|
|
761 * to by PRC, and paints only the intersection
|
|
762 */
|
|
763 static void
|
251
|
764 mswindows_redisplay_deadbox_maybe (struct window *w, CONST RECT* prc)
|
227
|
765 {
|
|
766 int sbh = window_scrollbar_height (w);
|
|
767 int sbw = window_scrollbar_width (w);
|
|
768 RECT rect_dead, rect_paint;
|
|
769 if (sbh == 0 || sbw == 0)
|
|
770 return;
|
|
771
|
282
|
772 if (!NILP (w->scrollbar_on_left_p))
|
284
|
773 rect_dead.left = WINDOW_LEFT (w);
|
227
|
774 else
|
284
|
775 rect_dead.left = WINDOW_TEXT_RIGHT (w);
|
|
776 rect_dead.right = rect_dead.left + sbw;
|
227
|
777
|
282
|
778 if (!NILP (w->scrollbar_on_top_p))
|
284
|
779 rect_dead.top = WINDOW_TOP (w);
|
227
|
780 else
|
284
|
781 rect_dead.top = WINDOW_TEXT_BOTTOM (w);
|
|
782 rect_dead.bottom = rect_dead.top + sbh;
|
227
|
783
|
|
784 if (IntersectRect (&rect_paint, &rect_dead, prc))
|
282
|
785 {
|
|
786 struct frame *f = XFRAME (WINDOW_FRAME (w));
|
|
787 FillRect (FRAME_MSWINDOWS_DC (f), &rect_paint,
|
|
788 (HBRUSH) (COLOR_BTNFACE+1));
|
|
789 }
|
227
|
790 }
|
|
791
|
|
792 #endif /* HAVE_SCROLLBARS */
|
|
793
|
213
|
794 /*****************************************************************************
|
|
795 mswindows_redraw_exposed_window
|
|
796
|
|
797 Given a bounding box for an area that needs to be redrawn, determine
|
|
798 what parts of what lines are contained within and re-output their
|
|
799 contents.
|
|
800 Copied from redisplay-x.c
|
|
801 ****************************************************************************/
|
|
802 static void
|
|
803 mswindows_redraw_exposed_window (struct window *w, int x, int y, int width,
|
|
804 int height)
|
|
805 {
|
|
806 struct frame *f = XFRAME (w->frame);
|
|
807 int line;
|
|
808 int orig_windows_structure_changed;
|
227
|
809 RECT rect_window = { WINDOW_LEFT (w), WINDOW_TOP (w),
|
|
810 WINDOW_RIGHT (w), WINDOW_BOTTOM (w) };
|
|
811 RECT rect_expose = { x, y, x + width, y + height };
|
|
812 RECT rect_draw;
|
213
|
813
|
|
814 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
815
|
|
816 if (!NILP (w->vchild))
|
|
817 {
|
|
818 mswindows_redraw_exposed_windows (w->vchild, x, y, width, height);
|
|
819 return;
|
|
820 }
|
|
821 else if (!NILP (w->hchild))
|
|
822 {
|
|
823 mswindows_redraw_exposed_windows (w->hchild, x, y, width, height);
|
|
824 return;
|
|
825 }
|
|
826
|
|
827 /* If the window doesn't intersect the exposed region, we're done here. */
|
227
|
828 if (!IntersectRect (&rect_draw, &rect_window, &rect_expose))
|
213
|
829 return;
|
|
830
|
227
|
831 /* We do this to make sure that the 3D modelines get redrawn if
|
|
832 they are in the exposed region. */
|
|
833 orig_windows_structure_changed = f->windows_structure_changed;
|
|
834 f->windows_structure_changed = 1;
|
213
|
835
|
|
836 if (window_needs_vertical_divider (w))
|
|
837 {
|
|
838 mswindows_output_vertical_divider (w, 0);
|
|
839 }
|
|
840
|
|
841 for (line = 0; line < Dynarr_length (cdla); line++)
|
|
842 {
|
|
843 struct display_line *cdl = Dynarr_atp (cdla, line);
|
|
844 int top_y = cdl->ypos - cdl->ascent;
|
|
845 int bottom_y = cdl->ypos + cdl->descent;
|
|
846
|
227
|
847 if (bottom_y >= rect_draw.top)
|
213
|
848 {
|
227
|
849 if (top_y > rect_draw.bottom)
|
213
|
850 {
|
|
851 if (line == 0)
|
|
852 continue;
|
|
853 else
|
|
854 break;
|
|
855 }
|
|
856 else
|
|
857 {
|
227
|
858 output_display_line (w, 0, cdla, line,
|
|
859 rect_draw.left, rect_draw.right);
|
213
|
860 }
|
|
861 }
|
|
862 }
|
|
863
|
|
864 f->windows_structure_changed = orig_windows_structure_changed;
|
|
865
|
|
866 /* If there have never been any face cache_elements created, then this
|
|
867 expose event doesn't actually have anything to do. */
|
|
868 if (Dynarr_largest (w->face_cachels))
|
227
|
869 redisplay_clear_bottom_of_window (w, cdla, rect_draw.top, rect_draw.bottom);
|
|
870
|
|
871 #ifdef HAVE_SCROLLBARS
|
|
872 mswindows_redisplay_deadbox_maybe (w, &rect_expose);
|
|
873 #endif
|
213
|
874 }
|
|
875
|
|
876 /*****************************************************************************
|
|
877 mswindows_redraw_exposed_windows
|
|
878
|
|
879 For each window beneath the given window in the window hierarchy,
|
|
880 ensure that it is redrawn if necessary after an Expose event.
|
|
881 ****************************************************************************/
|
|
882 static void
|
|
883 mswindows_redraw_exposed_windows (Lisp_Object window, int x, int y, int width,
|
|
884 int height)
|
|
885 {
|
|
886 for (; !NILP (window); window = XWINDOW (window)->next)
|
|
887 mswindows_redraw_exposed_window (XWINDOW (window), x, y, width, height);
|
|
888 }
|
|
889
|
|
890 /*****************************************************************************
|
|
891 mswindows_redraw_exposed_area
|
|
892
|
|
893 For each window on the given frame, ensure that any area in the
|
|
894 Exposed area is redrawn.
|
|
895 ****************************************************************************/
|
|
896 void
|
|
897 mswindows_redraw_exposed_area (struct frame *f, int x, int y, int width, int height)
|
|
898 {
|
|
899 /* If any window on the frame has had its face cache reset then the
|
|
900 redisplay structures are effectively invalid. If we attempt to
|
|
901 use them we'll blow up. We mark the frame as changed to ensure
|
|
902 that redisplay will do a full update. This probably isn't
|
|
903 necessary but it can't hurt. */
|
278
|
904 #ifdef HAVE_TOOLBARS
|
|
905 /* #### We would rather put these off as well but there is currently
|
|
906 no combination of flags which will force an unchanged toolbar to
|
|
907 redraw anyhow. */
|
|
908 MAYBE_FRAMEMETH (f, redraw_exposed_toolbars, (f, x, y, width, height));
|
|
909 #endif
|
213
|
910
|
|
911 if (!f->window_face_cache_reset)
|
215
|
912 {
|
|
913 mswindows_redraw_exposed_windows (f->root_window, x, y, width, height);
|
|
914 GdiFlush();
|
|
915 }
|
213
|
916 else
|
|
917 MARK_FRAME_CHANGED (f);
|
|
918 }
|
|
919
|
|
920
|
|
921 /*****************************************************************************
|
|
922 mswindows_bevel_modeline
|
|
923
|
|
924 Draw a 3d border around the modeline on window W.
|
|
925 ****************************************************************************/
|
|
926 static void
|
|
927 mswindows_bevel_modeline (struct window *w, struct display_line *dl)
|
|
928 {
|
|
929 struct frame *f = XFRAME (w->frame);
|
|
930 Lisp_Object color;
|
|
931 int shadow_width = MODELINE_SHADOW_THICKNESS (w);
|
|
932 RECT rect = { WINDOW_MODELINE_LEFT (w),
|
|
933 dl->ypos - dl->ascent - shadow_width,
|
|
934 WINDOW_MODELINE_RIGHT (w),
|
|
935 dl->ypos + dl->descent + shadow_width};
|
239
|
936 UINT edge;
|
213
|
937
|
|
938 color = WINDOW_FACE_CACHEL_BACKGROUND (w, MODELINE_INDEX);
|
251
|
939 mswindows_update_dc (FRAME_MSWINDOWS_DC (f), Qnil, Qnil, color, Qnil);
|
213
|
940
|
239
|
941 if (XINT (w->modeline_shadow_thickness) < 0)
|
|
942 shadow_width = -shadow_width;
|
213
|
943
|
239
|
944 if (shadow_width < -1)
|
|
945 edge = EDGE_SUNKEN;
|
|
946 else if (shadow_width < 0)
|
|
947 edge = BDR_SUNKENINNER;
|
|
948 else if (shadow_width == 1)
|
|
949 edge = BDR_RAISEDINNER;
|
|
950 else
|
|
951 edge = EDGE_RAISED;
|
|
952
|
251
|
953 DrawEdge (FRAME_MSWINDOWS_DC (f), &rect, edge, BF_RECT);
|
213
|
954 }
|
|
955
|
|
956
|
|
957 /*****************************************************************************
|
284
|
958 Display methods
|
245
|
959 *****************************************************************************/
|
213
|
960
|
|
961 /*****************************************************************************
|
|
962 mswindows_divider_height
|
|
963
|
|
964 Return the height of the horizontal divider.
|
|
965 ****************************************************************************/
|
|
966 static int
|
|
967 mswindows_divider_height (void)
|
|
968 {
|
|
969 return 1; /* XXX Copied from redisplay-X.c. What is this? */
|
|
970 }
|
|
971
|
|
972 /*****************************************************************************
|
|
973 mswindows_eol_cursor_width
|
|
974
|
|
975 Return the width of the end-of-line cursor.
|
|
976 ****************************************************************************/
|
|
977 static int
|
|
978 mswindows_eol_cursor_width (void)
|
|
979 {
|
|
980 return MSWINDOWS_EOL_CURSOR_WIDTH;
|
|
981 }
|
|
982
|
|
983 /*****************************************************************************
|
|
984 mswindows_output_begin
|
|
985
|
|
986 Perform any necessary initialization prior to an update.
|
|
987 ****************************************************************************/
|
|
988 static void
|
|
989 mswindows_output_begin (struct device *d)
|
|
990 {
|
|
991 }
|
|
992
|
|
993 /*****************************************************************************
|
|
994 mswindows_output_end
|
|
995
|
|
996 Perform any necessary flushing of queues when an update has completed.
|
|
997 ****************************************************************************/
|
|
998 static void
|
|
999 mswindows_output_end (struct device *d)
|
|
1000 {
|
215
|
1001 GdiFlush();
|
213
|
1002 }
|
|
1003
|
|
1004 static int
|
|
1005 mswindows_flash (struct device *d)
|
|
1006 {
|
|
1007 struct frame *f = device_selected_frame (d);
|
239
|
1008 RECT rc;
|
213
|
1009
|
239
|
1010 GetClientRect (FRAME_MSWINDOWS_HANDLE (f), &rc);
|
|
1011 InvertRect (FRAME_MSWINDOWS_DC (f), &rc);
|
|
1012 GdiFlush ();
|
|
1013 Sleep (25);
|
|
1014 InvertRect (FRAME_MSWINDOWS_DC (f), &rc);
|
|
1015
|
|
1016 return 1;
|
213
|
1017 }
|
|
1018
|
|
1019 static void
|
|
1020 mswindows_ring_bell (struct device *d, int volume, int pitch, int duration)
|
|
1021 {
|
223
|
1022 /* Beep does not work at all, anyways! -kkm */
|
|
1023 MessageBeep (MB_OK);
|
213
|
1024 }
|
|
1025
|
|
1026 /*****************************************************************************
|
|
1027 mswindows_output_display_block
|
|
1028
|
|
1029 Given a display line, a block number for that start line, output all
|
|
1030 runes between start and end in the specified display block.
|
|
1031 Ripped off with mininmal thought from the corresponding X routine.
|
|
1032 ****************************************************************************/
|
|
1033 static void
|
|
1034 mswindows_output_display_block (struct window *w, struct display_line *dl, int block,
|
|
1035 int start, int end, int start_pixpos, int cursor_start,
|
|
1036 int cursor_width, int cursor_height)
|
|
1037 {
|
|
1038 struct frame *f = XFRAME (w->frame);
|
|
1039 Emchar_dynarr *buf = Dynarr_new (Emchar);
|
|
1040 Lisp_Object window;
|
|
1041
|
|
1042 struct display_block *db = Dynarr_atp (dl->display_blocks, block);
|
|
1043 rune_dynarr *rba = db->runes;
|
|
1044 struct rune *rb;
|
|
1045
|
|
1046 int elt = start;
|
|
1047 face_index findex;
|
|
1048 int xpos, width;
|
|
1049 Lisp_Object charset = Qunbound; /* Qnil is a valid charset when
|
|
1050 MULE is not defined */
|
|
1051 XSETWINDOW (window, w);
|
|
1052 rb = Dynarr_atp (rba, start);
|
|
1053
|
|
1054 if (!rb)
|
|
1055 {
|
|
1056 /* Nothing to do so don't do anything. */
|
|
1057 return;
|
|
1058 }
|
|
1059 else
|
|
1060 {
|
|
1061 findex = rb->findex;
|
|
1062 xpos = rb->xpos;
|
|
1063 width = 0;
|
|
1064 if (rb->type == RUNE_CHAR)
|
|
1065 charset = CHAR_CHARSET (rb->object.chr.ch);
|
|
1066 }
|
|
1067
|
|
1068 if (end < 0)
|
|
1069 end = Dynarr_length (rba);
|
|
1070 Dynarr_reset (buf);
|
|
1071
|
|
1072 while (elt < end)
|
|
1073 {
|
|
1074 rb = Dynarr_atp (rba, elt);
|
|
1075
|
|
1076 if (rb->findex == findex && rb->type == RUNE_CHAR
|
|
1077 && rb->object.chr.ch != '\n' && rb->cursor_type != CURSOR_ON
|
|
1078 && EQ (charset, CHAR_CHARSET (rb->object.chr.ch)))
|
|
1079 {
|
|
1080 Dynarr_add (buf, rb->object.chr.ch);
|
|
1081 width += rb->width;
|
|
1082 elt++;
|
|
1083 }
|
|
1084 else
|
|
1085 {
|
|
1086 if (Dynarr_length (buf))
|
|
1087 {
|
|
1088 mswindows_output_string (w, dl, buf, xpos, 0, start_pixpos, width,
|
|
1089 findex);
|
|
1090 xpos = rb->xpos;
|
|
1091 width = 0;
|
|
1092 }
|
|
1093 Dynarr_reset (buf);
|
|
1094 width = 0;
|
|
1095
|
|
1096 if (rb->type == RUNE_CHAR)
|
|
1097 {
|
|
1098 findex = rb->findex;
|
|
1099 xpos = rb->xpos;
|
|
1100 charset = CHAR_CHARSET (rb->object.chr.ch);
|
|
1101
|
|
1102 if (rb->cursor_type == CURSOR_ON)
|
|
1103 {
|
|
1104 if (rb->object.chr.ch == '\n')
|
|
1105 {
|
269
|
1106 mswindows_output_cursor (w, dl, xpos, cursor_width,
|
|
1107 findex, 0, 0);
|
213
|
1108 }
|
|
1109 else
|
|
1110 {
|
|
1111 Dynarr_add (buf, rb->object.chr.ch);
|
269
|
1112 mswindows_output_cursor (w, dl, xpos, cursor_width,
|
|
1113 findex, rb->object.chr.ch, 0);
|
213
|
1114 Dynarr_reset (buf);
|
|
1115 }
|
|
1116
|
|
1117 xpos += rb->width;
|
|
1118 elt++;
|
|
1119 }
|
|
1120 else if (rb->object.chr.ch == '\n')
|
|
1121 {
|
|
1122 /* Clear in case a cursor was formerly here. */
|
|
1123 int height = dl->ascent + dl->descent - dl->clip;
|
|
1124
|
|
1125 mswindows_clear_region (window, findex, xpos, dl->ypos - dl->ascent,
|
|
1126 rb->width, height);
|
|
1127 elt++;
|
|
1128 }
|
|
1129 }
|
|
1130 else if (rb->type == RUNE_BLANK || rb->type == RUNE_HLINE)
|
|
1131 {
|
|
1132 if (rb->type == RUNE_BLANK)
|
280
|
1133 mswindows_output_blank (w, dl, rb, start_pixpos);
|
213
|
1134 else
|
|
1135 {
|
|
1136 /* #### Our flagging of when we need to redraw the
|
|
1137 modeline shadows sucks. Since RUNE_HLINE is only used
|
|
1138 by the modeline at the moment it is a good bet
|
|
1139 that if it gets redrawn then we should also
|
|
1140 redraw the shadows. This won't be true forever.
|
|
1141 We borrow the shadow_thickness_changed flag for
|
|
1142 now. */
|
|
1143 w->shadow_thickness_changed = 1;
|
|
1144 mswindows_output_hline (w, dl, rb);
|
|
1145 }
|
|
1146
|
|
1147 if (rb->cursor_type == CURSOR_ON)
|
269
|
1148 mswindows_output_cursor (w, dl, xpos, cursor_width, rb->findex, 0, 0);
|
213
|
1149
|
|
1150 elt++;
|
|
1151 if (elt < end)
|
|
1152 {
|
|
1153 rb = Dynarr_atp (rba, elt);
|
|
1154
|
|
1155 findex = rb->findex;
|
|
1156 xpos = rb->xpos;
|
|
1157 }
|
|
1158 }
|
|
1159 else if (rb->type == RUNE_DGLYPH)
|
|
1160 {
|
|
1161 Lisp_Object instance;
|
|
1162
|
|
1163 XSETWINDOW (window, w);
|
|
1164 instance = glyph_image_instance (rb->object.dglyph.glyph,
|
|
1165 window, ERROR_ME_NOT, 1);
|
|
1166 findex = rb->findex;
|
|
1167
|
|
1168 if (IMAGE_INSTANCEP (instance))
|
|
1169 switch (XIMAGE_INSTANCE_TYPE (instance))
|
|
1170 {
|
|
1171 case IMAGE_TEXT:
|
|
1172 {
|
|
1173 /* #### This is way losing. See the comment in
|
|
1174 add_glyph_rune(). */
|
|
1175 Lisp_Object string =
|
|
1176 XIMAGE_INSTANCE_TEXT_STRING (instance);
|
|
1177 convert_bufbyte_string_into_emchar_dynarr
|
|
1178 (XSTRING_DATA (string), XSTRING_LENGTH (string), buf);
|
|
1179
|
|
1180 if (rb->cursor_type == CURSOR_ON)
|
269
|
1181 mswindows_output_cursor (w, dl, xpos, cursor_width,
|
|
1182 findex, Dynarr_at (buf, 0), 0);
|
251
|
1183 else /* #### redisplay-x passes -1 as the width: why ? */
|
213
|
1184 mswindows_output_string (w, dl, buf, xpos,
|
|
1185 rb->object.dglyph.xoffset,
|
251
|
1186 start_pixpos, rb->width, findex);
|
213
|
1187 Dynarr_reset (buf);
|
|
1188 }
|
|
1189 break;
|
|
1190
|
|
1191 case IMAGE_MONO_PIXMAP:
|
|
1192 case IMAGE_COLOR_PIXMAP:
|
|
1193 mswindows_output_pixmap (w, dl, instance, xpos,
|
|
1194 rb->object.dglyph.xoffset, start_pixpos,
|
|
1195 rb->width, findex, cursor_start,
|
284
|
1196 cursor_width, cursor_height, 0);
|
269
|
1197 if (rb->cursor_type == CURSOR_ON)
|
|
1198 mswindows_output_cursor (w, dl, xpos, cursor_width,
|
|
1199 findex, 0, 1);
|
213
|
1200 break;
|
|
1201
|
|
1202 case IMAGE_POINTER:
|
|
1203 abort ();
|
|
1204
|
|
1205 case IMAGE_SUBWINDOW:
|
|
1206 /* #### implement me */
|
|
1207 break;
|
|
1208
|
|
1209 case IMAGE_NOTHING:
|
|
1210 /* nothing is as nothing does */
|
|
1211 break;
|
|
1212
|
|
1213 default:
|
|
1214 abort ();
|
|
1215 }
|
|
1216
|
|
1217 xpos += rb->width;
|
|
1218 elt++;
|
|
1219 }
|
|
1220 else
|
|
1221 abort ();
|
|
1222 }
|
|
1223 }
|
|
1224
|
|
1225 if (Dynarr_length (buf))
|
|
1226 mswindows_output_string (w, dl, buf, xpos, 0, start_pixpos, width, findex);
|
|
1227
|
|
1228 if (dl->modeline
|
|
1229 && !EQ (Qzero, w->modeline_shadow_thickness)
|
|
1230 && (f->clear
|
|
1231 || f->windows_structure_changed
|
|
1232 || w->shadow_thickness_changed))
|
|
1233 mswindows_bevel_modeline (w, dl);
|
|
1234
|
|
1235 Dynarr_free (buf);
|
|
1236 }
|
|
1237
|
|
1238
|
|
1239 /*****************************************************************************
|
|
1240 mswindows_output_vertical_divider
|
|
1241
|
284
|
1242 Draw a vertical divider down the right side of the given window.
|
213
|
1243 ****************************************************************************/
|
|
1244 static void
|
284
|
1245 mswindows_output_vertical_divider (struct window *w, int clear_unused)
|
213
|
1246 {
|
|
1247 struct frame *f = XFRAME (w->frame);
|
|
1248 RECT rect;
|
284
|
1249 int spacing = XINT (w->vertical_divider_spacing);
|
|
1250 int shadow = XINT (w->vertical_divider_shadow_thickness);
|
|
1251 int abs_shadow = abs (shadow);
|
|
1252 int line_width = XINT (w->vertical_divider_line_width);
|
|
1253 int div_left = WINDOW_RIGHT (w) - window_divider_width (w);
|
213
|
1254
|
284
|
1255 /* Clear left and right spacing areas */
|
|
1256 if (spacing)
|
|
1257 {
|
|
1258 rect.top = WINDOW_TOP (w);
|
|
1259 rect.bottom = WINDOW_BOTTOM (w);
|
|
1260 mswindows_update_dc (FRAME_MSWINDOWS_DC (f), Qnil, Qnil,
|
|
1261 WINDOW_FACE_CACHEL_BACKGROUND (w, DEFAULT_INDEX), Qnil);
|
|
1262 rect.right = WINDOW_RIGHT (w);
|
|
1263 rect.left = rect.right - spacing;
|
|
1264 ExtTextOut (FRAME_MSWINDOWS_DC (f), 0, 0, ETO_OPAQUE,
|
|
1265 &rect, NULL, 0, NULL);
|
|
1266 rect.left = div_left;
|
|
1267 rect.right = div_left + spacing;
|
|
1268 ExtTextOut (FRAME_MSWINDOWS_DC (f), 0, 0, ETO_OPAQUE,
|
|
1269 &rect, NULL, 0, NULL);
|
|
1270 }
|
|
1271
|
|
1272 /* Clear divider face */
|
|
1273 rect.top = WINDOW_TOP (w) + abs_shadow;
|
|
1274 rect.bottom = WINDOW_BOTTOM (w) - abs_shadow;
|
|
1275 rect.left = div_left + spacing + abs_shadow;
|
|
1276 rect.right = rect.left + line_width;
|
|
1277 if (rect.left < rect.right)
|
|
1278 {
|
|
1279 face_index div_face
|
|
1280 = get_builtin_face_cache_index (w, Vvertical_divider_face);
|
|
1281 mswindows_update_dc (FRAME_MSWINDOWS_DC (f), Qnil, Qnil,
|
|
1282 WINDOW_FACE_CACHEL_BACKGROUND (w, div_face), Qnil);
|
|
1283 ExtTextOut (FRAME_MSWINDOWS_DC (f), 0, 0, ETO_OPAQUE,
|
|
1284 &rect, NULL, 0, NULL);
|
|
1285 }
|
213
|
1286
|
284
|
1287 /* Draw a shadow around the divider */
|
|
1288 if (shadow != 0)
|
|
1289 {
|
|
1290 /* #### This will be fixed to support arbitrary thichkness */
|
|
1291 InflateRect (&rect, abs_shadow, abs_shadow);
|
|
1292 DrawEdge (FRAME_MSWINDOWS_DC (f), &rect,
|
|
1293 shadow > 0 ? EDGE_RAISED : EDGE_SUNKEN, BF_RECT);
|
|
1294 }
|
213
|
1295 }
|
|
1296
|
|
1297 /****************************************************************************
|
|
1298 mswindows_text_width
|
|
1299
|
|
1300 Given a string and a face, return the string's length in pixels when
|
|
1301 displayed in the font associated with the face.
|
|
1302 ****************************************************************************/
|
|
1303 static int
|
251
|
1304 mswindows_text_width (struct frame *f, struct face_cachel *cachel,
|
|
1305 CONST Emchar *str, Charcount len)
|
213
|
1306 {
|
|
1307 int width_so_far = 0;
|
|
1308 unsigned char *text_storage = (unsigned char *) alloca (2 * len);
|
|
1309 textual_run *runs = alloca_array (textual_run, len);
|
|
1310 int nruns;
|
|
1311 int i;
|
|
1312
|
|
1313 nruns = separate_textual_runs (text_storage, runs, str, len);
|
|
1314
|
|
1315 for (i = 0; i < nruns; i++)
|
251
|
1316 width_so_far += mswindows_text_width_single_run (FRAME_MSWINDOWS_DC (f),
|
|
1317 cachel, runs + i);
|
213
|
1318
|
|
1319 return width_so_far;
|
|
1320 }
|
|
1321
|
|
1322
|
|
1323 /****************************************************************************
|
|
1324 mswindows_clear_region
|
|
1325
|
|
1326 Clear the area in the box defined by the given parameters using the
|
|
1327 given face.
|
|
1328 ****************************************************************************/
|
|
1329 static void
|
|
1330 mswindows_clear_region (Lisp_Object locale, face_index findex, int x, int y,
|
|
1331 int width, int height)
|
|
1332 {
|
|
1333 struct window *w;
|
|
1334 struct frame *f;
|
|
1335 Lisp_Object background_pixmap = Qunbound;
|
|
1336 Lisp_Object temp;
|
|
1337 RECT rect = { x, y, x+width, y+height };
|
|
1338
|
|
1339 if (!(width && height)) /* We often seem to get called with width==0 */
|
|
1340 return;
|
|
1341
|
|
1342 if (WINDOWP (locale))
|
|
1343 {
|
|
1344 w = XWINDOW (locale);
|
|
1345 f = XFRAME (w->frame);
|
|
1346 }
|
|
1347 else if (FRAMEP (locale))
|
|
1348 {
|
|
1349 w = NULL;
|
|
1350 f = XFRAME (locale);
|
|
1351 }
|
|
1352 else
|
|
1353 abort ();
|
|
1354
|
|
1355 if (w)
|
|
1356 {
|
|
1357 temp = WINDOW_FACE_CACHEL_BACKGROUND_PIXMAP (w, findex);
|
|
1358
|
|
1359 if (IMAGE_INSTANCEP (temp)
|
|
1360 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (temp)))
|
|
1361 {
|
|
1362 /* #### maybe we could implement such that a string
|
|
1363 can be a background pixmap? */
|
|
1364 background_pixmap = temp;
|
|
1365 }
|
|
1366 }
|
|
1367 else
|
|
1368 {
|
|
1369 temp = FACE_BACKGROUND_PIXMAP (Vdefault_face, locale);
|
|
1370
|
|
1371 if (IMAGE_INSTANCEP (temp)
|
|
1372 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (temp)))
|
|
1373 {
|
|
1374 background_pixmap = temp;
|
|
1375 }
|
|
1376 }
|
|
1377
|
|
1378 if (!UNBOUNDP (background_pixmap))
|
|
1379 {
|
284
|
1380 Lisp_Object fcolor, bcolor;
|
|
1381
|
|
1382 if (w)
|
|
1383 {
|
|
1384 fcolor = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
|
|
1385 bcolor = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
|
|
1386 }
|
|
1387 else
|
|
1388 {
|
|
1389 fcolor = FACE_FOREGROUND (Vdefault_face, locale);
|
|
1390 bcolor = FACE_BACKGROUND (Vdefault_face, locale);
|
|
1391 }
|
|
1392
|
|
1393 mswindows_update_dc (FRAME_MSWINDOWS_DC (f),
|
|
1394 Qnil, fcolor, bcolor, background_pixmap);
|
|
1395
|
213
|
1396 if (XIMAGE_INSTANCE_PIXMAP_DEPTH (background_pixmap) == 0)
|
|
1397 {
|
286
|
1398 /* is this expensive? - I haven't seen it used as yet. */
|
|
1399 HBRUSH brush = CreateSolidBrush
|
|
1400 (COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (bcolor)));
|
280
|
1401 FillRect (FRAME_MSWINDOWS_DC(f), &rect, brush);
|
286
|
1402 DeleteObject (brush);
|
280
|
1403 }
|
|
1404 else
|
|
1405 {
|
284
|
1406 mswindows_output_dibitmap_region
|
|
1407 ( f, XIMAGE_INSTANCE (background_pixmap),
|
|
1408 x, y, 0, 0, 0, 0, width, height, 0, TRUE);
|
280
|
1409 }
|
213
|
1410 }
|
|
1411 else
|
|
1412 {
|
|
1413 Lisp_Object color = (w ? WINDOW_FACE_CACHEL_BACKGROUND (w, findex) :
|
|
1414 FACE_BACKGROUND (Vdefault_face, locale));
|
251
|
1415 mswindows_update_dc (FRAME_MSWINDOWS_DC (f), Qnil, Qnil, color, Qnil);
|
|
1416 ExtTextOut (FRAME_MSWINDOWS_DC (f), 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
|
213
|
1417 }
|
|
1418
|
227
|
1419 #ifdef HAVE_SCROLLBARS
|
|
1420 if (WINDOWP (locale))
|
|
1421 mswindows_redisplay_deadbox_maybe (w, &rect);
|
|
1422 #endif
|
213
|
1423 }
|
|
1424
|
|
1425 /*****************************************************************************
|
|
1426 mswindows_clear_to_window_end
|
|
1427
|
|
1428 Clear the area between ypos1 and ypos2. Each margin area and the
|
|
1429 text area is handled separately since they may each have their own
|
|
1430 background color.
|
|
1431 ****************************************************************************/
|
|
1432 static void
|
|
1433 mswindows_clear_to_window_end (struct window *w, int ypos1, int ypos2)
|
|
1434 {
|
|
1435 int height = ypos2 - ypos1;
|
|
1436
|
|
1437 if (height)
|
|
1438 {
|
|
1439 struct frame *f = XFRAME (w->frame);
|
|
1440 Lisp_Object window;
|
|
1441 int bflag = (window_needs_vertical_divider (w) ? 0 : 1);
|
|
1442 layout_bounds bounds;
|
|
1443
|
|
1444 bounds = calculate_display_line_boundaries (w, bflag);
|
|
1445 XSETWINDOW (window, w);
|
|
1446
|
|
1447 if (window_is_leftmost (w))
|
|
1448 mswindows_clear_region (window, DEFAULT_INDEX, FRAME_LEFT_BORDER_START (f),
|
|
1449 ypos1, FRAME_BORDER_WIDTH (f), height);
|
|
1450
|
|
1451 if (bounds.left_in - bounds.left_out > 0)
|
|
1452 mswindows_clear_region (window,
|
|
1453 get_builtin_face_cache_index (w, Vleft_margin_face),
|
|
1454 bounds.left_out, ypos1,
|
|
1455 bounds.left_in - bounds.left_out, height);
|
|
1456
|
|
1457 if (bounds.right_in - bounds.left_in > 0)
|
|
1458 mswindows_clear_region (window, DEFAULT_INDEX, bounds.left_in, ypos1,
|
|
1459 bounds.right_in - bounds.left_in, height);
|
|
1460
|
|
1461 if (bounds.right_out - bounds.right_in > 0)
|
|
1462 mswindows_clear_region (window,
|
|
1463 get_builtin_face_cache_index (w, Vright_margin_face),
|
|
1464 bounds.right_in, ypos1,
|
|
1465 bounds.right_out - bounds.right_in, height);
|
|
1466
|
|
1467 if (window_is_rightmost (w))
|
|
1468 mswindows_clear_region (window, DEFAULT_INDEX, FRAME_RIGHT_BORDER_START (f),
|
|
1469 ypos1, FRAME_BORDER_WIDTH (f), height);
|
|
1470 }
|
|
1471
|
|
1472 }
|
|
1473
|
|
1474
|
215
|
1475 /* XXX Implement me! */
|
213
|
1476 static void
|
|
1477 mswindows_clear_frame (struct frame *f)
|
|
1478 {
|
215
|
1479 GdiFlush();
|
213
|
1480 }
|
|
1481
|
|
1482
|
|
1483
|
|
1484 /************************************************************************/
|
|
1485 /* initialization */
|
|
1486 /************************************************************************/
|
|
1487
|
|
1488 void
|
|
1489 console_type_create_redisplay_mswindows (void)
|
|
1490 {
|
|
1491 /* redisplay methods */
|
|
1492 CONSOLE_HAS_METHOD (mswindows, text_width);
|
|
1493 CONSOLE_HAS_METHOD (mswindows, output_display_block);
|
|
1494 CONSOLE_HAS_METHOD (mswindows, divider_height);
|
|
1495 CONSOLE_HAS_METHOD (mswindows, eol_cursor_width);
|
|
1496 CONSOLE_HAS_METHOD (mswindows, output_vertical_divider);
|
|
1497 CONSOLE_HAS_METHOD (mswindows, clear_to_window_end);
|
|
1498 CONSOLE_HAS_METHOD (mswindows, clear_region);
|
|
1499 CONSOLE_HAS_METHOD (mswindows, clear_frame);
|
|
1500 CONSOLE_HAS_METHOD (mswindows, output_begin);
|
|
1501 CONSOLE_HAS_METHOD (mswindows, output_end);
|
|
1502 CONSOLE_HAS_METHOD (mswindows, flash);
|
|
1503 CONSOLE_HAS_METHOD (mswindows, ring_bell);
|
|
1504 }
|