Mercurial > hg > xemacs-beta
comparison src/redisplay-msw.c @ 267:966663fcf606 r20-5b32
Import from CVS: tag r20-5b32
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:26:29 +0200 |
parents | 8efd647ea9ca |
children | b2472a1930f2 |
comparison
equal
deleted
inserted
replaced
266:18d185df8c54 | 267:966663fcf606 |
---|---|
38 #include "buffer.h" | 38 #include "buffer.h" |
39 #include "debug.h" | 39 #include "debug.h" |
40 #include "events.h" | 40 #include "events.h" |
41 #include "faces.h" | 41 #include "faces.h" |
42 #include "frame.h" | 42 #include "frame.h" |
43 #include "glyphs.h" /* XXX FIXME: Should be glyphs-mswindows when we make one */ | 43 #include "glyphs-msw.h" |
44 #include "redisplay.h" | 44 #include "redisplay.h" |
45 #include "sysdep.h" | 45 #include "sysdep.h" |
46 #include "window.h" | 46 #include "window.h" |
47 | 47 |
48 #include "windows.h" | 48 #include "windows.h" |
69 static void mswindows_clear_region (Lisp_Object locale, face_index findex, | 69 static void mswindows_clear_region (Lisp_Object locale, face_index findex, |
70 int x, int y, int width, int height); | 70 int x, int y, int width, int height); |
71 static void mswindows_output_vertical_divider (struct window *w, int clear); | 71 static void mswindows_output_vertical_divider (struct window *w, int clear); |
72 static void mswindows_redraw_exposed_windows (Lisp_Object window, int x, | 72 static void mswindows_redraw_exposed_windows (Lisp_Object window, int x, |
73 int y, int width, int height); | 73 int y, int width, int height); |
74 | |
75 | |
76 | 74 |
77 typedef struct textual_run | 75 typedef struct textual_run |
78 { | 76 { |
79 Lisp_Object charset; | 77 Lisp_Object charset; |
80 unsigned char *ptr; | 78 unsigned char *ptr; |
226 #if 0 | 224 #if 0 |
227 fprintf (stderr, "Help! mswindows_update_dc got a bogus fg value! fg = "); | 225 fprintf (stderr, "Help! mswindows_update_dc got a bogus fg value! fg = "); |
228 debug_print (fg); | 226 debug_print (fg); |
229 #endif | 227 #endif |
230 fg = Qnil; | 228 fg = Qnil; |
231 } | 229 } |
232 | 230 |
233 if (!NILP (bg) && !COLOR_INSTANCEP (bg)) | 231 if (!NILP (bg) && !COLOR_INSTANCEP (bg)) |
234 { | 232 { |
235 /* this break under mule */ | 233 /* this break under mule */ |
236 #if 0 | 234 #if 0 |
237 fprintf (stderr, "Help! mswindows_update_dc got a bogus fg value! bg = "); | 235 fprintf (stderr, "Help! mswindows_update_dc got a bogus fg value! bg = "); |
238 debug_print (bg); | 236 debug_print (bg); |
239 #endif | 237 #endif |
240 bg = Qnil; | 238 bg = Qnil; |
241 } | 239 } |
242 #endif | 240 #endif |
243 | 241 |
244 if (!NILP (fg)) | 242 if (!NILP (fg)) |
245 SetTextColor (hdc, COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (fg))); | 243 SetTextColor (hdc, COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (fg))); |
246 | 244 |
488 | 486 |
489 xpos += this_width; | 487 xpos += this_width; |
490 } | 488 } |
491 } | 489 } |
492 | 490 |
491 void | |
492 mswindows_output_dibitmap (struct frame *f, struct Lisp_Image_Instance *p, | |
493 int x, int y, | |
494 int clip_x, int clip_y, | |
495 int clip_width, int clip_height, | |
496 int width, int height, int pixmap_offset) | |
497 { | |
498 HDC hdc = FRAME_MSWINDOWS_DC (f); | |
499 HGDIOBJ old; | |
500 int need_clipping = (clip_x || clip_y); | |
501 | |
502 if (need_clipping) | |
503 { | |
504 #if 0 | |
505 XRectangle clip_box[1]; | |
506 | |
507 clip_box[0].x = clip_x; | |
508 clip_box[0].y = clip_y; | |
509 clip_box[0].width = clip_width; | |
510 clip_box[0].height = clip_height; | |
511 | |
512 XSetClipRectangles (dpy, gc, x, y, clip_box, 1, Unsorted); | |
513 #endif | |
514 } | |
515 | |
516 /* Select the bitmaps into the compatible DC. */ | |
517 if ((old=SelectObject(IMAGE_INSTANCE_MSWINDOWS_DC(p), | |
518 IMAGE_INSTANCE_MSWINDOWS_BITMAP(p)))) | |
519 { | |
520 BitBlt(hdc, | |
521 x,y, | |
522 width, height, | |
523 IMAGE_INSTANCE_MSWINDOWS_DC(p), | |
524 0,0, | |
525 SRCCOPY); | |
526 SelectObject(IMAGE_INSTANCE_MSWINDOWS_DC(p),old); | |
527 } | |
528 else | |
529 { | |
530 /* error */ | |
531 } | |
532 | |
533 #if 0 | |
534 if (need_clipping) | |
535 { | |
536 XSetClipMask (dpy, gc, None); | |
537 XSetClipOrigin (dpy, gc, 0, 0); | |
538 } | |
539 #endif | |
540 } | |
541 | |
542 static void | |
543 mswindows_output_pixmap (struct window *w, struct display_line *dl, | |
544 Lisp_Object image_instance, int xpos, int xoffset, | |
545 int start_pixpos, int width, face_index findex, | |
546 int cursor_start, int cursor_width, int cursor_height) | |
547 { | |
548 struct frame *f = XFRAME (w->frame); | |
549 struct device *d = XDEVICE (f->device); | |
550 HDC hdc = FRAME_MSWINDOWS_DC (f); | |
551 struct Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance); | |
552 Lisp_Object window; | |
553 | |
554 int lheight = dl->ascent + dl->descent - dl->clip; | |
555 int pheight = ((int) IMAGE_INSTANCE_PIXMAP_HEIGHT (p) > lheight ? lheight : | |
556 IMAGE_INSTANCE_PIXMAP_HEIGHT (p)); | |
557 int pwidth = min (width + xoffset, (int) IMAGE_INSTANCE_PIXMAP_WIDTH (p)); | |
558 int clip_x, clip_y, clip_width, clip_height; | |
559 | |
560 /* The pixmap_offset is used to center the pixmap on lines which are | |
561 shorter than it is. This results in odd effects when scrolling | |
562 pixmaps off of the bottom. Let's try not using it. */ | |
563 #if 0 | |
564 int pixmap_offset = (int) (IMAGE_INSTANCE_PIXMAP_HEIGHT (p) - lheight) / 2; | |
565 #else | |
566 int pixmap_offset = 0; | |
567 #endif | |
568 | |
569 XSETWINDOW (window, w); | |
570 | |
571 if ((start_pixpos >= 0 && start_pixpos > xpos) || xoffset) | |
572 { | |
573 if (start_pixpos > xpos && start_pixpos > xpos + width) | |
574 return; | |
575 | |
576 clip_x = xoffset; | |
577 clip_width = width; | |
578 if (start_pixpos > xpos) | |
579 { | |
580 clip_x += (start_pixpos - xpos); | |
581 clip_width -= (start_pixpos - xpos); | |
582 } | |
583 } | |
584 else | |
585 { | |
586 clip_x = 0; | |
587 clip_width = 0; | |
588 } | |
589 | |
590 /* Place markers for possible future functionality (clipping the top | |
591 half instead of the bottom half; think pixel scrolling). */ | |
592 clip_y = 0; | |
593 clip_height = pheight; | |
594 | |
595 /* Clear the area the pixmap is going into. The pixmap itself will | |
596 always take care of the full width. We don't want to clear where | |
597 it is going to go in order to avoid flicker. So, all we have to | |
598 take care of is any area above or below the pixmap. */ | |
599 /* #### We take a shortcut for now. We know that since we have | |
600 pixmap_offset hardwired to 0 that the pixmap is against the top | |
601 edge so all we have to worry about is below it. */ | |
602 /* #### Unless the pixmap has a mask in which case we have to clear | |
603 the whole damn thing since we can't yet clear just the area not | |
604 included in the mask. */ | |
605 if (((int) (dl->ypos - dl->ascent + pheight) < | |
606 (int) (dl->ypos + dl->descent - dl->clip)) | |
607 || IMAGE_INSTANCE_MSWINDOWS_MASK (p)) | |
608 { | |
609 int clear_x, clear_y, clear_width, clear_height; | |
610 | |
611 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p)) | |
612 { | |
613 clear_y = dl->ypos - dl->ascent; | |
614 clear_height = lheight; | |
615 } | |
616 else | |
617 { | |
618 clear_y = dl->ypos - dl->ascent + pheight; | |
619 clear_height = lheight - pheight; | |
620 } | |
621 | |
622 if (start_pixpos >= 0 && start_pixpos > xpos) | |
623 { | |
624 clear_x = start_pixpos; | |
625 clear_width = xpos + width - start_pixpos; | |
626 } | |
627 else | |
628 { | |
629 clear_x = xpos; | |
630 clear_width = width; | |
631 } | |
632 | |
633 mswindows_clear_region (window, findex, clear_x, clear_y, | |
634 clear_width, clear_height); | |
635 } | |
636 | |
637 /* Output the pixmap. */ | |
638 { | |
639 Lisp_Object tmp_pixel; | |
640 COLORREF tmp_bcolor, tmp_fcolor; | |
641 | |
642 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex); | |
643 tmp_fcolor = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (tmp_pixel)); | |
644 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex); | |
645 tmp_bcolor = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (tmp_pixel)); | |
646 #if 0 | |
647 mswindows_update_dc (hdc, Qnil, tmp_fcolor, | |
648 tmp_bcolor, Qnil); | |
649 #endif | |
650 mswindows_output_dibitmap (f, p, xpos - xoffset, dl->ypos - dl->ascent, | |
651 clip_x, clip_y, clip_width, clip_height, | |
652 pwidth, pheight, pixmap_offset); | |
653 } | |
654 | |
655 /* Draw a cursor over top of the pixmap. */ | |
656 if (cursor_width && cursor_height && (cursor_start >= xpos) | |
657 && !NILP (w->text_cursor_visible_p) | |
658 && (cursor_start < xpos + pwidth)) | |
659 { | |
660 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d)); | |
661 int y = dl->ypos - dl->ascent; | |
662 struct face_cachel *cursor_cachel = | |
663 WINDOW_FACE_CACHEL (w, | |
664 get_builtin_face_cache_index | |
665 (w, Vtext_cursor_face)); | |
666 | |
667 mswindows_update_dc(hdc, Qnil, cursor_cachel->background, Qnil, | |
668 Qnil); | |
669 | |
670 if (cursor_width > xpos + pwidth - cursor_start) | |
671 cursor_width = xpos + pwidth - cursor_start; | |
672 | |
673 if (focus) | |
674 { | |
675 RECT rect={cursor_start, y + cursor_height, | |
676 cursor_start + cursor_width, y}; | |
677 FrameRect(hdc, &rect, | |
678 COLOR_INSTANCE_MSWINDOWS_BRUSH | |
679 (XCOLOR_INSTANCE(cursor_cachel->background))); | |
680 } | |
681 else | |
682 { | |
683 Rectangle (hdc, cursor_start, y, cursor_width, | |
684 cursor_height); | |
685 } | |
686 } | |
687 } | |
493 | 688 |
494 #ifdef HAVE_SCROLLBARS | 689 #ifdef HAVE_SCROLLBARS |
495 /* | 690 /* |
496 * This function paints window's deadbox, a rectangle between window | 691 * This function paints window's deadbox, a rectangle between window |
497 * borders and two short edges of both scrollbars. | 692 * borders and two short edges of both scrollbars. |
939 } | 1134 } |
940 break; | 1135 break; |
941 | 1136 |
942 case IMAGE_MONO_PIXMAP: | 1137 case IMAGE_MONO_PIXMAP: |
943 case IMAGE_COLOR_PIXMAP: | 1138 case IMAGE_COLOR_PIXMAP: |
944 #if 0 | |
945 mswindows_output_pixmap (w, dl, instance, xpos, | 1139 mswindows_output_pixmap (w, dl, instance, xpos, |
946 rb->object.dglyph.xoffset, start_pixpos, | 1140 rb->object.dglyph.xoffset, start_pixpos, |
947 rb->width, findex, cursor_start, | 1141 rb->width, findex, cursor_start, |
948 cursor_width, cursor_height); | 1142 cursor_width, cursor_height); |
949 #endif | |
950 break; | 1143 break; |
951 | 1144 |
952 case IMAGE_POINTER: | 1145 case IMAGE_POINTER: |
953 abort (); | 1146 abort (); |
954 | 1147 |
1212 static void | 1405 static void |
1213 mswindows_clear_frame (struct frame *f) | 1406 mswindows_clear_frame (struct frame *f) |
1214 { | 1407 { |
1215 GdiFlush(); | 1408 GdiFlush(); |
1216 } | 1409 } |
1217 | |
1218 | 1410 |
1219 | 1411 |
1220 | 1412 |
1221 /************************************************************************/ | 1413 /************************************************************************/ |
1222 /* initialization */ | 1414 /* initialization */ |