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