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