Mercurial > hg > xemacs-beta
comparison src/glyphs-msw.c @ 400:a86b2b5e0111 r21-2-30
Import from CVS: tag r21-2-30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:14:34 +0200 |
parents | 74fd4e045ea6 |
children | 2f8bb876ab1d |
comparison
equal
deleted
inserted
replaced
399:376370fb5946 | 400:a86b2b5e0111 |
---|---|
296 { | 296 { |
297 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 297 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
298 struct device *d = XDEVICE (device); | 298 struct device *d = XDEVICE (device); |
299 struct frame *f; | 299 struct frame *f; |
300 void* bmp_buf=0; | 300 void* bmp_buf=0; |
301 int type = 0; | 301 enum image_instance_type type; |
302 HBITMAP bitmap; | 302 HBITMAP bitmap; |
303 HDC hdc; | 303 HDC hdc; |
304 | 304 |
305 if (!DEVICE_MSWINDOWS_P (d)) | 305 if (!DEVICE_MSWINDOWS_P (d)) |
306 signal_simple_error ("Not an mswindows device", device); | 306 signal_simple_error ("Not an mswindows device", device); |
456 struct frame* f) | 456 struct frame* f) |
457 { | 457 { |
458 HBITMAP mask; | 458 HBITMAP mask; |
459 HGDIOBJ old = NULL; | 459 HGDIOBJ old = NULL; |
460 HDC hcdc = FRAME_MSWINDOWS_CDC (f); | 460 HDC hcdc = FRAME_MSWINDOWS_CDC (f); |
461 unsigned char* dibits; | 461 unsigned char *dibits, *and_bits; |
462 BITMAPINFO* bmp_info = | 462 BITMAPINFO *bmp_info = |
463 xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD)); | 463 (BITMAPINFO*) xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD)); |
464 int i, j; | 464 int i, j; |
465 int height = IMAGE_INSTANCE_PIXMAP_HEIGHT (image); | 465 int height = IMAGE_INSTANCE_PIXMAP_HEIGHT (image); |
466 | 466 |
467 void* and_bits; | |
468 int maskbpline = BPLINE ((IMAGE_INSTANCE_PIXMAP_WIDTH (image)+7)/8); | 467 int maskbpline = BPLINE ((IMAGE_INSTANCE_PIXMAP_WIDTH (image)+7)/8); |
469 int bpline = BPLINE (IMAGE_INSTANCE_PIXMAP_WIDTH (image) * 3); | 468 int bpline = BPLINE (IMAGE_INSTANCE_PIXMAP_WIDTH (image) * 3); |
470 | 469 |
471 if (!bmp_info) | 470 if (!bmp_info) |
472 return; | 471 return; |
490 bmp_info->bmiColors[0].rgbReserved = 0; | 489 bmp_info->bmiColors[0].rgbReserved = 0; |
491 | 490 |
492 if (!(mask = CreateDIBSection (hcdc, | 491 if (!(mask = CreateDIBSection (hcdc, |
493 bmp_info, | 492 bmp_info, |
494 DIB_RGB_COLORS, | 493 DIB_RGB_COLORS, |
495 &and_bits, | 494 (void**)&and_bits, |
496 0,0))) | 495 0,0))) |
497 { | 496 { |
498 xfree (bmp_info); | 497 xfree (bmp_info); |
499 return; | 498 return; |
500 } | 499 } |
511 bmp_info->bmiHeader.biCompression=BI_RGB; | 510 bmp_info->bmiHeader.biCompression=BI_RGB; |
512 bmp_info->bmiHeader.biClrUsed = 0; | 511 bmp_info->bmiHeader.biClrUsed = 0; |
513 bmp_info->bmiHeader.biClrImportant = 0; | 512 bmp_info->bmiHeader.biClrImportant = 0; |
514 bmp_info->bmiHeader.biSizeImage = height * bpline; | 513 bmp_info->bmiHeader.biSizeImage = height * bpline; |
515 | 514 |
516 dibits = xmalloc_and_zero (bpline * height); | 515 dibits = (unsigned char*) xmalloc_and_zero (bpline * height); |
517 if (GetDIBits (hcdc, | 516 if (GetDIBits (hcdc, |
518 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image), | 517 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image), |
519 0, | 518 0, |
520 height, | 519 height, |
521 dibits, | 520 dibits, |
526 return; | 525 return; |
527 } | 526 } |
528 | 527 |
529 /* now set the colored bits in the mask and transparent ones to | 528 /* now set the colored bits in the mask and transparent ones to |
530 black in the original */ | 529 black in the original */ |
531 for(i=0; i<IMAGE_INSTANCE_PIXMAP_WIDTH (image); i++) | 530 for (i=0; i<IMAGE_INSTANCE_PIXMAP_WIDTH (image); i++) |
532 { | 531 { |
533 for(j=0; j<height; j++) | 532 for (j=0; j<height; j++) |
534 { | 533 { |
535 unsigned char* idx = &dibits[j * bpline + i * 3]; | 534 unsigned char* idx = &dibits[j * bpline + i * 3]; |
536 | 535 |
537 if( RGB (idx[2], idx[1], idx[0]) == transparent_color ) | 536 if (RGB (idx[2], idx[1], idx[0]) == transparent_color) |
538 { | 537 { |
539 idx[0] = idx[1] = idx[2] = 0; | 538 idx[0] = idx[1] = idx[2] = 0; |
540 set_mono_pixel( and_bits, maskbpline, height, i, j, TRUE ); | 539 set_mono_pixel (and_bits, maskbpline, height, i, j, TRUE); |
541 } | 540 } |
542 else | 541 else |
543 { | 542 { |
544 set_mono_pixel( and_bits, maskbpline, height, i, j, FALSE ); | 543 set_mono_pixel (and_bits, maskbpline, height, i, j, FALSE); |
545 } | 544 } |
546 } | 545 } |
547 } | 546 } |
548 | 547 |
549 SetDIBits (hcdc, | 548 SetDIBits (hcdc, |
1220 unsigned int type = 0; | 1219 unsigned int type = 0; |
1221 HANDLE himage = NULL; | 1220 HANDLE himage = NULL; |
1222 LPCTSTR resid=0; | 1221 LPCTSTR resid=0; |
1223 HINSTANCE hinst = NULL; | 1222 HINSTANCE hinst = NULL; |
1224 ICONINFO iconinfo; | 1223 ICONINFO iconinfo; |
1225 int iitype=0; | 1224 enum image_instance_type iitype; |
1226 char* fname=0; | 1225 char* fname=0; |
1227 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 1226 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
1228 | 1227 |
1229 Lisp_Object file = find_keyword_in_vector (instantiator, Q_file); | 1228 Lisp_Object file = find_keyword_in_vector (instantiator, Q_file); |
1230 Lisp_Object resource_type = find_keyword_in_vector (instantiator, | 1229 Lisp_Object resource_type = find_keyword_in_vector (instantiator, |
1302 | 1301 |
1303 /* hey, we've got an icon type thing so we can reverse engineer the | 1302 /* hey, we've got an icon type thing so we can reverse engineer the |
1304 bitmap and mask */ | 1303 bitmap and mask */ |
1305 if (type != IMAGE_BITMAP) | 1304 if (type != IMAGE_BITMAP) |
1306 { | 1305 { |
1307 GetIconInfo (himage, &iconinfo); | 1306 GetIconInfo ((HICON)himage, &iconinfo); |
1308 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = iconinfo.hbmColor; | 1307 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = iconinfo.hbmColor; |
1309 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = iconinfo.hbmMask; | 1308 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = iconinfo.hbmMask; |
1310 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), iconinfo.xHotspot); | 1309 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), iconinfo.xHotspot); |
1311 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), iconinfo.yHotspot); | 1310 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), iconinfo.yHotspot); |
1312 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = himage; | 1311 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = (HICON) himage; |
1313 } | 1312 } |
1314 else | 1313 else |
1315 { | 1314 { |
1316 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = NULL; | 1315 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = NULL; |
1317 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = himage; | 1316 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = (HBITMAP) himage; |
1318 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL; | 1317 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL; |
1319 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0); | 1318 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0); |
1320 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0); | 1319 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0); |
1321 } | 1320 } |
1322 } | 1321 } |
1474 * The data returned by the following routine is always in left-most byte | 1473 * 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 | 1474 * 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 | 1475 * its arguments won't have been touched. This routine should look as much |
1477 * like the Xlib routine XReadBitmapfile as possible. | 1476 * like the Xlib routine XReadBitmapfile as possible. |
1478 */ | 1477 */ |
1479 int read_bitmap_data (fstream, width, height, datap, x_hot, y_hot) | 1478 int read_bitmap_data (FILE* fstream, unsigned int *width, |
1480 FILE *fstream; /* handle on file */ | 1479 unsigned int *height, unsigned char **datap, |
1481 unsigned int *width, *height; /* RETURNED */ | 1480 int *x_hot, int *y_hot) |
1482 unsigned char **datap; /* RETURNED */ | |
1483 int *x_hot, *y_hot; /* RETURNED */ | |
1484 { | 1481 { |
1485 unsigned char *data = NULL; /* working variable */ | 1482 unsigned char *data = NULL; /* working variable */ |
1486 char line[MAX_SIZE]; /* input line from file */ | 1483 char line[MAX_SIZE]; /* input line from file */ |
1487 int size; /* number of bytes of data */ | 1484 int size; /* number of bytes of data */ |
1488 char name_and_type[MAX_SIZE]; /* an input line */ | 1485 char name_and_type[MAX_SIZE]; /* an input line */ |
1638 int new_width = BPLINE (2*((width + 15)/16)); | 1635 int new_width = BPLINE (2*((width + 15)/16)); |
1639 unsigned char *offset; | 1636 unsigned char *offset; |
1640 void *bmp_buf = 0; | 1637 void *bmp_buf = 0; |
1641 unsigned char *new_data, *new_offset; | 1638 unsigned char *new_data, *new_offset; |
1642 int i, j; | 1639 int i, j; |
1643 BITMAPINFO* bmp_info = | 1640 BITMAPINFO *bmp_info = |
1644 xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD)); | 1641 (BITMAPINFO*) xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD)); |
1645 HBITMAP bitmap; | 1642 HBITMAP bitmap; |
1646 | 1643 |
1647 if (!bmp_info) | 1644 if (!bmp_info) |
1648 return NULL; | 1645 return NULL; |
1649 | 1646 |
2507 | 2504 |
2508 /* Update the state of a button. */ | 2505 /* Update the state of a button. */ |
2509 static void | 2506 static void |
2510 mswindows_button_update (Lisp_Object image_instance) | 2507 mswindows_button_update (Lisp_Object image_instance) |
2511 { | 2508 { |
2509 /* This function can GC if IN_REDISPLAY is false. */ | |
2512 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2510 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2511 | |
2513 /* buttons checked or otherwise */ | 2512 /* buttons checked or otherwise */ |
2514 if (gui_item_selected_p (IMAGE_INSTANCE_WIDGET_ITEM (ii))) | 2513 if (gui_item_selected_p (IMAGE_INSTANCE_WIDGET_ITEM (ii))) |
2515 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | 2514 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), |
2516 BM_SETCHECK, (WPARAM)BST_CHECKED, 0); | 2515 BM_SETCHECK, (WPARAM)BST_CHECKED, 0); |
2517 else | 2516 else |
2721 static void | 2720 static void |
2722 mswindows_tab_control_update (Lisp_Object image_instance) | 2721 mswindows_tab_control_update (Lisp_Object image_instance) |
2723 { | 2722 { |
2724 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2723 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2725 | 2724 |
2726 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii)); | 2725 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii)) |
2727 { | 2726 { |
2728 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2727 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2729 int i = 0; | 2728 int i = 0; |
2730 Lisp_Object rest; | 2729 Lisp_Object rest; |
2731 | 2730 |
2769 mswindows_combo_box_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2768 mswindows_combo_box_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2770 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2769 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2771 int dest_mask, Lisp_Object domain) | 2770 int dest_mask, Lisp_Object domain) |
2772 { | 2771 { |
2773 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2772 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2774 HANDLE wnd; | 2773 HWND wnd; |
2775 Lisp_Object rest; | 2774 Lisp_Object rest; |
2776 Lisp_Object data = Fplist_get (find_keyword_in_vector (instantiator, Q_properties), | 2775 Lisp_Object data = Fplist_get (find_keyword_in_vector (instantiator, Q_properties), |
2777 Q_items, Qnil); | 2776 Q_items, Qnil); |
2778 int len, height; | 2777 int len, height; |
2779 | 2778 |
2823 /* get properties of a control */ | 2822 /* get properties of a control */ |
2824 static Lisp_Object | 2823 static Lisp_Object |
2825 mswindows_widget_property (Lisp_Object image_instance, Lisp_Object prop) | 2824 mswindows_widget_property (Lisp_Object image_instance, Lisp_Object prop) |
2826 { | 2825 { |
2827 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2826 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2828 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2827 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2829 /* get the text from a control */ | 2828 /* get the text from a control */ |
2830 if (EQ (prop, Q_text)) | 2829 if (EQ (prop, Q_text)) |
2831 { | 2830 { |
2832 Extcount len = SendMessage (wnd, WM_GETTEXTLENGTH, 0, 0); | 2831 Extcount len = SendMessage (wnd, WM_GETTEXTLENGTH, 0, 0); |
2833 Extbyte* buf =alloca (len+1); | 2832 Extbyte *buf = (Extbyte*) alloca (len+1); |
2834 | 2833 |
2835 SendMessage (wnd, WM_GETTEXT, (WPARAM)len+1, (LPARAM) buf); | 2834 SendMessage (wnd, WM_GETTEXT, (WPARAM)len+1, (LPARAM) buf); |
2836 return build_ext_string (buf, Qnative); | 2835 return build_ext_string (buf, Qnative); |
2837 } | 2836 } |
2838 return Qunbound; | 2837 return Qunbound; |
2841 /* get properties of a button */ | 2840 /* get properties of a button */ |
2842 static Lisp_Object | 2841 static Lisp_Object |
2843 mswindows_button_property (Lisp_Object image_instance, Lisp_Object prop) | 2842 mswindows_button_property (Lisp_Object image_instance, Lisp_Object prop) |
2844 { | 2843 { |
2845 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2844 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2846 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2845 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2847 /* check the state of a button */ | 2846 /* check the state of a button */ |
2848 if (EQ (prop, Q_selected)) | 2847 if (EQ (prop, Q_selected)) |
2849 { | 2848 { |
2850 if (SendMessage (wnd, BM_GETSTATE, 0, 0) & BST_CHECKED) | 2849 if (SendMessage (wnd, BM_GETSTATE, 0, 0) & BST_CHECKED) |
2851 return Qt; | 2850 return Qt; |
2858 /* get properties of a combo box */ | 2857 /* get properties of a combo box */ |
2859 static Lisp_Object | 2858 static Lisp_Object |
2860 mswindows_combo_box_property (Lisp_Object image_instance, Lisp_Object prop) | 2859 mswindows_combo_box_property (Lisp_Object image_instance, Lisp_Object prop) |
2861 { | 2860 { |
2862 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2861 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2863 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2862 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2864 /* get the text from a control */ | 2863 /* get the text from a control */ |
2865 if (EQ (prop, Q_text)) | 2864 if (EQ (prop, Q_text)) |
2866 { | 2865 { |
2867 long item = SendMessage (wnd, CB_GETCURSEL, 0, 0); | 2866 long item = SendMessage (wnd, CB_GETCURSEL, 0, 0); |
2868 Extcount len = SendMessage (wnd, CB_GETLBTEXTLEN, (WPARAM)item, 0); | 2867 Extcount len = SendMessage (wnd, CB_GETLBTEXTLEN, (WPARAM)item, 0); |
2869 Extbyte* buf = alloca (len+1); | 2868 Extbyte* buf = (Extbyte*) alloca (len+1); |
2870 SendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM)buf); | 2869 SendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM)buf); |
2871 return build_ext_string (buf, Qnative); | 2870 return build_ext_string (buf, Qnative); |
2872 } | 2871 } |
2873 return Qunbound; | 2872 return Qunbound; |
2874 } | 2873 } |