/[emacs]/emacs/src/w32term.c
ViewVC logotype

Diff of /emacs/src/w32term.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.128 by jasonr, Wed Nov 28 20:36:12 2001 UTC revision 1.129 by kfstorm, Sat Dec 1 01:25:42 2001 UTC
# Line 84  enum fringe_bitmap_type Line 84  enum fringe_bitmap_type
84     `indicate-empty-lines' is non-nil.  */     `indicate-empty-lines' is non-nil.  */
85    
86  #define zv_width 8  #define zv_width 8
87  #define zv_height 8  #define zv_height 72
88  static unsigned short zv_bits[] = {  #define zv_period 3
89     0x00, 0x00, 0x78, 0x78, 0x78, 0x78, 0x00, 0x00};  static unsigned char zv_bits[] = {
90      0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
91      0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
92      0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
93      0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
94      0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
95      0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
96      0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
97      0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00};
98  static HBITMAP zv_bmp;  static HBITMAP zv_bmp;
99    
100  /* An arrow like this: `<-'.  */  /* An arrow like this: `<-'.  */
# Line 400  static void x_erase_phys_cursor P_ ((str Line 408  static void x_erase_phys_cursor P_ ((str
408  void x_display_cursor P_ ((struct window *w, int, int, int, int, int));  void x_display_cursor P_ ((struct window *w, int, int, int, int, int));
409  void x_display_and_set_cursor P_ ((struct window *, int, int, int, int, int));  void x_display_and_set_cursor P_ ((struct window *, int, int, int, int, int));
410  static void w32_draw_fringe_bitmap P_ ((struct window *, HDC hdc, struct glyph_row *,  static void w32_draw_fringe_bitmap P_ ((struct window *, HDC hdc, struct glyph_row *,
411                                          enum fringe_bitmap_type));                                          enum fringe_bitmap_type, int left_p));
412  static void w32_clip_to_row P_ ((struct window *, struct glyph_row *,  static void w32_clip_to_row P_ ((struct window *, struct glyph_row *,
413                                   HDC, int));                                   HDC, int));
414  static int x_phys_cursor_in_rect_p P_ ((struct window *, RECT *));  static int x_phys_cursor_in_rect_p P_ ((struct window *, RECT *));
# Line 810  x_after_update_window_line (desired_row) Line 818  x_after_update_window_line (desired_row)
818     drawn.  */     drawn.  */
819    
820  static void  static void
821  w32_draw_fringe_bitmap (w, hdc, row, which)  w32_draw_fringe_bitmap (w, hdc, row, which, left_p)
822       struct window *w;       struct window *w;
823       HDC hdc;       HDC hdc;
824       struct glyph_row *row;       struct glyph_row *row;
825       enum fringe_bitmap_type which;       enum fringe_bitmap_type which;
826         int left_p;
827  {  {
828    struct frame *f = XFRAME (WINDOW_FRAME (w));    struct frame *f = XFRAME (WINDOW_FRAME (w));
829    Window window = FRAME_W32_WINDOW (f);    Window window = FRAME_W32_WINDOW (f);
830    HDC compat_hdc;    HDC compat_hdc;
831    int x, y, wd, h, dy;    int x, y, wd, h, dy;
832      int b1, b2;
833    HBITMAP pixmap;    HBITMAP pixmap;
834    HANDLE horig_obj;    HANDLE horig_obj;
835    struct face *face;    struct face *face;
# Line 827  w32_draw_fringe_bitmap (w, hdc, row, whi Line 837  w32_draw_fringe_bitmap (w, hdc, row, whi
837    /* Must clip because of partially visible lines.  */    /* Must clip because of partially visible lines.  */
838    w32_clip_to_row (w, row, hdc, 1);    w32_clip_to_row (w, row, hdc, 1);
839    
840      /* Convert row to frame coordinates.  */
841      y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
842    
843    switch (which)    switch (which)
844      {      {
845        case NO_FRINGE_BITMAP:
846          wd = 0;
847          h = 0;
848          break;
849    
850      case LEFT_TRUNCATION_BITMAP:      case LEFT_TRUNCATION_BITMAP:
851        wd = left_width;        wd = left_width;
852        h = left_height;        h = left_height;
853        pixmap = left_bmp;        pixmap = left_bmp;
       x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)  
            - wd  
            - (FRAME_X_LEFT_FRINGE_WIDTH (f) - wd) / 2);  
854        break;        break;
855                
856      case OVERLAY_ARROW_BITMAP:      case OVERLAY_ARROW_BITMAP:
857        wd = ov_width;        wd = ov_width;
858        h = ov_height;        h = ov_height;
859        pixmap = ov_bmp;        pixmap = ov_bmp;
       x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)  
            - wd  
            - (FRAME_X_LEFT_FRINGE_WIDTH (f) - wd) / 2);  
860        break;        break;
861                
862      case RIGHT_TRUNCATION_BITMAP:      case RIGHT_TRUNCATION_BITMAP:
863        wd = right_width;        wd = right_width;
864        h = right_height;        h = right_height;
865        pixmap = right_bmp;        pixmap = right_bmp;
       x = window_box_right (w, -1);  
       x += (FRAME_X_RIGHT_FRINGE_WIDTH (f) - wd) / 2;  
866        break;        break;
867    
868      case CONTINUED_LINE_BITMAP:      case CONTINUED_LINE_BITMAP:
869        wd = continued_width;        wd = continued_width;
870        h = continued_height;        h = continued_height;
871        pixmap = continued_bmp;        pixmap = continued_bmp;
       x = window_box_right (w, -1);  
       x += (FRAME_X_RIGHT_FRINGE_WIDTH (f) - wd) / 2;  
872        break;        break;
873                
874      case CONTINUATION_LINE_BITMAP:      case CONTINUATION_LINE_BITMAP:
875        wd = continuation_width;        wd = continuation_width;
876        h = continuation_height;        h = continuation_height;
877        pixmap = continuation_bmp;        pixmap = continuation_bmp;
       x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)  
            - wd  
            - (FRAME_X_LEFT_FRINGE_WIDTH (f) - wd) / 2);  
878        break;        break;
879    
880      case ZV_LINE_BITMAP:      case ZV_LINE_BITMAP:
881        wd = zv_width;        wd = zv_width;
882        h = zv_height;        h = zv_height - (y % zv_period);
883        pixmap = zv_bmp;        pixmap = zv_bmp;
       x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)  
            - wd  
            - (FRAME_X_LEFT_FRINGE_WIDTH (f) - wd) / 2);  
884        break;        break;
885    
886      default:      default:
887        abort ();        abort ();
888      }      }
889    
890    /* Convert to frame coordinates.  Set dy to the offset in the row to    /* Clip bitmap if too high.  */
891       start drawing the bitmap.  */    if (h > row->height)
892    y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);      h = row->height;
893    
894      /* Set dy to the offset in the row to start drawing the bitmap.  */
895    dy = (row->height - h) / 2;    dy = (row->height - h) / 2;
896    
897    /* Draw the bitmap.  */    /* Draw the bitmap.  */
898    face = FACE_FROM_ID (f, FRINGE_FACE_ID);    face = FACE_FROM_ID (f, FRINGE_FACE_ID);
899      PREPARE_FACE_FOR_DISPLAY (f, face);
900    
901      /* Clear left fringe if no bitmap to draw or if bitmap doesn't fill
902         the fringe.  */
903      b1 = -1;
904      if (left_p)
905        {
906          if (wd > FRAME_X_LEFT_FRINGE_WIDTH (f))
907            wd = FRAME_X_LEFT_FRINGE_WIDTH (f);
908          x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)
909               - wd
910               - (FRAME_X_LEFT_FRINGE_WIDTH (f) - wd) / 2);
911          if (wd < FRAME_X_LEFT_FRINGE_WIDTH (f) || row->height > h)
912            {
913              /* If W has a vertical border to its left, don't draw over it.  */
914              int border = ((XFASTINT (w->left) > 0
915                             && !FRAME_HAS_VERTICAL_SCROLL_BARS (f))
916                            ? 1 : 0);
917              b1 = (window_box_left (w, -1)
918                    - FRAME_X_LEFT_FRINGE_WIDTH (f)
919                    + border);
920              b2 = (FRAME_X_LEFT_FRINGE_WIDTH (f) - border);
921            }
922        }
923      else
924        {
925          if (wd > FRAME_X_RIGHT_FRINGE_WIDTH (f))
926            wd = FRAME_X_RIGHT_FRINGE_WIDTH (f);
927          x = (window_box_right (w, -1)
928               + (FRAME_X_RIGHT_FRINGE_WIDTH (f) - wd) / 2);
929          /* Clear right fringe if no bitmap to draw of if bitmap doesn't fill
930             the fringe.  */
931          if (wd < FRAME_X_RIGHT_FRINGE_WIDTH (f) || row->height > h)
932            {
933              b1 = window_box_right (w, -1);
934              b2 = FRAME_X_RIGHT_FRINGE_WIDTH (f);
935            }
936        }
937    
938      if (b1 >= 0)
939        {
940          int header_line_height = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
941          
942          w32_fill_area (f, hdc, face->background,
943                         b1,
944                         WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,
945                                                          row->y)),
946                         b2,
947                         row->visible_height);
948        }
949    
950      if (which == NO_FRINGE_BITMAP)
951        return;
952    
953    compat_hdc = CreateCompatibleDC (hdc);    compat_hdc = CreateCompatibleDC (hdc);
954    SaveDC (hdc);    SaveDC (hdc);
# Line 900  w32_draw_fringe_bitmap (w, hdc, row, whi Line 957  w32_draw_fringe_bitmap (w, hdc, row, whi
957    SetTextColor (hdc, face->background);    SetTextColor (hdc, face->background);
958    SetBkColor (hdc, face->foreground);    SetBkColor (hdc, face->foreground);
959    
960    BitBlt (hdc, x, y + dy, wd, h, compat_hdc, 0, 0, SRCCOPY);    BitBlt (hdc, x, y + dy, wd, h, compat_hdc, 0,
961              (which == ZV_LINE_BITMAP ? (row->y % zv_period) : 0),
962              SRCCOPY);
963    
964    SelectObject (compat_hdc, horig_obj);    SelectObject (compat_hdc, horig_obj);
965    DeleteDC (compat_hdc);    DeleteDC (compat_hdc);
# Line 918  x_draw_row_fringe_bitmaps (w, row) Line 977  x_draw_row_fringe_bitmaps (w, row)
977  {  {
978    struct frame *f = XFRAME (w->frame);    struct frame *f = XFRAME (w->frame);
979    enum fringe_bitmap_type bitmap;    enum fringe_bitmap_type bitmap;
   struct face *face;  
   int header_line_height = -1;  
980    HDC hdc;    HDC hdc;
981    
982    xassert (interrupt_input_blocked);    xassert (interrupt_input_blocked);
# Line 929  x_draw_row_fringe_bitmaps (w, row) Line 986  x_draw_row_fringe_bitmaps (w, row)
986    if (row->visible_height <= 0)    if (row->visible_height <= 0)
987      return;      return;
988    
   face = FACE_FROM_ID (f, FRINGE_FACE_ID);  
   PREPARE_FACE_FOR_DISPLAY (f, face);  
   
   /* Decide which bitmap to draw in the left fringe.  */  
   if (row->overlay_arrow_p)  
     bitmap = OVERLAY_ARROW_BITMAP;  
   else if (row->truncated_on_left_p)  
     bitmap = LEFT_TRUNCATION_BITMAP;  
   else if (MATRIX_ROW_CONTINUATION_LINE_P (row))  
     bitmap = CONTINUATION_LINE_BITMAP;  
   else if (row->indicate_empty_line_p)  
     bitmap = ZV_LINE_BITMAP;  
   else  
     bitmap = NO_FRINGE_BITMAP;  
   
989    hdc = get_frame_dc (f);    hdc = get_frame_dc (f);
990    
991    /* Clear left fringe if no bitmap to draw or if bitmap doesn't fill    if (FRAME_X_LEFT_FRINGE_WIDTH (f) != 0)
992       the fringe.  */      {
993    if (bitmap == NO_FRINGE_BITMAP        /* Decide which bitmap to draw in the left fringe.  */
994        || FRAME_FRINGE_BITMAP_WIDTH (f) < FRAME_X_LEFT_FRINGE_WIDTH (f)        if (row->overlay_arrow_p)
995        || row->height > FRAME_FRINGE_BITMAP_HEIGHT (f))          bitmap = OVERLAY_ARROW_BITMAP;
996      {        else if (row->truncated_on_left_p)
997        /* If W has a vertical border to its left, don't draw over it.  */          bitmap = LEFT_TRUNCATION_BITMAP;
998        int border = ((XFASTINT (w->left) > 0        else if (MATRIX_ROW_CONTINUATION_LINE_P (row))
999                       && !FRAME_HAS_VERTICAL_SCROLL_BARS (f))          bitmap = CONTINUATION_LINE_BITMAP;
1000                      ? 1 : 0);        else if (row->indicate_empty_line_p)
1001        int left = window_box_left (w, -1);          bitmap = ZV_LINE_BITMAP;
1002          else
1003            bitmap = NO_FRINGE_BITMAP;
1004    
1005        if (header_line_height < 0)        w32_draw_fringe_bitmap (w, hdc, row, bitmap, 1);
         header_line_height = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);  
         
       w32_fill_area (f, hdc, face->background,  
                      left - FRAME_X_LEFT_FRINGE_WIDTH (f) + border,  
                      WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,  
                                                       row->y)),  
                      FRAME_X_LEFT_FRINGE_WIDTH (f) - border,  
                      row->visible_height);  
1006      }      }
1007    
1008    /* Draw the left bitmap.  */    if (FRAME_X_RIGHT_FRINGE_WIDTH (f) != 0)
   if (bitmap != NO_FRINGE_BITMAP)  
     w32_draw_fringe_bitmap (w, hdc, row, bitmap);  
   
   /* Decide which bitmap to draw in the right fringe.  */  
   if (row->truncated_on_right_p)  
     bitmap = RIGHT_TRUNCATION_BITMAP;  
   else if (row->continued_p)  
     bitmap = CONTINUED_LINE_BITMAP;  
   else  
     bitmap = NO_FRINGE_BITMAP;  
   
   /* Clear right fringe if no bitmap to draw of if bitmap doesn't fill  
      the fringe.  */  
   if (bitmap == NO_FRINGE_BITMAP  
       || FRAME_FRINGE_BITMAP_WIDTH (f) < FRAME_X_RIGHT_FRINGE_WIDTH (f)  
       || row->height > FRAME_FRINGE_BITMAP_HEIGHT (f))  
1009      {      {
1010        int right = window_box_right (w, -1);        /* Decide which bitmap to draw in the right fringe.  */
1011          if (row->truncated_on_right_p)
1012        if (header_line_height < 0)          bitmap = RIGHT_TRUNCATION_BITMAP;
1013          header_line_height = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);        else if (row->continued_p)
1014            bitmap = CONTINUED_LINE_BITMAP;
1015          else if (row->indicate_empty_line_p && FRAME_X_LEFT_FRINGE_WIDTH (f) == 0)
1016            bitmap = ZV_LINE_BITMAP;
1017          else
1018            bitmap = NO_FRINGE_BITMAP;
1019    
1020        w32_fill_area (f, hdc, face->background,        w32_draw_fringe_bitmap (w, hdc, row, bitmap, 0);
                      right,  
                      WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,  
                                                       row->y)),  
                      FRAME_X_RIGHT_FRINGE_WIDTH (f),  
                      row->visible_height);  
1021      }      }
1022    
   /* Draw the right bitmap.  */  
   if (bitmap != NO_FRINGE_BITMAP)  
     w32_draw_fringe_bitmap (w, hdc, row, bitmap);  
   
1023    release_frame_dc (f, hdc);    release_frame_dc (f, hdc);
1024  }  }
1025    
# Line 4898  x_draw_glyphs (w, x, row, area, start, e Line 4914  x_draw_glyphs (w, x, row, area, start, e
4914        /* X is relative to the left edge of W, without scroll bars        /* X is relative to the left edge of W, without scroll bars
4915           or fringes.  */           or fringes.  */
4916        struct frame *f = XFRAME (WINDOW_FRAME (w));        struct frame *f = XFRAME (WINDOW_FRAME (w));
       /* int width = FRAME_FRINGE_WIDTH (f); */  
4917        int window_left_x = WINDOW_LEFT_MARGIN (w) * CANON_X_UNIT (f);        int window_left_x = WINDOW_LEFT_MARGIN (w) * CANON_X_UNIT (f);
4918    
4919        x += window_left_x;        x += window_left_x;
# Line 9887  x_new_fontset (f, fontsetname) Line 9902  x_new_fontset (f, fontsetname)
9902    return build_string (fontsetname);    return build_string (fontsetname);
9903  }  }
9904    
9905    /* Compute actual fringe widths */
9906    
9907    void
9908    x_compute_fringe_widths (f, redraw)
9909         struct frame *f;
9910         int redraw;
9911    {
9912      int o_left = f->output_data.w32->left_fringe_width;
9913      int o_right = f->output_data.w32->right_fringe_width;
9914      int o_cols = f->output_data.w32->fringe_cols;
9915    
9916      Lisp_Object left_fringe = Fassq (Qleft_fringe, f->param_alist);
9917      Lisp_Object right_fringe = Fassq (Qright_fringe, f->param_alist);
9918      int left_fringe_width, right_fringe_width;
9919    
9920      if (!NILP (left_fringe))
9921        left_fringe = Fcdr (left_fringe);
9922      if (!NILP (right_fringe))
9923        right_fringe = Fcdr (right_fringe);
9924    
9925      left_fringe_width = ((NILP (left_fringe) || !INTEGERP (left_fringe)) ? 8 :
9926                           XINT (left_fringe));
9927      right_fringe_width = ((NILP (right_fringe) || !INTEGERP (right_fringe)) ? 8 :
9928                            XINT (right_fringe));
9929    
9930      if (left_fringe_width || right_fringe_width)
9931        {
9932          int left_wid = left_fringe_width >= 0 ? left_fringe_width : -left_fringe_width;
9933          int right_wid = right_fringe_width >= 0 ? right_fringe_width : -right_fringe_width;
9934          int conf_wid = left_wid + right_wid;
9935          int font_wid = FONT_WIDTH (f->output_data.w32->font);
9936          int cols = (left_wid + right_wid + font_wid-1) / font_wid;
9937          int real_wid = cols * font_wid;
9938          if (left_wid && right_wid)
9939            {
9940              if (left_fringe_width < 0)
9941                {
9942                  /* Left fringe width is fixed, adjust right fringe if necessary */
9943                  f->output_data.w32->left_fringe_width = left_wid;
9944                  f->output_data.w32->right_fringe_width = real_wid - left_wid;
9945                }
9946              else if (right_fringe_width < 0)
9947                {
9948                  /* Right fringe width is fixed, adjust left fringe if necessary */
9949                  f->output_data.w32->left_fringe_width = real_wid - right_wid;
9950                  f->output_data.w32->right_fringe_width = right_wid;
9951                }
9952              else
9953                {
9954                  /* Adjust both fringes with an equal amount.
9955                     Note that we are doing integer arithmetic here, so don't
9956                     lose a pixel if the total width is an odd number.  */
9957                  int fill = real_wid - conf_wid;
9958                  f->output_data.w32->left_fringe_width = left_wid + fill/2;
9959                  f->output_data.w32->right_fringe_width = right_wid + fill - fill/2;
9960                }
9961            }
9962          else if (left_fringe_width)
9963            {
9964              f->output_data.w32->left_fringe_width = real_wid;
9965              f->output_data.w32->right_fringe_width = 0;
9966            }
9967          else
9968            {
9969              f->output_data.w32->left_fringe_width = 0;
9970              f->output_data.w32->right_fringe_width = real_wid;
9971            }
9972          f->output_data.w32->fringe_cols = cols;
9973          f->output_data.w32->fringes_extra = real_wid;
9974        }
9975      else
9976        {
9977          f->output_data.w32->left_fringe_width = 0;
9978          f->output_data.w32->right_fringe_width = 0;
9979          f->output_data.w32->fringe_cols = 0;
9980          f->output_data.w32->fringes_extra = 0;
9981        }
9982    
9983      if (redraw && FRAME_VISIBLE_P (f))
9984        if (o_left != f->output_data.w32->left_fringe_width ||
9985            o_right != f->output_data.w32->right_fringe_width ||
9986            o_cols != f->output_data.w32->fringe_cols)
9987          redraw_frame (f);
9988    }
9989    
9990  /***********************************************************************  /***********************************************************************
9991          TODO: W32 Input Methods          TODO: W32 Input Methods
# Line 10020  x_set_window_size (f, change_gravity, co Line 10119  x_set_window_size (f, change_gravity, co
10119      = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)      = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
10120         ? 0         ? 0
10121         : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (f->output_data.w32->font)));         : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (f->output_data.w32->font)));
10122    f->output_data.w32->fringes_extra  
10123      = FRAME_FRINGE_WIDTH (f);    x_compute_fringe_widths (f, 0);
10124    
10125    pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols);    pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols);
10126    pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows);    pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows);
10127        

Legend:
Removed from v.1.128  
changed lines
  Added in v.1.129

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26