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