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