Mercurial > hg > xemacs-beta
comparison src/glyphs-msw.c @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 8de8e3f6228a |
children | 576fb035e263 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 Boston, MA 02111-1307, USA. */ | 19 Boston, MA 02111-1307, USA. */ |
20 | 20 |
21 /* Synched up with: Not in FSF. */ | 21 /* Synched up with: Not in FSF. */ |
22 | 22 |
23 /* written by Andy Piper <andy@xemacs.org> plagerising bits from | 23 /* written by Andy Piper <andy@xemacs.org> plagiarising bits from |
24 glyphs-x.c */ | 24 glyphs-x.c */ |
25 | 25 |
26 #include <config.h> | 26 #include <config.h> |
27 #include "lisp.h" | 27 #include "lisp.h" |
28 #include "lstream.h" | 28 #include "lstream.h" |
55 | 55 |
56 DECLARE_IMAGE_INSTANTIATOR_FORMAT (nothing); | 56 DECLARE_IMAGE_INSTANTIATOR_FORMAT (nothing); |
57 DECLARE_IMAGE_INSTANTIATOR_FORMAT (string); | 57 DECLARE_IMAGE_INSTANTIATOR_FORMAT (string); |
58 DECLARE_IMAGE_INSTANTIATOR_FORMAT (formatted_string); | 58 DECLARE_IMAGE_INSTANTIATOR_FORMAT (formatted_string); |
59 DECLARE_IMAGE_INSTANTIATOR_FORMAT (inherit); | 59 DECLARE_IMAGE_INSTANTIATOR_FORMAT (inherit); |
60 DECLARE_IMAGE_INSTANTIATOR_FORMAT (layout); | |
61 #ifdef HAVE_JPEG | 60 #ifdef HAVE_JPEG |
62 DECLARE_IMAGE_INSTANTIATOR_FORMAT (jpeg); | 61 DECLARE_IMAGE_INSTANTIATOR_FORMAT (jpeg); |
63 #endif | 62 #endif |
64 #ifdef HAVE_TIFF | 63 #ifdef HAVE_TIFF |
65 DECLARE_IMAGE_INSTANTIATOR_FORMAT (tiff); | 64 DECLARE_IMAGE_INSTANTIATOR_FORMAT (tiff); |
70 #ifdef HAVE_GIF | 69 #ifdef HAVE_GIF |
71 DECLARE_IMAGE_INSTANTIATOR_FORMAT (gif); | 70 DECLARE_IMAGE_INSTANTIATOR_FORMAT (gif); |
72 #endif | 71 #endif |
73 #ifdef HAVE_XPM | 72 #ifdef HAVE_XPM |
74 DEFINE_DEVICE_IIFORMAT (mswindows, xpm); | 73 DEFINE_DEVICE_IIFORMAT (mswindows, xpm); |
74 DEFINE_DEVICE_IIFORMAT (msprinter, xpm); | |
75 #endif | 75 #endif |
76 DEFINE_DEVICE_IIFORMAT (mswindows, xbm); | 76 DEFINE_DEVICE_IIFORMAT (mswindows, xbm); |
77 DEFINE_DEVICE_IIFORMAT (msprinter, xbm); | |
77 #ifdef HAVE_XFACE | 78 #ifdef HAVE_XFACE |
78 DEFINE_DEVICE_IIFORMAT (mswindows, xface); | 79 DEFINE_DEVICE_IIFORMAT (mswindows, xface); |
79 #endif | 80 DEFINE_DEVICE_IIFORMAT (msprinter, xface); |
81 #endif | |
82 DECLARE_IMAGE_INSTANTIATOR_FORMAT (layout); | |
83 DEFINE_DEVICE_IIFORMAT (mswindows, native_layout); | |
80 DEFINE_DEVICE_IIFORMAT (mswindows, button); | 84 DEFINE_DEVICE_IIFORMAT (mswindows, button); |
81 DEFINE_DEVICE_IIFORMAT (mswindows, edit_field); | 85 DEFINE_DEVICE_IIFORMAT (mswindows, edit_field); |
82 DEFINE_DEVICE_IIFORMAT (mswindows, subwindow); | 86 DEFINE_DEVICE_IIFORMAT (mswindows, subwindow); |
83 DEFINE_DEVICE_IIFORMAT (mswindows, widget); | 87 DEFINE_DEVICE_IIFORMAT (mswindows, widget); |
84 DEFINE_DEVICE_IIFORMAT (mswindows, label); | 88 DEFINE_DEVICE_IIFORMAT (mswindows, label); |
101 mswindows_initialize_dibitmap_image_instance (Lisp_Image_Instance *ii, | 105 mswindows_initialize_dibitmap_image_instance (Lisp_Image_Instance *ii, |
102 int slices, | 106 int slices, |
103 enum image_instance_type type); | 107 enum image_instance_type type); |
104 static void | 108 static void |
105 mswindows_initialize_image_instance_mask (Lisp_Image_Instance* image, | 109 mswindows_initialize_image_instance_mask (Lisp_Image_Instance* image, |
106 struct frame* f); | 110 HDC hcdc); |
111 | |
112 /* | |
113 * Given device D, retrieve compatible device context. D can be either | |
114 * mswindows or an msprinter device. | |
115 */ | |
116 inline static HDC | |
117 get_device_compdc (struct device *d) | |
118 { | |
119 if (DEVICE_MSWINDOWS_P (d)) | |
120 return DEVICE_MSWINDOWS_HCDC (d); | |
121 else | |
122 return DEVICE_MSPRINTER_HCDC (d); | |
123 } | |
124 | |
125 /* | |
126 * Initialize image instance pixel sizes in II. For a display bitmap, | |
127 * these will be same as real bitmap sizes. For a printer bitmap, | |
128 * these will be scaled up so that the bitmap is proportionally enlarged | |
129 * when output to printer. Redisplay code takes care of scaling, to | |
130 * conserve memory we do not really scale bitmaps. Set the watermark | |
131 * only here. | |
132 * #### Add support for unscalable bitmaps. | |
133 */ | |
134 static void init_image_instance_geometry (Lisp_Image_Instance *ii) | |
135 { | |
136 struct device *d = DOMAIN_XDEVICE (ii->domain); | |
137 | |
138 if (/* #### Scaleable && */ DEVICE_MSPRINTER_P (d)) | |
139 { | |
140 HDC printer_dc = DEVICE_MSPRINTER_HCDC (d); | |
141 HDC display_dc = CreateCompatibleDC (NULL); | |
142 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = | |
143 MulDiv (IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii), | |
144 GetDeviceCaps (printer_dc, LOGPIXELSX), | |
145 GetDeviceCaps (display_dc, LOGPIXELSX)); | |
146 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = | |
147 MulDiv (IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii), | |
148 GetDeviceCaps (printer_dc, LOGPIXELSY), | |
149 GetDeviceCaps (display_dc, LOGPIXELSY)); | |
150 } | |
151 else | |
152 { | |
153 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = | |
154 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii); | |
155 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = | |
156 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii); | |
157 } | |
158 } | |
107 | 159 |
108 #define BPLINE(width) ((int)(~3UL & (unsigned long)((width) +3))) | 160 #define BPLINE(width) ((int)(~3UL & (unsigned long)((width) +3))) |
109 | 161 |
110 /************************************************************************/ | 162 /************************************************************************/ |
111 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/ | 163 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/ |
122 RGBQUAD* colortbl; | 174 RGBQUAD* colortbl; |
123 int ncolors; | 175 int ncolors; |
124 BITMAPINFO* bmp_info; | 176 BITMAPINFO* bmp_info; |
125 unsigned char *ip, *dp; | 177 unsigned char *ip, *dp; |
126 | 178 |
127 if (DEVICE_MSWINDOWS_BITSPIXEL (d) > 0) | 179 if (GetDeviceCaps (get_device_compdc (d), BITSPIXEL) > 0) |
128 { | 180 { |
129 int bpline = BPLINE(width * 3); | 181 int bpline = BPLINE(width * 3); |
130 /* FIXME: we can do this because 24bpp implies no color table, once | 182 /* FIXME: we can do this because 24bpp implies no color table, once |
131 * we start palettizing this is no longer true. The X versions of | 183 * we start palettizing this is no longer true. The X versions of |
132 * this function quantises to 256 colors or bit masks down to a | 184 * this function quantises to 256 colors or bit masks down to a |
204 xfree (bmp_info); | 256 xfree (bmp_info); |
205 return NULL; | 257 return NULL; |
206 } | 258 } |
207 | 259 |
208 /* build up an RGBQUAD colortable */ | 260 /* build up an RGBQUAD colortable */ |
209 for (i = 0; i < qtable->num_active_colors; i++) { | 261 for (i = 0; i < qtable->num_active_colors; i++) |
210 colortbl[i].rgbRed = (BYTE) qtable->rm[i]; | 262 { |
211 colortbl[i].rgbGreen = (BYTE) qtable->gm[i]; | 263 colortbl[i].rgbRed = (BYTE) qtable->rm[i]; |
212 colortbl[i].rgbBlue = (BYTE) qtable->bm[i]; | 264 colortbl[i].rgbGreen = (BYTE) qtable->gm[i]; |
213 colortbl[i].rgbReserved = 0; | 265 colortbl[i].rgbBlue = (BYTE) qtable->bm[i]; |
214 } | 266 colortbl[i].rgbReserved = 0; |
267 } | |
215 | 268 |
216 /* now build up the data. picture has to be upside-down and | 269 /* now build up the data. picture has to be upside-down and |
217 back-to-front for msw bitmaps */ | 270 back-to-front for msw bitmaps */ |
218 ip = pic; | 271 ip = pic; |
219 for (i = height-1; i >= 0; i--) { | 272 for (i = height-1; i >= 0; i--) |
220 dp = (*bmp_data) + (i * bpline); | 273 { |
221 for (j = 0; j < width; j++) { | 274 dp = (*bmp_data) + (i * bpline); |
222 rd = *ip++; | 275 for (j = 0; j < width; j++) |
223 gr = *ip++; | 276 { |
224 bl = *ip++; | 277 rd = *ip++; |
225 *dp++ = QUANT_GET_COLOR (qtable,rd,gr,bl); | 278 gr = *ip++; |
279 bl = *ip++; | |
280 *dp++ = QUANT_GET_COLOR (qtable,rd,gr,bl); | |
281 } | |
226 } | 282 } |
227 } | |
228 xfree (qtable); | 283 xfree (qtable); |
229 } | 284 } |
230 /* fix up the standard stuff */ | 285 /* fix up the standard stuff */ |
231 bmp_info->bmiHeader.biWidth=width; | 286 bmp_info->bmiHeader.biWidth=width; |
232 bmp_info->bmiHeader.biHeight=height; | 287 bmp_info->bmiHeader.biHeight=height; |
292 int slices, | 347 int slices, |
293 Lisp_Object instantiator, | 348 Lisp_Object instantiator, |
294 int x_hot, int y_hot, | 349 int x_hot, int y_hot, |
295 int create_mask) | 350 int create_mask) |
296 { | 351 { |
297 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 352 struct device *d = XDEVICE (IMAGE_INSTANCE_DEVICE (ii)); |
298 struct device *d = XDEVICE (device); | |
299 struct frame *f; | |
300 void* bmp_buf=0; | 353 void* bmp_buf=0; |
301 int type = 0; | 354 enum image_instance_type type; |
302 HBITMAP bitmap; | 355 HBITMAP bitmap; |
303 HDC hdc; | 356 HDC hdc; |
304 | |
305 if (!DEVICE_MSWINDOWS_P (d)) | |
306 signal_simple_error ("Not an mswindows device", device); | |
307 | |
308 if (NILP (DEVICE_SELECTED_FRAME (d))) | |
309 signal_simple_error ("No selected frame on mswindows device", device); | |
310 | |
311 f = XFRAME (DEVICE_SELECTED_FRAME (d)); | |
312 | 357 |
313 if (dest_mask & IMAGE_COLOR_PIXMAP_MASK) | 358 if (dest_mask & IMAGE_COLOR_PIXMAP_MASK) |
314 type = IMAGE_COLOR_PIXMAP; | 359 type = IMAGE_COLOR_PIXMAP; |
315 else if (dest_mask & IMAGE_POINTER_MASK) | 360 else if (dest_mask & IMAGE_POINTER_MASK) |
316 type = IMAGE_POINTER; | 361 type = IMAGE_POINTER; |
317 else | 362 else |
318 incompatible_image_types (instantiator, dest_mask, | 363 incompatible_image_types (instantiator, dest_mask, |
319 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK); | 364 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK); |
320 hdc = FRAME_MSWINDOWS_CDC (f); | 365 |
321 | 366 hdc = get_device_compdc (d); |
322 bitmap=CreateDIBSection (hdc, | 367 bitmap = CreateDIBSection (hdc, |
323 bmp_info, | 368 bmp_info, |
324 DIB_RGB_COLORS, | 369 DIB_RGB_COLORS, |
325 &bmp_buf, | 370 &bmp_buf, |
326 0,0); | 371 0, 0); |
327 | 372 |
328 if (!bitmap || !bmp_buf) | 373 if (!bitmap || !bmp_buf) |
329 signal_simple_error ("Unable to create bitmap", instantiator); | 374 signal_simple_error ("Unable to create bitmap", instantiator); |
330 | 375 |
331 /* copy in the actual bitmap */ | 376 /* copy in the actual bitmap */ |
338 | 383 |
339 /* Fixup a set of bitmaps. */ | 384 /* Fixup a set of bitmaps. */ |
340 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = bitmap; | 385 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = bitmap; |
341 | 386 |
342 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL; | 387 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL; |
343 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = bmp_info->bmiHeader.biWidth; | 388 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii) = |
344 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = bmp_info->bmiHeader.biHeight; | 389 bmp_info->bmiHeader.biWidth; |
345 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = bmp_info->bmiHeader.biBitCount; | 390 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii) = |
391 bmp_info->bmiHeader.biHeight; | |
392 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = bmp_info->bmiHeader.biBitCount; | |
346 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), x_hot); | 393 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), x_hot); |
347 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), y_hot); | 394 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), y_hot); |
395 init_image_instance_geometry (ii); | |
348 | 396 |
349 if (create_mask) | 397 if (create_mask) |
350 { | 398 { |
351 mswindows_initialize_image_instance_mask (ii, f); | 399 mswindows_initialize_image_instance_mask (ii, hdc); |
352 } | 400 } |
353 | 401 |
354 if (type == IMAGE_POINTER) | 402 if (type == IMAGE_POINTER) |
355 { | 403 { |
356 mswindows_initialize_image_instance_icon(ii, TRUE); | 404 mswindows_initialize_image_instance_icon(ii, TRUE); |
363 void *bmp_data, | 411 void *bmp_data, |
364 int bmp_bits, | 412 int bmp_bits, |
365 int slice, | 413 int slice, |
366 Lisp_Object instantiator) | 414 Lisp_Object instantiator) |
367 { | 415 { |
368 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 416 struct device *d = XDEVICE (IMAGE_INSTANCE_DEVICE (ii)); |
369 struct device *d = XDEVICE (device); | |
370 struct frame *f = XFRAME (DEVICE_SELECTED_FRAME (d)); | |
371 void* bmp_buf=0; | 417 void* bmp_buf=0; |
372 HDC hdc = FRAME_MSWINDOWS_CDC (f); | 418 |
373 HBITMAP bitmap = CreateDIBSection (hdc, | 419 HBITMAP bitmap = CreateDIBSection (get_device_compdc (d), |
374 bmp_info, | 420 bmp_info, |
375 DIB_RGB_COLORS, | 421 DIB_RGB_COLORS, |
376 &bmp_buf, | 422 &bmp_buf, |
377 0,0); | 423 0,0); |
378 | 424 |
398 unsigned char* bmp_data; | 444 unsigned char* bmp_data; |
399 int bmp_bits; | 445 int bmp_bits; |
400 COLORREF bkcolor; | 446 COLORREF bkcolor; |
401 int slice; | 447 int slice; |
402 | 448 |
403 if (!DEVICE_MSWINDOWS_P (XDEVICE (device))) | 449 CHECK_MSGDI_DEVICE (device); |
404 signal_simple_error ("Not an mswindows device", device); | |
405 | 450 |
406 /* this is a hack but MaskBlt and TransparentBlt are not supported | 451 /* this is a hack but MaskBlt and TransparentBlt are not supported |
407 on most windows variants */ | 452 on most windows variants */ |
408 bkcolor = COLOR_INSTANCE_MSWINDOWS_COLOR | 453 bkcolor = COLOR_INSTANCE_MSWINDOWS_COLOR |
409 (XCOLOR_INSTANCE (FACE_BACKGROUND (Vdefault_face, domain))); | 454 (XCOLOR_INSTANCE (FACE_BACKGROUND (Vdefault_face, domain))); |
431 xfree (bmp_info); | 476 xfree (bmp_info); |
432 xfree (bmp_data); | 477 xfree (bmp_data); |
433 } | 478 } |
434 } | 479 } |
435 | 480 |
436 static void set_mono_pixel ( unsigned char* bits, | 481 inline static void |
437 int bpline, int height, | 482 set_mono_pixel (unsigned char* bits, |
438 int x, int y, int white ) | 483 int bpline, int height, |
484 int x, int y, int white) | |
439 { | 485 { |
440 int i; | 486 int i; |
441 unsigned char bitnum; | 487 unsigned char bitnum; |
442 /* Find the byte on which this scanline begins */ | 488 /* Find the byte on which this scanline begins */ |
443 i = (height - y - 1) * bpline; | 489 i = (height - y - 1) * bpline; |
444 /* Find the byte containing this pixel */ | 490 /* Find the byte containing this pixel */ |
445 i += (x >> 3); | 491 i += (x >> 3); |
446 /* Which bit is it? */ | 492 /* Which bit is it? */ |
447 bitnum = (unsigned char)( 7 - (x % 8) ); | 493 bitnum = (unsigned char) (7 - (x & 7)); |
448 if( white ) /* Turn it on */ | 494 if (white) /* Turn it on */ |
449 bits[i] |= (1<<bitnum); | 495 bits[i] |= (1 << bitnum); |
450 else /* Turn it off */ | 496 else /* Turn it off */ |
451 bits[i] &= ~(1<<bitnum); | 497 bits[i] &= ~(1 << bitnum); |
452 } | 498 } |
453 | 499 |
454 static void | 500 static void |
455 mswindows_initialize_image_instance_mask (Lisp_Image_Instance* image, | 501 mswindows_initialize_image_instance_mask (Lisp_Image_Instance* image, |
456 struct frame* f) | 502 HDC hcdc) |
457 { | 503 { |
458 HBITMAP mask; | 504 HBITMAP mask; |
459 HGDIOBJ old = NULL; | 505 HGDIOBJ old = NULL; |
460 HDC hcdc = FRAME_MSWINDOWS_CDC (f); | 506 unsigned char *dibits, *and_bits; |
461 unsigned char* dibits; | 507 BITMAPINFO *bmp_info = |
462 BITMAPINFO* bmp_info = | 508 (BITMAPINFO*) xmalloc_and_zero (sizeof (BITMAPINFO) + sizeof (RGBQUAD)); |
463 xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD)); | |
464 int i, j; | 509 int i, j; |
465 int height = IMAGE_INSTANCE_PIXMAP_HEIGHT (image); | 510 int height = IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (image); |
466 | 511 |
467 void* and_bits; | 512 int maskbpline = BPLINE ((IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image) + 7) / 8); |
468 int maskbpline = BPLINE ((IMAGE_INSTANCE_PIXMAP_WIDTH (image)+7)/8); | 513 int bpline = BPLINE (IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image) * 3); |
469 int bpline = BPLINE (IMAGE_INSTANCE_PIXMAP_WIDTH (image) * 3); | |
470 | 514 |
471 if (!bmp_info) | 515 if (!bmp_info) |
472 return; | 516 return; |
473 | 517 |
474 bmp_info->bmiHeader.biWidth=IMAGE_INSTANCE_PIXMAP_WIDTH (image); | 518 bmp_info->bmiHeader.biWidth=IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image); |
475 bmp_info->bmiHeader.biHeight = height; | 519 bmp_info->bmiHeader.biHeight = height; |
476 bmp_info->bmiHeader.biPlanes=1; | 520 bmp_info->bmiHeader.biPlanes = 1; |
477 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); | 521 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); |
478 bmp_info->bmiHeader.biBitCount=1; | 522 bmp_info->bmiHeader.biBitCount = 1; |
479 bmp_info->bmiHeader.biCompression=BI_RGB; | 523 bmp_info->bmiHeader.biCompression = BI_RGB; |
480 bmp_info->bmiHeader.biClrUsed = 2; | 524 bmp_info->bmiHeader.biClrUsed = 2; |
481 bmp_info->bmiHeader.biClrImportant = 2; | 525 bmp_info->bmiHeader.biClrImportant = 2; |
482 bmp_info->bmiHeader.biSizeImage = height * maskbpline; | 526 bmp_info->bmiHeader.biSizeImage = height * maskbpline; |
483 bmp_info->bmiColors[0].rgbRed = 0; | 527 bmp_info->bmiColors[0].rgbRed = 0; |
484 bmp_info->bmiColors[0].rgbGreen = 0; | 528 bmp_info->bmiColors[0].rgbGreen = 0; |
490 bmp_info->bmiColors[0].rgbReserved = 0; | 534 bmp_info->bmiColors[0].rgbReserved = 0; |
491 | 535 |
492 if (!(mask = CreateDIBSection (hcdc, | 536 if (!(mask = CreateDIBSection (hcdc, |
493 bmp_info, | 537 bmp_info, |
494 DIB_RGB_COLORS, | 538 DIB_RGB_COLORS, |
495 &and_bits, | 539 (void**)&and_bits, |
496 0,0))) | 540 0,0))) |
497 { | 541 { |
498 xfree (bmp_info); | 542 xfree (bmp_info); |
499 return; | 543 return; |
500 } | 544 } |
501 | 545 |
502 old = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_BITMAP (image)); | 546 old = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_BITMAP (image)); |
503 /* build up an in-memory set of bits to mess with */ | 547 /* build up an in-memory set of bits to mess with */ |
504 xzero (*bmp_info); | 548 xzero (*bmp_info); |
505 | 549 |
506 bmp_info->bmiHeader.biWidth=IMAGE_INSTANCE_PIXMAP_WIDTH (image); | 550 bmp_info->bmiHeader.biWidth = IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image); |
507 bmp_info->bmiHeader.biHeight = -height; | 551 bmp_info->bmiHeader.biHeight = -height; |
508 bmp_info->bmiHeader.biPlanes=1; | 552 bmp_info->bmiHeader.biPlanes = 1; |
509 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); | 553 bmp_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
510 bmp_info->bmiHeader.biBitCount=24; | 554 bmp_info->bmiHeader.biBitCount = 24; |
511 bmp_info->bmiHeader.biCompression=BI_RGB; | 555 bmp_info->bmiHeader.biCompression = BI_RGB; |
512 bmp_info->bmiHeader.biClrUsed = 0; | 556 bmp_info->bmiHeader.biClrUsed = 0; |
513 bmp_info->bmiHeader.biClrImportant = 0; | 557 bmp_info->bmiHeader.biClrImportant = 0; |
514 bmp_info->bmiHeader.biSizeImage = height * bpline; | 558 bmp_info->bmiHeader.biSizeImage = height * bpline; |
515 | 559 |
516 dibits = xmalloc_and_zero (bpline * height); | 560 dibits = (unsigned char*) xmalloc_and_zero (bpline * height); |
517 if (GetDIBits (hcdc, | 561 if (GetDIBits (hcdc, |
518 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image), | 562 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image), |
519 0, | 563 0, |
520 height, | 564 height, |
521 dibits, | 565 dibits, |
526 return; | 570 return; |
527 } | 571 } |
528 | 572 |
529 /* now set the colored bits in the mask and transparent ones to | 573 /* now set the colored bits in the mask and transparent ones to |
530 black in the original */ | 574 black in the original */ |
531 for(i=0; i<IMAGE_INSTANCE_PIXMAP_WIDTH (image); i++) | 575 for (i = 0; i < IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image); i++) |
532 { | 576 { |
533 for(j=0; j<height; j++) | 577 for (j=0; j<height; j++) |
534 { | 578 { |
535 unsigned char* idx = &dibits[j * bpline + i * 3]; | 579 unsigned char* idx = &dibits[j * bpline + i * 3]; |
536 | 580 |
537 if( RGB (idx[2], idx[1], idx[0]) == transparent_color ) | 581 if (RGB (idx[2], idx[1], idx[0]) == transparent_color) |
538 { | 582 { |
539 idx[0] = idx[1] = idx[2] = 0; | 583 idx[0] = idx[1] = idx[2] = 0; |
540 set_mono_pixel( and_bits, maskbpline, height, i, j, TRUE ); | 584 set_mono_pixel (and_bits, maskbpline, height, i, j, TRUE); |
541 } | 585 } |
542 else | 586 else |
543 { | 587 { |
544 set_mono_pixel( and_bits, maskbpline, height, i, j, FALSE ); | 588 set_mono_pixel (and_bits, maskbpline, height, i, j, FALSE); |
545 } | 589 } |
546 } | 590 } |
547 } | 591 } |
548 | 592 |
549 SetDIBits (hcdc, | 593 SetDIBits (hcdc, |
577 | 621 |
578 IMAGE_INSTANCE_MSWINDOWS_ICON (image)= | 622 IMAGE_INSTANCE_MSWINDOWS_ICON (image)= |
579 CreateIconIndirect (&x_icon); | 623 CreateIconIndirect (&x_icon); |
580 } | 624 } |
581 | 625 |
626 static HBITMAP | |
627 create_resized_bitmap (HBITMAP curbmp, struct frame *f, | |
628 int curx, int cury, | |
629 int newx, int newy) | |
630 { | |
631 HBITMAP newbmp; | |
632 HGDIOBJ old1, old2; | |
633 | |
634 HDC hcdc = get_device_compdc (XDEVICE (FRAME_DEVICE (f))); | |
635 HDC hdcDst = CreateCompatibleDC (hcdc); | |
636 | |
637 old1 = SelectObject (hcdc, curbmp); | |
638 | |
639 newbmp = CreateCompatibleBitmap (hcdc, newx, newy); | |
640 | |
641 old2 = SelectObject (hdcDst, newbmp); | |
642 | |
643 if (!StretchBlt (hdcDst, 0, 0, newx, newy, | |
644 hcdc, 0, 0, | |
645 curx, | |
646 cury, | |
647 SRCCOPY)) | |
648 { | |
649 DeleteObject (newbmp); | |
650 DeleteDC (hdcDst); | |
651 return 0; | |
652 } | |
653 | |
654 SelectObject (hdcDst, old2); | |
655 SelectObject (hcdc, old1); | |
656 DeleteDC (hdcDst); | |
657 | |
658 return newbmp; | |
659 } | |
660 | |
582 HBITMAP | 661 HBITMAP |
583 mswindows_create_resized_bitmap (Lisp_Image_Instance* ii, | 662 mswindows_create_resized_bitmap (Lisp_Image_Instance* ii, |
584 struct frame* f, | 663 struct frame* f, |
585 int newx, int newy) | 664 int newx, int newy) |
586 { | 665 { |
587 HBITMAP newbmp; | 666 return create_resized_bitmap (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii), |
588 HGDIOBJ old1, old2; | 667 f, |
589 HDC hcdc = FRAME_MSWINDOWS_CDC (f); | 668 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii), |
590 HDC hdcDst = CreateCompatibleDC (hcdc); | 669 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii), |
591 | 670 newx, newy); |
592 old1 = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii)); | |
593 | |
594 newbmp = CreateCompatibleBitmap (hcdc, newx, newy); | |
595 | |
596 old2 = SelectObject (hdcDst, newbmp); | |
597 | |
598 if (!StretchBlt (hdcDst, 0, 0, newx, newy, | |
599 hcdc, 0, 0, | |
600 IMAGE_INSTANCE_PIXMAP_WIDTH (ii), | |
601 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii), | |
602 SRCCOPY)) | |
603 { | |
604 DeleteObject (newbmp); | |
605 DeleteDC (hdcDst); | |
606 return 0; | |
607 } | |
608 | |
609 SelectObject (hdcDst, old2); | |
610 SelectObject (hcdc, old1); | |
611 DeleteDC (hdcDst); | |
612 | |
613 return newbmp; | |
614 } | 671 } |
615 | 672 |
616 HBITMAP | 673 HBITMAP |
617 mswindows_create_resized_mask (Lisp_Image_Instance* ii, | 674 mswindows_create_resized_mask (Lisp_Image_Instance* ii, |
618 struct frame* f, | 675 struct frame* f, |
619 int newx, int newy) | 676 int newx, int newy) |
620 { | 677 { |
621 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii)) | 678 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii) == NULL) |
622 { | 679 return NULL; |
623 HBITMAP newmask; | 680 |
624 HGDIOBJ old1, old2; | 681 return create_resized_bitmap (IMAGE_INSTANCE_MSWINDOWS_MASK (ii), |
625 HDC hcdc = FRAME_MSWINDOWS_CDC (f); | 682 f, |
626 HDC hdcDst = CreateCompatibleDC (hcdc); | 683 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii), |
627 | 684 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii), |
628 old1 = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_MASK (ii)); | 685 newx, newy); |
629 newmask = CreateCompatibleBitmap(hcdc, newx, newy); | 686 } |
630 old2 = SelectObject (hdcDst, newmask); | 687 |
631 | 688 #if 0 /* Currently unused */ |
632 if (!StretchBlt(hdcDst, 0, 0, newx, newy, | 689 /* #### Warning: This function is not correct anymore with |
633 hcdc, 0, 0, | 690 resizable printer bitmaps. If you uncomment it, clean it. --kkm */ |
634 IMAGE_INSTANCE_PIXMAP_WIDTH (ii), | |
635 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii), | |
636 SRCCOPY)) | |
637 { | |
638 DeleteObject (newmask); | |
639 DeleteDC (hdcDst); | |
640 return NULL; | |
641 } | |
642 | |
643 SelectObject (hdcDst, old2); | |
644 SelectObject (hcdc, old1); | |
645 | |
646 DeleteDC (hdcDst); | |
647 | |
648 return newmask; | |
649 } | |
650 | |
651 return NULL; | |
652 } | |
653 | |
654 int | 691 int |
655 mswindows_resize_dibitmap_instance (Lisp_Image_Instance* ii, | 692 mswindows_resize_dibitmap_instance (Lisp_Image_Instance* ii, |
656 struct frame* f, | 693 struct frame* f, |
657 int newx, int newy) | 694 int newx, int newy) |
658 { | 695 { |
672 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = newx; | 709 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = newx; |
673 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = newy; | 710 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = newy; |
674 | 711 |
675 return TRUE; | 712 return TRUE; |
676 } | 713 } |
714 #endif | |
677 | 715 |
678 /********************************************************************** | 716 /********************************************************************** |
679 * XPM * | 717 * XPM * |
680 **********************************************************************/ | 718 **********************************************************************/ |
681 | 719 |
750 free_cons (XCONS (cons)); | 788 free_cons (XCONS (cons)); |
751 } | 789 } |
752 return colortbl; | 790 return colortbl; |
753 } | 791 } |
754 | 792 |
755 static int xpm_to_eimage (Lisp_Object image, CONST Extbyte *buffer, | 793 static int xpm_to_eimage (Lisp_Object image, const Extbyte *buffer, |
756 unsigned char** data, | 794 unsigned char** data, |
757 int* width, int* height, | 795 int* width, int* height, |
758 int* x_hot, int* y_hot, | 796 int* x_hot, int* y_hot, |
759 int* transp, | 797 int* transp, |
760 struct color_symbol* color_symbols, | 798 struct color_symbol* color_symbols, |
790 "out of memory", image); | 828 "out of memory", image); |
791 } | 829 } |
792 default: | 830 default: |
793 { | 831 { |
794 signal_double_file_error_2 ("Parsing pixmap data", | 832 signal_double_file_error_2 ("Parsing pixmap data", |
795 "unknown error code", | 833 "unknown error", |
796 make_int (result), image); | 834 make_int (result), image); |
797 } | 835 } |
798 } | 836 } |
799 | 837 |
800 *width = xpmimage.width; | 838 *width = xpmimage.width; |
906 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 944 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
907 int dest_mask, Lisp_Object domain) | 945 int dest_mask, Lisp_Object domain) |
908 { | 946 { |
909 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 947 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
910 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 948 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
911 CONST Extbyte *bytes; | 949 const Extbyte *bytes; |
912 Extcount len; | 950 Extcount len; |
913 unsigned char *eimage; | 951 unsigned char *eimage; |
914 int width, height, x_hot, y_hot; | 952 int width, height, x_hot, y_hot; |
915 BITMAPINFO* bmp_info; | 953 BITMAPINFO* bmp_info; |
916 unsigned char* bmp_data; | 954 unsigned char* bmp_data; |
920 | 958 |
921 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 959 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
922 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator, | 960 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator, |
923 Q_color_symbols); | 961 Q_color_symbols); |
924 | 962 |
925 if (!DEVICE_MSWINDOWS_P (XDEVICE (device))) | 963 CHECK_MSGDI_DEVICE (device); |
926 signal_simple_error ("Not an mswindows device", device); | |
927 | 964 |
928 assert (!NILP (data)); | 965 assert (!NILP (data)); |
929 | 966 |
930 TO_EXTERNAL_FORMAT (LISP_STRING, data, | 967 TO_EXTERNAL_FORMAT (LISP_STRING, data, |
931 ALLOCA, (bytes, len), | 968 ALLOCA, (bytes, len), |
980 { | 1017 { |
981 file_or_data_must_be_present (instantiator); | 1018 file_or_data_must_be_present (instantiator); |
982 } | 1019 } |
983 | 1020 |
984 static Lisp_Object | 1021 static Lisp_Object |
985 bmp_normalize (Lisp_Object inst, Lisp_Object console_type) | 1022 bmp_normalize (Lisp_Object inst, Lisp_Object console_type, |
1023 Lisp_Object dest_mask) | |
986 { | 1024 { |
987 return simple_image_type_normalize (inst, console_type, Qbmp); | 1025 return simple_image_type_normalize (inst, console_type, Qbmp); |
988 } | 1026 } |
989 | 1027 |
990 static int | 1028 static int |
998 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 1036 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
999 int dest_mask, Lisp_Object domain) | 1037 int dest_mask, Lisp_Object domain) |
1000 { | 1038 { |
1001 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 1039 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
1002 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 1040 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
1003 CONST Extbyte *bytes; | 1041 const Extbyte *bytes; |
1004 Extcount len; | 1042 Extcount len; |
1005 BITMAPFILEHEADER* bmp_file_header; | 1043 BITMAPFILEHEADER* bmp_file_header; |
1006 BITMAPINFO* bmp_info; | 1044 BITMAPINFO* bmp_info; |
1007 void* bmp_data; | 1045 void* bmp_data; |
1008 int bmp_bits; | 1046 int bmp_bits; |
1009 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 1047 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
1010 | 1048 |
1011 if (!DEVICE_MSWINDOWS_P (XDEVICE (device))) | 1049 CHECK_MSGDI_DEVICE (device); |
1012 signal_simple_error ("Not an mswindows device", device); | |
1013 | 1050 |
1014 assert (!NILP (data)); | 1051 assert (!NILP (data)); |
1015 | 1052 |
1016 TO_EXTERNAL_FORMAT (LISP_STRING, data, | 1053 TO_EXTERNAL_FORMAT (LISP_STRING, data, |
1017 ALLOCA, (bytes, len), | 1054 ALLOCA, (bytes, len), |
1048 signal_simple_error ("Must supply :file, :resource-id and :resource-type", | 1085 signal_simple_error ("Must supply :file, :resource-id and :resource-type", |
1049 instantiator); | 1086 instantiator); |
1050 } | 1087 } |
1051 | 1088 |
1052 static Lisp_Object | 1089 static Lisp_Object |
1053 mswindows_resource_normalize (Lisp_Object inst, Lisp_Object console_type) | 1090 mswindows_resource_normalize (Lisp_Object inst, Lisp_Object console_type, |
1091 Lisp_Object dest_mask) | |
1054 { | 1092 { |
1055 /* This function can call lisp */ | 1093 /* This function can call lisp */ |
1056 Lisp_Object file = Qnil; | 1094 Lisp_Object file = Qnil; |
1057 struct gcpro gcpro1, gcpro2; | 1095 struct gcpro gcpro1, gcpro2; |
1058 Lisp_Object alist = Qnil; | 1096 Lisp_Object alist = Qnil; |
1102 #define OIC_HAND 32513 | 1140 #define OIC_HAND 32513 |
1103 #define OIC_QUES 32514 | 1141 #define OIC_QUES 32514 |
1104 #define OIC_BANG 32515 | 1142 #define OIC_BANG 32515 |
1105 #define OIC_NOTE 32516 | 1143 #define OIC_NOTE 32516 |
1106 #define OIC_WINLOGO 32517 | 1144 #define OIC_WINLOGO 32517 |
1107 #if defined (__CYGWIN32__) && CYGWIN_VERSION_DLL_MAJOR < 21 | 1145 #if defined (CYGWIN) && CYGWIN_VERSION_DLL_MAJOR < 21 |
1108 #define LR_SHARED 0x8000 | 1146 #define LR_SHARED 0x8000 |
1109 #endif | 1147 #endif |
1110 #endif | 1148 #endif |
1111 | 1149 |
1112 static CONST resource_t bitmap_table[] = | 1150 static const resource_t bitmap_table[] = |
1113 { | 1151 { |
1114 /* bitmaps */ | 1152 /* bitmaps */ |
1115 { "close", OBM_CLOSE }, | 1153 { "close", OBM_CLOSE }, |
1116 { "uparrow", OBM_UPARROW }, | 1154 { "uparrow", OBM_UPARROW }, |
1117 { "dnarrow", OBM_DNARROW }, | 1155 { "dnarrow", OBM_DNARROW }, |
1139 { "checkboxes", OBM_CHECKBOXES }, | 1177 { "checkboxes", OBM_CHECKBOXES }, |
1140 { "btncorners" , OBM_BTNCORNERS }, | 1178 { "btncorners" , OBM_BTNCORNERS }, |
1141 {0} | 1179 {0} |
1142 }; | 1180 }; |
1143 | 1181 |
1144 static CONST resource_t cursor_table[] = | 1182 static const resource_t cursor_table[] = |
1145 { | 1183 { |
1146 /* cursors */ | 1184 /* cursors */ |
1147 { "normal", OCR_NORMAL }, | 1185 { "normal", OCR_NORMAL }, |
1148 { "ibeam", OCR_IBEAM }, | 1186 { "ibeam", OCR_IBEAM }, |
1149 { "wait", OCR_WAIT }, | 1187 { "wait", OCR_WAIT }, |
1158 /* { "icour", OCR_ICOCUR }, */ | 1196 /* { "icour", OCR_ICOCUR }, */ |
1159 { "no", OCR_NO }, | 1197 { "no", OCR_NO }, |
1160 { 0 } | 1198 { 0 } |
1161 }; | 1199 }; |
1162 | 1200 |
1163 static CONST resource_t icon_table[] = | 1201 static const resource_t icon_table[] = |
1164 { | 1202 { |
1165 /* icons */ | 1203 /* icons */ |
1166 { "sample", OIC_SAMPLE }, | 1204 { "sample", OIC_SAMPLE }, |
1167 { "hand", OIC_HAND }, | 1205 { "hand", OIC_HAND }, |
1168 { "ques", OIC_QUES }, | 1206 { "ques", OIC_QUES }, |
1172 {0} | 1210 {0} |
1173 }; | 1211 }; |
1174 | 1212 |
1175 static int resource_name_to_resource (Lisp_Object name, int type) | 1213 static int resource_name_to_resource (Lisp_Object name, int type) |
1176 { | 1214 { |
1177 CONST resource_t* res = (type == IMAGE_CURSOR ? cursor_table | 1215 const resource_t* res = (type == IMAGE_CURSOR ? cursor_table |
1178 : type == IMAGE_ICON ? icon_table | 1216 : type == IMAGE_ICON ? icon_table |
1179 : bitmap_table); | 1217 : bitmap_table); |
1180 | 1218 |
1181 if (INTP (name)) | 1219 if (INTP (name)) |
1182 { | 1220 { |
1220 unsigned int type = 0; | 1258 unsigned int type = 0; |
1221 HANDLE himage = NULL; | 1259 HANDLE himage = NULL; |
1222 LPCTSTR resid=0; | 1260 LPCTSTR resid=0; |
1223 HINSTANCE hinst = NULL; | 1261 HINSTANCE hinst = NULL; |
1224 ICONINFO iconinfo; | 1262 ICONINFO iconinfo; |
1225 int iitype=0; | 1263 enum image_instance_type iitype; |
1226 char* fname=0; | 1264 char* fname=0; |
1227 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 1265 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
1228 | 1266 |
1229 Lisp_Object file = find_keyword_in_vector (instantiator, Q_file); | 1267 Lisp_Object file = find_keyword_in_vector (instantiator, Q_file); |
1230 Lisp_Object resource_type = find_keyword_in_vector (instantiator, | 1268 Lisp_Object resource_type = find_keyword_in_vector (instantiator, |
1232 Lisp_Object resource_id = find_keyword_in_vector (instantiator, | 1270 Lisp_Object resource_id = find_keyword_in_vector (instantiator, |
1233 Q_resource_id); | 1271 Q_resource_id); |
1234 | 1272 |
1235 xzero (iconinfo); | 1273 xzero (iconinfo); |
1236 | 1274 |
1237 if (!DEVICE_MSWINDOWS_P (XDEVICE (device))) | 1275 CHECK_MSGDI_DEVICE (device); |
1238 signal_simple_error ("Not an mswindows device", device); | |
1239 | 1276 |
1240 type = resource_symbol_to_type (resource_type); | 1277 type = resource_symbol_to_type (resource_type); |
1241 | 1278 |
1242 if (dest_mask & IMAGE_POINTER_MASK && type == IMAGE_CURSOR) | 1279 if (dest_mask & IMAGE_POINTER_MASK && type == IMAGE_CURSOR) |
1243 iitype = IMAGE_POINTER; | 1280 iitype = IMAGE_POINTER; |
1252 { | 1289 { |
1253 Extbyte* f=0; | 1290 Extbyte* f=0; |
1254 TO_EXTERNAL_FORMAT (LISP_STRING, file, | 1291 TO_EXTERNAL_FORMAT (LISP_STRING, file, |
1255 C_STRING_ALLOCA, f, | 1292 C_STRING_ALLOCA, f, |
1256 Qfile_name); | 1293 Qfile_name); |
1257 #ifdef __CYGWIN32__ | 1294 #ifdef CYGWIN |
1258 CYGWIN_WIN32_PATH (f, fname); | 1295 CYGWIN_WIN32_PATH (f, fname); |
1259 #else | 1296 #else |
1260 fname = f; | 1297 fname = f; |
1261 #endif | 1298 #endif |
1262 | 1299 |
1278 else if (!(resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id, | 1315 else if (!(resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id, |
1279 type)))) | 1316 type)))) |
1280 signal_simple_error ("Invalid resource identifier", resource_id); | 1317 signal_simple_error ("Invalid resource identifier", resource_id); |
1281 | 1318 |
1282 /* load the image */ | 1319 /* load the image */ |
1283 if (!(himage = LoadImage (hinst, resid, type, 0, 0, | 1320 if (xLoadImageA) /* not in NT 3.5 */ |
1284 LR_CREATEDIBSECTION | LR_DEFAULTSIZE | | 1321 { |
1285 LR_SHARED | | 1322 if (!(himage = xLoadImageA (hinst, resid, type, 0, 0, |
1286 (!NILP (file) ? LR_LOADFROMFILE : 0)))) | 1323 LR_CREATEDIBSECTION | LR_DEFAULTSIZE | |
1287 { | 1324 LR_SHARED | |
1288 signal_simple_error ("Cannot load image", instantiator); | 1325 (!NILP (file) ? LR_LOADFROMFILE : 0)))) |
1326 signal_simple_error ("Cannot load image", instantiator); | |
1327 } | |
1328 else | |
1329 { | |
1330 /* Is this correct? I don't really care. */ | |
1331 switch (type) | |
1332 { | |
1333 case IMAGE_BITMAP: | |
1334 himage = LoadBitmap (hinst, resid); | |
1335 break; | |
1336 case IMAGE_CURSOR: | |
1337 himage = LoadCursor (hinst, resid); | |
1338 break; | |
1339 case IMAGE_ICON: | |
1340 himage = LoadIcon (hinst, resid); | |
1341 break; | |
1342 } | |
1343 | |
1344 if (!himage) | |
1345 signal_simple_error ("Cannot load image", instantiator); | |
1289 } | 1346 } |
1290 | 1347 |
1291 if (hinst) | 1348 if (hinst) |
1292 FreeLibrary (hinst); | 1349 FreeLibrary (hinst); |
1293 | 1350 |
1294 mswindows_initialize_dibitmap_image_instance (ii, 1, iitype); | 1351 mswindows_initialize_dibitmap_image_instance (ii, 1, iitype); |
1295 | 1352 |
1296 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = file; | 1353 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = file; |
1297 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = | 1354 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii) = |
1298 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CXCURSOR : SM_CXICON); | 1355 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CXCURSOR : SM_CXICON); |
1299 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = | 1356 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii) = |
1300 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CYCURSOR : SM_CYICON); | 1357 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CYCURSOR : SM_CYICON); |
1301 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1; | 1358 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1; |
1359 init_image_instance_geometry (ii); | |
1302 | 1360 |
1303 /* hey, we've got an icon type thing so we can reverse engineer the | 1361 /* hey, we've got an icon type thing so we can reverse engineer the |
1304 bitmap and mask */ | 1362 bitmap and mask */ |
1305 if (type != IMAGE_BITMAP) | 1363 if (type != IMAGE_BITMAP) |
1306 { | 1364 { |
1307 GetIconInfo (himage, &iconinfo); | 1365 GetIconInfo ((HICON)himage, &iconinfo); |
1308 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = iconinfo.hbmColor; | 1366 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = iconinfo.hbmColor; |
1309 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = iconinfo.hbmMask; | 1367 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = iconinfo.hbmMask; |
1310 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), iconinfo.xHotspot); | 1368 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), iconinfo.xHotspot); |
1311 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), iconinfo.yHotspot); | 1369 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), iconinfo.yHotspot); |
1312 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = himage; | 1370 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = (HICON) himage; |
1313 } | 1371 } |
1314 else | 1372 else |
1315 { | 1373 { |
1316 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = NULL; | 1374 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = NULL; |
1317 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = himage; | 1375 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = (HBITMAP) himage; |
1318 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL; | 1376 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL; |
1319 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0); | 1377 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0); |
1320 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0); | 1378 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0); |
1321 } | 1379 } |
1322 } | 1380 } |
1406 | 1464 |
1407 /* | 1465 /* |
1408 * Table index for the hex values. Initialized once, first time. | 1466 * Table index for the hex values. Initialized once, first time. |
1409 * Used for translation value or delimiter significance lookup. | 1467 * Used for translation value or delimiter significance lookup. |
1410 */ | 1468 */ |
1411 static void initHexTable() | 1469 static void |
1470 initHexTable (void) | |
1412 { | 1471 { |
1413 /* | 1472 /* |
1414 * We build the table at run time for several reasons: | 1473 * We build the table at run time for several reasons: |
1415 * | 1474 * |
1416 * 1. portable to non-ASCII machines. | 1475 * 1. portable to non-ASCII machines. |
1439 } | 1498 } |
1440 | 1499 |
1441 /* | 1500 /* |
1442 * read next hex value in the input stream, return -1 if EOF | 1501 * read next hex value in the input stream, return -1 if EOF |
1443 */ | 1502 */ |
1444 static int NextInt ( FILE *fstream ) | 1503 static int |
1504 NextInt (FILE *fstream) | |
1445 { | 1505 { |
1446 int ch; | 1506 int ch; |
1447 int value = 0; | 1507 int value = 0; |
1448 int gotone = 0; | 1508 int gotone = 0; |
1449 int done = 0; | 1509 int done = 0; |
1474 * The data returned by the following routine is always in left-most byte | 1534 * The data returned by the following routine is always in left-most byte |
1475 * first and left-most bit first. If it doesn't return BitmapSuccess then | 1535 * first and left-most bit first. If it doesn't return BitmapSuccess then |
1476 * its arguments won't have been touched. This routine should look as much | 1536 * its arguments won't have been touched. This routine should look as much |
1477 * like the Xlib routine XReadBitmapfile as possible. | 1537 * like the Xlib routine XReadBitmapfile as possible. |
1478 */ | 1538 */ |
1479 int read_bitmap_data (fstream, width, height, datap, x_hot, y_hot) | 1539 int read_bitmap_data (FILE* fstream, unsigned int *width, |
1480 FILE *fstream; /* handle on file */ | 1540 unsigned int *height, unsigned char **datap, |
1481 unsigned int *width, *height; /* RETURNED */ | 1541 int *x_hot, int *y_hot) |
1482 unsigned char **datap; /* RETURNED */ | |
1483 int *x_hot, *y_hot; /* RETURNED */ | |
1484 { | 1542 { |
1485 unsigned char *data = NULL; /* working variable */ | 1543 unsigned char *data = NULL; /* working variable */ |
1486 char line[MAX_SIZE]; /* input line from file */ | 1544 char line[MAX_SIZE]; /* input line from file */ |
1487 int size; /* number of bytes of data */ | 1545 int size; /* number of bytes of data */ |
1488 char name_and_type[MAX_SIZE]; /* an input line */ | 1546 char name_and_type[MAX_SIZE]; /* an input line */ |
1598 | 1656 |
1599 RETURN (BitmapSuccess); | 1657 RETURN (BitmapSuccess); |
1600 } | 1658 } |
1601 | 1659 |
1602 | 1660 |
1603 int read_bitmap_data_from_file (CONST char *filename, unsigned int *width, | 1661 int read_bitmap_data_from_file (const char *filename, unsigned int *width, |
1604 unsigned int *height, unsigned char **datap, | 1662 unsigned int *height, unsigned char **datap, |
1605 int *x_hot, int *y_hot) | 1663 int *x_hot, int *y_hot) |
1606 { | 1664 { |
1607 FILE *fstream; | 1665 FILE *fstream; |
1608 int status; | 1666 int status; |
1638 int new_width = BPLINE (2*((width + 15)/16)); | 1696 int new_width = BPLINE (2*((width + 15)/16)); |
1639 unsigned char *offset; | 1697 unsigned char *offset; |
1640 void *bmp_buf = 0; | 1698 void *bmp_buf = 0; |
1641 unsigned char *new_data, *new_offset; | 1699 unsigned char *new_data, *new_offset; |
1642 int i, j; | 1700 int i, j; |
1643 BITMAPINFO* bmp_info = | 1701 BITMAPINFO *bmp_info = |
1644 xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD)); | 1702 (BITMAPINFO*) xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD)); |
1645 HBITMAP bitmap; | 1703 HBITMAP bitmap; |
1646 | 1704 |
1647 if (!bmp_info) | 1705 if (!bmp_info) |
1648 return NULL; | 1706 return NULL; |
1649 | 1707 |
1722 | 1780 |
1723 static void | 1781 static void |
1724 init_image_instance_from_xbm_inline (Lisp_Image_Instance *ii, | 1782 init_image_instance_from_xbm_inline (Lisp_Image_Instance *ii, |
1725 int width, int height, | 1783 int width, int height, |
1726 /* Note that data is in ext-format! */ | 1784 /* Note that data is in ext-format! */ |
1727 CONST char *bits, | 1785 const char *bits, |
1728 Lisp_Object instantiator, | 1786 Lisp_Object instantiator, |
1729 Lisp_Object pointer_fg, | 1787 Lisp_Object pointer_fg, |
1730 Lisp_Object pointer_bg, | 1788 Lisp_Object pointer_bg, |
1731 int dest_mask, | 1789 int dest_mask, |
1732 HBITMAP mask, | 1790 HBITMAP mask, |
1733 Lisp_Object mask_filename) | 1791 Lisp_Object mask_filename) |
1734 { | 1792 { |
1735 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 1793 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
1736 struct frame* f = XFRAME (DEVICE_SELECTED_FRAME (XDEVICE (device))); | |
1737 Lisp_Object foreground = find_keyword_in_vector (instantiator, Q_foreground); | 1794 Lisp_Object foreground = find_keyword_in_vector (instantiator, Q_foreground); |
1738 Lisp_Object background = find_keyword_in_vector (instantiator, Q_background); | 1795 Lisp_Object background = find_keyword_in_vector (instantiator, Q_background); |
1739 enum image_instance_type type; | 1796 enum image_instance_type type; |
1740 COLORREF black = PALETTERGB (0,0,0); | 1797 COLORREF black = PALETTERGB (0,0,0); |
1741 COLORREF white = PALETTERGB (255,255,255); | 1798 COLORREF white = PALETTERGB (255,255,255); |
1742 | 1799 HDC hdc; |
1743 HDC hdc = FRAME_MSWINDOWS_CDC (f); | 1800 |
1744 | 1801 CHECK_MSGDI_DEVICE (device); |
1745 if (!DEVICE_MSWINDOWS_P (XDEVICE (device))) | 1802 |
1746 signal_simple_error ("Not an MS-Windows device", device); | 1803 hdc = get_device_compdc (XDEVICE (device)); |
1747 | 1804 |
1748 if ((dest_mask & IMAGE_MONO_PIXMAP_MASK) && | 1805 if ((dest_mask & IMAGE_MONO_PIXMAP_MASK) && |
1749 (dest_mask & IMAGE_COLOR_PIXMAP_MASK)) | 1806 (dest_mask & IMAGE_COLOR_PIXMAP_MASK)) |
1750 { | 1807 { |
1751 if (!NILP (foreground) || !NILP (background)) | 1808 if (!NILP (foreground) || !NILP (background)) |
1766 | 1823 |
1767 mswindows_initialize_dibitmap_image_instance (ii, 1, type); | 1824 mswindows_initialize_dibitmap_image_instance (ii, 1, type); |
1768 | 1825 |
1769 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = | 1826 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = |
1770 find_keyword_in_vector (instantiator, Q_file); | 1827 find_keyword_in_vector (instantiator, Q_file); |
1771 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = width; | 1828 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii) = width; |
1772 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = height; | 1829 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii) = height; |
1773 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1; | 1830 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1; |
1774 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0); | 1831 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0); |
1775 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0); | 1832 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0); |
1833 init_image_instance_geometry (ii); | |
1834 | |
1776 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = mask ? mask : | 1835 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = mask ? mask : |
1777 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height, | 1836 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height, |
1778 TRUE, black, white); | 1837 TRUE, black, white); |
1779 | 1838 |
1780 switch (type) | 1839 switch (type) |
1851 static void | 1910 static void |
1852 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator, | 1911 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator, |
1853 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 1912 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
1854 int dest_mask, int width, int height, | 1913 int dest_mask, int width, int height, |
1855 /* Note that data is in ext-format! */ | 1914 /* Note that data is in ext-format! */ |
1856 CONST char *bits) | 1915 const char *bits) |
1857 { | 1916 { |
1858 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data); | 1917 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data); |
1859 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file); | 1918 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file); |
1860 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 1919 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
1861 struct frame* f = XFRAME (DEVICE_SELECTED_FRAME | 1920 HDC hdc = get_device_compdc (XDEVICE (IMAGE_INSTANCE_DEVICE (ii))); |
1862 (XDEVICE (IMAGE_INSTANCE_DEVICE (ii)))); | |
1863 HDC hdc = FRAME_MSWINDOWS_CDC (f); | |
1864 HBITMAP mask = 0; | 1921 HBITMAP mask = 0; |
1865 | 1922 |
1866 if (!NILP (mask_data)) | 1923 if (!NILP (mask_data)) |
1867 { | 1924 { |
1868 CONST char *ext_data; | 1925 const char *ext_data; |
1869 | 1926 |
1870 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (mask_data))), | 1927 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (mask_data))), |
1871 C_STRING_ALLOCA, ext_data, | 1928 C_STRING_ALLOCA, ext_data, |
1872 Qbinary); | 1929 Qbinary); |
1873 mask = xbm_create_bitmap_from_data (hdc, | 1930 mask = xbm_create_bitmap_from_data (hdc, |
1891 Lisp_Object instantiator, | 1948 Lisp_Object instantiator, |
1892 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 1949 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
1893 int dest_mask, Lisp_Object domain) | 1950 int dest_mask, Lisp_Object domain) |
1894 { | 1951 { |
1895 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 1952 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
1896 CONST char *ext_data; | 1953 const char *ext_data; |
1897 | 1954 |
1898 assert (!NILP (data)); | 1955 assert (!NILP (data)); |
1899 | 1956 |
1900 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (data))), | 1957 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (data))), |
1901 C_STRING_ALLOCA, ext_data, | 1958 C_STRING_ALLOCA, ext_data, |
1936 int dest_mask, Lisp_Object domain) | 1993 int dest_mask, Lisp_Object domain) |
1937 { | 1994 { |
1938 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 1995 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
1939 int i, stattis; | 1996 int i, stattis; |
1940 char *p, *bits, *bp; | 1997 char *p, *bits, *bp; |
1941 CONST char * volatile emsg = 0; | 1998 const char * volatile emsg = 0; |
1942 CONST char * volatile dstring; | 1999 const char * volatile dstring; |
1943 | 2000 |
1944 assert (!NILP (data)); | 2001 assert (!NILP (data)); |
1945 | 2002 |
1946 TO_EXTERNAL_FORMAT (LISP_STRING, data, | 2003 TO_EXTERNAL_FORMAT (LISP_STRING, data, |
1947 C_STRING_ALLOCA, dstring, | 2004 C_STRING_ALLOCA, dstring, |
2034 #endif | 2091 #endif |
2035 | 2092 |
2036 static void | 2093 static void |
2037 mswindows_finalize_image_instance (Lisp_Image_Instance *p) | 2094 mswindows_finalize_image_instance (Lisp_Image_Instance *p) |
2038 { | 2095 { |
2039 if (DEVICE_LIVE_P (XDEVICE (p->device))) | 2096 if (!p->data) |
2040 { | 2097 return; |
2041 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET | 2098 |
2042 || | 2099 if (DEVICE_LIVE_P (XDEVICE (IMAGE_INSTANCE_DEVICE (p)))) |
2043 IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW) | 2100 { |
2101 if (image_instance_type_to_mask (IMAGE_INSTANCE_TYPE (p)) | |
2102 & (IMAGE_WIDGET_MASK | IMAGE_SUBWINDOW_MASK)) | |
2044 { | 2103 { |
2045 #ifdef DEBUG_WIDGETS | 2104 #ifdef DEBUG_WIDGETS |
2046 debug_widget_instances--; | 2105 debug_widget_instances--; |
2047 stderr_out ("widget destroyed, %d left\n", debug_widget_instances); | 2106 stderr_out ("widget destroyed, %d left\n", debug_widget_instances); |
2048 #endif | 2107 #endif |
2101 face, domain); | 2160 face, domain); |
2102 | 2161 |
2103 return mswindows_get_hfont (XFONT_INSTANCE (font), under, strike); | 2162 return mswindows_get_hfont (XFONT_INSTANCE (font), under, strike); |
2104 } | 2163 } |
2105 | 2164 |
2165 static HDWP | |
2166 begin_defer_window_pos (struct frame *f) | |
2167 { | |
2168 #ifdef DEFER_WINDOW_POS | |
2169 if (FRAME_MSWINDOWS_DATA (f)->hdwp == 0) | |
2170 FRAME_MSWINDOWS_DATA (f)->hdwp = BeginDeferWindowPos (10); | |
2171 #endif | |
2172 return FRAME_MSWINDOWS_DATA (f)->hdwp; | |
2173 } | |
2174 | |
2106 /* unmap the image if it is a widget. This is used by redisplay via | 2175 /* unmap the image if it is a widget. This is used by redisplay via |
2107 redisplay_unmap_subwindows */ | 2176 redisplay_unmap_subwindows */ |
2108 static void | 2177 static void |
2109 mswindows_unmap_subwindow (Lisp_Image_Instance *p) | 2178 mswindows_unmap_subwindow (Lisp_Image_Instance *p) |
2110 { | 2179 { |
2111 if (IMAGE_INSTANCE_SUBWINDOW_ID (p)) | 2180 if (IMAGE_INSTANCE_SUBWINDOW_ID (p)) |
2112 { | 2181 { |
2182 #ifdef DEFER_WINDOW_POS | |
2183 struct frame *f = XFRAME (IMAGE_INSTANCE_FRAME (p)); | |
2184 HDWP hdwp = begin_defer_window_pos (f); | |
2185 HDWP new_hdwp; | |
2186 new_hdwp = DeferWindowPos (hdwp, IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), | |
2187 NULL, | |
2188 0, 0, 0, 0, | |
2189 SWP_HIDEWINDOW | SWP_NOACTIVATE | | |
2190 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | |
2191 /* Setting this flag causes the call to | |
2192 DeferWindowPos to fail with | |
2193 "Invalid parameter". I don't understand | |
2194 why we bother to try and set this | |
2195 anyway. -- ben */ | |
2196 /* | SWP_NOSENDCHANGING */ | |
2197 ); | |
2198 if (!new_hdwp) | |
2199 mswindows_output_last_error ("unmapping"); | |
2200 else | |
2201 hdwp = new_hdwp; | |
2202 FRAME_MSWINDOWS_DATA (f)->hdwp = hdwp; | |
2203 #else | |
2113 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), | 2204 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), |
2114 NULL, | 2205 NULL, |
2115 0, 0, 0, 0, | 2206 0, 0, 0, 0, |
2116 SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE | 2207 SWP_HIDEWINDOW | SWP_NOACTIVATE | |
2117 | SWP_NOSENDCHANGING); | 2208 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER ); |
2209 #endif | |
2118 if (GetFocus() == WIDGET_INSTANCE_MSWINDOWS_HANDLE (p)) | 2210 if (GetFocus() == WIDGET_INSTANCE_MSWINDOWS_HANDLE (p)) |
2119 SetFocus (GetParent (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p))); | 2211 SetFocus (GetParent (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p))); |
2120 } | 2212 } |
2121 } | 2213 } |
2122 | 2214 |
2124 redisplay_output_subwindow */ | 2216 redisplay_output_subwindow */ |
2125 static void | 2217 static void |
2126 mswindows_map_subwindow (Lisp_Image_Instance *p, int x, int y, | 2218 mswindows_map_subwindow (Lisp_Image_Instance *p, int x, int y, |
2127 struct display_glyph_area* dga) | 2219 struct display_glyph_area* dga) |
2128 { | 2220 { |
2221 #ifdef DEFER_WINDOW_POS | |
2222 struct frame *f = XFRAME (IMAGE_INSTANCE_FRAME (p)); | |
2223 HDWP hdwp = begin_defer_window_pos (f); | |
2224 HDWP new_hdwp; | |
2225 #endif | |
2129 /* move the window before mapping it ... */ | 2226 /* move the window before mapping it ... */ |
2130 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), | 2227 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), |
2131 NULL, | 2228 NULL, |
2132 x, y, dga->width, dga->height, | 2229 x, y, dga->width, dga->height, |
2133 SWP_NOZORDER | 2230 SWP_NOZORDER |
2137 NULL, | 2234 NULL, |
2138 -dga->xoffset, -dga->yoffset, 0, 0, | 2235 -dga->xoffset, -dga->yoffset, 0, 0, |
2139 SWP_NOZORDER | SWP_NOSIZE | 2236 SWP_NOZORDER | SWP_NOSIZE |
2140 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING); | 2237 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING); |
2141 /* ... now map it - we are not allowed to move it at the same time. */ | 2238 /* ... now map it - we are not allowed to move it at the same time. */ |
2142 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), | 2239 if (!IMAGE_INSTANCE_SUBWINDOW_DISPLAYEDP (p)) |
2143 NULL, | 2240 { |
2144 0, 0, 0, 0, | 2241 #ifdef DEFER_WINDOW_POS |
2145 SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | 2242 new_hdwp = DeferWindowPos |
2146 | SWP_SHOWWINDOW | SWP_NOCOPYBITS | 2243 (hdwp, |
2147 | SWP_NOSENDCHANGING); | 2244 IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), |
2245 NULL, 0, 0, 0, 0, | |
2246 SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | |
2247 | SWP_SHOWWINDOW | |
2248 /* | SWP_NOCOPYBITS */ | |
2249 /* Setting this flag causes the call to | |
2250 DeferWindowPos to fail with | |
2251 "Invalid parameter". I don't understand | |
2252 why we bother to try and set this | |
2253 anyway. -- ben */ | |
2254 /* | SWP_NOSENDCHANGING */ | |
2255 | SWP_NOACTIVATE); | |
2256 if (!new_hdwp) | |
2257 mswindows_output_last_error ("mapping"); | |
2258 else | |
2259 hdwp = new_hdwp; | |
2260 FRAME_MSWINDOWS_DATA (f)->hdwp = hdwp; | |
2261 #else | |
2262 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), | |
2263 NULL, | |
2264 0, 0, 0, 0, | |
2265 SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | |
2266 | SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOACTIVATE); | |
2267 #endif | |
2268 } | |
2148 } | 2269 } |
2149 | 2270 |
2150 /* resize the subwindow instance */ | 2271 /* resize the subwindow instance */ |
2151 static void | 2272 static void |
2152 mswindows_resize_subwindow (Lisp_Image_Instance* ii, int w, int h) | 2273 mswindows_resize_subwindow (Lisp_Image_Instance* ii, int w, int h) |
2153 { | 2274 { |
2154 /* Set the size of the control .... */ | 2275 /* Set the size of the control .... */ |
2155 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | 2276 if (!SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), |
2156 NULL, | 2277 NULL, |
2157 0, 0, w, h, | 2278 0, 0, w, h, |
2158 SWP_NOZORDER | SWP_NOMOVE | 2279 SWP_NOZORDER | SWP_NOMOVE |
2159 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING); | 2280 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING)) |
2281 mswindows_output_last_error ("resizing"); | |
2282 } | |
2283 | |
2284 /* Simply resize the window here. */ | |
2285 static void | |
2286 mswindows_redisplay_subwindow (Lisp_Image_Instance *p) | |
2287 { | |
2288 mswindows_resize_subwindow (p, | |
2289 IMAGE_INSTANCE_WIDTH (p), | |
2290 IMAGE_INSTANCE_HEIGHT (p)); | |
2160 } | 2291 } |
2161 | 2292 |
2162 /* when you click on a widget you may activate another widget this | 2293 /* when you click on a widget you may activate another widget this |
2163 needs to be checked and all appropriate widgets updated */ | 2294 needs to be checked and all appropriate widgets updated */ |
2164 static void | 2295 static void |
2165 mswindows_update_subwindow (Lisp_Image_Instance *p) | 2296 mswindows_redisplay_widget (Lisp_Image_Instance *p) |
2166 { | 2297 { |
2167 /* Now do widget specific updates. */ | 2298 /* Possibly update the face font and colors. */ |
2168 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET) | 2299 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (p)) |
2169 { | 2300 && (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (p) |
2170 /* buttons checked or otherwise */ | 2301 || XFRAME (IMAGE_INSTANCE_FRAME (p))->faces_changed |
2171 if ( EQ (IMAGE_INSTANCE_WIDGET_TYPE (p), Qbutton)) | 2302 || IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p))) |
2172 { | 2303 { |
2173 if (gui_item_selected_p (IMAGE_INSTANCE_WIDGET_ITEM (p))) | |
2174 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), | |
2175 BM_SETCHECK, (WPARAM)BST_CHECKED, 0); | |
2176 else | |
2177 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), | |
2178 BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); | |
2179 } | |
2180 | |
2181 /* set the widget font from the widget face */ | 2304 /* set the widget font from the widget face */ |
2182 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), | 2305 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), |
2183 WM_SETFONT, | 2306 WM_SETFONT, |
2184 (WPARAM) mswindows_widget_hfont | 2307 (WPARAM) mswindows_widget_hfont |
2185 (p, IMAGE_INSTANCE_SUBWINDOW_FRAME (p)), | 2308 (p, IMAGE_INSTANCE_FRAME (p)), |
2186 MAKELPARAM (TRUE, 0)); | 2309 MAKELPARAM (TRUE, 0)); |
2187 } | 2310 } |
2188 } | 2311 /* Possibly update the dimensions. */ |
2189 | 2312 if (IMAGE_INSTANCE_SIZE_CHANGED (p)) |
2190 /* register widgets into our hastable so that we can cope with the | 2313 { |
2314 mswindows_resize_subwindow (p, | |
2315 IMAGE_INSTANCE_WIDTH (p), | |
2316 IMAGE_INSTANCE_HEIGHT (p)); | |
2317 } | |
2318 /* Possibly update the text in the widget. */ | |
2319 if (IMAGE_INSTANCE_TEXT_CHANGED (p) | |
2320 && !NILP (IMAGE_INSTANCE_WIDGET_TEXT (p))) | |
2321 { | |
2322 Extbyte* lparam=0; | |
2323 TO_EXTERNAL_FORMAT (LISP_STRING, IMAGE_INSTANCE_WIDGET_TEXT (p), | |
2324 C_STRING_ALLOCA, lparam, | |
2325 Qnative); | |
2326 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), | |
2327 WM_SETTEXT, 0, (LPARAM)lparam); | |
2328 } | |
2329 } | |
2330 | |
2331 /* register widgets into our hashtable so that we can cope with the | |
2191 callbacks. The hashtable is weak so deregistration is handled | 2332 callbacks. The hashtable is weak so deregistration is handled |
2192 automatically */ | 2333 automatically */ |
2193 static int | 2334 static int |
2194 mswindows_register_gui_item (Lisp_Object gui, Lisp_Object domain) | 2335 mswindows_register_gui_item (Lisp_Object image_instance, |
2195 { | 2336 Lisp_Object gui, Lisp_Object domain) |
2196 Lisp_Object frame = FW_FRAME (domain); | 2337 { |
2338 Lisp_Object frame = DOMAIN_FRAME (domain); | |
2197 struct frame* f = XFRAME (frame); | 2339 struct frame* f = XFRAME (frame); |
2198 int id = gui_item_id_hash (FRAME_MSWINDOWS_WIDGET_HASH_TABLE (f), | 2340 int id = gui_item_id_hash (FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f), |
2199 gui, | 2341 gui, |
2200 WIDGET_GLYPH_SLOT); | 2342 WIDGET_GLYPH_SLOT); |
2201 Fputhash (make_int (id), | 2343 Fputhash (make_int (id), image_instance, |
2202 XGUI_ITEM (gui)->callback, | 2344 FRAME_MSWINDOWS_WIDGET_HASH_TABLE1 (f)); |
2203 FRAME_MSWINDOWS_WIDGET_HASH_TABLE (f)); | 2345 Fputhash (make_int (id), XGUI_ITEM (gui)->callback, |
2346 FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f)); | |
2347 Fputhash (make_int (id), XGUI_ITEM (gui)->callback_ex, | |
2348 FRAME_MSWINDOWS_WIDGET_HASH_TABLE3 (f)); | |
2204 return id; | 2349 return id; |
2205 } | 2350 } |
2206 | 2351 |
2207 static int | 2352 static int |
2208 mswindows_register_widget_instance (Lisp_Object instance, Lisp_Object domain) | 2353 mswindows_register_widget_instance (Lisp_Object instance, Lisp_Object domain) |
2209 { | 2354 { |
2210 return mswindows_register_gui_item (XIMAGE_INSTANCE_WIDGET_ITEM (instance), | 2355 return mswindows_register_gui_item (instance, |
2356 XIMAGE_INSTANCE_WIDGET_ITEM (instance), | |
2211 domain); | 2357 domain); |
2212 } | 2358 } |
2213 | 2359 |
2214 static void | 2360 static void |
2215 mswindows_subwindow_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2361 mswindows_subwindow_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2216 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2362 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2217 int dest_mask, Lisp_Object domain) | 2363 int dest_mask, Lisp_Object domain) |
2218 { | 2364 { |
2219 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2365 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2220 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 2366 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
2221 struct device* d = XDEVICE (device); | 2367 Lisp_Object frame = DOMAIN_FRAME (domain); |
2222 Lisp_Object frame = FW_FRAME (domain); | |
2223 HWND wnd; | 2368 HWND wnd; |
2224 | 2369 |
2225 if (!DEVICE_MSWINDOWS_P (d)) | 2370 CHECK_MSWINDOWS_DEVICE (device); |
2226 signal_simple_error ("Not an mswindows device", device); | |
2227 | 2371 |
2228 /* have to set the type this late in case there is no device | 2372 /* have to set the type this late in case there is no device |
2229 instantiation for a widget */ | 2373 instantiation for a widget */ |
2230 IMAGE_INSTANCE_TYPE (ii) = IMAGE_SUBWINDOW; | 2374 IMAGE_INSTANCE_TYPE (ii) = IMAGE_SUBWINDOW; |
2231 /* Allocate space for the clip window */ | 2375 /* Allocate space for the clip window */ |
2335 /************************************************************************/ | 2479 /************************************************************************/ |
2336 static void | 2480 static void |
2337 mswindows_widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2481 mswindows_widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2338 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2482 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2339 int dest_mask, Lisp_Object domain, | 2483 int dest_mask, Lisp_Object domain, |
2340 CONST char* class, int flags, int exflags) | 2484 const char* class, int flags, int exflags) |
2341 { | 2485 { |
2342 /* this function can call lisp */ | 2486 /* this function can call lisp */ |
2343 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2487 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2344 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), style; | 2488 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), style; |
2345 struct device* d = XDEVICE (device); | 2489 Lisp_Object frame = DOMAIN_FRAME (domain); |
2346 Lisp_Object frame = FW_FRAME (domain); | |
2347 Extbyte* nm=0; | 2490 Extbyte* nm=0; |
2348 HWND wnd; | 2491 HWND wnd; |
2349 int id = 0xffff; | 2492 int id = 0xffff; |
2350 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); | 2493 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); |
2351 Lisp_Gui_Item* pgui = XGUI_ITEM (gui); | 2494 Lisp_Gui_Item* pgui = XGUI_ITEM (gui); |
2352 | 2495 |
2353 if (!DEVICE_MSWINDOWS_P (d)) | 2496 CHECK_MSWINDOWS_DEVICE (device); |
2354 signal_simple_error ("Not an mswindows device", device); | |
2355 | 2497 |
2356 if (!gui_item_active_p (gui)) | 2498 if (!gui_item_active_p (gui)) |
2357 flags |= WS_DISABLED; | 2499 flags |= WS_DISABLED; |
2358 | 2500 |
2359 style = pgui->style; | 2501 style = pgui->style; |
2360 | 2502 |
2361 if (!NILP (pgui->callback)) | 2503 if (!NILP (pgui->callback) || !NILP (pgui->callback_ex)) |
2362 { | 2504 { |
2363 id = mswindows_register_widget_instance (image_instance, domain); | 2505 id = mswindows_register_widget_instance (image_instance, domain); |
2364 } | 2506 } |
2365 | 2507 |
2366 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) | 2508 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) |
2380 0, /* starting x position */ | 2522 0, /* starting x position */ |
2381 0, /* starting y position */ | 2523 0, /* starting y position */ |
2382 IMAGE_INSTANCE_WIDGET_WIDTH (ii), | 2524 IMAGE_INSTANCE_WIDGET_WIDTH (ii), |
2383 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), | 2525 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), |
2384 /* parent window */ | 2526 /* parent window */ |
2385 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), | 2527 DOMAIN_MSWINDOWS_HANDLE (domain), |
2386 (HMENU)id, /* No menu */ | 2528 (HMENU)id, /* No menu */ |
2387 NULL, /* must be null for this class */ | 2529 NULL, /* must be null for this class */ |
2388 NULL)) == NULL) | 2530 NULL)) == NULL) |
2389 signal_simple_error ("window creation failed with code", | 2531 signal_simple_error ("window creation failed with code", |
2390 make_int (GetLastError())); | 2532 make_int (GetLastError())); |
2410 make_int (GetLastError())); | 2552 make_int (GetLastError())); |
2411 | 2553 |
2412 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; | 2554 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; |
2413 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); | 2555 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); |
2414 /* set the widget font from the widget face */ | 2556 /* set the widget font from the widget face */ |
2415 SendMessage (wnd, WM_SETFONT, | 2557 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) |
2416 (WPARAM) mswindows_widget_hfont (ii, domain), | 2558 SendMessage (wnd, WM_SETFONT, |
2417 MAKELPARAM (TRUE, 0)); | 2559 (WPARAM) mswindows_widget_hfont (ii, domain), |
2560 MAKELPARAM (TRUE, 0)); | |
2561 #if 0 | |
2562 /* #### doesn't work. need to investigate more closely. */ | |
2563 if (IMAGE_INSTANCE_WANTS_INITIAL_FOCUS (ii)) | |
2564 SetFocus (wnd); | |
2565 #endif | |
2566 } | |
2567 | |
2568 /* Instantiate a native layout widget. */ | |
2569 static void | |
2570 mswindows_native_layout_instantiate (Lisp_Object image_instance, | |
2571 Lisp_Object instantiator, | |
2572 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | |
2573 int dest_mask, Lisp_Object domain) | |
2574 { | |
2575 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | |
2576 | |
2577 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | |
2578 pointer_bg, dest_mask, domain, "STATIC", | |
2579 /* Approximation to styles available with | |
2580 an XEmacs layout. */ | |
2581 (EQ (IMAGE_INSTANCE_LAYOUT_BORDER (ii), | |
2582 Qetched_in) || | |
2583 EQ (IMAGE_INSTANCE_LAYOUT_BORDER (ii), | |
2584 Qetched_out) || | |
2585 GLYPHP (IMAGE_INSTANCE_LAYOUT_BORDER (ii)) | |
2586 ? SS_ETCHEDFRAME : SS_SUNKEN) | DS_CONTROL, | |
2587 0); | |
2418 } | 2588 } |
2419 | 2589 |
2420 /* Instantiate a button widget. Unfortunately instantiated widgets are | 2590 /* Instantiate a button widget. Unfortunately instantiated widgets are |
2421 particular to a frame since they need to have a parent. It's not | 2591 particular to a frame since they need to have a parent. It's not |
2422 like images where you just select the image into the context you | 2592 like images where you just select the image into the context you |
2426 static void | 2596 static void |
2427 mswindows_button_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2597 mswindows_button_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2428 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2598 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2429 int dest_mask, Lisp_Object domain) | 2599 int dest_mask, Lisp_Object domain) |
2430 { | 2600 { |
2431 /* this function can call lisp */ | 2601 /* This function can call lisp */ |
2432 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2602 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2433 HWND wnd; | 2603 HWND wnd; |
2434 int flags = WS_TABSTOP;/* BS_NOTIFY #### is needed to get exotic feedback | 2604 int flags = WS_TABSTOP;/* BS_NOTIFY #### is needed to get exotic feedback |
2435 only. Since we seem to want nothing beyond BN_CLICK, | 2605 only. Since we seem to want nothing beyond BN_CLICK, |
2436 the style is perhaps not necessary -- kkm */ | 2606 the style is perhaps not necessary -- kkm */ |
2488 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) : | 2658 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) : |
2489 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_ICON (glyph))); | 2659 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_ICON (glyph))); |
2490 } | 2660 } |
2491 } | 2661 } |
2492 | 2662 |
2663 /* Update the state of a button. */ | |
2664 static void | |
2665 mswindows_button_redisplay (Lisp_Object image_instance) | |
2666 { | |
2667 /* This function can GC if IN_REDISPLAY is false. */ | |
2668 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | |
2669 | |
2670 /* buttons checked or otherwise */ | |
2671 if (gui_item_selected_p (IMAGE_INSTANCE_WIDGET_ITEM (ii))) | |
2672 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | |
2673 BM_SETCHECK, (WPARAM)BST_CHECKED, 0); | |
2674 else | |
2675 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | |
2676 BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); | |
2677 } | |
2678 | |
2493 /* instantiate an edit control */ | 2679 /* instantiate an edit control */ |
2494 static void | 2680 static void |
2495 mswindows_edit_field_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2681 mswindows_edit_field_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2496 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2682 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2497 int dest_mask, Lisp_Object domain) | 2683 int dest_mask, Lisp_Object domain) |
2508 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2694 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2509 int dest_mask, Lisp_Object domain) | 2695 int dest_mask, Lisp_Object domain) |
2510 { | 2696 { |
2511 HWND wnd; | 2697 HWND wnd; |
2512 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2698 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2699 Lisp_Object val; | |
2513 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | 2700 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
2514 pointer_bg, dest_mask, domain, PROGRESS_CLASS, | 2701 pointer_bg, dest_mask, domain, PROGRESS_CLASS, |
2515 WS_BORDER | PBS_SMOOTH, WS_EX_CLIENTEDGE); | 2702 WS_BORDER | PBS_SMOOTH, WS_EX_CLIENTEDGE); |
2516 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2703 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2517 /* set the colors */ | 2704 /* set the colors */ |
2519 SendMessage (wnd, PBS_SETBKCOLOR, 0, | 2706 SendMessage (wnd, PBS_SETBKCOLOR, 0, |
2520 (LPARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR | 2707 (LPARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR |
2521 (XCOLOR_INSTANCE | 2708 (XCOLOR_INSTANCE |
2522 (FACE_BACKGROUND | 2709 (FACE_BACKGROUND |
2523 (XIMAGE_INSTANCE_WIDGET_FACE (ii), | 2710 (XIMAGE_INSTANCE_WIDGET_FACE (ii), |
2524 XIMAGE_INSTANCE_SUBWINDOW_FRAME (ii)))))); | 2711 XIMAGE_INSTANCE_FRAME (ii)))))); |
2525 #endif | 2712 #endif |
2526 #ifdef PBS_SETBARCOLOR | 2713 #ifdef PBS_SETBARCOLOR |
2527 SendMessage (wnd, PBS_SETBARCOLOR, 0, | 2714 SendMessage (wnd, PBS_SETBARCOLOR, 0, |
2528 (L:PARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR | 2715 (L:PARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR |
2529 (XCOLOR_INSTANCE | 2716 (XCOLOR_INSTANCE |
2530 (FACE_FOREGROUND | 2717 (FACE_FOREGROUND |
2531 (XIMAGE_INSTANCE_WIDGET_FACE (ii), | 2718 (XIMAGE_INSTANCE_WIDGET_FACE (ii), |
2532 XIMAGE_INSTANCE_SUBWINDOW_FRAME (ii)))))); | 2719 XIMAGE_INSTANCE_FRAME (ii)))))); |
2533 #endif | 2720 #endif |
2721 val = XGUI_ITEM (IMAGE_INSTANCE_WIDGET_ITEMS (ii))->value; | |
2722 CHECK_INT (val); | |
2723 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | |
2724 PBM_SETPOS, (WPARAM)XINT (val), 0); | |
2534 } | 2725 } |
2535 | 2726 |
2536 /* instantiate a tree view widget */ | 2727 /* instantiate a tree view widget */ |
2537 static HTREEITEM add_tree_item (Lisp_Object image_instance, | 2728 static HTREEITEM add_tree_item (Lisp_Object image_instance, |
2538 HWND wnd, HTREEITEM parent, Lisp_Object item, | 2729 HWND wnd, HTREEITEM parent, Lisp_Object item, |
2546 tvitem.item.mask = TVIF_TEXT | TVIF_CHILDREN; | 2737 tvitem.item.mask = TVIF_TEXT | TVIF_CHILDREN; |
2547 tvitem.item.cChildren = children; | 2738 tvitem.item.cChildren = children; |
2548 | 2739 |
2549 if (GUI_ITEMP (item)) | 2740 if (GUI_ITEMP (item)) |
2550 { | 2741 { |
2551 tvitem.item.lParam = mswindows_register_gui_item (item, domain); | 2742 tvitem.item.lParam = mswindows_register_gui_item (image_instance, |
2743 item, domain); | |
2552 tvitem.item.mask |= TVIF_PARAM; | 2744 tvitem.item.mask |= TVIF_PARAM; |
2553 TO_EXTERNAL_FORMAT (LISP_STRING, XGUI_ITEM (item)->name, | 2745 TO_EXTERNAL_FORMAT (LISP_STRING, XGUI_ITEM (item)->name, |
2554 C_STRING_ALLOCA, tvitem.item.pszText, | 2746 C_STRING_ALLOCA, tvitem.item.pszText, |
2555 Qnative); | 2747 Qnative); |
2556 } | 2748 } |
2617 else | 2809 else |
2618 add_tree_item (image_instance, wnd, parent, XCAR (rest), FALSE, domain); | 2810 add_tree_item (image_instance, wnd, parent, XCAR (rest), FALSE, domain); |
2619 } | 2811 } |
2620 } | 2812 } |
2621 | 2813 |
2814 /* Set the properties of a tree view. */ | |
2815 static void | |
2816 mswindows_tree_view_redisplay (Lisp_Object image_instance) | |
2817 { | |
2818 /* This function can GC if IN_REDISPLAY is false. */ | |
2819 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | |
2820 | |
2821 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii)) | |
2822 { | |
2823 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | |
2824 Lisp_Object rest; | |
2825 HTREEITEM parent; | |
2826 /* Delete previous items. */ | |
2827 SendMessage (wnd, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT); | |
2828 /* define a root */ | |
2829 parent = add_tree_item (image_instance, wnd, NULL, | |
2830 XCAR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)), | |
2831 TRUE, IMAGE_INSTANCE_DOMAIN (ii)); | |
2832 | |
2833 /* recursively add items to the tree view */ | |
2834 /* add items to the tab */ | |
2835 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))) | |
2836 { | |
2837 if (LISTP (XCAR (rest))) | |
2838 add_tree_item_list (image_instance, wnd, parent, XCAR (rest), | |
2839 IMAGE_INSTANCE_DOMAIN (ii)); | |
2840 else | |
2841 add_tree_item (image_instance, wnd, parent, XCAR (rest), FALSE, | |
2842 IMAGE_INSTANCE_DOMAIN (ii)); | |
2843 } | |
2844 } | |
2845 } | |
2846 | |
2622 /* instantiate a tab control */ | 2847 /* instantiate a tab control */ |
2623 static TC_ITEM* add_tab_item (Lisp_Object image_instance, | 2848 static int |
2624 HWND wnd, Lisp_Object item, | 2849 add_tab_item (Lisp_Object image_instance, |
2625 Lisp_Object domain, int i) | 2850 HWND wnd, Lisp_Object item, |
2626 { | 2851 Lisp_Object domain, int i) |
2627 TC_ITEM tvitem, *ret; | 2852 { |
2853 TC_ITEM tvitem; | |
2854 int ret = 0; | |
2628 | 2855 |
2629 tvitem.mask = TCIF_TEXT; | 2856 tvitem.mask = TCIF_TEXT; |
2630 | 2857 |
2631 if (GUI_ITEMP (item)) | 2858 if (GUI_ITEMP (item)) |
2632 { | 2859 { |
2633 tvitem.lParam = mswindows_register_gui_item (item, domain); | 2860 tvitem.lParam = mswindows_register_gui_item (image_instance, |
2861 item, domain); | |
2634 tvitem.mask |= TCIF_PARAM; | 2862 tvitem.mask |= TCIF_PARAM; |
2635 TO_EXTERNAL_FORMAT (LISP_STRING, XGUI_ITEM (item)->name, | 2863 TO_EXTERNAL_FORMAT (LISP_STRING, XGUI_ITEM (item)->name, |
2636 C_STRING_ALLOCA, tvitem.pszText, | 2864 C_STRING_ALLOCA, tvitem.pszText, |
2637 Qnative); | 2865 Qnative); |
2638 } | 2866 } |
2644 Qnative); | 2872 Qnative); |
2645 } | 2873 } |
2646 | 2874 |
2647 tvitem.cchTextMax = strlen (tvitem.pszText); | 2875 tvitem.cchTextMax = strlen (tvitem.pszText); |
2648 | 2876 |
2649 if ((ret = (TC_ITEM*)SendMessage (wnd, TCM_INSERTITEM, | 2877 if ((ret = SendMessage (wnd, TCM_INSERTITEM, |
2650 i, (LPARAM)&tvitem)) < 0) | 2878 i, (LPARAM)&tvitem)) < 0) |
2651 signal_simple_error ("error adding tab entry", item); | 2879 signal_simple_error ("error adding tab entry", item); |
2652 | 2880 |
2653 return ret; | 2881 return ret; |
2654 } | 2882 } |
2655 | 2883 |
2656 static void | 2884 static void |
2657 mswindows_tab_control_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2885 mswindows_tab_control_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2658 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2886 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2659 int dest_mask, Lisp_Object domain) | 2887 int dest_mask, Lisp_Object domain) |
2660 { | 2888 { |
2889 /* This function can call lisp */ | |
2661 Lisp_Object rest; | 2890 Lisp_Object rest; |
2662 HWND wnd; | 2891 HWND wnd; |
2663 int i = 0; | 2892 int i = 0, selected = 0; |
2664 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2893 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2665 Lisp_Object orient = find_keyword_in_vector (instantiator, Q_orientation); | 2894 Lisp_Object orient = find_keyword_in_vector (instantiator, Q_orientation); |
2666 unsigned int flags = WS_TABSTOP; | 2895 unsigned int flags = WS_TABSTOP; |
2667 | 2896 |
2668 if (EQ (orient, Qleft) || EQ (orient, Qright)) | 2897 if (EQ (orient, Qleft) || EQ (orient, Qright)) |
2676 | 2905 |
2677 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | 2906 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
2678 pointer_bg, dest_mask, domain, WC_TABCONTROL, | 2907 pointer_bg, dest_mask, domain, WC_TABCONTROL, |
2679 /* borders don't suit tabs so well */ | 2908 /* borders don't suit tabs so well */ |
2680 flags, 0); | 2909 flags, 0); |
2681 | |
2682 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2910 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2683 /* add items to the tab */ | 2911 /* add items to the tab */ |
2684 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii))) | 2912 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii))) |
2685 { | 2913 { |
2686 add_tab_item (image_instance, wnd, XCAR (rest), domain, i); | 2914 int idx = add_tab_item (image_instance, wnd, XCAR (rest), domain, i); |
2915 assert (idx == i); | |
2916 if (gui_item_selected_p (XCAR (rest))) | |
2917 selected = i; | |
2687 i++; | 2918 i++; |
2688 } | 2919 } |
2689 } | 2920 SendMessage (wnd, TCM_SETCURSEL, selected, 0); |
2690 | 2921 } |
2691 /* set the properties of a tab control */ | 2922 |
2692 static Lisp_Object | 2923 /* Set the properties of a tab control. */ |
2693 mswindows_tab_control_set_property (Lisp_Object image_instance, Lisp_Object prop, | 2924 static void |
2694 Lisp_Object val) | 2925 mswindows_tab_control_redisplay (Lisp_Object image_instance) |
2695 { | 2926 { |
2927 /* This function can GC if IN_REDISPLAY is false. */ | |
2696 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2928 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2697 | 2929 #ifdef DEBUG_WIDGET_OUTPUT |
2698 if (EQ (prop, Q_items)) | 2930 stderr_out ("tab control %p redisplayed\n", IMAGE_INSTANCE_SUBWINDOW_ID (ii)); |
2931 #endif | |
2932 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii) | |
2933 || | |
2934 IMAGE_INSTANCE_WIDGET_ACTION_OCCURRED (ii)) | |
2699 { | 2935 { |
2700 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2936 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2701 int i = 0; | 2937 int i = 0, selected = 0; |
2702 Lisp_Object rest; | 2938 Lisp_Object rest; |
2703 check_valid_item_list_1 (val); | 2939 |
2704 | 2940 assert (!NILP (IMAGE_INSTANCE_WIDGET_ITEMS (ii))); |
2705 /* delete the pre-existing items */ | 2941 |
2706 SendMessage (wnd, TCM_DELETEALLITEMS, 0, 0); | 2942 /* If only the order has changed then simply select the first |
2707 | 2943 one. This stops horrendous rebuilding of the tabs each time |
2708 IMAGE_INSTANCE_WIDGET_ITEMS (ii) = | 2944 you click on one. */ |
2709 Fcons (XCAR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)), | 2945 if (tab_control_order_only_changed (image_instance)) |
2710 parse_gui_item_tree_children (val)); | |
2711 | |
2712 /* add items to the tab */ | |
2713 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii))) | |
2714 { | 2946 { |
2715 add_tab_item (image_instance, wnd, XCAR (rest), | 2947 Lisp_Object selected = |
2716 IMAGE_INSTANCE_SUBWINDOW_FRAME (ii), i); | 2948 gui_item_list_find_selected |
2717 i++; | 2949 (NILP (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)) ? |
2950 XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)) : | |
2951 XCDR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))); | |
2952 | |
2953 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii))) | |
2954 { | |
2955 if (gui_item_equal_sans_selected (XCAR (rest), selected, 0)) | |
2956 { | |
2957 Lisp_Object old_selected = gui_item_list_find_selected | |
2958 (XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii))); | |
2959 | |
2960 /* Pick up the new selected item. */ | |
2961 XGUI_ITEM (old_selected)->selected = | |
2962 XGUI_ITEM (XCAR (rest))->selected; | |
2963 XGUI_ITEM (XCAR (rest))->selected = | |
2964 XGUI_ITEM (selected)->selected; | |
2965 /* We're not actually changing the items. */ | |
2966 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii) = 0; | |
2967 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) = Qnil; | |
2968 | |
2969 SendMessage (wnd, TCM_SETCURSEL, i, 0); | |
2970 #ifdef DEBUG_WIDGET_OUTPUT | |
2971 stderr_out ("tab control %p selected item %d\n", | |
2972 IMAGE_INSTANCE_SUBWINDOW_ID (ii), i); | |
2973 #endif | |
2974 break; | |
2975 } | |
2976 i++; | |
2977 } | |
2718 } | 2978 } |
2719 | 2979 else |
2720 return Qt; | 2980 { |
2721 } | 2981 /* delete the pre-existing items */ |
2722 return Qunbound; | 2982 SendMessage (wnd, TCM_DELETEALLITEMS, 0, 0); |
2983 | |
2984 /* add items to the tab */ | |
2985 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))) | |
2986 { | |
2987 add_tab_item (image_instance, wnd, XCAR (rest), | |
2988 IMAGE_INSTANCE_FRAME (ii), i); | |
2989 if (gui_item_selected_p (XCAR (rest))) | |
2990 selected = i; | |
2991 i++; | |
2992 } | |
2993 SendMessage (wnd, TCM_SETCURSEL, selected, 0); | |
2994 } | |
2995 } | |
2723 } | 2996 } |
2724 | 2997 |
2725 /* instantiate a static control possible for putting other things in */ | 2998 /* instantiate a static control possible for putting other things in */ |
2726 static void | 2999 static void |
2727 mswindows_label_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 3000 mswindows_label_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2749 mswindows_combo_box_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 3022 mswindows_combo_box_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2750 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 3023 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2751 int dest_mask, Lisp_Object domain) | 3024 int dest_mask, Lisp_Object domain) |
2752 { | 3025 { |
2753 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 3026 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2754 HANDLE wnd; | 3027 HWND wnd; |
2755 Lisp_Object rest; | 3028 Lisp_Object rest; |
2756 Lisp_Object data = Fplist_get (find_keyword_in_vector (instantiator, Q_properties), | 3029 Lisp_Object items = find_keyword_in_vector (instantiator, Q_items); |
2757 Q_items, Qnil); | |
2758 int len, height; | 3030 int len, height; |
2759 | 3031 |
2760 /* Maybe ought to generalise this more but it may be very windows | 3032 /* Maybe ought to generalise this more but it may be very windows |
2761 specific. In windows the window height of a combo box is the | 3033 specific. In windows the window height of a combo box is the |
2762 height when the combo box is open. Thus we need to set the height | 3034 height when the combo box is open. Thus we need to set the height |
2766 widget_instantiate (image_instance, instantiator, pointer_fg, | 3038 widget_instantiate (image_instance, instantiator, pointer_fg, |
2767 pointer_bg, dest_mask, domain); | 3039 pointer_bg, dest_mask, domain); |
2768 | 3040 |
2769 /* We now have everything right apart from the height. */ | 3041 /* We now have everything right apart from the height. */ |
2770 default_face_font_info (domain, 0, 0, &height, 0, 0); | 3042 default_face_font_info (domain, 0, 0, &height, 0, 0); |
2771 GET_LIST_LENGTH (data, len); | 3043 GET_LIST_LENGTH (items, len); |
2772 | 3044 |
2773 height = (height + WIDGET_BORDER_HEIGHT * 2 ) * len; | 3045 height = (height + WIDGET_BORDER_HEIGHT * 2 ) * len; |
2774 IMAGE_INSTANCE_HEIGHT (ii) = height; | 3046 IMAGE_INSTANCE_HEIGHT (ii) = height; |
2775 | 3047 |
2776 /* Now create the widget. */ | 3048 /* Now create the widget. */ |
2782 WS_EX_CLIENTEDGE); | 3054 WS_EX_CLIENTEDGE); |
2783 /* Reset the height. layout will probably do this safely, but better make sure. */ | 3055 /* Reset the height. layout will probably do this safely, but better make sure. */ |
2784 image_instance_layout (image_instance, | 3056 image_instance_layout (image_instance, |
2785 IMAGE_UNSPECIFIED_GEOMETRY, | 3057 IMAGE_UNSPECIFIED_GEOMETRY, |
2786 IMAGE_UNSPECIFIED_GEOMETRY, | 3058 IMAGE_UNSPECIFIED_GEOMETRY, |
3059 IMAGE_UNCHANGED_GEOMETRY, | |
3060 IMAGE_UNCHANGED_GEOMETRY, | |
2787 domain); | 3061 domain); |
2788 | 3062 |
2789 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 3063 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2790 /* add items to the combo box */ | 3064 /* add items to the combo box */ |
2791 SendMessage (wnd, CB_RESETCONTENT, 0, 0); | 3065 SendMessage (wnd, CB_RESETCONTENT, 0, 0); |
2792 LIST_LOOP (rest, Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii), Q_items, Qnil)) | 3066 LIST_LOOP (rest, items) |
2793 { | 3067 { |
2794 Extbyte* lparam; | 3068 Extbyte* lparam; |
2795 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (rest), | 3069 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (rest), |
2796 C_STRING_ALLOCA, lparam, | 3070 C_STRING_ALLOCA, lparam, |
2797 Qnative); | 3071 Qnative); |
2803 /* get properties of a control */ | 3077 /* get properties of a control */ |
2804 static Lisp_Object | 3078 static Lisp_Object |
2805 mswindows_widget_property (Lisp_Object image_instance, Lisp_Object prop) | 3079 mswindows_widget_property (Lisp_Object image_instance, Lisp_Object prop) |
2806 { | 3080 { |
2807 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 3081 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2808 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 3082 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2809 /* get the text from a control */ | 3083 /* get the text from a control */ |
2810 if (EQ (prop, Q_text)) | 3084 if (EQ (prop, Q_text)) |
2811 { | 3085 { |
2812 Extcount len = SendMessage (wnd, WM_GETTEXTLENGTH, 0, 0); | 3086 Extcount len = SendMessage (wnd, WM_GETTEXTLENGTH, 0, 0); |
2813 Extbyte* buf =alloca (len+1); | 3087 Extbyte *buf = (Extbyte*) alloca (len+1); |
2814 | 3088 |
2815 SendMessage (wnd, WM_GETTEXT, (WPARAM)len+1, (LPARAM) buf); | 3089 SendMessage (wnd, WM_GETTEXT, (WPARAM)len+1, (LPARAM) buf); |
2816 return build_ext_string (buf, Qnative); | 3090 return build_ext_string (buf, Qnative); |
2817 } | 3091 } |
2818 return Qunbound; | 3092 return Qunbound; |
2821 /* get properties of a button */ | 3095 /* get properties of a button */ |
2822 static Lisp_Object | 3096 static Lisp_Object |
2823 mswindows_button_property (Lisp_Object image_instance, Lisp_Object prop) | 3097 mswindows_button_property (Lisp_Object image_instance, Lisp_Object prop) |
2824 { | 3098 { |
2825 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 3099 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2826 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 3100 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2827 /* check the state of a button */ | 3101 /* check the state of a button */ |
2828 if (EQ (prop, Q_selected)) | 3102 if (EQ (prop, Q_selected)) |
2829 { | 3103 { |
2830 if (SendMessage (wnd, BM_GETSTATE, 0, 0) & BST_CHECKED) | 3104 if (SendMessage (wnd, BM_GETSTATE, 0, 0) & BST_CHECKED) |
2831 return Qt; | 3105 return Qt; |
2838 /* get properties of a combo box */ | 3112 /* get properties of a combo box */ |
2839 static Lisp_Object | 3113 static Lisp_Object |
2840 mswindows_combo_box_property (Lisp_Object image_instance, Lisp_Object prop) | 3114 mswindows_combo_box_property (Lisp_Object image_instance, Lisp_Object prop) |
2841 { | 3115 { |
2842 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 3116 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2843 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 3117 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2844 /* get the text from a control */ | 3118 /* get the text from a control */ |
2845 if (EQ (prop, Q_text)) | 3119 if (EQ (prop, Q_text)) |
2846 { | 3120 { |
2847 long item = SendMessage (wnd, CB_GETCURSEL, 0, 0); | 3121 long item = SendMessage (wnd, CB_GETCURSEL, 0, 0); |
2848 Extcount len = SendMessage (wnd, CB_GETLBTEXTLEN, (WPARAM)item, 0); | 3122 Extcount len = SendMessage (wnd, CB_GETLBTEXTLEN, (WPARAM)item, 0); |
2849 Extbyte* buf = alloca (len+1); | 3123 Extbyte* buf = (Extbyte*) alloca (len+1); |
2850 SendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM)buf); | 3124 SendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM)buf); |
2851 return build_ext_string (buf, Qnative); | 3125 return build_ext_string (buf, Qnative); |
2852 } | 3126 } |
2853 return Qunbound; | 3127 return Qunbound; |
2854 } | 3128 } |
2855 | 3129 |
2856 /* set the properties of a control */ | 3130 /* set the properties of a progress gauge */ |
2857 static Lisp_Object | 3131 static void |
2858 mswindows_widget_set_property (Lisp_Object image_instance, Lisp_Object prop, | 3132 mswindows_progress_gauge_redisplay (Lisp_Object image_instance) |
2859 Lisp_Object val) | |
2860 { | 3133 { |
2861 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 3134 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2862 | 3135 |
2863 if (EQ (prop, Q_text)) | 3136 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii)) |
2864 { | 3137 { |
2865 Extbyte* lparam=0; | 3138 Lisp_Object val; |
2866 CHECK_STRING (val); | 3139 #ifdef ERROR_CHECK_GLYPHS |
2867 TO_EXTERNAL_FORMAT (LISP_STRING, val, | 3140 assert (GUI_ITEMP (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))); |
2868 C_STRING_ALLOCA, lparam, | 3141 #endif |
2869 Qnative); | 3142 val = XGUI_ITEM (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))->value; |
2870 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | 3143 #ifdef DEBUG_WIDGET_OUTPUT |
2871 WM_SETTEXT, 0, (LPARAM)lparam); | 3144 stderr_out ("progress gauge displayed value on %p updated to %ld\n", |
2872 /* We don't return Qt here so that other widget methods can be | 3145 WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), |
2873 called afterwards. */ | 3146 XINT(val)); |
2874 } | 3147 #endif |
2875 return Qunbound; | |
2876 } | |
2877 | |
2878 /* set the properties of a progres guage */ | |
2879 static Lisp_Object | |
2880 mswindows_progress_gauge_set_property (Lisp_Object image_instance, Lisp_Object prop, | |
2881 Lisp_Object val) | |
2882 { | |
2883 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | |
2884 | |
2885 if (EQ (prop, Q_percent)) | |
2886 { | |
2887 CHECK_INT (val); | 3148 CHECK_INT (val); |
2888 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | 3149 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), |
2889 PBM_SETPOS, (WPARAM)XINT (val), 0); | 3150 PBM_SETPOS, (WPARAM)XINT (val), 0); |
2890 return Qt; | 3151 } |
2891 } | |
2892 return Qunbound; | |
2893 } | 3152 } |
2894 | 3153 |
2895 LRESULT WINAPI | 3154 LRESULT WINAPI |
2896 mswindows_control_wnd_proc (HWND hwnd, UINT msg, | 3155 mswindows_control_wnd_proc (HWND hwnd, UINT msg, |
2897 WPARAM wParam, LPARAM lParam) | 3156 WPARAM wParam, LPARAM lParam) |
2927 } | 3186 } |
2928 | 3187 |
2929 void | 3188 void |
2930 console_type_create_glyphs_mswindows (void) | 3189 console_type_create_glyphs_mswindows (void) |
2931 { | 3190 { |
2932 /* image methods */ | 3191 /* image methods - display */ |
2933 | |
2934 CONSOLE_HAS_METHOD (mswindows, print_image_instance); | 3192 CONSOLE_HAS_METHOD (mswindows, print_image_instance); |
2935 CONSOLE_HAS_METHOD (mswindows, finalize_image_instance); | 3193 CONSOLE_HAS_METHOD (mswindows, finalize_image_instance); |
2936 CONSOLE_HAS_METHOD (mswindows, unmap_subwindow); | 3194 CONSOLE_HAS_METHOD (mswindows, unmap_subwindow); |
2937 CONSOLE_HAS_METHOD (mswindows, map_subwindow); | 3195 CONSOLE_HAS_METHOD (mswindows, map_subwindow); |
2938 CONSOLE_HAS_METHOD (mswindows, update_subwindow); | 3196 CONSOLE_HAS_METHOD (mswindows, redisplay_subwindow); |
3197 CONSOLE_HAS_METHOD (mswindows, resize_subwindow); | |
3198 CONSOLE_HAS_METHOD (mswindows, redisplay_widget); | |
2939 CONSOLE_HAS_METHOD (mswindows, image_instance_equal); | 3199 CONSOLE_HAS_METHOD (mswindows, image_instance_equal); |
2940 CONSOLE_HAS_METHOD (mswindows, image_instance_hash); | 3200 CONSOLE_HAS_METHOD (mswindows, image_instance_hash); |
2941 CONSOLE_HAS_METHOD (mswindows, init_image_instance_from_eimage); | 3201 CONSOLE_HAS_METHOD (mswindows, init_image_instance_from_eimage); |
2942 CONSOLE_HAS_METHOD (mswindows, locate_pixmap_file); | 3202 CONSOLE_HAS_METHOD (mswindows, locate_pixmap_file); |
2943 CONSOLE_HAS_METHOD (mswindows, resize_subwindow); | 3203 |
3204 /* image methods - printer */ | |
3205 CONSOLE_INHERITS_METHOD (msprinter, mswindows, print_image_instance); | |
3206 CONSOLE_INHERITS_METHOD (msprinter, mswindows, finalize_image_instance); | |
3207 CONSOLE_INHERITS_METHOD (msprinter, mswindows, image_instance_equal); | |
3208 CONSOLE_INHERITS_METHOD (msprinter, mswindows, image_instance_hash); | |
3209 CONSOLE_INHERITS_METHOD (msprinter, mswindows, init_image_instance_from_eimage); | |
3210 CONSOLE_INHERITS_METHOD (msprinter, mswindows, locate_pixmap_file); | |
2944 } | 3211 } |
2945 | 3212 |
2946 void | 3213 void |
2947 image_instantiator_format_create_glyphs_mswindows (void) | 3214 image_instantiator_format_create_glyphs_mswindows (void) |
2948 { | 3215 { |
2949 IIFORMAT_VALID_CONSOLE (mswindows, nothing); | 3216 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, nothing); |
2950 IIFORMAT_VALID_CONSOLE (mswindows, string); | 3217 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, string); |
2951 IIFORMAT_VALID_CONSOLE (mswindows, layout); | 3218 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, formatted_string); |
2952 IIFORMAT_VALID_CONSOLE (mswindows, formatted_string); | 3219 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, inherit); |
2953 IIFORMAT_VALID_CONSOLE (mswindows, inherit); | |
2954 /* image-instantiator types */ | 3220 /* image-instantiator types */ |
3221 INITIALIZE_DEVICE_IIFORMAT (mswindows, xbm); | |
3222 INITIALIZE_DEVICE_IIFORMAT (msprinter, xbm); | |
3223 IIFORMAT_HAS_DEVMETHOD (mswindows, xbm, instantiate); | |
3224 IIFORMAT_INHERITS_DEVMETHOD (msprinter, mswindows, xbm, instantiate); | |
2955 #ifdef HAVE_XPM | 3225 #ifdef HAVE_XPM |
2956 INITIALIZE_DEVICE_IIFORMAT (mswindows, xpm); | 3226 INITIALIZE_DEVICE_IIFORMAT (mswindows, xpm); |
3227 INITIALIZE_DEVICE_IIFORMAT (msprinter, xpm); | |
2957 IIFORMAT_HAS_DEVMETHOD (mswindows, xpm, instantiate); | 3228 IIFORMAT_HAS_DEVMETHOD (mswindows, xpm, instantiate); |
2958 #endif | 3229 IIFORMAT_INHERITS_DEVMETHOD (msprinter, mswindows, xpm, instantiate); |
2959 INITIALIZE_DEVICE_IIFORMAT (mswindows, xbm); | 3230 #endif |
2960 IIFORMAT_HAS_DEVMETHOD (mswindows, xbm, instantiate); | |
2961 #ifdef HAVE_XFACE | 3231 #ifdef HAVE_XFACE |
2962 INITIALIZE_DEVICE_IIFORMAT (mswindows, xface); | 3232 INITIALIZE_DEVICE_IIFORMAT (mswindows, xface); |
3233 INITIALIZE_DEVICE_IIFORMAT (msprinter, xface); | |
2963 IIFORMAT_HAS_DEVMETHOD (mswindows, xface, instantiate); | 3234 IIFORMAT_HAS_DEVMETHOD (mswindows, xface, instantiate); |
3235 IIFORMAT_INHERITS_DEVMETHOD (msprinter, mswindows, xface, instantiate); | |
2964 #endif | 3236 #endif |
2965 #ifdef HAVE_JPEG | 3237 #ifdef HAVE_JPEG |
2966 IIFORMAT_VALID_CONSOLE (mswindows, jpeg); | 3238 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, jpeg); |
2967 #endif | 3239 #endif |
2968 #ifdef HAVE_TIFF | 3240 #ifdef HAVE_TIFF |
2969 IIFORMAT_VALID_CONSOLE (mswindows, tiff); | 3241 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, tiff); |
2970 #endif | 3242 #endif |
2971 #ifdef HAVE_PNG | 3243 #ifdef HAVE_PNG |
2972 IIFORMAT_VALID_CONSOLE (mswindows, png); | 3244 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, png); |
2973 #endif | 3245 #endif |
2974 #ifdef HAVE_GIF | 3246 #ifdef HAVE_GIF |
2975 IIFORMAT_VALID_CONSOLE (mswindows, gif); | 3247 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, gif); |
2976 #endif | 3248 #endif |
2977 #ifdef HAVE_WIDGETS | 3249 #ifdef HAVE_WIDGETS |
3250 INITIALIZE_DEVICE_IIFORMAT (mswindows, widget); | |
3251 IIFORMAT_HAS_DEVMETHOD (mswindows, widget, property); | |
3252 /* layout widget */ | |
3253 IIFORMAT_VALID_CONSOLE (mswindows, layout); | |
3254 INITIALIZE_DEVICE_IIFORMAT (mswindows, native_layout); | |
3255 IIFORMAT_HAS_DEVMETHOD (mswindows, native_layout, instantiate); | |
2978 /* button widget */ | 3256 /* button widget */ |
2979 INITIALIZE_DEVICE_IIFORMAT (mswindows, button); | 3257 INITIALIZE_DEVICE_IIFORMAT (mswindows, button); |
2980 IIFORMAT_HAS_DEVMETHOD (mswindows, button, property); | 3258 IIFORMAT_HAS_DEVMETHOD (mswindows, button, property); |
2981 IIFORMAT_HAS_DEVMETHOD (mswindows, button, instantiate); | 3259 IIFORMAT_HAS_DEVMETHOD (mswindows, button, instantiate); |
2982 | 3260 IIFORMAT_HAS_DEVMETHOD (mswindows, button, redisplay); |
3261 /* edit-field widget */ | |
2983 INITIALIZE_DEVICE_IIFORMAT (mswindows, edit_field); | 3262 INITIALIZE_DEVICE_IIFORMAT (mswindows, edit_field); |
2984 IIFORMAT_HAS_DEVMETHOD (mswindows, edit_field, instantiate); | 3263 IIFORMAT_HAS_DEVMETHOD (mswindows, edit_field, instantiate); |
2985 | 3264 /* subwindow */ |
2986 INITIALIZE_DEVICE_IIFORMAT (mswindows, subwindow); | 3265 INITIALIZE_DEVICE_IIFORMAT (mswindows, subwindow); |
2987 IIFORMAT_HAS_DEVMETHOD (mswindows, subwindow, instantiate); | 3266 IIFORMAT_HAS_DEVMETHOD (mswindows, subwindow, instantiate); |
2988 | |
2989 INITIALIZE_DEVICE_IIFORMAT (mswindows, widget); | |
2990 IIFORMAT_HAS_DEVMETHOD (mswindows, widget, property); | |
2991 IIFORMAT_HAS_DEVMETHOD (mswindows, widget, set_property); | |
2992 | |
2993 /* label */ | 3267 /* label */ |
2994 INITIALIZE_DEVICE_IIFORMAT (mswindows, label); | 3268 INITIALIZE_DEVICE_IIFORMAT (mswindows, label); |
2995 IIFORMAT_HAS_DEVMETHOD (mswindows, label, instantiate); | 3269 IIFORMAT_HAS_DEVMETHOD (mswindows, label, instantiate); |
2996 | |
2997 /* combo box */ | 3270 /* combo box */ |
2998 INITIALIZE_DEVICE_IIFORMAT (mswindows, combo_box); | 3271 INITIALIZE_DEVICE_IIFORMAT (mswindows, combo_box); |
2999 IIFORMAT_HAS_DEVMETHOD (mswindows, combo_box, property); | 3272 IIFORMAT_HAS_DEVMETHOD (mswindows, combo_box, property); |
3000 IIFORMAT_HAS_DEVMETHOD (mswindows, combo_box, instantiate); | 3273 IIFORMAT_HAS_DEVMETHOD (mswindows, combo_box, instantiate); |
3001 | |
3002 /* scrollbar */ | 3274 /* scrollbar */ |
3003 INITIALIZE_DEVICE_IIFORMAT (mswindows, scrollbar); | 3275 INITIALIZE_DEVICE_IIFORMAT (mswindows, scrollbar); |
3004 IIFORMAT_HAS_DEVMETHOD (mswindows, scrollbar, instantiate); | 3276 IIFORMAT_HAS_DEVMETHOD (mswindows, scrollbar, instantiate); |
3005 | |
3006 /* progress gauge */ | 3277 /* progress gauge */ |
3007 INITIALIZE_DEVICE_IIFORMAT (mswindows, progress_gauge); | 3278 INITIALIZE_DEVICE_IIFORMAT (mswindows, progress_gauge); |
3008 IIFORMAT_HAS_DEVMETHOD (mswindows, progress_gauge, set_property); | 3279 IIFORMAT_HAS_DEVMETHOD (mswindows, progress_gauge, redisplay); |
3009 IIFORMAT_HAS_DEVMETHOD (mswindows, progress_gauge, instantiate); | 3280 IIFORMAT_HAS_DEVMETHOD (mswindows, progress_gauge, instantiate); |
3010 | |
3011 /* tree view widget */ | 3281 /* tree view widget */ |
3012 INITIALIZE_DEVICE_IIFORMAT (mswindows, tree_view); | 3282 INITIALIZE_DEVICE_IIFORMAT (mswindows, tree_view); |
3013 /* IIFORMAT_HAS_DEVMETHOD (mswindows, progress, set_property);*/ | |
3014 IIFORMAT_HAS_DEVMETHOD (mswindows, tree_view, instantiate); | 3283 IIFORMAT_HAS_DEVMETHOD (mswindows, tree_view, instantiate); |
3015 | 3284 IIFORMAT_HAS_DEVMETHOD (mswindows, tree_view, redisplay); |
3016 /* tab control widget */ | 3285 /* tab control widget */ |
3017 INITIALIZE_DEVICE_IIFORMAT (mswindows, tab_control); | 3286 INITIALIZE_DEVICE_IIFORMAT (mswindows, tab_control); |
3018 IIFORMAT_HAS_DEVMETHOD (mswindows, tab_control, instantiate); | 3287 IIFORMAT_HAS_DEVMETHOD (mswindows, tab_control, instantiate); |
3019 IIFORMAT_HAS_DEVMETHOD (mswindows, tab_control, set_property); | 3288 IIFORMAT_HAS_DEVMETHOD (mswindows, tab_control, redisplay); |
3020 #endif | 3289 #endif |
3021 /* windows bitmap format */ | 3290 /* windows bitmap format */ |
3022 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (bmp, "bmp"); | 3291 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (bmp, "bmp"); |
3023 IIFORMAT_HAS_METHOD (bmp, validate); | 3292 IIFORMAT_HAS_METHOD (bmp, validate); |
3024 IIFORMAT_HAS_METHOD (bmp, normalize); | 3293 IIFORMAT_HAS_METHOD (bmp, normalize); |
3025 IIFORMAT_HAS_METHOD (bmp, possible_dest_types); | 3294 IIFORMAT_HAS_METHOD (bmp, possible_dest_types); |
3026 IIFORMAT_HAS_METHOD (bmp, instantiate); | 3295 IIFORMAT_HAS_METHOD (bmp, instantiate); |
3027 | 3296 |
3028 IIFORMAT_VALID_KEYWORD (bmp, Q_data, check_valid_string); | 3297 IIFORMAT_VALID_KEYWORD (bmp, Q_data, check_valid_string); |
3029 IIFORMAT_VALID_KEYWORD (bmp, Q_file, check_valid_string); | 3298 IIFORMAT_VALID_KEYWORD (bmp, Q_file, check_valid_string); |
3030 IIFORMAT_VALID_CONSOLE (mswindows, bmp); | 3299 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, bmp); |
3031 | 3300 |
3032 /* mswindows resources */ | 3301 /* mswindows resources */ |
3033 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource, | 3302 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource, |
3034 "mswindows-resource"); | 3303 "mswindows-resource"); |
3035 | 3304 |
3040 | 3309 |
3041 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_type, | 3310 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_type, |
3042 check_valid_resource_symbol); | 3311 check_valid_resource_symbol); |
3043 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_id, check_valid_resource_id); | 3312 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_id, check_valid_resource_id); |
3044 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_file, check_valid_string); | 3313 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_file, check_valid_string); |
3045 IIFORMAT_VALID_CONSOLE (mswindows, mswindows_resource); | 3314 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, mswindows_resource); |
3046 } | 3315 } |
3047 | 3316 |
3048 void | 3317 void |
3049 vars_of_glyphs_mswindows (void) | 3318 vars_of_glyphs_mswindows (void) |
3050 { | 3319 { |