comparison src/redisplay-msw.c @ 404:2f8bb876ab1d r21-2-32

Import from CVS: tag r21-2-32
author cvs
date Mon, 13 Aug 2007 11:16:07 +0200
parents 74fd4e045ea6
children b8cc9ab3f761
comparison
equal deleted inserted replaced
403:9f011ab08d48 404:2f8bb876ab1d
200 } 200 }
201 } 201 }
202 202
203 /* 203 /*
204 * Given F, retrieve device context. F can be a display frame, or 204 * Given F, retrieve device context. F can be a display frame, or
205 * a print job. 205 * a print job. For a print job, page is also started when printer's
206 * device context is first time requested.
206 */ 207 */
207 INLINE HDC 208 static HDC
208 get_frame_dc (struct frame *f) 209 get_frame_dc (struct frame *f, int start_page_p)
209 { 210 {
210 if (FRAME_MSWINDOWS_P (f)) 211 if (FRAME_MSWINDOWS_P (f))
211 return FRAME_MSWINDOWS_DC (f); 212 return FRAME_MSWINDOWS_DC (f);
212 else 213 else
213 { 214 {
214 if (!FRAME_MSPRINTER_PAGE_STARTED (f)) 215 if (start_page_p && !FRAME_MSPRINTER_PAGE_STARTED (f))
215 msprinter_start_page (f); 216 msprinter_start_page (f);
216 return DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f))); 217 return DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f)));
217 } 218 }
218 } 219 }
219 220
220 /* 221 /*
221 * Given F, retrieve compatible device context. F can be a display 222 * Given F, retrieve compatible device context. F can be a display
222 * frame, or a print job. 223 * frame, or a print job.
223 */ 224 */
224 INLINE HDC 225 static HDC
225 get_frame_compdc (struct frame *f) 226 get_frame_compdc (struct frame *f)
226 { 227 {
227 if (FRAME_MSWINDOWS_P (f)) 228 struct device *d = XDEVICE (FRAME_DEVICE (f));
228 return FRAME_MSWINDOWS_CDC (f); 229 if (DEVICE_MSWINDOWS_P (d))
230 return DEVICE_MSWINDOWS_HCDC (d);
229 else 231 else
230 return FRAME_MSPRINTER_CDC (f); 232 return DEVICE_MSPRINTER_HCDC (d);
231 } 233 }
232 234
233 /***************************************************************************** 235 /*****************************************************************************
234 mswindows_update_dc 236 mswindows_update_dc
235 237
283 static void 285 static void
284 mswindows_output_blank (struct window *w, struct display_line *dl, 286 mswindows_output_blank (struct window *w, struct display_line *dl,
285 struct rune *rb, int start_pixpos) 287 struct rune *rb, int start_pixpos)
286 { 288 {
287 struct frame *f = XFRAME (w->frame); 289 struct frame *f = XFRAME (w->frame);
288 HDC hdc = get_frame_dc (f); 290 HDC hdc = get_frame_dc (f, 1);
289 RECT rect = { rb->xpos, DISPLAY_LINE_YPOS (dl), 291 RECT rect = { rb->xpos, DISPLAY_LINE_YPOS (dl),
290 rb->xpos+rb->width, 292 rb->xpos+rb->width,
291 DISPLAY_LINE_YEND (dl) }; 293 DISPLAY_LINE_YEND (dl) };
292 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, rb->findex); 294 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, rb->findex);
293 295
336 struct frame *f = XFRAME (w->frame); 338 struct frame *f = XFRAME (w->frame);
337 struct device *d = XDEVICE (f->device); 339 struct device *d = XDEVICE (f->device);
338 struct face_cachel *cachel=0; 340 struct face_cachel *cachel=0;
339 Lisp_Object font = Qnil; 341 Lisp_Object font = Qnil;
340 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d)); 342 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
341 HDC hdc = get_frame_dc (f); 343 HDC hdc = get_frame_dc (f, 1);
342 unsigned int local_face_index=0; 344 unsigned int local_face_index=0;
343 char *p_char = NULL; 345 char *p_char = NULL;
344 int n_char = 0; 346 int n_char = 0;
345 RECT rect = { xpos, 347 RECT rect = { xpos,
346 DISPLAY_LINE_YPOS (dl), 348 DISPLAY_LINE_YPOS (dl),
456 int cursor_height) 458 int cursor_height)
457 { 459 {
458 struct frame *f = XFRAME (w->frame); 460 struct frame *f = XFRAME (w->frame);
459 /* struct device *d = XDEVICE (f->device);*/ 461 /* struct device *d = XDEVICE (f->device);*/
460 Lisp_Object window; 462 Lisp_Object window;
461 HDC hdc = get_frame_dc (f); 463 HDC hdc = get_frame_dc (f, 1);
462 int clip_end; 464 int clip_end;
463 Lisp_Object bg_pmap; 465 Lisp_Object bg_pmap;
464 int len = Dynarr_length (buf); 466 int len = Dynarr_length (buf);
465 unsigned char *text_storage = (unsigned char *) alloca (2 * len); 467 unsigned char *text_storage = (unsigned char *) alloca (2 * len);
466 textual_run *runs = alloca_array (textual_run, len); 468 textual_run *runs = alloca_array (textual_run, len);
569 static void 571 static void
570 mswindows_output_dibitmap (struct frame *f, Lisp_Image_Instance *p, 572 mswindows_output_dibitmap (struct frame *f, Lisp_Image_Instance *p,
571 struct display_box* db, 573 struct display_box* db,
572 struct display_glyph_area* dga) 574 struct display_glyph_area* dga)
573 { 575 {
574 HDC hdc = get_frame_dc (f); 576 HDC hdc = get_frame_dc (f, 1);
575 HDC hcompdc = get_frame_compdc (f); 577 HDC hcompdc = get_frame_compdc (f);
576 HGDIOBJ old=NULL; 578 HGDIOBJ old=NULL;
577 COLORREF bgcolor = GetBkColor (hdc); 579 COLORREF bgcolor = GetBkColor (hdc);
578 580
579 /* first blt the mask */ 581 /* first blt the mask */
678 struct display_box *db, struct display_glyph_area *dga, 680 struct display_box *db, struct display_glyph_area *dga,
679 face_index findex, int cursor_start, int cursor_width, 681 face_index findex, int cursor_start, int cursor_width,
680 int cursor_height, int bg_pixmap) 682 int cursor_height, int bg_pixmap)
681 { 683 {
682 struct frame *f = XFRAME (w->frame); 684 struct frame *f = XFRAME (w->frame);
683 HDC hdc = get_frame_dc (f); 685 HDC hdc = get_frame_dc (f, 1);
684 686
685 Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance); 687 Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
686 Lisp_Object window; 688 Lisp_Object window;
687 689
688 XSETWINDOW (window, w); 690 XSETWINDOW (window, w);
729 rect_dead.bottom = rect_dead.top + sbh; 731 rect_dead.bottom = rect_dead.top + sbh;
730 732
731 if (IntersectRect (&rect_paint, &rect_dead, prc)) 733 if (IntersectRect (&rect_paint, &rect_dead, prc))
732 { 734 {
733 struct frame *f = XFRAME (WINDOW_FRAME (w)); 735 struct frame *f = XFRAME (WINDOW_FRAME (w));
734 FillRect (get_frame_dc (f), &rect_paint, 736 FillRect (get_frame_dc (f, 1), &rect_paint,
735 (HBRUSH) (COLOR_BTNFACE+1)); 737 (HBRUSH) (COLOR_BTNFACE+1));
736 } 738 }
737 } 739 }
738 740
739 #endif /* HAVE_SCROLLBARS */ 741 #endif /* HAVE_SCROLLBARS */
908 border |= BF_RIGHT; 910 border |= BF_RIGHT;
909 911
910 { 912 {
911 RECT rect = { x, y, x + width, y + height }; 913 RECT rect = { x, y, x + width, y + height };
912 Lisp_Object color = WINDOW_FACE_CACHEL_BACKGROUND (w, findex); 914 Lisp_Object color = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
913 HDC hdc = get_frame_dc (f); 915 HDC hdc = get_frame_dc (f, 1);
914 916
915 mswindows_update_dc (hdc, Qnil, color, Qnil); 917 mswindows_update_dc (hdc, Qnil, color, Qnil);
916 DrawEdge (hdc, &rect, edge, border); 918 DrawEdge (hdc, &rect, edge, border);
917 } 919 }
918 } 920 }
967 969
968 static int 970 static int
969 mswindows_flash (struct device *d) 971 mswindows_flash (struct device *d)
970 { 972 {
971 struct frame *f = device_selected_frame (d); 973 struct frame *f = device_selected_frame (d);
972 HDC hdc = get_frame_dc (f); 974 HDC hdc = get_frame_dc (f, 1);
973 RECT rc; 975 RECT rc;
974 976
975 GetClientRect (FRAME_MSWINDOWS_HANDLE (f), &rc); 977 GetClientRect (FRAME_MSWINDOWS_HANDLE (f), &rc);
976 InvertRect (hdc, &rc); 978 InvertRect (hdc, &rc);
977 GdiFlush (); 979 GdiFlush ();
1119 else if (rb->type == RUNE_DGLYPH) 1121 else if (rb->type == RUNE_DGLYPH)
1120 { 1122 {
1121 Lisp_Object instance; 1123 Lisp_Object instance;
1122 struct display_box dbox; 1124 struct display_box dbox;
1123 struct display_glyph_area dga; 1125 struct display_glyph_area dga;
1126
1124 redisplay_calculate_display_boxes (dl, rb->xpos, rb->object.dglyph.xoffset, 1127 redisplay_calculate_display_boxes (dl, rb->xpos, rb->object.dglyph.xoffset,
1125 start_pixpos, rb->width, 1128 start_pixpos, rb->width,
1126 &dbox, &dga); 1129 &dbox, &dga);
1127 1130
1128 XSETWINDOW (window, w); 1131 XSETWINDOW (window, w);
1129 instance = glyph_image_instance (rb->object.dglyph.glyph, 1132 instance = glyph_image_instance (rb->object.dglyph.glyph,
1130 window, ERROR_ME_NOT, 1); 1133 window, ERROR_ME_NOT, 1);
1131 findex = rb->findex; 1134 findex = rb->findex;
1132 1135
1133 if (IMAGE_INSTANCEP (instance)) 1136 if (IMAGE_INSTANCEP (instance))
1134 switch (XIMAGE_INSTANCE_TYPE (instance)) 1137 {
1135 { 1138 switch (XIMAGE_INSTANCE_TYPE (instance))
1136 case IMAGE_TEXT:
1137 { 1139 {
1138 /* #### This is way losing. See the comment in 1140 case IMAGE_TEXT:
1139 add_glyph_rune(). */ 1141 {
1140 Lisp_Object string = 1142 /* #### This is way losing. See the comment in
1141 XIMAGE_INSTANCE_TEXT_STRING (instance); 1143 add_glyph_rune(). */
1142 convert_bufbyte_string_into_emchar_dynarr 1144 Lisp_Object string =
1143 (XSTRING_DATA (string), XSTRING_LENGTH (string), buf); 1145 XIMAGE_INSTANCE_TEXT_STRING (instance);
1144 1146 convert_bufbyte_string_into_emchar_dynarr
1147 (XSTRING_DATA (string), XSTRING_LENGTH (string), buf);
1148
1149 if (rb->cursor_type == CURSOR_ON)
1150 mswindows_output_cursor (w, dl, xpos, cursor_width,
1151 findex, Dynarr_at (buf, 0), 0);
1152 else /* #### redisplay-x passes -1 as the width: why ? */
1153 mswindows_output_string (w, dl, buf, xpos,
1154 rb->object.dglyph.xoffset,
1155 start_pixpos, rb->width, findex,
1156 0, 0, 0, 0);
1157 Dynarr_reset (buf);
1158 }
1159 break;
1160
1161 case IMAGE_MONO_PIXMAP:
1162 case IMAGE_COLOR_PIXMAP:
1163 redisplay_output_pixmap (w, instance, &dbox, &dga, findex,
1164 cursor_start, cursor_width,
1165 cursor_height, 0);
1145 if (rb->cursor_type == CURSOR_ON) 1166 if (rb->cursor_type == CURSOR_ON)
1146 mswindows_output_cursor (w, dl, xpos, cursor_width, 1167 mswindows_output_cursor (w, dl, xpos, cursor_width,
1147 findex, Dynarr_at (buf, 0), 0); 1168 findex, 0, 1);
1148 else /* #### redisplay-x passes -1 as the width: why ? */ 1169 break;
1149 mswindows_output_string (w, dl, buf, xpos, 1170
1150 rb->object.dglyph.xoffset, 1171 case IMAGE_POINTER:
1151 start_pixpos, rb->width, findex, 1172 abort ();
1152 0, 0, 0, 0); 1173
1153 Dynarr_reset (buf); 1174 case IMAGE_SUBWINDOW:
1175 case IMAGE_WIDGET:
1176 redisplay_output_subwindow (w, instance, &dbox, &dga, findex,
1177 cursor_start, cursor_width,
1178 cursor_height);
1179 if (rb->cursor_type == CURSOR_ON)
1180 mswindows_output_cursor (w, dl, xpos, cursor_width,
1181 findex, 0, 1);
1182 break;
1183
1184 case IMAGE_LAYOUT:
1185 redisplay_output_layout (w, instance, &dbox, &dga, findex,
1186 cursor_start, cursor_width,
1187 cursor_height);
1188 if (rb->cursor_type == CURSOR_ON)
1189 mswindows_output_cursor (w, dl, xpos, cursor_width,
1190 findex, 0, 1);
1191 break;
1192
1193 case IMAGE_NOTHING:
1194 /* nothing is as nothing does */
1195 break;
1196
1197 default:
1198 abort ();
1154 } 1199 }
1155 break; 1200 IMAGE_INSTANCE_OPTIMIZE_OUTPUT
1156 1201 (XIMAGE_INSTANCE (instance)) = 0;
1157 case IMAGE_MONO_PIXMAP: 1202 }
1158 case IMAGE_COLOR_PIXMAP:
1159 redisplay_output_pixmap (w, instance, &dbox, &dga, findex,
1160 cursor_start, cursor_width,
1161 cursor_height, 0);
1162 if (rb->cursor_type == CURSOR_ON)
1163 mswindows_output_cursor (w, dl, xpos, cursor_width,
1164 findex, 0, 1);
1165 break;
1166
1167 case IMAGE_POINTER:
1168 abort ();
1169
1170 case IMAGE_SUBWINDOW:
1171 case IMAGE_WIDGET:
1172 redisplay_output_subwindow (w, instance, &dbox, &dga, findex,
1173 cursor_start, cursor_width,
1174 cursor_height);
1175 if (rb->cursor_type == CURSOR_ON)
1176 mswindows_output_cursor (w, dl, xpos, cursor_width,
1177 findex, 0, 1);
1178 break;
1179
1180 case IMAGE_LAYOUT:
1181 redisplay_output_layout (w, instance, &dbox, &dga, findex,
1182 cursor_start, cursor_width,
1183 cursor_height);
1184 if (rb->cursor_type == CURSOR_ON)
1185 mswindows_output_cursor (w, dl, xpos, cursor_width,
1186 findex, 0, 1);
1187 break;
1188
1189 case IMAGE_NOTHING:
1190 /* nothing is as nothing does */
1191 break;
1192
1193 default:
1194 abort ();
1195 }
1196
1197 xpos += rb->width; 1203 xpos += rb->width;
1198 elt++; 1204 elt++;
1199 } 1205 }
1200 else 1206 else
1201 abort (); 1207 abort ();
1224 ****************************************************************************/ 1230 ****************************************************************************/
1225 static void 1231 static void
1226 mswindows_output_vertical_divider (struct window *w, int clear_unused) 1232 mswindows_output_vertical_divider (struct window *w, int clear_unused)
1227 { 1233 {
1228 struct frame *f = XFRAME (w->frame); 1234 struct frame *f = XFRAME (w->frame);
1229 HDC hdc = get_frame_dc (f); 1235 HDC hdc = get_frame_dc (f, 1);
1230 RECT rect; 1236 RECT rect;
1231 int spacing = XINT (w->vertical_divider_spacing); 1237 int spacing = XINT (w->vertical_divider_spacing);
1232 int shadow = XINT (w->vertical_divider_shadow_thickness); 1238 int shadow = XINT (w->vertical_divider_shadow_thickness);
1233 int abs_shadow = abs (shadow); 1239 int abs_shadow = abs (shadow);
1234 int line_width = XINT (w->vertical_divider_line_width); 1240 int line_width = XINT (w->vertical_divider_line_width);
1235 int div_left = WINDOW_RIGHT (w) - window_divider_width (w); 1241 int div_left = WINDOW_RIGHT (w) - window_divider_width (w);
1236 int y1 = WINDOW_TOP (w) + FRAME_TOP_GUTTER_BOUNDS (f); 1242 int y1 = WINDOW_TOP (w);
1237 int y2 = WINDOW_BOTTOM (w) + FRAME_BOTTOM_GUTTER_BOUNDS (f); 1243 int y2 = WINDOW_BOTTOM (w);
1238 1244
1239 /* Clear left and right spacing areas */ 1245 /* Clear left and right spacing areas */
1240 if (spacing) 1246 if (spacing)
1241 { 1247 {
1242 rect.top = y1; 1248 rect.top = y1;
1285 ****************************************************************************/ 1291 ****************************************************************************/
1286 static int 1292 static int
1287 mswindows_text_width (struct frame *f, struct face_cachel *cachel, 1293 mswindows_text_width (struct frame *f, struct face_cachel *cachel,
1288 const Emchar *str, Charcount len) 1294 const Emchar *str, Charcount len)
1289 { 1295 {
1290 HDC hdc = get_frame_dc (f); 1296 HDC hdc = get_frame_dc (f, 0);
1291 int width_so_far = 0; 1297 int width_so_far = 0;
1292 unsigned char *text_storage = (unsigned char *) alloca (2 * len); 1298 unsigned char *text_storage = (unsigned char *) alloca (2 * len);
1293 textual_run *runs = alloca_array (textual_run, len); 1299 textual_run *runs = alloca_array (textual_run, len);
1294 int nruns; 1300 int nruns;
1295 int i; 1301 int i;
1315 face_index findex, int x, int y, 1321 face_index findex, int x, int y,
1316 int width, int height, Lisp_Object fcolor, Lisp_Object bcolor, 1322 int width, int height, Lisp_Object fcolor, Lisp_Object bcolor,
1317 Lisp_Object background_pixmap) 1323 Lisp_Object background_pixmap)
1318 { 1324 {
1319 RECT rect = { x, y, x+width, y+height }; 1325 RECT rect = { x, y, x+width, y+height };
1320 HDC hdc = get_frame_dc (f); 1326 HDC hdc = get_frame_dc (f, 1);
1321 1327
1322 if (!NILP (background_pixmap)) 1328 if (!NILP (background_pixmap))
1323 { 1329 {
1324 struct display_box db = { x, y, width, height }; 1330 struct display_box db = { x, y, width, height };
1325 mswindows_update_dc (hdc, 1331 mswindows_update_dc (hdc,