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. */
|
269
|
527 if ((old=SelectObject(FRAME_MSWINDOWS_CDC(f),
|
267
|
528 IMAGE_INSTANCE_MSWINDOWS_BITMAP(p))))
|
|
529 {
|
|
530 BitBlt(hdc,
|
|
531 x,y,
|
|
532 width, height,
|
269
|
533 FRAME_MSWINDOWS_CDC(f),
|
267
|
534 0,0,
|
|
535 SRCCOPY);
|
269
|
536 SelectObject(FRAME_MSWINDOWS_CDC(f),old);
|
267
|
537 }
|
|
538 else
|
|
539 {
|
|
540 /* error */
|
|
541 }
|
|
542
|
|
543 #if 0
|
|
544 if (need_clipping)
|
|
545 {
|
|
546 XSetClipMask (dpy, gc, None);
|
|
547 XSetClipOrigin (dpy, gc, 0, 0);
|
|
548 }
|
|
549 #endif
|
|
550 }
|
|
551
|
|
552 static void
|
|
553 mswindows_output_pixmap (struct window *w, struct display_line *dl,
|
|
554 Lisp_Object image_instance, int xpos, int xoffset,
|
|
555 int start_pixpos, int width, face_index findex,
|
|
556 int cursor_start, int cursor_width, int cursor_height)
|
|
557 {
|
|
558 struct frame *f = XFRAME (w->frame);
|
276
|
559 #if 0
|
267
|
560 HDC hdc = FRAME_MSWINDOWS_DC (f);
|
276
|
561 #endif
|
267
|
562 struct Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
|
|
563 Lisp_Object window;
|
|
564
|
|
565 int lheight = dl->ascent + dl->descent - dl->clip;
|
|
566 int pheight = ((int) IMAGE_INSTANCE_PIXMAP_HEIGHT (p) > lheight ? lheight :
|
|
567 IMAGE_INSTANCE_PIXMAP_HEIGHT (p));
|
|
568 int pwidth = min (width + xoffset, (int) IMAGE_INSTANCE_PIXMAP_WIDTH (p));
|
|
569 int clip_x, clip_y, clip_width, clip_height;
|
|
570
|
|
571 /* The pixmap_offset is used to center the pixmap on lines which are
|
|
572 shorter than it is. This results in odd effects when scrolling
|
|
573 pixmaps off of the bottom. Let's try not using it. */
|
|
574 #if 0
|
|
575 int pixmap_offset = (int) (IMAGE_INSTANCE_PIXMAP_HEIGHT (p) - lheight) / 2;
|
|
576 #else
|
|
577 int pixmap_offset = 0;
|
|
578 #endif
|
|
579
|
|
580 XSETWINDOW (window, w);
|
|
581
|
|
582 if ((start_pixpos >= 0 && start_pixpos > xpos) || xoffset)
|
|
583 {
|
|
584 if (start_pixpos > xpos && start_pixpos > xpos + width)
|
|
585 return;
|
|
586
|
|
587 clip_x = xoffset;
|
|
588 clip_width = width;
|
|
589 if (start_pixpos > xpos)
|
|
590 {
|
|
591 clip_x += (start_pixpos - xpos);
|
|
592 clip_width -= (start_pixpos - xpos);
|
|
593 }
|
|
594 }
|
|
595 else
|
|
596 {
|
|
597 clip_x = 0;
|
|
598 clip_width = 0;
|
|
599 }
|
|
600
|
|
601 /* Place markers for possible future functionality (clipping the top
|
|
602 half instead of the bottom half; think pixel scrolling). */
|
|
603 clip_y = 0;
|
|
604 clip_height = pheight;
|
|
605
|
|
606 /* Clear the area the pixmap is going into. The pixmap itself will
|
|
607 always take care of the full width. We don't want to clear where
|
|
608 it is going to go in order to avoid flicker. So, all we have to
|
|
609 take care of is any area above or below the pixmap. */
|
|
610 /* #### We take a shortcut for now. We know that since we have
|
|
611 pixmap_offset hardwired to 0 that the pixmap is against the top
|
|
612 edge so all we have to worry about is below it. */
|
|
613 /* #### Unless the pixmap has a mask in which case we have to clear
|
|
614 the whole damn thing since we can't yet clear just the area not
|
|
615 included in the mask. */
|
|
616 if (((int) (dl->ypos - dl->ascent + pheight) <
|
|
617 (int) (dl->ypos + dl->descent - dl->clip))
|
|
618 || IMAGE_INSTANCE_MSWINDOWS_MASK (p))
|
|
619 {
|
|
620 int clear_x, clear_y, clear_width, clear_height;
|
|
621
|
|
622 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
|
|
623 {
|
|
624 clear_y = dl->ypos - dl->ascent;
|
|
625 clear_height = lheight;
|
|
626 }
|
|
627 else
|
|
628 {
|
|
629 clear_y = dl->ypos - dl->ascent + pheight;
|
|
630 clear_height = lheight - pheight;
|
|
631 }
|
|
632
|
|
633 if (start_pixpos >= 0 && start_pixpos > xpos)
|
|
634 {
|
|
635 clear_x = start_pixpos;
|
|
636 clear_width = xpos + width - start_pixpos;
|
|
637 }
|
|
638 else
|
|
639 {
|
|
640 clear_x = xpos;
|
|
641 clear_width = width;
|
|
642 }
|
|
643
|
|
644 mswindows_clear_region (window, findex, clear_x, clear_y,
|
|
645 clear_width, clear_height);
|
|
646 }
|
|
647
|
|
648 /* Output the pixmap. */
|
|
649 {
|
|
650 Lisp_Object tmp_pixel;
|
|
651 COLORREF tmp_bcolor, tmp_fcolor;
|
|
652
|
|
653 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
|
|
654 tmp_fcolor = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (tmp_pixel));
|
|
655 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
|
|
656 tmp_bcolor = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (tmp_pixel));
|
|
657 #if 0
|
|
658 mswindows_update_dc (hdc, Qnil, tmp_fcolor,
|
|
659 tmp_bcolor, Qnil);
|
|
660 #endif
|
|
661 mswindows_output_dibitmap (f, p, xpos - xoffset, dl->ypos - dl->ascent,
|
|
662 clip_x, clip_y, clip_width, clip_height,
|
|
663 pwidth, pheight, pixmap_offset);
|
|
664 }
|
|
665 }
|
227
|
666
|
|
667 #ifdef HAVE_SCROLLBARS
|
|
668 /*
|
|
669 * This function paints window's deadbox, a rectangle between window
|
|
670 * borders and two short edges of both scrollbars.
|
|
671 *
|
|
672 * Function checks whether deadbox intersects with the rectangle pointed
|
|
673 * to by PRC, and paints only the intersection
|
|
674 */
|
|
675 static void
|
251
|
676 mswindows_redisplay_deadbox_maybe (struct window *w, CONST RECT* prc)
|
227
|
677 {
|
|
678 int sbh = window_scrollbar_height (w);
|
|
679 int sbw = window_scrollbar_width (w);
|
|
680 RECT rect_dead, rect_paint;
|
|
681 struct frame *f;
|
|
682 if (sbh == 0 || sbw == 0)
|
|
683 return;
|
|
684
|
|
685 f = XFRAME (WINDOW_FRAME (w));
|
|
686 if (f->scrollbar_on_left)
|
|
687 {
|
|
688 rect_dead.left = WINDOW_LEFT (w);
|
|
689 rect_dead.right = WINDOW_LEFT (w) + sbw;
|
|
690 }
|
|
691 else
|
|
692 {
|
|
693 rect_dead.left = WINDOW_RIGHT (w) - sbw;
|
|
694 rect_dead.right = WINDOW_RIGHT (w);
|
|
695 }
|
|
696
|
|
697 if (f->scrollbar_on_top)
|
|
698 {
|
|
699 rect_dead.top = WINDOW_TOP (w);
|
|
700 rect_dead.bottom = WINDOW_TOP (w) + sbh;
|
|
701 }
|
|
702 else
|
|
703 {
|
|
704 int modh = window_modeline_height (w);
|
|
705 rect_dead.top = WINDOW_BOTTOM (w) - modh - sbh;
|
|
706 rect_dead.bottom = WINDOW_BOTTOM (w) - modh;
|
|
707 }
|
|
708
|
|
709 if (IntersectRect (&rect_paint, &rect_dead, prc))
|
|
710 FillRect (FRAME_MSWINDOWS_DC (f), &rect_paint,
|
249
|
711 (HBRUSH) (COLOR_BTNFACE+1));
|
227
|
712 }
|
|
713
|
|
714 #endif /* HAVE_SCROLLBARS */
|
|
715
|
213
|
716 /*****************************************************************************
|
|
717 mswindows_redraw_exposed_window
|
|
718
|
|
719 Given a bounding box for an area that needs to be redrawn, determine
|
|
720 what parts of what lines are contained within and re-output their
|
|
721 contents.
|
|
722 Copied from redisplay-x.c
|
|
723 ****************************************************************************/
|
|
724 static void
|
|
725 mswindows_redraw_exposed_window (struct window *w, int x, int y, int width,
|
|
726 int height)
|
|
727 {
|
|
728 struct frame *f = XFRAME (w->frame);
|
|
729 int line;
|
|
730 int orig_windows_structure_changed;
|
227
|
731 RECT rect_window = { WINDOW_LEFT (w), WINDOW_TOP (w),
|
|
732 WINDOW_RIGHT (w), WINDOW_BOTTOM (w) };
|
|
733 RECT rect_expose = { x, y, x + width, y + height };
|
|
734 RECT rect_draw;
|
213
|
735
|
|
736 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
737
|
|
738 if (!NILP (w->vchild))
|
|
739 {
|
|
740 mswindows_redraw_exposed_windows (w->vchild, x, y, width, height);
|
|
741 return;
|
|
742 }
|
|
743 else if (!NILP (w->hchild))
|
|
744 {
|
|
745 mswindows_redraw_exposed_windows (w->hchild, x, y, width, height);
|
|
746 return;
|
|
747 }
|
|
748
|
|
749 /* If the window doesn't intersect the exposed region, we're done here. */
|
227
|
750 if (!IntersectRect (&rect_draw, &rect_window, &rect_expose))
|
213
|
751 return;
|
|
752
|
227
|
753 /* We do this to make sure that the 3D modelines get redrawn if
|
|
754 they are in the exposed region. */
|
|
755 orig_windows_structure_changed = f->windows_structure_changed;
|
|
756 f->windows_structure_changed = 1;
|
213
|
757
|
|
758 if (window_needs_vertical_divider (w))
|
|
759 {
|
|
760 mswindows_output_vertical_divider (w, 0);
|
|
761 }
|
|
762
|
|
763 for (line = 0; line < Dynarr_length (cdla); line++)
|
|
764 {
|
|
765 struct display_line *cdl = Dynarr_atp (cdla, line);
|
|
766 int top_y = cdl->ypos - cdl->ascent;
|
|
767 int bottom_y = cdl->ypos + cdl->descent;
|
|
768
|
227
|
769 if (bottom_y >= rect_draw.top)
|
213
|
770 {
|
227
|
771 if (top_y > rect_draw.bottom)
|
213
|
772 {
|
|
773 if (line == 0)
|
|
774 continue;
|
|
775 else
|
|
776 break;
|
|
777 }
|
|
778 else
|
|
779 {
|
227
|
780 output_display_line (w, 0, cdla, line,
|
|
781 rect_draw.left, rect_draw.right);
|
213
|
782 }
|
|
783 }
|
|
784 }
|
|
785
|
|
786 f->windows_structure_changed = orig_windows_structure_changed;
|
|
787
|
|
788 /* If there have never been any face cache_elements created, then this
|
|
789 expose event doesn't actually have anything to do. */
|
|
790 if (Dynarr_largest (w->face_cachels))
|
227
|
791 redisplay_clear_bottom_of_window (w, cdla, rect_draw.top, rect_draw.bottom);
|
|
792
|
|
793 #ifdef HAVE_SCROLLBARS
|
|
794 mswindows_redisplay_deadbox_maybe (w, &rect_expose);
|
|
795 #endif
|
213
|
796 }
|
|
797
|
|
798 /*****************************************************************************
|
|
799 mswindows_redraw_exposed_windows
|
|
800
|
|
801 For each window beneath the given window in the window hierarchy,
|
|
802 ensure that it is redrawn if necessary after an Expose event.
|
|
803 ****************************************************************************/
|
|
804 static void
|
|
805 mswindows_redraw_exposed_windows (Lisp_Object window, int x, int y, int width,
|
|
806 int height)
|
|
807 {
|
|
808 for (; !NILP (window); window = XWINDOW (window)->next)
|
|
809 mswindows_redraw_exposed_window (XWINDOW (window), x, y, width, height);
|
|
810 }
|
|
811
|
|
812 /*****************************************************************************
|
|
813 mswindows_redraw_exposed_area
|
|
814
|
|
815 For each window on the given frame, ensure that any area in the
|
|
816 Exposed area is redrawn.
|
|
817 ****************************************************************************/
|
|
818 void
|
|
819 mswindows_redraw_exposed_area (struct frame *f, int x, int y, int width, int height)
|
|
820 {
|
|
821 /* If any window on the frame has had its face cache reset then the
|
|
822 redisplay structures are effectively invalid. If we attempt to
|
|
823 use them we'll blow up. We mark the frame as changed to ensure
|
|
824 that redisplay will do a full update. This probably isn't
|
|
825 necessary but it can't hurt. */
|
278
|
826 #ifdef HAVE_TOOLBARS
|
|
827 /* #### We would rather put these off as well but there is currently
|
|
828 no combination of flags which will force an unchanged toolbar to
|
|
829 redraw anyhow. */
|
|
830 MAYBE_FRAMEMETH (f, redraw_exposed_toolbars, (f, x, y, width, height));
|
|
831 #endif
|
213
|
832
|
|
833 if (!f->window_face_cache_reset)
|
215
|
834 {
|
|
835 mswindows_redraw_exposed_windows (f->root_window, x, y, width, height);
|
|
836 GdiFlush();
|
|
837 }
|
213
|
838 else
|
|
839 MARK_FRAME_CHANGED (f);
|
|
840 }
|
|
841
|
|
842
|
|
843 /*****************************************************************************
|
|
844 mswindows_bevel_modeline
|
|
845
|
|
846 Draw a 3d border around the modeline on window W.
|
|
847 ****************************************************************************/
|
|
848 static void
|
|
849 mswindows_bevel_modeline (struct window *w, struct display_line *dl)
|
|
850 {
|
|
851 struct frame *f = XFRAME (w->frame);
|
|
852 Lisp_Object color;
|
|
853 int shadow_width = MODELINE_SHADOW_THICKNESS (w);
|
|
854 RECT rect = { WINDOW_MODELINE_LEFT (w),
|
|
855 dl->ypos - dl->ascent - shadow_width,
|
|
856 WINDOW_MODELINE_RIGHT (w),
|
|
857 dl->ypos + dl->descent + shadow_width};
|
239
|
858 UINT edge;
|
213
|
859
|
|
860 color = WINDOW_FACE_CACHEL_BACKGROUND (w, MODELINE_INDEX);
|
251
|
861 mswindows_update_dc (FRAME_MSWINDOWS_DC (f), Qnil, Qnil, color, Qnil);
|
213
|
862
|
239
|
863 if (XINT (w->modeline_shadow_thickness) < 0)
|
|
864 shadow_width = -shadow_width;
|
213
|
865
|
239
|
866 if (shadow_width < -1)
|
|
867 edge = EDGE_SUNKEN;
|
|
868 else if (shadow_width < 0)
|
|
869 edge = BDR_SUNKENINNER;
|
|
870 else if (shadow_width == 1)
|
|
871 edge = BDR_RAISEDINNER;
|
|
872 else
|
|
873 edge = EDGE_RAISED;
|
|
874
|
251
|
875 DrawEdge (FRAME_MSWINDOWS_DC (f), &rect, edge, BF_RECT);
|
213
|
876 }
|
|
877
|
|
878
|
|
879 /*****************************************************************************
|
|
880 #### Display methods
|
245
|
881 *****************************************************************************/
|
213
|
882
|
|
883 /*****************************************************************************
|
|
884 mswindows_divider_width
|
|
885
|
|
886 Return the width of the vertical divider.
|
|
887 ****************************************************************************/
|
|
888 static int
|
|
889 mswindows_divider_width (void)
|
|
890 {
|
|
891 return MSWINDOWS_DIVIDER_WIDTH;
|
|
892 }
|
|
893
|
|
894 /*****************************************************************************
|
|
895 mswindows_divider_height
|
|
896
|
|
897 Return the height of the horizontal divider.
|
|
898 ****************************************************************************/
|
|
899 static int
|
|
900 mswindows_divider_height (void)
|
|
901 {
|
|
902 return 1; /* XXX Copied from redisplay-X.c. What is this? */
|
|
903 }
|
|
904
|
|
905 /*****************************************************************************
|
|
906 mswindows_eol_cursor_width
|
|
907
|
|
908 Return the width of the end-of-line cursor.
|
|
909 ****************************************************************************/
|
|
910 static int
|
|
911 mswindows_eol_cursor_width (void)
|
|
912 {
|
|
913 return MSWINDOWS_EOL_CURSOR_WIDTH;
|
|
914 }
|
|
915
|
|
916 /*****************************************************************************
|
|
917 mswindows_output_begin
|
|
918
|
|
919 Perform any necessary initialization prior to an update.
|
|
920 ****************************************************************************/
|
|
921 static void
|
|
922 mswindows_output_begin (struct device *d)
|
|
923 {
|
|
924 }
|
|
925
|
|
926 /*****************************************************************************
|
|
927 mswindows_output_end
|
|
928
|
|
929 Perform any necessary flushing of queues when an update has completed.
|
|
930 ****************************************************************************/
|
|
931 static void
|
|
932 mswindows_output_end (struct device *d)
|
|
933 {
|
215
|
934 GdiFlush();
|
213
|
935 }
|
|
936
|
|
937 static int
|
|
938 mswindows_flash (struct device *d)
|
|
939 {
|
|
940 struct frame *f = device_selected_frame (d);
|
239
|
941 RECT rc;
|
213
|
942
|
239
|
943 GetClientRect (FRAME_MSWINDOWS_HANDLE (f), &rc);
|
|
944 InvertRect (FRAME_MSWINDOWS_DC (f), &rc);
|
|
945 GdiFlush ();
|
|
946 Sleep (25);
|
|
947 InvertRect (FRAME_MSWINDOWS_DC (f), &rc);
|
|
948
|
|
949 return 1;
|
213
|
950 }
|
|
951
|
|
952 static void
|
|
953 mswindows_ring_bell (struct device *d, int volume, int pitch, int duration)
|
|
954 {
|
223
|
955 /* Beep does not work at all, anyways! -kkm */
|
|
956 MessageBeep (MB_OK);
|
213
|
957 }
|
|
958
|
|
959 /*****************************************************************************
|
|
960 mswindows_output_display_block
|
|
961
|
|
962 Given a display line, a block number for that start line, output all
|
|
963 runes between start and end in the specified display block.
|
|
964 Ripped off with mininmal thought from the corresponding X routine.
|
|
965 ****************************************************************************/
|
|
966 static void
|
|
967 mswindows_output_display_block (struct window *w, struct display_line *dl, int block,
|
|
968 int start, int end, int start_pixpos, int cursor_start,
|
|
969 int cursor_width, int cursor_height)
|
|
970 {
|
|
971 struct frame *f = XFRAME (w->frame);
|
|
972 Emchar_dynarr *buf = Dynarr_new (Emchar);
|
|
973 Lisp_Object window;
|
|
974
|
|
975 struct display_block *db = Dynarr_atp (dl->display_blocks, block);
|
|
976 rune_dynarr *rba = db->runes;
|
|
977 struct rune *rb;
|
|
978
|
|
979 int elt = start;
|
|
980 face_index findex;
|
|
981 int xpos, width;
|
|
982 Lisp_Object charset = Qunbound; /* Qnil is a valid charset when
|
|
983 MULE is not defined */
|
|
984 XSETWINDOW (window, w);
|
|
985 rb = Dynarr_atp (rba, start);
|
|
986
|
|
987 if (!rb)
|
|
988 {
|
|
989 /* Nothing to do so don't do anything. */
|
|
990 return;
|
|
991 }
|
|
992 else
|
|
993 {
|
|
994 findex = rb->findex;
|
|
995 xpos = rb->xpos;
|
|
996 width = 0;
|
|
997 if (rb->type == RUNE_CHAR)
|
|
998 charset = CHAR_CHARSET (rb->object.chr.ch);
|
|
999 }
|
|
1000
|
|
1001 if (end < 0)
|
|
1002 end = Dynarr_length (rba);
|
|
1003 Dynarr_reset (buf);
|
|
1004
|
|
1005 while (elt < end)
|
|
1006 {
|
|
1007 rb = Dynarr_atp (rba, elt);
|
|
1008
|
|
1009 if (rb->findex == findex && rb->type == RUNE_CHAR
|
|
1010 && rb->object.chr.ch != '\n' && rb->cursor_type != CURSOR_ON
|
|
1011 && EQ (charset, CHAR_CHARSET (rb->object.chr.ch)))
|
|
1012 {
|
|
1013 Dynarr_add (buf, rb->object.chr.ch);
|
|
1014 width += rb->width;
|
|
1015 elt++;
|
|
1016 }
|
|
1017 else
|
|
1018 {
|
|
1019 if (Dynarr_length (buf))
|
|
1020 {
|
|
1021 mswindows_output_string (w, dl, buf, xpos, 0, start_pixpos, width,
|
|
1022 findex);
|
|
1023 xpos = rb->xpos;
|
|
1024 width = 0;
|
|
1025 }
|
|
1026 Dynarr_reset (buf);
|
|
1027 width = 0;
|
|
1028
|
|
1029 if (rb->type == RUNE_CHAR)
|
|
1030 {
|
|
1031 findex = rb->findex;
|
|
1032 xpos = rb->xpos;
|
|
1033 charset = CHAR_CHARSET (rb->object.chr.ch);
|
|
1034
|
|
1035 if (rb->cursor_type == CURSOR_ON)
|
|
1036 {
|
|
1037 if (rb->object.chr.ch == '\n')
|
|
1038 {
|
269
|
1039 mswindows_output_cursor (w, dl, xpos, cursor_width,
|
|
1040 findex, 0, 0);
|
213
|
1041 }
|
|
1042 else
|
|
1043 {
|
|
1044 Dynarr_add (buf, rb->object.chr.ch);
|
269
|
1045 mswindows_output_cursor (w, dl, xpos, cursor_width,
|
|
1046 findex, rb->object.chr.ch, 0);
|
213
|
1047 Dynarr_reset (buf);
|
|
1048 }
|
|
1049
|
|
1050 xpos += rb->width;
|
|
1051 elt++;
|
|
1052 }
|
|
1053 else if (rb->object.chr.ch == '\n')
|
|
1054 {
|
|
1055 /* Clear in case a cursor was formerly here. */
|
|
1056 int height = dl->ascent + dl->descent - dl->clip;
|
|
1057
|
|
1058 mswindows_clear_region (window, findex, xpos, dl->ypos - dl->ascent,
|
|
1059 rb->width, height);
|
|
1060 elt++;
|
|
1061 }
|
|
1062 }
|
|
1063 else if (rb->type == RUNE_BLANK || rb->type == RUNE_HLINE)
|
|
1064 {
|
|
1065 if (rb->type == RUNE_BLANK)
|
280
|
1066 mswindows_output_blank (w, dl, rb, start_pixpos);
|
213
|
1067 else
|
|
1068 {
|
|
1069 /* #### Our flagging of when we need to redraw the
|
|
1070 modeline shadows sucks. Since RUNE_HLINE is only used
|
|
1071 by the modeline at the moment it is a good bet
|
|
1072 that if it gets redrawn then we should also
|
|
1073 redraw the shadows. This won't be true forever.
|
|
1074 We borrow the shadow_thickness_changed flag for
|
|
1075 now. */
|
|
1076 w->shadow_thickness_changed = 1;
|
|
1077 mswindows_output_hline (w, dl, rb);
|
|
1078 }
|
|
1079
|
|
1080 if (rb->cursor_type == CURSOR_ON)
|
269
|
1081 mswindows_output_cursor (w, dl, xpos, cursor_width, rb->findex, 0, 0);
|
213
|
1082
|
|
1083 elt++;
|
|
1084 if (elt < end)
|
|
1085 {
|
|
1086 rb = Dynarr_atp (rba, elt);
|
|
1087
|
|
1088 findex = rb->findex;
|
|
1089 xpos = rb->xpos;
|
|
1090 }
|
|
1091 }
|
|
1092 else if (rb->type == RUNE_DGLYPH)
|
|
1093 {
|
|
1094 Lisp_Object instance;
|
|
1095
|
|
1096 XSETWINDOW (window, w);
|
|
1097 instance = glyph_image_instance (rb->object.dglyph.glyph,
|
|
1098 window, ERROR_ME_NOT, 1);
|
|
1099 findex = rb->findex;
|
|
1100
|
|
1101 if (IMAGE_INSTANCEP (instance))
|
|
1102 switch (XIMAGE_INSTANCE_TYPE (instance))
|
|
1103 {
|
|
1104 case IMAGE_TEXT:
|
|
1105 {
|
|
1106 /* #### This is way losing. See the comment in
|
|
1107 add_glyph_rune(). */
|
|
1108 Lisp_Object string =
|
|
1109 XIMAGE_INSTANCE_TEXT_STRING (instance);
|
|
1110 convert_bufbyte_string_into_emchar_dynarr
|
|
1111 (XSTRING_DATA (string), XSTRING_LENGTH (string), buf);
|
|
1112
|
|
1113 if (rb->cursor_type == CURSOR_ON)
|
269
|
1114 mswindows_output_cursor (w, dl, xpos, cursor_width,
|
|
1115 findex, Dynarr_at (buf, 0), 0);
|
251
|
1116 else /* #### redisplay-x passes -1 as the width: why ? */
|
213
|
1117 mswindows_output_string (w, dl, buf, xpos,
|
|
1118 rb->object.dglyph.xoffset,
|
251
|
1119 start_pixpos, rb->width, findex);
|
213
|
1120 Dynarr_reset (buf);
|
|
1121 }
|
|
1122 break;
|
|
1123
|
|
1124 case IMAGE_MONO_PIXMAP:
|
|
1125 case IMAGE_COLOR_PIXMAP:
|
|
1126 mswindows_output_pixmap (w, dl, instance, xpos,
|
|
1127 rb->object.dglyph.xoffset, start_pixpos,
|
|
1128 rb->width, findex, cursor_start,
|
|
1129 cursor_width, cursor_height);
|
269
|
1130 if (rb->cursor_type == CURSOR_ON)
|
|
1131 mswindows_output_cursor (w, dl, xpos, cursor_width,
|
|
1132 findex, 0, 1);
|
213
|
1133 break;
|
|
1134
|
|
1135 case IMAGE_POINTER:
|
|
1136 abort ();
|
|
1137
|
|
1138 case IMAGE_SUBWINDOW:
|
|
1139 /* #### implement me */
|
|
1140 break;
|
|
1141
|
|
1142 case IMAGE_NOTHING:
|
|
1143 /* nothing is as nothing does */
|
|
1144 break;
|
|
1145
|
|
1146 default:
|
|
1147 abort ();
|
|
1148 }
|
|
1149
|
|
1150 xpos += rb->width;
|
|
1151 elt++;
|
|
1152 }
|
|
1153 else
|
|
1154 abort ();
|
|
1155 }
|
|
1156 }
|
|
1157
|
|
1158 if (Dynarr_length (buf))
|
|
1159 mswindows_output_string (w, dl, buf, xpos, 0, start_pixpos, width, findex);
|
|
1160
|
|
1161 if (dl->modeline
|
|
1162 && !EQ (Qzero, w->modeline_shadow_thickness)
|
|
1163 && (f->clear
|
|
1164 || f->windows_structure_changed
|
|
1165 || w->shadow_thickness_changed))
|
|
1166 mswindows_bevel_modeline (w, dl);
|
|
1167
|
|
1168 Dynarr_free (buf);
|
|
1169 }
|
|
1170
|
|
1171
|
|
1172 /*****************************************************************************
|
|
1173 mswindows_output_vertical_divider
|
|
1174
|
|
1175 Draw a vertical divider down the left side of the given window.
|
|
1176 ****************************************************************************/
|
|
1177 static void
|
|
1178 mswindows_output_vertical_divider (struct window *w, int clear)
|
|
1179 {
|
|
1180 struct frame *f = XFRAME (w->frame);
|
|
1181 Lisp_Object color;
|
|
1182 RECT rect;
|
|
1183 int shadow_width = MODELINE_SHADOW_THICKNESS (w);
|
|
1184
|
|
1185 /* We don't use the normal gutter measurements here because the
|
|
1186 horizontal scrollbars and toolbars do not stretch completely over
|
|
1187 to the right edge of the window. Only the modeline does. */
|
|
1188 int modeline_height = window_modeline_height (w);
|
|
1189
|
|
1190 assert(!MSWINDOWS_DIVIDER_SPACING); /* This code doesn't handle this */
|
|
1191
|
|
1192 /* XXX Not sure about this */
|
|
1193 #ifdef HAVE_SCROLLBARS
|
|
1194 if (f->scrollbar_on_left)
|
|
1195 rect.left = WINDOW_LEFT (w);
|
|
1196 else
|
|
1197 rect.left = WINDOW_RIGHT (w) - MSWINDOWS_DIVIDER_WIDTH;
|
|
1198 #else
|
|
1199 rect.left = WINDOW_LEFT (w);
|
|
1200 #endif
|
|
1201 rect.right = rect.left + MSWINDOWS_DIVIDER_WIDTH;
|
|
1202
|
|
1203 #ifdef HAVE_SCROLLBARS
|
|
1204 if (f->scrollbar_on_top)
|
|
1205 rect.top = WINDOW_TOP (w);
|
|
1206 else
|
|
1207 #endif
|
|
1208 rect.top = WINDOW_TEXT_TOP (w);
|
|
1209 rect.bottom = WINDOW_BOTTOM (w) - modeline_height;
|
|
1210
|
|
1211 /* Draw the divider line */
|
|
1212 color = WINDOW_FACE_CACHEL_BACKGROUND (w, MODELINE_INDEX);
|
251
|
1213 mswindows_update_dc (FRAME_MSWINDOWS_DC(f), Qnil, Qnil, color, Qnil);
|
|
1214 ExtTextOut (FRAME_MSWINDOWS_DC (f), 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
|
213
|
1215 if (shadow_width)
|
251
|
1216 DrawEdge (FRAME_MSWINDOWS_DC (f), &rect,
|
213
|
1217 shadow_width==1 ? BDR_RAISEDINNER : EDGE_RAISED,
|
|
1218 BF_TOP|BF_RIGHT|BF_LEFT);
|
|
1219 }
|
|
1220
|
|
1221
|
|
1222 /****************************************************************************
|
|
1223 mswindows_text_width
|
|
1224
|
|
1225 Given a string and a face, return the string's length in pixels when
|
|
1226 displayed in the font associated with the face.
|
|
1227 ****************************************************************************/
|
|
1228 static int
|
251
|
1229 mswindows_text_width (struct frame *f, struct face_cachel *cachel,
|
|
1230 CONST Emchar *str, Charcount len)
|
213
|
1231 {
|
|
1232 int width_so_far = 0;
|
|
1233 unsigned char *text_storage = (unsigned char *) alloca (2 * len);
|
|
1234 textual_run *runs = alloca_array (textual_run, len);
|
|
1235 int nruns;
|
|
1236 int i;
|
|
1237
|
|
1238 nruns = separate_textual_runs (text_storage, runs, str, len);
|
|
1239
|
|
1240 for (i = 0; i < nruns; i++)
|
251
|
1241 width_so_far += mswindows_text_width_single_run (FRAME_MSWINDOWS_DC (f),
|
|
1242 cachel, runs + i);
|
213
|
1243
|
|
1244 return width_so_far;
|
|
1245 }
|
|
1246
|
|
1247
|
|
1248 /****************************************************************************
|
|
1249 mswindows_clear_region
|
|
1250
|
|
1251 Clear the area in the box defined by the given parameters using the
|
|
1252 given face.
|
|
1253 ****************************************************************************/
|
|
1254 static void
|
|
1255 mswindows_clear_region (Lisp_Object locale, face_index findex, int x, int y,
|
|
1256 int width, int height)
|
|
1257 {
|
|
1258 struct window *w;
|
|
1259 struct frame *f;
|
|
1260 Lisp_Object background_pixmap = Qunbound;
|
|
1261 Lisp_Object temp;
|
|
1262 RECT rect = { x, y, x+width, y+height };
|
|
1263 HBRUSH brush;
|
|
1264
|
|
1265 if (!(width && height)) /* We often seem to get called with width==0 */
|
|
1266 return;
|
|
1267
|
|
1268 if (WINDOWP (locale))
|
|
1269 {
|
|
1270 w = XWINDOW (locale);
|
|
1271 f = XFRAME (w->frame);
|
|
1272 }
|
|
1273 else if (FRAMEP (locale))
|
|
1274 {
|
|
1275 w = NULL;
|
|
1276 f = XFRAME (locale);
|
|
1277 }
|
|
1278 else
|
|
1279 abort ();
|
|
1280
|
|
1281 if (w)
|
|
1282 {
|
|
1283 temp = WINDOW_FACE_CACHEL_BACKGROUND_PIXMAP (w, findex);
|
|
1284
|
|
1285 if (IMAGE_INSTANCEP (temp)
|
|
1286 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (temp)))
|
|
1287 {
|
|
1288 /* #### maybe we could implement such that a string
|
|
1289 can be a background pixmap? */
|
|
1290 background_pixmap = temp;
|
|
1291 }
|
|
1292 }
|
|
1293 else
|
|
1294 {
|
|
1295 temp = FACE_BACKGROUND_PIXMAP (Vdefault_face, locale);
|
|
1296
|
|
1297 if (IMAGE_INSTANCEP (temp)
|
|
1298 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (temp)))
|
|
1299 {
|
|
1300 background_pixmap = temp;
|
|
1301 }
|
|
1302 }
|
|
1303
|
|
1304 if (!UNBOUNDP (background_pixmap))
|
|
1305 {
|
|
1306 if (XIMAGE_INSTANCE_PIXMAP_DEPTH (background_pixmap) == 0)
|
|
1307 {
|
|
1308 Lisp_Object fcolor, bcolor;
|
|
1309
|
|
1310 if (w)
|
|
1311 {
|
|
1312 fcolor = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
|
|
1313 bcolor = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
|
|
1314 }
|
|
1315 else
|
|
1316 {
|
|
1317 fcolor = FACE_FOREGROUND (Vdefault_face, locale);
|
|
1318 bcolor = FACE_BACKGROUND (Vdefault_face, locale);
|
|
1319 }
|
|
1320
|
251
|
1321 mswindows_update_dc (FRAME_MSWINDOWS_DC (f),
|
|
1322 Qnil, fcolor, bcolor, background_pixmap);
|
280
|
1323 FillRect (FRAME_MSWINDOWS_DC(f), &rect, brush);
|
|
1324 }
|
|
1325 else
|
|
1326 {
|
|
1327 assert(0);
|
|
1328 }
|
213
|
1329 }
|
|
1330 else
|
|
1331 {
|
|
1332 Lisp_Object color = (w ? WINDOW_FACE_CACHEL_BACKGROUND (w, findex) :
|
|
1333 FACE_BACKGROUND (Vdefault_face, locale));
|
251
|
1334 mswindows_update_dc (FRAME_MSWINDOWS_DC (f), Qnil, Qnil, color, Qnil);
|
|
1335 ExtTextOut (FRAME_MSWINDOWS_DC (f), 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
|
213
|
1336 }
|
|
1337
|
227
|
1338 #ifdef HAVE_SCROLLBARS
|
|
1339 if (WINDOWP (locale))
|
|
1340 mswindows_redisplay_deadbox_maybe (w, &rect);
|
|
1341 #endif
|
213
|
1342 }
|
|
1343
|
|
1344 /*****************************************************************************
|
|
1345 mswindows_clear_to_window_end
|
|
1346
|
|
1347 Clear the area between ypos1 and ypos2. Each margin area and the
|
|
1348 text area is handled separately since they may each have their own
|
|
1349 background color.
|
|
1350 ****************************************************************************/
|
|
1351 static void
|
|
1352 mswindows_clear_to_window_end (struct window *w, int ypos1, int ypos2)
|
|
1353 {
|
|
1354 int height = ypos2 - ypos1;
|
|
1355
|
|
1356 if (height)
|
|
1357 {
|
|
1358 struct frame *f = XFRAME (w->frame);
|
|
1359 Lisp_Object window;
|
|
1360 int bflag = (window_needs_vertical_divider (w) ? 0 : 1);
|
|
1361 layout_bounds bounds;
|
|
1362
|
|
1363 bounds = calculate_display_line_boundaries (w, bflag);
|
|
1364 XSETWINDOW (window, w);
|
|
1365
|
|
1366 if (window_is_leftmost (w))
|
|
1367 mswindows_clear_region (window, DEFAULT_INDEX, FRAME_LEFT_BORDER_START (f),
|
|
1368 ypos1, FRAME_BORDER_WIDTH (f), height);
|
|
1369
|
|
1370 if (bounds.left_in - bounds.left_out > 0)
|
|
1371 mswindows_clear_region (window,
|
|
1372 get_builtin_face_cache_index (w, Vleft_margin_face),
|
|
1373 bounds.left_out, ypos1,
|
|
1374 bounds.left_in - bounds.left_out, height);
|
|
1375
|
|
1376 if (bounds.right_in - bounds.left_in > 0)
|
|
1377 mswindows_clear_region (window, DEFAULT_INDEX, bounds.left_in, ypos1,
|
|
1378 bounds.right_in - bounds.left_in, height);
|
|
1379
|
|
1380 if (bounds.right_out - bounds.right_in > 0)
|
|
1381 mswindows_clear_region (window,
|
|
1382 get_builtin_face_cache_index (w, Vright_margin_face),
|
|
1383 bounds.right_in, ypos1,
|
|
1384 bounds.right_out - bounds.right_in, height);
|
|
1385
|
|
1386 if (window_is_rightmost (w))
|
|
1387 mswindows_clear_region (window, DEFAULT_INDEX, FRAME_RIGHT_BORDER_START (f),
|
|
1388 ypos1, FRAME_BORDER_WIDTH (f), height);
|
|
1389 }
|
|
1390
|
|
1391 }
|
|
1392
|
|
1393
|
215
|
1394 /* XXX Implement me! */
|
213
|
1395 static void
|
|
1396 mswindows_clear_frame (struct frame *f)
|
|
1397 {
|
215
|
1398 GdiFlush();
|
213
|
1399 }
|
|
1400
|
|
1401
|
|
1402
|
|
1403 /************************************************************************/
|
|
1404 /* initialization */
|
|
1405 /************************************************************************/
|
|
1406
|
|
1407 void
|
|
1408 console_type_create_redisplay_mswindows (void)
|
|
1409 {
|
|
1410 /* redisplay methods */
|
|
1411 CONSOLE_HAS_METHOD (mswindows, text_width);
|
|
1412 CONSOLE_HAS_METHOD (mswindows, output_display_block);
|
|
1413 CONSOLE_HAS_METHOD (mswindows, divider_width);
|
|
1414 CONSOLE_HAS_METHOD (mswindows, divider_height);
|
|
1415 CONSOLE_HAS_METHOD (mswindows, eol_cursor_width);
|
|
1416 CONSOLE_HAS_METHOD (mswindows, output_vertical_divider);
|
|
1417 CONSOLE_HAS_METHOD (mswindows, clear_to_window_end);
|
|
1418 CONSOLE_HAS_METHOD (mswindows, clear_region);
|
|
1419 CONSOLE_HAS_METHOD (mswindows, clear_frame);
|
|
1420 CONSOLE_HAS_METHOD (mswindows, output_begin);
|
|
1421 CONSOLE_HAS_METHOD (mswindows, output_end);
|
|
1422 CONSOLE_HAS_METHOD (mswindows, flash);
|
|
1423 CONSOLE_HAS_METHOD (mswindows, ring_bell);
|
|
1424 }
|