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