428
|
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.
|
771
|
5 Copyright (C) 2001 Ben Wing.
|
428
|
6
|
|
7 This file is part of XEmacs.
|
|
8
|
|
9 XEmacs is free software; you can redistribute it and/or modify it
|
|
10 under the terms of the GNU General Public License as published by the
|
|
11 Free Software Foundation; either version 2, or (at your option) any
|
|
12 later version.
|
|
13
|
|
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
17 for more details.
|
|
18
|
|
19 You should have received a copy of the GNU General Public License
|
|
20 along with XEmacs; see the file COPYING. If not, write to
|
|
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
22 Boston, MA 02111-1307, USA. */
|
|
23
|
|
24 /* Synched up with: Not in FSF. */
|
|
25
|
771
|
26 /* I think this file is essentially Mule-ized, but I'm not sure!
|
|
27 Could stand a good once-over. Unicode support is trash, of course. */
|
|
28
|
428
|
29 /* Authorship:
|
|
30
|
|
31 Chuck Thompson
|
|
32 Lots of work done by Ben Wing for Mule
|
442
|
33
|
|
34 Partially rewritten for mswindows by Jonathan Harris, November 1997
|
|
35 for 21.0. */
|
428
|
36
|
|
37 #include <config.h>
|
|
38 #include "lisp.h"
|
|
39
|
|
40 #include "console-msw.h"
|
|
41 #include "objects-msw.h"
|
|
42
|
|
43 #include "buffer.h"
|
|
44 #include "debug.h"
|
|
45 #include "events.h"
|
|
46 #include "faces.h"
|
|
47 #include "frame.h"
|
|
48 #include "glyphs-msw.h"
|
|
49 #include "gutter.h"
|
|
50 #include "redisplay.h"
|
|
51 #include "sysdep.h"
|
|
52 #include "window.h"
|
771
|
53 #include "charset.h"
|
428
|
54
|
|
55 #define MSWINDOWS_EOL_CURSOR_WIDTH 5
|
|
56
|
|
57 /*
|
|
58 * Random forward declarations
|
|
59 */
|
440
|
60 static void mswindows_update_dc (HDC hdc, Lisp_Object fg, Lisp_Object bg,
|
|
61 Lisp_Object bg_pmap);
|
|
62 static void mswindows_set_dc_font (HDC hdc, Lisp_Object font,
|
|
63 int under, int strike);
|
428
|
64 static void mswindows_output_vertical_divider (struct window *w, int clear);
|
|
65 static void mswindows_redraw_exposed_windows (Lisp_Object window, int x,
|
|
66 int y, int width, int height);
|
|
67 static void mswindows_output_dibitmap (struct frame *f,
|
440
|
68 Lisp_Image_Instance *p,
|
771
|
69 struct display_box *db,
|
|
70 struct display_glyph_area *dga);
|
428
|
71
|
|
72 typedef struct textual_run
|
|
73 {
|
771
|
74 Lisp_Object charset; /* charset of this run */
|
|
75 WCHAR *ptr; /* pointer to Unicode chars in this run */
|
|
76 int nchars; /* number of internal characters in this run */
|
|
77 int nwchars; /* number of Unicode chars in this run */
|
428
|
78 } textual_run;
|
|
79
|
771
|
80 /* Separate out the text in STR into a series of textual runs of a
|
|
81 particular charset. Returns the number of runs actually used.
|
|
82 Returns the textual runs (STATICALLY ALLOCATED!) in RUN_STORAGE_PTR. */
|
428
|
83
|
|
84 static int
|
771
|
85 separate_textual_runs (textual_run **run_storage_ptr,
|
442
|
86 const Emchar *str, Charcount len)
|
428
|
87 {
|
771
|
88 static WCHAR *ext_storage;
|
|
89 static int ext_storage_size; /* in WCHARS! */
|
|
90 static textual_run *run_storage;
|
|
91 static int run_storage_size;
|
428
|
92 int runs_so_far = 0;
|
771
|
93 int runbegin = 0;
|
|
94 int total_nchars = 0;
|
428
|
95 int i;
|
771
|
96 Lisp_Object prev_charset;
|
428
|
97
|
771
|
98 if (len == 0)
|
|
99 return 0;
|
|
100
|
|
101 prev_charset = CHAR_CHARSET (str[0]);
|
428
|
102
|
771
|
103 for (i = 1; i <= len; i++)
|
|
104 {
|
|
105 if (i == len || !EQ (CHAR_CHARSET (str[i]), prev_charset))
|
428
|
106 {
|
771
|
107 int j;
|
|
108 Intbyte *int_storage =
|
|
109 alloca_intbytes (MAX_EMCHAR_LEN * (i - runbegin));
|
|
110 int int_storage_ptr = 0;
|
|
111 Extbyte *alloca_ext_storage;
|
|
112 int nchars;
|
428
|
113
|
771
|
114 int_storage_ptr = 0;
|
|
115 for (j = runbegin; j < i; j++)
|
|
116 int_storage_ptr +=
|
|
117 set_charptr_emchar (int_storage + int_storage_ptr, str[j]);
|
|
118 TO_EXTERNAL_FORMAT (DATA, (int_storage, int_storage_ptr),
|
|
119 ALLOCA, (alloca_ext_storage, nchars),
|
|
120 Qmswindows_unicode);
|
|
121 nchars /= sizeof (WCHAR); /* Tricky ... */
|
|
122 DO_REALLOC (ext_storage, ext_storage_size, total_nchars + nchars,
|
|
123 WCHAR);
|
|
124 memcpy (ext_storage + total_nchars, alloca_ext_storage,
|
|
125 nchars * sizeof (WCHAR));
|
|
126 DO_REALLOC (run_storage, run_storage_size, runs_so_far + 1,
|
|
127 textual_run);
|
|
128 run_storage[runs_so_far].ptr = ext_storage + total_nchars;
|
|
129 run_storage[runs_so_far].charset = prev_charset;
|
|
130 run_storage[runs_so_far].nwchars = nchars;
|
|
131 run_storage[runs_so_far].nchars = i - runbegin;
|
|
132 total_nchars += nchars;
|
428
|
133 runs_so_far++;
|
771
|
134 runbegin = i;
|
|
135 if (i < len)
|
|
136 prev_charset = CHAR_CHARSET (str[i]);
|
428
|
137 }
|
|
138 }
|
|
139
|
771
|
140 *run_storage_ptr = run_storage;
|
428
|
141 return runs_so_far;
|
|
142 }
|
|
143
|
|
144
|
|
145 static int
|
|
146 mswindows_text_width_single_run (HDC hdc, struct face_cachel *cachel,
|
|
147 textual_run *run)
|
|
148 {
|
|
149 Lisp_Object font_inst = FACE_CACHEL_FONT (cachel, run->charset);
|
|
150 SIZE size;
|
|
151
|
771
|
152 #if 0 /* @@#### not the way of ikeyama's ws */
|
428
|
153 if (!fi->proportional_p || !hdc)
|
771
|
154 {
|
|
155 if (XCHARSET_DIMENSION (run->charset) == 2)
|
|
156 /* Don't trust FONT_INSTANCE_WIDTH. Asian fonts have both of
|
|
157 one and two column characters. */
|
|
158 goto the_hard_way;
|
|
159 else
|
|
160 return fi->width * run->nchars;
|
|
161 }
|
428
|
162 else
|
|
163 {
|
771
|
164 the_hard_way:
|
|
165 #endif
|
440
|
166 mswindows_set_dc_font (hdc, font_inst,
|
|
167 cachel->underline, cachel->strikethru);
|
771
|
168 GetTextExtentPoint32W (hdc, run->ptr, run->nwchars, &size);
|
|
169 return size.cx;
|
|
170 #if 0 /* @@#### not the way of ikeyama's ws */
|
428
|
171 }
|
771
|
172 #endif
|
428
|
173 }
|
|
174
|
440
|
175 /*
|
|
176 * Given F, retrieve device context. F can be a display frame, or
|
442
|
177 * a print job. For a print job, page is also started when printer's
|
|
178 * device context is first time requested.
|
440
|
179 */
|
|
180 static HDC
|
442
|
181 get_frame_dc (struct frame *f, int start_page_p)
|
440
|
182 {
|
|
183 if (FRAME_MSWINDOWS_P (f))
|
|
184 return FRAME_MSWINDOWS_DC (f);
|
|
185 else
|
442
|
186 {
|
|
187 if (start_page_p && !FRAME_MSPRINTER_PAGE_STARTED (f))
|
|
188 msprinter_start_page (f);
|
|
189 return DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f)));
|
|
190 }
|
440
|
191 }
|
|
192
|
|
193 /*
|
|
194 * Given F, retrieve compatible device context. F can be a display
|
|
195 * frame, or a print job.
|
|
196 */
|
|
197 static HDC
|
|
198 get_frame_compdc (struct frame *f)
|
|
199 {
|
442
|
200 struct device *d = XDEVICE (FRAME_DEVICE (f));
|
|
201 if (DEVICE_MSWINDOWS_P (d))
|
|
202 return DEVICE_MSWINDOWS_HCDC (d);
|
440
|
203 else
|
442
|
204 return DEVICE_MSPRINTER_HCDC (d);
|
440
|
205 }
|
428
|
206
|
|
207 /*****************************************************************************
|
|
208 mswindows_update_dc
|
|
209
|
|
210 Given a number of parameters munge the DC so it has those properties.
|
|
211 ****************************************************************************/
|
|
212 static void
|
440
|
213 mswindows_update_dc (HDC hdc, Lisp_Object fg, Lisp_Object bg,
|
|
214 Lisp_Object bg_pmap)
|
428
|
215 {
|
|
216 if (!NILP (fg))
|
|
217 {
|
|
218 SetTextColor (hdc, COLOR_INSTANCE_MSWINDOWS_COLOR
|
|
219 (XCOLOR_INSTANCE (fg)));
|
|
220 }
|
440
|
221
|
428
|
222 if (!NILP (bg))
|
|
223 {
|
|
224 SetBkMode (hdc, OPAQUE);
|
|
225 SetBkColor (hdc, COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (bg)));
|
|
226 }
|
|
227 else
|
|
228 {
|
|
229 SetBkMode (hdc, TRANSPARENT);
|
|
230 }
|
|
231 }
|
|
232
|
771
|
233 static void
|
|
234 mswindows_set_dc_font (HDC hdc, Lisp_Object font, int under, int strike)
|
428
|
235 {
|
771
|
236 SelectObject (hdc, mswindows_get_hfont (XFONT_INSTANCE (font),
|
|
237 under, strike));
|
428
|
238 }
|
|
239
|
|
240 /*****************************************************************************
|
|
241 mswindows_output_hline
|
|
242
|
|
243 Output a horizontal line in the foreground of its face.
|
|
244 ****************************************************************************/
|
|
245 static void
|
|
246 mswindows_output_hline (struct window *w, struct display_line *dl, struct rune *rb)
|
771
|
247 { /* #### Implement me */
|
428
|
248 }
|
|
249
|
|
250
|
|
251 /*****************************************************************************
|
|
252 mswindows_output_blank
|
|
253
|
|
254 Output a blank by clearing the area it covers in the background color
|
|
255 of its face.
|
|
256 ****************************************************************************/
|
|
257 static void
|
|
258 mswindows_output_blank (struct window *w, struct display_line *dl,
|
|
259 struct rune *rb, int start_pixpos)
|
|
260 {
|
|
261 struct frame *f = XFRAME (w->frame);
|
442
|
262 HDC hdc = get_frame_dc (f, 1);
|
428
|
263 RECT rect = { rb->xpos, DISPLAY_LINE_YPOS (dl),
|
|
264 rb->xpos+rb->width,
|
|
265 DISPLAY_LINE_YEND (dl) };
|
|
266 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, rb->findex);
|
|
267
|
|
268 Lisp_Object bg_pmap = WINDOW_FACE_CACHEL_BACKGROUND_PIXMAP (w, rb->findex);
|
|
269
|
|
270 /* Unmap all subwindows in the area we are going to blank. */
|
|
271 redisplay_unmap_subwindows_maybe (f, rb->xpos, DISPLAY_LINE_YPOS (dl),
|
|
272 rb->width, DISPLAY_LINE_HEIGHT (dl));
|
|
273
|
|
274 if (!IMAGE_INSTANCEP (bg_pmap)
|
|
275 || !IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
|
|
276 bg_pmap = Qnil;
|
|
277
|
|
278 if (!NILP(bg_pmap))
|
|
279 {
|
|
280 struct display_box db;
|
|
281 struct display_glyph_area dga;
|
|
282 redisplay_calculate_display_boxes (dl, rb->xpos,
|
|
283 /*rb->object.dglyph.xoffset*/ 0,
|
|
284 start_pixpos, rb->width,
|
|
285 &db, &dga);
|
|
286 /* blank the background in the appropriate color */
|
440
|
287 mswindows_update_dc (hdc, cachel->foreground,
|
428
|
288 cachel->background, Qnil);
|
|
289 redisplay_output_pixmap (w, bg_pmap, &db, &dga, rb->findex,
|
|
290 0, 0, 0, TRUE);
|
|
291 }
|
|
292 else
|
|
293 {
|
440
|
294 mswindows_update_dc (hdc, Qnil, cachel->background, Qnil);
|
771
|
295 ExtTextOutW (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
|
428
|
296 }
|
|
297 }
|
|
298
|
|
299
|
|
300 /*****************************************************************************
|
|
301 mswindows_output_cursor
|
|
302
|
|
303 Draw a normal or end-of-line cursor. The end-of-line cursor is
|
|
304 narrower than the normal cursor.
|
|
305 ****************************************************************************/
|
|
306 static void
|
|
307 mswindows_output_cursor (struct window *w, struct display_line *dl, int xpos,
|
|
308 int width, face_index findex, Emchar ch, int image_p)
|
|
309 {
|
|
310 struct frame *f = XFRAME (w->frame);
|
|
311 struct device *d = XDEVICE (f->device);
|
|
312 Lisp_Object font = Qnil;
|
|
313 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
|
442
|
314 HDC hdc = get_frame_dc (f, 1);
|
647
|
315 int local_face_index = 0;
|
771
|
316 textual_run *run;
|
|
317 int nruns = 0;
|
428
|
318 RECT rect = { xpos,
|
|
319 DISPLAY_LINE_YPOS (dl),
|
|
320 xpos + width,
|
|
321 DISPLAY_LINE_YEND (dl) };
|
|
322 Lisp_Object bar = symbol_value_in_buffer (Qbar_cursor,
|
|
323 WINDOW_BUFFER (w));
|
|
324 int bar_p = image_p || !NILP (bar);
|
|
325 int cursor_p = !NILP (w->text_cursor_visible_p);
|
|
326 int real_char_p = ch != 0;
|
|
327
|
|
328 /* Unmap all subwindows in the area we are going to blank. */
|
|
329 redisplay_unmap_subwindows_maybe (f, xpos, DISPLAY_LINE_YPOS (dl),
|
|
330 width, DISPLAY_LINE_HEIGHT (dl));
|
|
331
|
|
332 if (real_char_p)
|
|
333 {
|
|
334 /* Use the font from the underlying character */
|
771
|
335 struct face_cachel *font_cachel = WINDOW_FACE_CACHEL (w, findex);
|
|
336 nruns = separate_textual_runs (&run, &ch, 1);
|
|
337 font = FACE_CACHEL_FONT (font_cachel, run->charset);
|
|
338 mswindows_set_dc_font (hdc, font,
|
|
339 font_cachel->underline, font_cachel->strikethru);
|
428
|
340 }
|
|
341
|
|
342 if (!image_p)
|
|
343 {
|
|
344 struct face_cachel *color_cachel;
|
|
345
|
|
346 /* Use cursor fg/bg for block cursor, or character fg/bg for the bar
|
|
347 or when we need to erase the cursor. Output nothing at eol if bar
|
|
348 cursor */
|
440
|
349 local_face_index = get_builtin_face_cache_index (w, Vtext_cursor_face);
|
428
|
350 color_cachel = WINDOW_FACE_CACHEL (w, ((!cursor_p || bar_p) ?
|
440
|
351 findex : local_face_index));
|
|
352 mswindows_update_dc (hdc, color_cachel->foreground,
|
428
|
353 color_cachel->background, Qnil);
|
771
|
354 ExtTextOutW (hdc, xpos, dl->ypos, ETO_OPAQUE|ETO_CLIPPED, &rect,
|
|
355 nruns ? run->ptr : NULL, nruns ? run->nwchars : 0, NULL);
|
428
|
356 }
|
|
357
|
|
358 if (!cursor_p)
|
|
359 return;
|
|
360
|
|
361 if (focus && bar_p)
|
|
362 {
|
771
|
363 struct face_cachel *cursor_cachel;
|
428
|
364 rect.right = rect.left + (EQ (bar, Qt) ? 1 : min (2, width));
|
440
|
365 local_face_index = get_builtin_face_cache_index (w, Vtext_cursor_face);
|
771
|
366 cursor_cachel = WINDOW_FACE_CACHEL (w, local_face_index);
|
|
367 mswindows_update_dc (hdc, Qnil, cursor_cachel->background, Qnil);
|
|
368 ExtTextOutW (hdc, xpos, dl->ypos, ETO_OPAQUE, &rect, NULL, 0, NULL);
|
428
|
369 }
|
|
370 else if (!focus)
|
|
371 {
|
771
|
372 struct face_cachel *cursor_cachel;
|
|
373
|
428
|
374 /* Now have real character drawn in its own color. We deflate
|
|
375 the rectangle so character cell will be bounded by the
|
|
376 previously drawn cursor shape */
|
|
377 InflateRect (&rect, -1, -1);
|
771
|
378 local_face_index = get_builtin_face_cache_index (w, Vdefault_face);
|
|
379 cursor_cachel =
|
|
380 WINDOW_FACE_CACHEL (w, (real_char_p ? findex : local_face_index));
|
|
381 mswindows_update_dc (hdc,
|
|
382 cursor_cachel->foreground,
|
|
383 cursor_cachel->background, Qnil);
|
|
384 ExtTextOutW (hdc, xpos, dl->ypos, ETO_OPAQUE | ETO_CLIPPED,
|
|
385 &rect, nruns ? run->ptr : NULL, nruns ? run->nwchars : 0,
|
|
386 NULL);
|
|
387 }
|
428
|
388
|
771
|
389 #ifdef MULE
|
|
390 if (DEVICE_MSWINDOWS_P (d) &&
|
|
391 (FRAME_MSWINDOWS_CURSOR_X (f) != xpos
|
|
392 || FRAME_MSWINDOWS_CURSOR_Y (f) != DISPLAY_LINE_YPOS (dl)
|
|
393 || FRAME_MSWINDOWS_CURSOR_FINDEX (f) != findex))
|
|
394 {
|
|
395 HWND hwnd = FRAME_MSWINDOWS_HANDLE(f);
|
|
396 HIMC himc = ImmGetContext (hwnd);
|
|
397
|
|
398 FRAME_MSWINDOWS_CURSOR_X (f) = xpos;
|
|
399 FRAME_MSWINDOWS_CURSOR_Y (f) = DISPLAY_LINE_YPOS (dl);
|
|
400 FRAME_MSWINDOWS_CURSOR_FINDEX (f) = findex;
|
|
401
|
|
402 /* If the composition window is active, reset position of the
|
|
403 composition window. */
|
|
404 if (qxeImmGetCompositionString (himc, GCS_COMPSTR, NULL, 0))
|
|
405 mswindows_start_ime_composition (f);
|
|
406
|
|
407 ImmReleaseContext (hwnd, himc);
|
428
|
408 }
|
771
|
409 #endif /* MULE */
|
428
|
410 }
|
|
411
|
|
412
|
|
413 /*****************************************************************************
|
|
414 mswindows_output_string
|
|
415
|
|
416 Given a string and a starting position, output that string in the
|
|
417 given face.
|
|
418 Correctly handles multiple charsets in the string.
|
|
419
|
|
420 The meaning of the parameters is something like this:
|
|
421
|
|
422 W Window that the text is to be displayed in.
|
|
423 DL Display line that this text is on. The values in the
|
|
424 structure are used to determine the vertical position and
|
|
425 clipping range of the text.
|
|
426 BUF Dynamic array of Emchars specifying what is actually to be
|
|
427 drawn.
|
|
428 XPOS X position in pixels where the text should start being drawn.
|
|
429 XOFFSET Number of pixels to be chopped off the left side of the
|
|
430 text. The effect is as if the text were shifted to the
|
|
431 left this many pixels and clipped at XPOS.
|
|
432 CLIP_START Clip everything left of this X position.
|
|
433 WIDTH Clip everything right of XPOS + WIDTH.
|
|
434 FINDEX Index for the face cache element describing how to display
|
|
435 the text.
|
|
436 ****************************************************************************/
|
440
|
437 static void
|
428
|
438 mswindows_output_string (struct window *w, struct display_line *dl,
|
|
439 Emchar_dynarr *buf, int xpos, int xoffset, int clip_start,
|
|
440 int width, face_index findex,
|
|
441 int cursor, int cursor_start, int cursor_width,
|
|
442 int cursor_height)
|
|
443 {
|
|
444 struct frame *f = XFRAME (w->frame);
|
|
445 /* struct device *d = XDEVICE (f->device);*/
|
|
446 Lisp_Object window;
|
442
|
447 HDC hdc = get_frame_dc (f, 1);
|
428
|
448 int clip_end;
|
|
449 Lisp_Object bg_pmap;
|
771
|
450 textual_run *runs;
|
428
|
451 int nruns;
|
|
452 int i, height;
|
|
453 RECT rect;
|
|
454 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, findex);
|
|
455
|
|
456 XSETWINDOW (window, w);
|
|
457
|
|
458 #if 0 /* #### FIXME? */
|
|
459 /* We can't work out the width before we've set the font in the DC */
|
|
460 if (width < 0)
|
|
461 width = mswindows_text_width (cachel, Dynarr_atp (buf, 0), Dynarr_length (buf));
|
|
462 #else
|
|
463 assert(width>=0);
|
|
464 #endif
|
|
465
|
|
466 /* Regularize the variables passed in. */
|
|
467 if (clip_start < xpos)
|
|
468 clip_start = xpos;
|
|
469 clip_end = xpos + width;
|
|
470 if (clip_start >= clip_end)
|
|
471 /* It's all clipped out. */
|
|
472 return;
|
|
473
|
|
474 xpos -= xoffset;
|
|
475
|
|
476 /* sort out the destination rectangle */
|
|
477 height = DISPLAY_LINE_HEIGHT (dl);
|
|
478 rect.left = clip_start;
|
|
479 rect.top = DISPLAY_LINE_YPOS (dl);
|
|
480 rect.right = clip_end;
|
|
481 rect.bottom = rect.top + height;
|
|
482
|
|
483 /* make sure the area we are about to display is subwindow free. */
|
|
484 redisplay_unmap_subwindows_maybe (f, clip_start, DISPLAY_LINE_YPOS (dl),
|
|
485 clip_end - clip_start, DISPLAY_LINE_HEIGHT (dl));
|
|
486
|
|
487 /* output the background pixmap if there is one */
|
|
488 bg_pmap = cachel->background_pixmap;
|
|
489 if (!IMAGE_INSTANCEP (bg_pmap)
|
|
490 || !IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
|
|
491 bg_pmap = Qnil;
|
|
492
|
|
493 if (!NILP(bg_pmap))
|
|
494 {
|
|
495 struct display_box db;
|
|
496 struct display_glyph_area dga;
|
|
497 redisplay_calculate_display_boxes (dl, xpos + xoffset, 0,
|
|
498 clip_start, width, &db, &dga);
|
|
499 /* blank the background in the appropriate color */
|
440
|
500 mswindows_update_dc (hdc,
|
|
501 cachel->foreground, cachel->background, Qnil);
|
428
|
502 redisplay_output_pixmap (w, bg_pmap, &db, &dga, findex,
|
|
503 0, 0, 0, TRUE);
|
|
504 /* output pixmap calls this so we have to recall to get correct
|
|
505 references */
|
|
506 cachel = WINDOW_FACE_CACHEL (w, findex);
|
|
507 }
|
|
508
|
771
|
509 nruns = separate_textual_runs (&runs, Dynarr_atp (buf, 0),
|
428
|
510 Dynarr_length (buf));
|
|
511
|
|
512 for (i = 0; i < nruns; i++)
|
|
513 {
|
|
514 Lisp_Object font = FACE_CACHEL_FONT (cachel, runs[i].charset);
|
440
|
515 Lisp_Font_Instance *fi = XFONT_INSTANCE (font);
|
428
|
516 int this_width;
|
|
517
|
|
518 if (EQ (font, Vthe_null_font_instance))
|
|
519 continue;
|
|
520
|
440
|
521 mswindows_update_dc (hdc, cachel->foreground,
|
428
|
522 NILP(bg_pmap) ? cachel->background : Qnil, Qnil);
|
440
|
523 mswindows_set_dc_font (hdc, font, cachel->underline, cachel->strikethru);
|
428
|
524
|
|
525 this_width = mswindows_text_width_single_run (hdc, cachel, runs + i);
|
|
526
|
|
527 /* cope with fonts taller than lines */
|
|
528 if ((int) fi->height < (int) (height + dl->clip + dl->top_clip))
|
|
529 {
|
|
530 int clear_start = max (xpos, clip_start);
|
|
531 int clear_end = min (xpos + this_width, clip_end);
|
|
532
|
|
533 {
|
|
534 redisplay_clear_region (window, findex, clear_start,
|
|
535 DISPLAY_LINE_YPOS (dl),
|
|
536 clear_end - clear_start,
|
|
537 height);
|
|
538 /* output pixmap calls this so we have to recall to get correct
|
|
539 references */
|
|
540 cachel = WINDOW_FACE_CACHEL (w, findex);
|
|
541 }
|
|
542 }
|
|
543
|
771
|
544 ExtTextOutW (hdc, xpos, dl->ypos,
|
|
545 NILP(bg_pmap) ? ETO_CLIPPED | ETO_OPAQUE : ETO_CLIPPED,
|
|
546 &rect, runs[i].ptr, runs[i].nwchars, NULL);
|
428
|
547
|
|
548 xpos += this_width;
|
|
549 }
|
|
550 }
|
|
551
|
|
552 static void
|
440
|
553 mswindows_output_dibitmap (struct frame *f, Lisp_Image_Instance *p,
|
771
|
554 struct display_box *db,
|
|
555 struct display_glyph_area *dga)
|
428
|
556 {
|
442
|
557 HDC hdc = get_frame_dc (f, 1);
|
440
|
558 HDC hcompdc = get_frame_compdc (f);
|
428
|
559 HGDIOBJ old=NULL;
|
442
|
560 const int real_x = IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (p);
|
|
561 const int real_y = IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (p);
|
|
562 const int surface_x = IMAGE_INSTANCE_PIXMAP_WIDTH (p);
|
|
563 const int surface_y = IMAGE_INSTANCE_PIXMAP_HEIGHT (p);
|
428
|
564
|
442
|
565 /* first blit the mask */
|
428
|
566 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
|
|
567 {
|
442
|
568 RGBQUAD bg;
|
|
569 COLORREF bgcolor;
|
428
|
570
|
440
|
571 old = SelectObject (hcompdc, IMAGE_INSTANCE_MSWINDOWS_MASK (p));
|
428
|
572
|
442
|
573 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_MONO_PIXMAP)
|
|
574 {
|
|
575 COLORREF fgcolor;
|
|
576 RGBQUAD fg;
|
|
577
|
|
578 fgcolor = GetTextColor (hdc);
|
|
579 fg.rgbBlue = GetBValue (fgcolor);
|
|
580 fg.rgbRed = GetRValue (fgcolor);
|
|
581 fg.rgbGreen = GetGValue (fgcolor);
|
|
582 fg.rgbReserved = 0;
|
|
583 SetDIBColorTable (hcompdc, 0, 1, &fg);
|
|
584 }
|
428
|
585
|
442
|
586 bgcolor = GetBkColor (hdc);
|
|
587 bg.rgbBlue = GetBValue (bgcolor);
|
|
588 bg.rgbRed = GetRValue (bgcolor);
|
|
589 bg.rgbGreen = GetGValue (bgcolor);
|
|
590 bg.rgbReserved = 0;
|
|
591 SetDIBColorTable (hcompdc, 1, 1, &bg);
|
|
592
|
|
593 StretchBlt (hdc,
|
|
594 db->xpos, db->ypos,
|
|
595 dga->width, dga->height,
|
|
596 hcompdc,
|
|
597 MulDiv (dga->xoffset, real_x, surface_x),
|
|
598 MulDiv (dga->yoffset, real_y, surface_y),
|
|
599 MulDiv (dga->width, real_x, surface_x),
|
|
600 MulDiv (dga->height, real_y, surface_y),
|
|
601 SRCCOPY);
|
428
|
602
|
440
|
603 SelectObject (hcompdc, old);
|
428
|
604 }
|
|
605
|
442
|
606 /* Now blit the bitmap itself, or one of its slices. */
|
440
|
607 old = SelectObject (hcompdc,
|
428
|
608 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE
|
|
609 (p, IMAGE_INSTANCE_PIXMAP_SLICE (p)));
|
|
610
|
442
|
611 StretchBlt (hdc,
|
|
612 db->xpos, db->ypos,
|
|
613 dga->width, dga->height,
|
|
614 hcompdc,
|
|
615 MulDiv (dga->xoffset, real_x, surface_x),
|
|
616 MulDiv (dga->yoffset, real_y, surface_y),
|
|
617 MulDiv (dga->width, real_x, surface_x),
|
|
618 MulDiv (dga->height, real_y, surface_y),
|
|
619 IMAGE_INSTANCE_MSWINDOWS_MASK (p) ? SRCINVERT : SRCCOPY);
|
428
|
620
|
440
|
621 SelectObject (hcompdc, old);
|
428
|
622 }
|
|
623
|
|
624 /* X gc's have this nice property that setting the bg pixmap will
|
|
625 * output it offset relative to the window. Windows doesn't have this
|
|
626 * feature so we have to emulate this by outputting multiple pixmaps.
|
|
627 * This is only used for background pixmaps. Normal pixmaps are
|
|
628 * outputted once and are scrollable */
|
|
629 static void
|
|
630 mswindows_output_dibitmap_region (struct frame *f,
|
440
|
631 Lisp_Image_Instance *p,
|
428
|
632 struct display_box *db,
|
|
633 struct display_glyph_area *dga)
|
|
634 {
|
|
635 struct display_box xdb = { db->xpos, db->ypos, db->width, db->height };
|
|
636 struct display_glyph_area xdga
|
|
637 = { 0, 0, IMAGE_INSTANCE_PIXMAP_WIDTH (p),
|
|
638 IMAGE_INSTANCE_PIXMAP_HEIGHT (p) };
|
|
639 int pxoffset = 0, pyoffset = 0;
|
|
640
|
|
641 if (dga)
|
|
642 {
|
|
643 xdga.width = dga->width;
|
|
644 xdga.height = dga->height;
|
|
645 }
|
|
646 else if (!redisplay_normalize_glyph_area (&xdb, &xdga))
|
|
647 return;
|
|
648
|
|
649 /* when doing a bg pixmap do a partial pixmap first so that we
|
|
650 blt whole pixmaps thereafter */
|
|
651 xdga.height = min (xdga.height, IMAGE_INSTANCE_PIXMAP_HEIGHT (p) -
|
|
652 db->ypos % IMAGE_INSTANCE_PIXMAP_HEIGHT (p));
|
|
653
|
|
654 while (xdga.height > 0)
|
|
655 {
|
|
656 xdga.width = min (min (db->width, IMAGE_INSTANCE_PIXMAP_WIDTH (p)),
|
|
657 IMAGE_INSTANCE_PIXMAP_WIDTH (p) -
|
|
658 db->xpos % IMAGE_INSTANCE_PIXMAP_WIDTH (p));
|
|
659 pxoffset = 0;
|
|
660 while (xdga.width > 0)
|
|
661 {
|
|
662 xdb.xpos = db->xpos + pxoffset;
|
|
663 xdb.ypos = db->ypos + pyoffset;
|
|
664 /* do we need to offset the pixmap vertically? this is necessary
|
|
665 for background pixmaps. */
|
|
666 xdga.yoffset = xdb.ypos % IMAGE_INSTANCE_PIXMAP_HEIGHT (p);
|
|
667 xdga.xoffset = xdb.xpos % IMAGE_INSTANCE_PIXMAP_WIDTH (p);
|
|
668 /* the width is handled by mswindows_output_pixmap_region */
|
|
669 mswindows_output_dibitmap (f, p, &xdb, &xdga);
|
|
670 pxoffset += xdga.width;
|
|
671 xdga.width = min ((db->width - pxoffset),
|
|
672 IMAGE_INSTANCE_PIXMAP_WIDTH (p));
|
|
673 }
|
|
674 pyoffset += xdga.height;
|
|
675 xdga.height = min ((db->height - pyoffset),
|
|
676 IMAGE_INSTANCE_PIXMAP_HEIGHT (p));
|
|
677 }
|
|
678 }
|
|
679
|
|
680 /* Output a pixmap at the desired location.
|
|
681 DB normalized display_box.
|
|
682 DGA normalized display_glyph_area. */
|
|
683 static void
|
|
684 mswindows_output_pixmap (struct window *w, Lisp_Object image_instance,
|
|
685 struct display_box *db, struct display_glyph_area *dga,
|
|
686 face_index findex, int cursor_start, int cursor_width,
|
|
687 int cursor_height, int bg_pixmap)
|
|
688 {
|
|
689 struct frame *f = XFRAME (w->frame);
|
442
|
690 HDC hdc = get_frame_dc (f, 1);
|
428
|
691
|
440
|
692 Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
|
428
|
693 Lisp_Object window;
|
|
694
|
|
695 XSETWINDOW (window, w);
|
|
696
|
|
697 /* Output the pixmap. Have to do this as many times as is required
|
|
698 to fill the given area */
|
440
|
699 mswindows_update_dc (hdc,
|
428
|
700 WINDOW_FACE_CACHEL_FOREGROUND (w, findex),
|
|
701 WINDOW_FACE_CACHEL_BACKGROUND (w, findex), Qnil);
|
|
702
|
|
703 if (bg_pixmap)
|
|
704 mswindows_output_dibitmap_region (f, p, db, dga);
|
|
705 else
|
|
706 mswindows_output_dibitmap (f, p, db, dga);
|
|
707 }
|
|
708
|
|
709 #ifdef HAVE_SCROLLBARS
|
|
710 /*
|
|
711 * This function paints window's deadbox, a rectangle between window
|
|
712 * borders and two short edges of both scrollbars.
|
|
713 *
|
|
714 * Function checks whether deadbox intersects with the rectangle pointed
|
|
715 * to by PRC, and paints only the intersection
|
|
716 */
|
|
717 static void
|
771
|
718 mswindows_redisplay_deadbox_maybe (struct window *w, const RECT *prc)
|
428
|
719 {
|
|
720 int sbh = window_scrollbar_height (w);
|
|
721 int sbw = window_scrollbar_width (w);
|
|
722 RECT rect_dead, rect_paint;
|
|
723 if (sbh == 0 || sbw == 0)
|
|
724 return;
|
|
725
|
|
726 if (!NILP (w->scrollbar_on_left_p))
|
|
727 rect_dead.left = WINDOW_LEFT (w);
|
|
728 else
|
|
729 rect_dead.left = WINDOW_TEXT_RIGHT (w);
|
|
730 rect_dead.right = rect_dead.left + sbw;
|
|
731
|
|
732 if (!NILP (w->scrollbar_on_top_p))
|
|
733 rect_dead.top = WINDOW_TOP (w);
|
|
734 else
|
|
735 rect_dead.top = WINDOW_TEXT_BOTTOM (w);
|
|
736 rect_dead.bottom = rect_dead.top + sbh;
|
|
737
|
|
738 if (IntersectRect (&rect_paint, &rect_dead, prc))
|
|
739 {
|
|
740 struct frame *f = XFRAME (WINDOW_FRAME (w));
|
442
|
741 FillRect (get_frame_dc (f, 1), &rect_paint,
|
428
|
742 (HBRUSH) (COLOR_BTNFACE+1));
|
|
743 }
|
|
744 }
|
|
745
|
|
746 #endif /* HAVE_SCROLLBARS */
|
|
747
|
|
748 /*****************************************************************************
|
|
749 mswindows_redraw_exposed_window
|
|
750
|
|
751 Given a bounding box for an area that needs to be redrawn, determine
|
|
752 what parts of what lines are contained within and re-output their
|
|
753 contents.
|
|
754 Copied from redisplay-x.c
|
|
755 ****************************************************************************/
|
|
756 static void
|
|
757 mswindows_redraw_exposed_window (struct window *w, int x, int y, int width,
|
|
758 int height)
|
|
759 {
|
|
760 struct frame *f = XFRAME (w->frame);
|
|
761 int line;
|
|
762 int orig_windows_structure_changed;
|
|
763 RECT rect_window = { WINDOW_LEFT (w), WINDOW_TOP (w),
|
|
764 WINDOW_RIGHT (w), WINDOW_BOTTOM (w) };
|
|
765 RECT rect_expose = { x, y, x + width, y + height };
|
|
766 RECT rect_draw;
|
|
767
|
|
768 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
769
|
|
770 if (!NILP (w->vchild))
|
|
771 {
|
|
772 mswindows_redraw_exposed_windows (w->vchild, x, y, width, height);
|
|
773 return;
|
|
774 }
|
|
775 else if (!NILP (w->hchild))
|
|
776 {
|
|
777 mswindows_redraw_exposed_windows (w->hchild, x, y, width, height);
|
|
778 return;
|
|
779 }
|
|
780
|
|
781 /* If the window doesn't intersect the exposed region, we're done here. */
|
|
782 if (!IntersectRect (&rect_draw, &rect_window, &rect_expose))
|
|
783 return;
|
|
784
|
|
785 /* We do this to make sure that the 3D modelines get redrawn if
|
|
786 they are in the exposed region. */
|
|
787 orig_windows_structure_changed = f->windows_structure_changed;
|
|
788 f->windows_structure_changed = 1;
|
|
789
|
|
790 if (window_needs_vertical_divider (w))
|
|
791 {
|
|
792 mswindows_output_vertical_divider (w, 0);
|
|
793 }
|
|
794
|
|
795 for (line = 0; line < Dynarr_length (cdla); line++)
|
|
796 {
|
|
797 struct display_line *cdl = Dynarr_atp (cdla, line);
|
|
798
|
|
799 if (DISPLAY_LINE_YPOS (cdl) + DISPLAY_LINE_HEIGHT (cdl)
|
|
800 >= rect_draw.top)
|
|
801 {
|
|
802 if (DISPLAY_LINE_YPOS (cdl) > rect_draw.bottom)
|
|
803 {
|
|
804 if (line == 0)
|
|
805 continue;
|
|
806 else
|
|
807 break;
|
|
808 }
|
|
809 else
|
|
810 {
|
|
811 output_display_line (w, 0, cdla, line,
|
|
812 rect_draw.left, rect_draw.right);
|
|
813 }
|
|
814 }
|
|
815 }
|
|
816
|
|
817 f->windows_structure_changed = orig_windows_structure_changed;
|
|
818
|
|
819 /* If there have never been any face cache_elements created, then this
|
|
820 expose event doesn't actually have anything to do. */
|
|
821 if (Dynarr_largest (w->face_cachels))
|
|
822 redisplay_clear_bottom_of_window (w, cdla, rect_draw.top, rect_draw.bottom);
|
|
823
|
|
824 #ifdef HAVE_SCROLLBARS
|
|
825 mswindows_redisplay_deadbox_maybe (w, &rect_expose);
|
|
826 #endif
|
|
827 }
|
|
828
|
|
829 /*****************************************************************************
|
|
830 mswindows_redraw_exposed_windows
|
|
831
|
|
832 For each window beneath the given window in the window hierarchy,
|
|
833 ensure that it is redrawn if necessary after an Expose event.
|
|
834 ****************************************************************************/
|
|
835 static void
|
|
836 mswindows_redraw_exposed_windows (Lisp_Object window, int x, int y, int width,
|
|
837 int height)
|
|
838 {
|
|
839 for (; !NILP (window); window = XWINDOW (window)->next)
|
|
840 mswindows_redraw_exposed_window (XWINDOW (window), x, y, width, height);
|
|
841 }
|
|
842
|
|
843 /*****************************************************************************
|
|
844 mswindows_redraw_exposed_area
|
|
845
|
|
846 For each window on the given frame, ensure that any area in the
|
|
847 Exposed area is redrawn.
|
|
848 ****************************************************************************/
|
|
849 void
|
|
850 mswindows_redraw_exposed_area (struct frame *f, int x, int y, int width, int height)
|
|
851 {
|
|
852 /* If any window on the frame has had its face cache reset then the
|
|
853 redisplay structures are effectively invalid. If we attempt to
|
|
854 use them we'll blow up. We mark the frame as changed to ensure
|
|
855 that redisplay will do a full update. This probably isn't
|
|
856 necessary but it can't hurt. */
|
|
857 #ifdef HAVE_TOOLBARS
|
|
858 /* #### We would rather put these off as well but there is currently
|
|
859 no combination of flags which will force an unchanged toolbar to
|
|
860 redraw anyhow. */
|
|
861 MAYBE_FRAMEMETH (f, redraw_exposed_toolbars, (f, x, y, width, height));
|
|
862 #endif
|
|
863 redraw_exposed_gutters (f, x, y, width, height);
|
|
864
|
|
865 if (!f->window_face_cache_reset)
|
|
866 {
|
|
867 mswindows_redraw_exposed_windows (f->root_window, x, y, width, height);
|
|
868 GdiFlush();
|
|
869 }
|
|
870 else
|
|
871 MARK_FRAME_CHANGED (f);
|
|
872 }
|
|
873
|
|
874
|
|
875 /*****************************************************************************
|
|
876 mswindows_bevel_area
|
|
877
|
|
878 Draw a 3d border around the specified area on window W.
|
|
879 ****************************************************************************/
|
|
880 static void
|
|
881 mswindows_bevel_area (struct window *w, face_index findex, int x, int y,
|
|
882 int width, int height, int thickness,
|
|
883 int edges, enum edge_style style)
|
|
884 {
|
|
885 struct frame *f = XFRAME (w->frame);
|
|
886 UINT edge;
|
|
887 UINT border = 0;
|
|
888
|
|
889 if (style == EDGE_ETCHED_IN)
|
|
890 edge = EDGE_ETCHED;
|
|
891 else if (style == EDGE_ETCHED_OUT)
|
|
892 edge = EDGE_BUMP;
|
|
893 else if (style == EDGE_BEVEL_IN)
|
|
894 {
|
|
895 if (thickness == 1)
|
|
896 edge = BDR_SUNKENINNER;
|
|
897 else
|
|
898 edge = EDGE_SUNKEN;
|
|
899 }
|
|
900 else /* EDGE_BEVEL_OUT */
|
|
901 {
|
|
902 if (thickness == 1)
|
|
903 edge = BDR_RAISEDINNER;
|
|
904 else
|
|
905 edge = EDGE_RAISED;
|
|
906 }
|
|
907
|
|
908 if (edges & EDGE_TOP)
|
|
909 border |= BF_TOP;
|
|
910 if (edges & EDGE_LEFT)
|
|
911 border |= BF_LEFT;
|
|
912 if (edges & EDGE_BOTTOM)
|
|
913 border |= BF_BOTTOM;
|
|
914 if (edges & EDGE_RIGHT)
|
|
915 border |= BF_RIGHT;
|
|
916
|
|
917 {
|
|
918 RECT rect = { x, y, x + width, y + height };
|
|
919 Lisp_Object color = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
|
442
|
920 HDC hdc = get_frame_dc (f, 1);
|
428
|
921
|
440
|
922 mswindows_update_dc (hdc, Qnil, color, Qnil);
|
|
923 DrawEdge (hdc, &rect, edge, border);
|
428
|
924 }
|
|
925 }
|
|
926
|
|
927
|
|
928 /*****************************************************************************
|
|
929 Display methods
|
|
930 *****************************************************************************/
|
|
931
|
|
932 /*****************************************************************************
|
|
933 mswindows_divider_height
|
|
934
|
|
935 Return the height of the horizontal divider.
|
|
936 ****************************************************************************/
|
|
937 static int
|
|
938 mswindows_divider_height (void)
|
|
939 {
|
|
940 return 1; /* XXX Copied from redisplay-X.c. What is this? */
|
|
941 }
|
|
942
|
|
943 /*****************************************************************************
|
|
944 mswindows_eol_cursor_width
|
|
945
|
|
946 Return the width of the end-of-line cursor.
|
|
947 ****************************************************************************/
|
|
948 static int
|
|
949 mswindows_eol_cursor_width (void)
|
|
950 {
|
|
951 return MSWINDOWS_EOL_CURSOR_WIDTH;
|
|
952 }
|
|
953
|
|
954 /*****************************************************************************
|
442
|
955 mswindows_frame_output_begin
|
428
|
956
|
|
957 Perform any necessary initialization prior to an update.
|
|
958 ****************************************************************************/
|
|
959 static void
|
442
|
960 mswindows_frame_output_begin (struct frame *f)
|
428
|
961 {
|
|
962 }
|
|
963
|
|
964 /*****************************************************************************
|
442
|
965 mswindows_frame_output_end
|
428
|
966
|
|
967 Perform any necessary flushing of queues when an update has completed.
|
|
968 ****************************************************************************/
|
|
969 static void
|
442
|
970 mswindows_frame_output_end (struct frame *f)
|
|
971 {
|
|
972 #ifdef DEFER_WINDOW_POS
|
|
973 HDWP hdwp = FRAME_MSWINDOWS_DATA (f)->hdwp;
|
|
974
|
|
975 if (hdwp != 0)
|
|
976 {
|
|
977 EndDeferWindowPos (hdwp);
|
|
978 FRAME_MSWINDOWS_DATA (f)->hdwp = 0;
|
|
979 }
|
|
980 #endif
|
|
981 GdiFlush();
|
|
982 }
|
|
983
|
|
984 /* Printer version is more lightweight. */
|
|
985 static void
|
|
986 msprinter_frame_output_end (struct frame *f)
|
428
|
987 {
|
|
988 GdiFlush();
|
|
989 }
|
|
990
|
|
991 static int
|
|
992 mswindows_flash (struct device *d)
|
|
993 {
|
|
994 struct frame *f = device_selected_frame (d);
|
442
|
995 HDC hdc = get_frame_dc (f, 1);
|
428
|
996 RECT rc;
|
|
997
|
|
998 GetClientRect (FRAME_MSWINDOWS_HANDLE (f), &rc);
|
440
|
999 InvertRect (hdc, &rc);
|
428
|
1000 GdiFlush ();
|
|
1001 Sleep (25);
|
440
|
1002 InvertRect (hdc, &rc);
|
428
|
1003
|
|
1004 return 1;
|
|
1005 }
|
|
1006
|
|
1007 static void
|
|
1008 mswindows_ring_bell (struct device *d, int volume, int pitch, int duration)
|
|
1009 {
|
|
1010 /* Beep does not work at all, anyways! -kkm */
|
|
1011 MessageBeep (MB_OK);
|
|
1012 }
|
|
1013
|
|
1014 /*****************************************************************************
|
|
1015 mswindows_output_display_block
|
|
1016
|
|
1017 Given a display line, a block number for that start line, output all
|
|
1018 runes between start and end in the specified display block.
|
|
1019 Ripped off with minimal thought from the corresponding X routine.
|
|
1020 ****************************************************************************/
|
|
1021 static void
|
771
|
1022 mswindows_output_display_block (struct window *w, struct display_line *dl,
|
|
1023 int block, int start, int end,
|
|
1024 int start_pixpos, int cursor_start,
|
|
1025 int cursor_width, int cursor_height)
|
428
|
1026 {
|
|
1027 struct frame *f = XFRAME (w->frame);
|
|
1028 Emchar_dynarr *buf = Dynarr_new (Emchar);
|
|
1029 Lisp_Object window;
|
|
1030
|
|
1031 struct display_block *db = Dynarr_atp (dl->display_blocks, block);
|
|
1032 rune_dynarr *rba = db->runes;
|
|
1033 struct rune *rb;
|
|
1034
|
|
1035 int elt = start;
|
|
1036 face_index findex;
|
|
1037 int xpos, width;
|
|
1038 Lisp_Object charset = Qunbound; /* Qnil is a valid charset when
|
|
1039 MULE is not defined */
|
|
1040 XSETWINDOW (window, w);
|
|
1041 rb = Dynarr_atp (rba, start);
|
|
1042
|
|
1043 if (!rb)
|
|
1044 /* Nothing to do so don't do anything. */
|
|
1045 return;
|
|
1046
|
|
1047 findex = rb->findex;
|
|
1048 xpos = rb->xpos;
|
|
1049 width = 0;
|
|
1050 if (rb->type == RUNE_CHAR)
|
|
1051 charset = CHAR_CHARSET (rb->object.chr.ch);
|
|
1052
|
|
1053 if (end < 0)
|
|
1054 end = Dynarr_length (rba);
|
|
1055 Dynarr_reset (buf);
|
|
1056
|
|
1057 while (elt < end)
|
|
1058 {
|
|
1059 rb = Dynarr_atp (rba, elt);
|
|
1060
|
|
1061 if (rb->findex == findex && rb->type == RUNE_CHAR
|
|
1062 && rb->object.chr.ch != '\n' && rb->cursor_type != CURSOR_ON
|
|
1063 && EQ (charset, CHAR_CHARSET (rb->object.chr.ch)))
|
|
1064 {
|
|
1065 Dynarr_add (buf, rb->object.chr.ch);
|
|
1066 width += rb->width;
|
|
1067 elt++;
|
|
1068 }
|
|
1069 else
|
|
1070 {
|
|
1071 if (Dynarr_length (buf))
|
|
1072 {
|
771
|
1073 mswindows_output_string (w, dl, buf, xpos, 0, start_pixpos,
|
|
1074 width, findex, 0, 0, 0, 0);
|
428
|
1075 xpos = rb->xpos;
|
|
1076 width = 0;
|
|
1077 }
|
|
1078 Dynarr_reset (buf);
|
|
1079 width = 0;
|
|
1080
|
|
1081 if (rb->type == RUNE_CHAR)
|
|
1082 {
|
|
1083 findex = rb->findex;
|
|
1084 xpos = rb->xpos;
|
|
1085 charset = CHAR_CHARSET (rb->object.chr.ch);
|
|
1086
|
|
1087 if (rb->cursor_type == CURSOR_ON)
|
|
1088 {
|
|
1089 if (rb->object.chr.ch == '\n')
|
|
1090 {
|
|
1091 mswindows_output_cursor (w, dl, xpos, cursor_width,
|
|
1092 findex, 0, 0);
|
|
1093 }
|
|
1094 else
|
|
1095 {
|
|
1096 Dynarr_add (buf, rb->object.chr.ch);
|
|
1097 mswindows_output_cursor (w, dl, xpos, cursor_width,
|
|
1098 findex, rb->object.chr.ch, 0);
|
|
1099 Dynarr_reset (buf);
|
|
1100 }
|
|
1101
|
|
1102 xpos += rb->width;
|
|
1103 elt++;
|
|
1104 }
|
|
1105 else if (rb->object.chr.ch == '\n')
|
|
1106 {
|
|
1107 /* Clear in case a cursor was formerly here. */
|
|
1108 redisplay_clear_region (window, findex, xpos,
|
|
1109 DISPLAY_LINE_YPOS (dl),
|
|
1110 rb->width, DISPLAY_LINE_HEIGHT (dl));
|
|
1111 elt++;
|
|
1112 }
|
|
1113 }
|
|
1114 else if (rb->type == RUNE_BLANK || rb->type == RUNE_HLINE)
|
|
1115 {
|
|
1116 if (rb->type == RUNE_BLANK)
|
|
1117 mswindows_output_blank (w, dl, rb, start_pixpos);
|
|
1118 else
|
|
1119 {
|
|
1120 /* #### Our flagging of when we need to redraw the
|
|
1121 modeline shadows sucks. Since RUNE_HLINE is only used
|
|
1122 by the modeline at the moment it is a good bet
|
|
1123 that if it gets redrawn then we should also
|
|
1124 redraw the shadows. This won't be true forever.
|
|
1125 We borrow the shadow_thickness_changed flag for
|
|
1126 now. */
|
|
1127 w->shadow_thickness_changed = 1;
|
|
1128 mswindows_output_hline (w, dl, rb);
|
|
1129 }
|
|
1130
|
|
1131 if (rb->cursor_type == CURSOR_ON)
|
|
1132 mswindows_output_cursor (w, dl, xpos, cursor_width, rb->findex, 0, 0);
|
|
1133
|
|
1134 elt++;
|
|
1135 if (elt < end)
|
|
1136 {
|
|
1137 rb = Dynarr_atp (rba, elt);
|
|
1138
|
|
1139 findex = rb->findex;
|
|
1140 xpos = rb->xpos;
|
|
1141 }
|
|
1142 }
|
|
1143 else if (rb->type == RUNE_DGLYPH)
|
|
1144 {
|
|
1145 Lisp_Object instance;
|
440
|
1146 struct display_box dbox;
|
428
|
1147 struct display_glyph_area dga;
|
442
|
1148
|
428
|
1149 redisplay_calculate_display_boxes (dl, rb->xpos, rb->object.dglyph.xoffset,
|
|
1150 start_pixpos, rb->width,
|
440
|
1151 &dbox, &dga);
|
428
|
1152
|
|
1153 XSETWINDOW (window, w);
|
|
1154 instance = glyph_image_instance (rb->object.dglyph.glyph,
|
|
1155 window, ERROR_ME_NOT, 1);
|
|
1156 findex = rb->findex;
|
|
1157
|
|
1158 if (IMAGE_INSTANCEP (instance))
|
442
|
1159 {
|
|
1160 switch (XIMAGE_INSTANCE_TYPE (instance))
|
428
|
1161 {
|
442
|
1162 case IMAGE_MONO_PIXMAP:
|
|
1163 case IMAGE_COLOR_PIXMAP:
|
|
1164 redisplay_output_pixmap (w, instance, &dbox, &dga, findex,
|
|
1165 cursor_start, cursor_width,
|
|
1166 cursor_height, 0);
|
428
|
1167 if (rb->cursor_type == CURSOR_ON)
|
|
1168 mswindows_output_cursor (w, dl, xpos, cursor_width,
|
442
|
1169 findex, 0, 1);
|
|
1170 break;
|
|
1171
|
|
1172 case IMAGE_WIDGET:
|
|
1173 if (EQ (XIMAGE_INSTANCE_WIDGET_TYPE (instance),
|
|
1174 Qlayout))
|
|
1175 {
|
|
1176 redisplay_output_layout (window, instance, &dbox, &dga, findex,
|
|
1177 cursor_start, cursor_width,
|
|
1178 cursor_height);
|
|
1179 if (rb->cursor_type == CURSOR_ON)
|
|
1180 mswindows_output_cursor (w, dl, xpos, cursor_width,
|
|
1181 findex, 0, 1);
|
|
1182 break;
|
|
1183 }
|
|
1184 case IMAGE_SUBWINDOW:
|
|
1185 redisplay_output_subwindow (w, instance, &dbox, &dga, findex,
|
|
1186 cursor_start, cursor_width,
|
|
1187 cursor_height);
|
|
1188 if (rb->cursor_type == CURSOR_ON)
|
|
1189 mswindows_output_cursor (w, dl, xpos, cursor_width,
|
|
1190 findex, 0, 1);
|
|
1191 break;
|
|
1192
|
|
1193 case IMAGE_NOTHING:
|
|
1194 /* nothing is as nothing does */
|
|
1195 break;
|
428
|
1196
|
442
|
1197 case IMAGE_TEXT:
|
|
1198 case IMAGE_POINTER:
|
|
1199 default:
|
|
1200 abort ();
|
|
1201 }
|
|
1202 IMAGE_INSTANCE_OPTIMIZE_OUTPUT
|
|
1203 (XIMAGE_INSTANCE (instance)) = 0;
|
|
1204 }
|
428
|
1205 xpos += rb->width;
|
|
1206 elt++;
|
|
1207 }
|
|
1208 else
|
|
1209 abort ();
|
|
1210 }
|
|
1211 }
|
|
1212
|
|
1213 if (Dynarr_length (buf))
|
|
1214 mswindows_output_string (w, dl, buf, xpos, 0, start_pixpos, width, findex,
|
|
1215 0, 0, 0, 0);
|
|
1216
|
|
1217 if (dl->modeline
|
|
1218 && !EQ (Qzero, w->modeline_shadow_thickness)
|
|
1219 && (f->clear
|
|
1220 || f->windows_structure_changed
|
|
1221 || w->shadow_thickness_changed))
|
|
1222 bevel_modeline (w, dl);
|
|
1223
|
|
1224 Dynarr_free (buf);
|
|
1225 }
|
|
1226
|
|
1227
|
|
1228 /*****************************************************************************
|
|
1229 mswindows_output_vertical_divider
|
|
1230
|
|
1231 Draw a vertical divider down the right side of the given window.
|
|
1232 ****************************************************************************/
|
|
1233 static void
|
|
1234 mswindows_output_vertical_divider (struct window *w, int clear_unused)
|
|
1235 {
|
|
1236 struct frame *f = XFRAME (w->frame);
|
442
|
1237 HDC hdc = get_frame_dc (f, 1);
|
428
|
1238 RECT rect;
|
|
1239 int spacing = XINT (w->vertical_divider_spacing);
|
|
1240 int shadow = XINT (w->vertical_divider_shadow_thickness);
|
|
1241 int abs_shadow = abs (shadow);
|
|
1242 int line_width = XINT (w->vertical_divider_line_width);
|
|
1243 int div_left = WINDOW_RIGHT (w) - window_divider_width (w);
|
442
|
1244 int y1 = WINDOW_TOP (w);
|
|
1245 int y2 = WINDOW_BOTTOM (w);
|
428
|
1246
|
|
1247 /* Clear left and right spacing areas */
|
|
1248 if (spacing)
|
|
1249 {
|
|
1250 rect.top = y1;
|
|
1251 rect.bottom = y2;
|
440
|
1252 mswindows_update_dc (hdc, Qnil,
|
428
|
1253 WINDOW_FACE_CACHEL_BACKGROUND (w, DEFAULT_INDEX), Qnil);
|
|
1254 rect.right = WINDOW_RIGHT (w);
|
|
1255 rect.left = rect.right - spacing;
|
771
|
1256 ExtTextOutW (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
|
428
|
1257 rect.left = div_left;
|
|
1258 rect.right = div_left + spacing;
|
771
|
1259 ExtTextOutW (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
|
428
|
1260 }
|
|
1261
|
|
1262 /* Clear divider face */
|
|
1263 rect.top = y1 + abs_shadow;
|
|
1264 rect.bottom = y2 - abs_shadow;
|
|
1265 rect.left = div_left + spacing + abs_shadow;
|
|
1266 rect.right = rect.left + line_width;
|
|
1267 if (rect.left < rect.right)
|
|
1268 {
|
|
1269 face_index div_face
|
|
1270 = get_builtin_face_cache_index (w, Vvertical_divider_face);
|
440
|
1271 mswindows_update_dc (hdc, Qnil,
|
428
|
1272 WINDOW_FACE_CACHEL_BACKGROUND (w, div_face), Qnil);
|
771
|
1273 ExtTextOutW (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
|
428
|
1274 }
|
|
1275
|
|
1276 /* Draw a shadow around the divider */
|
|
1277 if (shadow != 0)
|
|
1278 {
|
|
1279 /* #### This will be fixed to support arbitrary thickness */
|
|
1280 InflateRect (&rect, abs_shadow, abs_shadow);
|
440
|
1281 DrawEdge (hdc, &rect,
|
428
|
1282 shadow > 0 ? EDGE_RAISED : EDGE_SUNKEN, BF_RECT);
|
|
1283 }
|
|
1284 }
|
|
1285
|
|
1286 /****************************************************************************
|
|
1287 mswindows_text_width
|
|
1288
|
|
1289 Given a string and a face, return the string's length in pixels when
|
|
1290 displayed in the font associated with the face.
|
|
1291 ****************************************************************************/
|
|
1292 static int
|
|
1293 mswindows_text_width (struct frame *f, struct face_cachel *cachel,
|
442
|
1294 const Emchar *str, Charcount len)
|
428
|
1295 {
|
442
|
1296 HDC hdc = get_frame_dc (f, 0);
|
428
|
1297 int width_so_far = 0;
|
771
|
1298 textual_run *runs;
|
428
|
1299 int nruns;
|
|
1300 int i;
|
|
1301
|
771
|
1302 nruns = separate_textual_runs (&runs, str, len);
|
428
|
1303
|
|
1304 for (i = 0; i < nruns; i++)
|
771
|
1305 width_so_far += mswindows_text_width_single_run (hdc, cachel, runs + i);
|
428
|
1306
|
|
1307 return width_so_far;
|
|
1308 }
|
|
1309
|
|
1310
|
|
1311 /****************************************************************************
|
|
1312 mswindows_clear_region
|
|
1313
|
|
1314 Clear the area in the box defined by the given parameters using the
|
|
1315 given face.
|
|
1316 ****************************************************************************/
|
|
1317 static void
|
771
|
1318 mswindows_clear_region (Lisp_Object locale, struct device *d, struct frame *f,
|
428
|
1319 face_index findex, int x, int y,
|
|
1320 int width, int height, Lisp_Object fcolor, Lisp_Object bcolor,
|
|
1321 Lisp_Object background_pixmap)
|
|
1322 {
|
|
1323 RECT rect = { x, y, x+width, y+height };
|
442
|
1324 HDC hdc = get_frame_dc (f, 1);
|
428
|
1325
|
|
1326 if (!NILP (background_pixmap))
|
|
1327 {
|
|
1328 struct display_box db = { x, y, width, height };
|
440
|
1329 mswindows_update_dc (hdc,
|
|
1330 fcolor, bcolor, background_pixmap);
|
428
|
1331 mswindows_output_dibitmap_region
|
|
1332 ( f, XIMAGE_INSTANCE (background_pixmap), &db, 0);
|
|
1333 }
|
|
1334 else
|
|
1335 {
|
440
|
1336 mswindows_update_dc (hdc, Qnil, fcolor, Qnil);
|
771
|
1337 ExtTextOutW (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
|
428
|
1338 }
|
|
1339
|
|
1340 #ifdef HAVE_SCROLLBARS
|
|
1341 if (WINDOWP (locale))
|
|
1342 mswindows_redisplay_deadbox_maybe (XWINDOW (locale), &rect);
|
|
1343 #endif
|
|
1344 }
|
|
1345
|
|
1346 /* XXX Implement me! */
|
|
1347 static void
|
|
1348 mswindows_clear_frame (struct frame *f)
|
|
1349 {
|
|
1350 GdiFlush();
|
|
1351 }
|
|
1352
|
|
1353
|
|
1354 /************************************************************************/
|
|
1355 /* initialization */
|
|
1356 /************************************************************************/
|
|
1357
|
|
1358 void
|
|
1359 console_type_create_redisplay_mswindows (void)
|
|
1360 {
|
440
|
1361 /* redisplay methods - display*/
|
428
|
1362 CONSOLE_HAS_METHOD (mswindows, text_width);
|
|
1363 CONSOLE_HAS_METHOD (mswindows, output_display_block);
|
|
1364 CONSOLE_HAS_METHOD (mswindows, divider_height);
|
|
1365 CONSOLE_HAS_METHOD (mswindows, eol_cursor_width);
|
|
1366 CONSOLE_HAS_METHOD (mswindows, output_vertical_divider);
|
|
1367 CONSOLE_HAS_METHOD (mswindows, clear_region);
|
|
1368 CONSOLE_HAS_METHOD (mswindows, clear_frame);
|
442
|
1369 CONSOLE_HAS_METHOD (mswindows, frame_output_begin);
|
|
1370 CONSOLE_HAS_METHOD (mswindows, frame_output_end);
|
428
|
1371 CONSOLE_HAS_METHOD (mswindows, flash);
|
|
1372 CONSOLE_HAS_METHOD (mswindows, ring_bell);
|
|
1373 CONSOLE_HAS_METHOD (mswindows, bevel_area);
|
|
1374 CONSOLE_HAS_METHOD (mswindows, output_string);
|
|
1375 CONSOLE_HAS_METHOD (mswindows, output_pixmap);
|
440
|
1376
|
|
1377 /* redisplay methods - printer */
|
442
|
1378 CONSOLE_HAS_METHOD (msprinter, frame_output_end);
|
440
|
1379 CONSOLE_INHERITS_METHOD (msprinter, mswindows, text_width);
|
|
1380 CONSOLE_INHERITS_METHOD (msprinter, mswindows, output_display_block);
|
|
1381 CONSOLE_INHERITS_METHOD (msprinter, mswindows, divider_height);
|
|
1382 CONSOLE_INHERITS_METHOD (msprinter, mswindows, eol_cursor_width);
|
|
1383 CONSOLE_INHERITS_METHOD (msprinter, mswindows, output_vertical_divider);
|
|
1384 CONSOLE_INHERITS_METHOD (msprinter, mswindows, clear_region);
|
|
1385 CONSOLE_INHERITS_METHOD (msprinter, mswindows, clear_frame);
|
442
|
1386 CONSOLE_INHERITS_METHOD (msprinter, mswindows, frame_output_begin);
|
440
|
1387 CONSOLE_INHERITS_METHOD (msprinter, mswindows, bevel_area);
|
|
1388 CONSOLE_INHERITS_METHOD (msprinter, mswindows, output_string);
|
|
1389 CONSOLE_INHERITS_METHOD (msprinter, mswindows, output_pixmap);
|
428
|
1390 }
|