diff options
| author | Kim F. Storm | 2004-04-20 22:17:56 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2004-04-20 22:17:56 +0000 |
| commit | cb0b194af078526844a64859d247976d8f31f313 (patch) | |
| tree | 2da009c591f625a0660edd8f1359b4ed112954b7 /src | |
| parent | ffe8b3f4e8cf60dd97c3e5ec5f12183ad9006c02 (diff) | |
| download | emacs-cb0b194af078526844a64859d247976d8f31f313.tar.gz emacs-cb0b194af078526844a64859d247976d8f31f313.zip | |
(w32_draw_relief_rect): Add top_p and bot_p args.
(x_draw_glyph_string_box): Fix call to x_draw_relief_rect.
(x_draw_image_foreground, x_draw_image_relief)
(w32_draw_image_foreground_1, x_draw_image_glyph_string):
Draw sliced images.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32term.c | 153 |
1 files changed, 85 insertions, 68 deletions
diff --git a/src/w32term.c b/src/w32term.c index 5e81afc7724..6654b1a4087 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -1220,7 +1220,8 @@ static void w32_draw_image_foreground_1 P_ ((struct glyph_string *, HBITMAP)); | |||
| 1220 | static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int, | 1220 | static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int, |
| 1221 | int, int, int)); | 1221 | int, int, int)); |
| 1222 | static void w32_draw_relief_rect P_ ((struct frame *, int, int, int, int, | 1222 | static void w32_draw_relief_rect P_ ((struct frame *, int, int, int, int, |
| 1223 | int, int, int, int, RECT *)); | 1223 | int, int, int, int, int, int, |
| 1224 | RECT *)); | ||
| 1224 | static void w32_draw_box_rect P_ ((struct glyph_string *, int, int, int, int, | 1225 | static void w32_draw_box_rect P_ ((struct glyph_string *, int, int, int, int, |
| 1225 | int, int, int, RECT *)); | 1226 | int, int, int, RECT *)); |
| 1226 | 1227 | ||
| @@ -1801,9 +1802,10 @@ x_setup_relief_colors (s) | |||
| 1801 | 1802 | ||
| 1802 | static void | 1803 | static void |
| 1803 | w32_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width, | 1804 | w32_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width, |
| 1804 | raised_p, left_p, right_p, clip_rect) | 1805 | raised_p, top_p, bot_p, left_p, right_p, clip_rect) |
| 1805 | struct frame *f; | 1806 | struct frame *f; |
| 1806 | int left_x, top_y, right_x, bottom_y, width, left_p, right_p, raised_p; | 1807 | int left_x, top_y, right_x, bottom_y, width; |
| 1808 | int top_p, bot_p, left_p, right_p, raised_p; | ||
| 1807 | RECT *clip_rect; | 1809 | RECT *clip_rect; |
| 1808 | { | 1810 | { |
| 1809 | int i; | 1811 | int i; |
| @@ -1818,10 +1820,11 @@ w32_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width, | |||
| 1818 | w32_set_clip_rectangle (hdc, clip_rect); | 1820 | w32_set_clip_rectangle (hdc, clip_rect); |
| 1819 | 1821 | ||
| 1820 | /* Top. */ | 1822 | /* Top. */ |
| 1821 | for (i = 0; i < width; ++i) | 1823 | if (top_p) |
| 1822 | w32_fill_area (f, hdc, gc.foreground, | 1824 | for (i = 0; i < width; ++i) |
| 1823 | left_x + i * left_p, top_y + i, | 1825 | w32_fill_area (f, hdc, gc.foreground, |
| 1824 | right_x - left_x - i * (left_p + right_p ) + 1, 1); | 1826 | left_x + i * left_p, top_y + i, |
| 1827 | right_x - left_x - i * (left_p + right_p ) + 1, 1); | ||
| 1825 | 1828 | ||
| 1826 | /* Left. */ | 1829 | /* Left. */ |
| 1827 | if (left_p) | 1830 | if (left_p) |
| @@ -1836,10 +1839,11 @@ w32_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width, | |||
| 1836 | gc.foreground = f->output_data.w32->white_relief.gc->foreground; | 1839 | gc.foreground = f->output_data.w32->white_relief.gc->foreground; |
| 1837 | 1840 | ||
| 1838 | /* Bottom. */ | 1841 | /* Bottom. */ |
| 1839 | for (i = 0; i < width; ++i) | 1842 | if (bot_p) |
| 1840 | w32_fill_area (f, hdc, gc.foreground, | 1843 | for (i = 0; i < width; ++i) |
| 1841 | left_x + i * left_p, bottom_y - i, | 1844 | w32_fill_area (f, hdc, gc.foreground, |
| 1842 | right_x - left_x - i * (left_p + right_p) + 1, 1); | 1845 | left_x + i * left_p, bottom_y - i, |
| 1846 | right_x - left_x - i * (left_p + right_p) + 1, 1); | ||
| 1843 | 1847 | ||
| 1844 | /* Right. */ | 1848 | /* Right. */ |
| 1845 | if (right_p) | 1849 | if (right_p) |
| @@ -1949,7 +1953,7 @@ x_draw_glyph_string_box (s) | |||
| 1949 | { | 1953 | { |
| 1950 | x_setup_relief_colors (s); | 1954 | x_setup_relief_colors (s); |
| 1951 | w32_draw_relief_rect (s->f, left_x, top_y, right_x, bottom_y, | 1955 | w32_draw_relief_rect (s->f, left_x, top_y, right_x, bottom_y, |
| 1952 | width, raised_p, left_p, right_p, &clip_rect); | 1956 | width, raised_p, 1, 1, left_p, right_p, &clip_rect); |
| 1953 | } | 1957 | } |
| 1954 | } | 1958 | } |
| 1955 | 1959 | ||
| @@ -1960,21 +1964,22 @@ static void | |||
| 1960 | x_draw_image_foreground (s) | 1964 | x_draw_image_foreground (s) |
| 1961 | struct glyph_string *s; | 1965 | struct glyph_string *s; |
| 1962 | { | 1966 | { |
| 1963 | int x; | 1967 | int x = s->x; |
| 1964 | int y = s->ybase - image_ascent (s->img, s->face); | 1968 | int y = s->ybase - image_ascent (s->img, s->face, &s->slice); |
| 1965 | 1969 | ||
| 1966 | /* If first glyph of S has a left box line, start drawing it to the | 1970 | /* If first glyph of S has a left box line, start drawing it to the |
| 1967 | right of that line. */ | 1971 | right of that line. */ |
| 1968 | if (s->face->box != FACE_NO_BOX | 1972 | if (s->face->box != FACE_NO_BOX |
| 1969 | && s->first_glyph->left_box_line_p) | 1973 | && s->first_glyph->left_box_line_p |
| 1970 | x = s->x + abs (s->face->box_line_width); | 1974 | && s->slice.x == 0) |
| 1971 | else | 1975 | x += abs (s->face->box_line_width); |
| 1972 | x = s->x; | ||
| 1973 | 1976 | ||
| 1974 | /* If there is a margin around the image, adjust x- and y-position | 1977 | /* If there is a margin around the image, adjust x- and y-position |
| 1975 | by that margin. */ | 1978 | by that margin. */ |
| 1976 | x += s->img->hmargin; | 1979 | if (s->slice.x == 0) |
| 1977 | y += s->img->vmargin; | 1980 | x += s->img->hmargin; |
| 1981 | if (s->slice.y == 0) | ||
| 1982 | y += s->img->vmargin; | ||
| 1978 | 1983 | ||
| 1979 | SaveDC (s->hdc); | 1984 | SaveDC (s->hdc); |
| 1980 | 1985 | ||
| @@ -1996,12 +2001,12 @@ x_draw_image_foreground (s) | |||
| 1996 | SetTextColor (s->hdc, RGB (255, 255, 255)); | 2001 | SetTextColor (s->hdc, RGB (255, 255, 255)); |
| 1997 | SetBkColor (s->hdc, RGB (0, 0, 0)); | 2002 | SetBkColor (s->hdc, RGB (0, 0, 0)); |
| 1998 | 2003 | ||
| 1999 | BitBlt (s->hdc, x, y, s->img->width, s->img->height, | 2004 | BitBlt (s->hdc, x, y, s->slice.width, s->slice.height, |
| 2000 | compat_hdc, 0, 0, SRCINVERT); | 2005 | compat_hdc, s->slice.x, s->slice.y, SRCINVERT); |
| 2001 | BitBlt (s->hdc, x, y, s->img->width, s->img->height, | 2006 | BitBlt (s->hdc, x, y, s->slice.width, s->slice.height, |
| 2002 | mask_dc, 0, 0, SRCAND); | 2007 | mask_dc, s->slice.x, s->slice.y, SRCAND); |
| 2003 | BitBlt (s->hdc, x, y, s->img->width, s->img->height, | 2008 | BitBlt (s->hdc, x, y, s->slice.width, s->slice.height, |
| 2004 | compat_hdc, 0, 0, SRCINVERT); | 2009 | compat_hdc, s->slice.x, s->slice.y, SRCINVERT); |
| 2005 | 2010 | ||
| 2006 | SelectObject (mask_dc, mask_orig_obj); | 2011 | SelectObject (mask_dc, mask_orig_obj); |
| 2007 | DeleteDC (mask_dc); | 2012 | DeleteDC (mask_dc); |
| @@ -2011,8 +2016,8 @@ x_draw_image_foreground (s) | |||
| 2011 | SetTextColor (s->hdc, s->gc->foreground); | 2016 | SetTextColor (s->hdc, s->gc->foreground); |
| 2012 | SetBkColor (s->hdc, s->gc->background); | 2017 | SetBkColor (s->hdc, s->gc->background); |
| 2013 | 2018 | ||
| 2014 | BitBlt (s->hdc, x, y, s->img->width, s->img->height, | 2019 | BitBlt (s->hdc, x, y, s->slice.width, s->slice.height, |
| 2015 | compat_hdc, 0, 0, SRCCOPY); | 2020 | compat_hdc, s->slice.x, s->slice.y, SRCCOPY); |
| 2016 | 2021 | ||
| 2017 | /* When the image has a mask, we can expect that at | 2022 | /* When the image has a mask, we can expect that at |
| 2018 | least part of a mouse highlight or a block cursor will | 2023 | least part of a mouse highlight or a block cursor will |
| @@ -2025,7 +2030,8 @@ x_draw_image_foreground (s) | |||
| 2025 | int r = s->img->relief; | 2030 | int r = s->img->relief; |
| 2026 | if (r < 0) r = -r; | 2031 | if (r < 0) r = -r; |
| 2027 | w32_draw_rectangle (s->hdc, s->gc, x - r, y - r , | 2032 | w32_draw_rectangle (s->hdc, s->gc, x - r, y - r , |
| 2028 | s->img->width + r*2 - 1, s->img->height + r*2 - 1); | 2033 | s->slice.width + r*2 - 1, |
| 2034 | s->slice.height + r*2 - 1); | ||
| 2029 | } | 2035 | } |
| 2030 | } | 2036 | } |
| 2031 | 2037 | ||
| @@ -2036,8 +2042,8 @@ x_draw_image_foreground (s) | |||
| 2036 | DeleteDC (compat_hdc); | 2042 | DeleteDC (compat_hdc); |
| 2037 | } | 2043 | } |
| 2038 | else | 2044 | else |
| 2039 | w32_draw_rectangle (s->hdc, s->gc, x, y, s->img->width -1, | 2045 | w32_draw_rectangle (s->hdc, s->gc, x, y, |
| 2040 | s->img->height - 1); | 2046 | s->slice.width - 1, s->slice.height - 1); |
| 2041 | 2047 | ||
| 2042 | RestoreDC (s->hdc ,-1); | 2048 | RestoreDC (s->hdc ,-1); |
| 2043 | } | 2049 | } |
| @@ -2052,21 +2058,22 @@ x_draw_image_relief (s) | |||
| 2052 | { | 2058 | { |
| 2053 | int x0, y0, x1, y1, thick, raised_p; | 2059 | int x0, y0, x1, y1, thick, raised_p; |
| 2054 | RECT r; | 2060 | RECT r; |
| 2055 | int x; | 2061 | int x = s->x; |
| 2056 | int y = s->ybase - image_ascent (s->img, s->face); | 2062 | int y = s->ybase - image_ascent (s->img, s->face, &s->slice); |
| 2057 | 2063 | ||
| 2058 | /* If first glyph of S has a left box line, start drawing it to the | 2064 | /* If first glyph of S has a left box line, start drawing it to the |
| 2059 | right of that line. */ | 2065 | right of that line. */ |
| 2060 | if (s->face->box != FACE_NO_BOX | 2066 | if (s->face->box != FACE_NO_BOX |
| 2061 | && s->first_glyph->left_box_line_p) | 2067 | && s->first_glyph->left_box_line_p |
| 2062 | x = s->x + abs (s->face->box_line_width); | 2068 | && s->slice.x == 0) |
| 2063 | else | 2069 | x += abs (s->face->box_line_width); |
| 2064 | x = s->x; | ||
| 2065 | 2070 | ||
| 2066 | /* If there is a margin around the image, adjust x- and y-position | 2071 | /* If there is a margin around the image, adjust x- and y-position |
| 2067 | by that margin. */ | 2072 | by that margin. */ |
| 2068 | x += s->img->hmargin; | 2073 | if (s->slice.x == 0) |
| 2069 | y += s->img->vmargin; | 2074 | x += s->img->hmargin; |
| 2075 | if (s->slice.y == 0) | ||
| 2076 | y += s->img->vmargin; | ||
| 2070 | 2077 | ||
| 2071 | if (s->hl == DRAW_IMAGE_SUNKEN | 2078 | if (s->hl == DRAW_IMAGE_SUNKEN |
| 2072 | || s->hl == DRAW_IMAGE_RAISED) | 2079 | || s->hl == DRAW_IMAGE_RAISED) |
| @@ -2082,12 +2089,17 @@ x_draw_image_relief (s) | |||
| 2082 | 2089 | ||
| 2083 | x0 = x - thick; | 2090 | x0 = x - thick; |
| 2084 | y0 = y - thick; | 2091 | y0 = y - thick; |
| 2085 | x1 = x + s->img->width + thick - 1; | 2092 | x1 = x + s->slice.width + thick - 1; |
| 2086 | y1 = y + s->img->height + thick - 1; | 2093 | y1 = y + s->slice.height + thick - 1; |
| 2087 | 2094 | ||
| 2088 | x_setup_relief_colors (s); | 2095 | x_setup_relief_colors (s); |
| 2089 | get_glyph_string_clip_rect (s, &r); | 2096 | get_glyph_string_clip_rect (s, &r); |
| 2090 | w32_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p, 1, 1, &r); | 2097 | w32_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p, |
| 2098 | s->slice.y == 0, | ||
| 2099 | s->slice.y + s->slice.height == s->img->height, | ||
| 2100 | s->slice.x == 0, | ||
| 2101 | s->slice.x + s->slice.width == s->img->width, | ||
| 2102 | &r); | ||
| 2091 | } | 2103 | } |
| 2092 | 2104 | ||
| 2093 | 2105 | ||
| @@ -2100,21 +2112,22 @@ w32_draw_image_foreground_1 (s, pixmap) | |||
| 2100 | { | 2112 | { |
| 2101 | HDC hdc = CreateCompatibleDC (s->hdc); | 2113 | HDC hdc = CreateCompatibleDC (s->hdc); |
| 2102 | HGDIOBJ orig_hdc_obj = SelectObject (hdc, pixmap); | 2114 | HGDIOBJ orig_hdc_obj = SelectObject (hdc, pixmap); |
| 2103 | int x; | 2115 | int x = 0; |
| 2104 | int y = s->ybase - s->y - image_ascent (s->img, s->face); | 2116 | int y = s->ybase - s->y - image_ascent (s->img, s->face, &s->slice); |
| 2105 | 2117 | ||
| 2106 | /* If first glyph of S has a left box line, start drawing it to the | 2118 | /* If first glyph of S has a left box line, start drawing it to the |
| 2107 | right of that line. */ | 2119 | right of that line. */ |
| 2108 | if (s->face->box != FACE_NO_BOX | 2120 | if (s->face->box != FACE_NO_BOX |
| 2109 | && s->first_glyph->left_box_line_p) | 2121 | && s->first_glyph->left_box_line_p |
| 2110 | x = abs (s->face->box_line_width); | 2122 | && s->slice.x == 0) |
| 2111 | else | 2123 | x += abs (s->face->box_line_width); |
| 2112 | x = 0; | ||
| 2113 | 2124 | ||
| 2114 | /* If there is a margin around the image, adjust x- and y-position | 2125 | /* If there is a margin around the image, adjust x- and y-position |
| 2115 | by that margin. */ | 2126 | by that margin. */ |
| 2116 | x += s->img->hmargin; | 2127 | if (s->slice.x == 0) |
| 2117 | y += s->img->vmargin; | 2128 | x += s->img->hmargin; |
| 2129 | if (s->slice.y == 0) | ||
| 2130 | y += s->img->vmargin; | ||
| 2118 | 2131 | ||
| 2119 | if (s->img->pixmap) | 2132 | if (s->img->pixmap) |
| 2120 | { | 2133 | { |
| @@ -2130,12 +2143,12 @@ w32_draw_image_foreground_1 (s, pixmap) | |||
| 2130 | 2143 | ||
| 2131 | SetTextColor (hdc, RGB (0, 0, 0)); | 2144 | SetTextColor (hdc, RGB (0, 0, 0)); |
| 2132 | SetBkColor (hdc, RGB (255, 255, 255)); | 2145 | SetBkColor (hdc, RGB (255, 255, 255)); |
| 2133 | BitBlt (hdc, x, y, s->img->width, s->img->height, | 2146 | BitBlt (hdc, x, y, s->slice.width, s->slice.height, |
| 2134 | compat_hdc, 0, 0, SRCINVERT); | 2147 | compat_hdc, s->slice.x, s->slice.y, SRCINVERT); |
| 2135 | BitBlt (hdc, x, y, s->img->width, s->img->height, | 2148 | BitBlt (hdc, x, y, s->slice.width, s->slice.height, |
| 2136 | mask_dc, 0, 0, SRCAND); | 2149 | mask_dc, s->slice.x, s->slice.y, SRCAND); |
| 2137 | BitBlt (hdc, x, y, s->img->width, s->img->height, | 2150 | BitBlt (hdc, x, y, s->slice.width, s->slice.height, |
| 2138 | compat_hdc, 0, 0, SRCINVERT); | 2151 | compat_hdc, s->slice.x, s->slice.y, SRCINVERT); |
| 2139 | 2152 | ||
| 2140 | SelectObject (mask_dc, mask_orig_obj); | 2153 | SelectObject (mask_dc, mask_orig_obj); |
| 2141 | DeleteDC (mask_dc); | 2154 | DeleteDC (mask_dc); |
| @@ -2145,8 +2158,8 @@ w32_draw_image_foreground_1 (s, pixmap) | |||
| 2145 | SetTextColor (hdc, s->gc->foreground); | 2158 | SetTextColor (hdc, s->gc->foreground); |
| 2146 | SetBkColor (hdc, s->gc->background); | 2159 | SetBkColor (hdc, s->gc->background); |
| 2147 | 2160 | ||
| 2148 | BitBlt (hdc, x, y, s->img->width, s->img->height, | 2161 | BitBlt (hdc, x, y, s->slice.width, s->slice.height, |
| 2149 | compat_hdc, 0, 0, SRCCOPY); | 2162 | compat_hdc, s->slice.x, s->slice.y, SRCCOPY); |
| 2150 | 2163 | ||
| 2151 | /* When the image has a mask, we can expect that at | 2164 | /* When the image has a mask, we can expect that at |
| 2152 | least part of a mouse highlight or a block cursor will | 2165 | least part of a mouse highlight or a block cursor will |
| @@ -2158,8 +2171,9 @@ w32_draw_image_foreground_1 (s, pixmap) | |||
| 2158 | { | 2171 | { |
| 2159 | int r = s->img->relief; | 2172 | int r = s->img->relief; |
| 2160 | if (r < 0) r = -r; | 2173 | if (r < 0) r = -r; |
| 2161 | w32_draw_rectangle (hdc, s->gc, x - r, y - r , | 2174 | w32_draw_rectangle (hdc, s->gc, x - r, y - r, |
| 2162 | s->img->width + r*2 - 1, s->img->height + r*2 - 1); | 2175 | s->slice.width + r*2 - 1, |
| 2176 | s->slice.height + r*2 - 1); | ||
| 2163 | } | 2177 | } |
| 2164 | } | 2178 | } |
| 2165 | 2179 | ||
| @@ -2169,8 +2183,8 @@ w32_draw_image_foreground_1 (s, pixmap) | |||
| 2169 | DeleteDC (compat_hdc); | 2183 | DeleteDC (compat_hdc); |
| 2170 | } | 2184 | } |
| 2171 | else | 2185 | else |
| 2172 | w32_draw_rectangle (hdc, s->gc, x, y, s->img->width - 1, | 2186 | w32_draw_rectangle (hdc, s->gc, x, y, |
| 2173 | s->img->height - 1); | 2187 | s->slice.width - 1, s->slice.height - 1); |
| 2174 | 2188 | ||
| 2175 | SelectObject (hdc, orig_hdc_obj); | 2189 | SelectObject (hdc, orig_hdc_obj); |
| 2176 | DeleteDC (hdc); | 2190 | DeleteDC (hdc); |
| @@ -2229,19 +2243,22 @@ x_draw_image_glyph_string (s) | |||
| 2229 | taller than image or if image has a clip mask to reduce | 2243 | taller than image or if image has a clip mask to reduce |
| 2230 | flickering. */ | 2244 | flickering. */ |
| 2231 | s->stippled_p = s->face->stipple != 0; | 2245 | s->stippled_p = s->face->stipple != 0; |
| 2232 | if (height > s->img->height | 2246 | if (height > s->slice.height |
| 2233 | || s->img->hmargin | 2247 | || s->img->hmargin |
| 2234 | || s->img->vmargin | 2248 | || s->img->vmargin |
| 2235 | || s->img->mask | 2249 | || s->img->mask |
| 2236 | || s->img->pixmap == 0 | 2250 | || s->img->pixmap == 0 |
| 2237 | || s->width != s->background_width) | 2251 | || s->width != s->background_width) |
| 2238 | { | 2252 | { |
| 2239 | if (box_line_hwidth && s->first_glyph->left_box_line_p) | 2253 | x = s->x; |
| 2240 | x = s->x + box_line_hwidth; | 2254 | if (s->first_glyph->left_box_line_p |
| 2241 | else | 2255 | && s->slice.x == 0) |
| 2242 | x = s->x; | 2256 | x += box_line_hwidth; |
| 2257 | |||
| 2258 | y = s->y; | ||
| 2259 | if (s->slice.y == 0) | ||
| 2260 | y += box_line_vwidth; | ||
| 2243 | 2261 | ||
| 2244 | y = s->y + box_line_vwidth; | ||
| 2245 | #if 0 /* TODO: figure out if we need to do this on Windows. */ | 2262 | #if 0 /* TODO: figure out if we need to do this on Windows. */ |
| 2246 | if (s->img->mask) | 2263 | if (s->img->mask) |
| 2247 | { | 2264 | { |