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