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