Mercurial > hg > xemacs-beta
comparison src/glyphs-x.c @ 276:6330739388db r21-0b36
Import from CVS: tag r21-0b36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:30:37 +0200 |
parents | ca9a9ec9c1c1 |
children | 90d73dddcdc4 |
comparison
equal
deleted
inserted
replaced
275:a68ae4439f57 | 276:6330739388db |
---|---|
33 GIF/JPEG support added by Ben Wing for 19.14 | 33 GIF/JPEG support added by Ben Wing for 19.14 |
34 PNG support added by Bill Perry for 19.14 | 34 PNG support added by Bill Perry for 19.14 |
35 Improved GIF/JPEG support added by Bill Perry for 19.14 | 35 Improved GIF/JPEG support added by Bill Perry for 19.14 |
36 Cleanup/simplification of error handling by Ben Wing for 19.14 | 36 Cleanup/simplification of error handling by Ben Wing for 19.14 |
37 Pointer/icon overhaul, more restructuring by Ben Wing for 19.14 | 37 Pointer/icon overhaul, more restructuring by Ben Wing for 19.14 |
38 GIF support changed to external GIFlib 3.1 by Jareth Hein for 20.5 | 38 GIF support changed to external GIFlib 3.1 by Jareth Hein for 21.0 |
39 Many changes for color work and optimizations by Jareth Hein for 20.5 | 39 Many changes for color work and optimizations by Jareth Hein for 21.0 |
40 Switch of GIF/JPEG/PNG to new EImage intermediate code by Jareth Hein for 20.5 | 40 Switch of GIF/JPEG/PNG to new EImage intermediate code by Jareth Hein for 21.0 |
41 TIFF code by Jareth Hein for 20.5 | 41 TIFF code by Jareth Hein for 21.0 |
42 | 42 |
43 TODO: | 43 TODO: |
44 Convert images.el to C and stick it in here? | 44 Convert images.el to C and stick it in here? |
45 */ | 45 */ |
46 | 46 |
93 | 93 |
94 Lisp_Object Q_mask_file, Q_mask_data, Q_hotspot_x, Q_hotspot_y; | 94 Lisp_Object Q_mask_file, Q_mask_data, Q_hotspot_x, Q_hotspot_y; |
95 Lisp_Object Q_foreground, Q_background; | 95 Lisp_Object Q_foreground, Q_background; |
96 | 96 |
97 #ifdef HAVE_XPM | 97 #ifdef HAVE_XPM |
98 DEFINE_IMAGE_INSTANTIATOR_FORMAT (xpm); | |
99 Lisp_Object Qxpm; | |
100 Lisp_Object Q_color_symbols; | 98 Lisp_Object Q_color_symbols; |
101 void mswindows_xpm_instantiate (Lisp_Object image_instance, | |
102 Lisp_Object instantiator, | |
103 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | |
104 int dest_mask, Lisp_Object domain); | |
105 #endif | 99 #endif |
106 | 100 |
107 #ifdef HAVE_XFACE | 101 #ifdef HAVE_XFACE |
108 DEFINE_IMAGE_INSTANTIATOR_FORMAT (xface); | 102 DEFINE_IMAGE_INSTANTIATOR_FORMAT (xface); |
109 Lisp_Object Qxface; | 103 Lisp_Object Qxface; |
147 | 141 |
148 | 142 |
149 /************************************************************************/ | 143 /************************************************************************/ |
150 /* image instance methods */ | 144 /* image instance methods */ |
151 /************************************************************************/ | 145 /************************************************************************/ |
152 static DOESNT_RETURN | |
153 signal_image_error (CONST char *reason, Lisp_Object frob) | |
154 { | |
155 signal_error (Qimage_conversion_error, | |
156 list2 (build_translated_string (reason), frob)); | |
157 } | |
158 | |
159 static DOESNT_RETURN | |
160 signal_image_error_2 (CONST char *reason, Lisp_Object frob0, Lisp_Object frob1) | |
161 { | |
162 signal_error (Qimage_conversion_error, | |
163 list3 (build_translated_string (reason), frob0, frob1)); | |
164 } | |
165 | 146 |
166 /************************************************************************/ | 147 /************************************************************************/ |
167 /* convert from a series of RGB triples to an XImage formated for the */ | 148 /* convert from a series of RGB triples to an XImage formated for the */ |
168 /* proper display */ | 149 /* proper display */ |
169 /************************************************************************/ | 150 /************************************************************************/ |
1333 | 1314 |
1334 /********************************************************************** | 1315 /********************************************************************** |
1335 * XPM * | 1316 * XPM * |
1336 **********************************************************************/ | 1317 **********************************************************************/ |
1337 | 1318 |
1338 static void | |
1339 check_valid_xpm_color_symbols (Lisp_Object data) | |
1340 { | |
1341 Lisp_Object rest; | |
1342 | |
1343 for (rest = data; !NILP (rest); rest = XCDR (rest)) | |
1344 { | |
1345 if (!CONSP (rest) || | |
1346 !CONSP (XCAR (rest)) || | |
1347 !STRINGP (XCAR (XCAR (rest))) || | |
1348 (!STRINGP (XCDR (XCAR (rest))) && | |
1349 !COLOR_SPECIFIERP (XCDR (XCAR (rest))))) | |
1350 signal_simple_error ("Invalid color symbol alist", data); | |
1351 } | |
1352 } | |
1353 | |
1354 static void | |
1355 xpm_validate (Lisp_Object instantiator) | |
1356 { | |
1357 file_or_data_must_be_present (instantiator); | |
1358 } | |
1359 | |
1360 static Lisp_Object | 1319 static Lisp_Object |
1361 pixmap_to_lisp_data (Lisp_Object name, int ok_if_data_invalid) | 1320 pixmap_to_lisp_data (Lisp_Object name, int ok_if_data_invalid) |
1362 { | 1321 { |
1363 char **data; | 1322 char **data; |
1364 int result; | 1323 int result; |
1435 } | 1394 } |
1436 | 1395 |
1437 return Qnil; /* not reached */ | 1396 return Qnil; /* not reached */ |
1438 } | 1397 } |
1439 | 1398 |
1440 Lisp_Object Vxpm_color_symbols; | 1399 Lisp_Object |
1441 | 1400 x_xpm_normalize (Lisp_Object inst, Lisp_Object console_type) |
1442 static Lisp_Object | |
1443 evaluate_xpm_color_symbols (void) | |
1444 { | |
1445 Lisp_Object rest, results = Qnil; | |
1446 struct gcpro gcpro1, gcpro2; | |
1447 | |
1448 GCPRO2 (rest, results); | |
1449 for (rest = Vxpm_color_symbols; !NILP (rest); rest = XCDR (rest)) | |
1450 { | |
1451 Lisp_Object name, value, cons; | |
1452 | |
1453 CHECK_CONS (rest); | |
1454 cons = XCAR (rest); | |
1455 CHECK_CONS (cons); | |
1456 name = XCAR (cons); | |
1457 CHECK_STRING (name); | |
1458 value = XCDR (cons); | |
1459 CHECK_CONS (value); | |
1460 value = XCAR (value); | |
1461 value = Feval (value); | |
1462 if (NILP (value)) | |
1463 continue; | |
1464 if (!STRINGP (value) && !COLOR_SPECIFIERP (value)) | |
1465 signal_simple_error | |
1466 ("Result from xpm-color-symbols eval must be nil, string, or color", | |
1467 value); | |
1468 results = Fcons (Fcons (name, value), results); | |
1469 } | |
1470 UNGCPRO; /* no more evaluation */ | |
1471 return results; | |
1472 } | |
1473 | |
1474 static Lisp_Object | |
1475 xpm_normalize (Lisp_Object inst, Lisp_Object console_type) | |
1476 { | 1401 { |
1477 Lisp_Object file = Qnil; | 1402 Lisp_Object file = Qnil; |
1478 Lisp_Object color_symbols; | 1403 Lisp_Object color_symbols; |
1479 struct gcpro gcpro1, gcpro2; | 1404 struct gcpro gcpro1, gcpro2; |
1480 Lisp_Object alist = Qnil; | 1405 Lisp_Object alist = Qnil; |
1524 { | 1449 { |
1525 Lisp_Object result = alist_to_tagged_vector (Qxpm, alist); | 1450 Lisp_Object result = alist_to_tagged_vector (Qxpm, alist); |
1526 free_alist (alist); | 1451 free_alist (alist); |
1527 RETURN_UNGCPRO (result); | 1452 RETURN_UNGCPRO (result); |
1528 } | 1453 } |
1529 } | |
1530 | |
1531 static int | |
1532 xpm_possible_dest_types (void) | |
1533 { | |
1534 return | |
1535 IMAGE_MONO_PIXMAP_MASK | | |
1536 IMAGE_COLOR_PIXMAP_MASK | | |
1537 IMAGE_POINTER_MASK; | |
1538 } | 1454 } |
1539 | 1455 |
1540 /* xpm 3.2g and better has XpmCreatePixmapFromBuffer()... | 1456 /* xpm 3.2g and better has XpmCreatePixmapFromBuffer()... |
1541 There was no version number in xpm.h before 3.3, but this should do. | 1457 There was no version number in xpm.h before 3.3, but this should do. |
1542 */ | 1458 */ |
1628 to all zeros was ok (and also that it's ok to call XpmFreeAttributes() | 1544 to all zeros was ok (and also that it's ok to call XpmFreeAttributes() |
1629 multiple times, since it zeros slots as it frees them...) */ | 1545 multiple times, since it zeros slots as it frees them...) */ |
1630 XpmFreeAttributes (xpmattrs); | 1546 XpmFreeAttributes (xpmattrs); |
1631 } | 1547 } |
1632 | 1548 |
1633 static void | 1549 void |
1634 xpm_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 1550 x_xpm_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
1635 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 1551 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
1636 int dest_mask, Lisp_Object domain) | 1552 int dest_mask, Lisp_Object domain) |
1637 { | 1553 { |
1638 /* This function can GC */ | 1554 /* This function can GC */ |
1639 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 1555 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
1556 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | |
1640 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 1557 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
1641 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | |
1642 Display *dpy; | 1558 Display *dpy; |
1643 Screen *xs; | 1559 Screen *xs; |
1644 Colormap cmap; | 1560 Colormap cmap; |
1645 int depth; | 1561 int depth; |
1646 Pixmap pixmap; | 1562 Pixmap pixmap; |
1651 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator, | 1567 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator, |
1652 Q_color_symbols); | 1568 Q_color_symbols); |
1653 enum image_instance_type type; | 1569 enum image_instance_type type; |
1654 int force_mono; | 1570 int force_mono; |
1655 unsigned int w, h; | 1571 unsigned int w, h; |
1656 #ifdef HAVE_MS_WINDOWS | |
1657 if (DEVICE_MSWINDOWS_P (XDEVICE (device))) | |
1658 return mswindows_xpm_instantiate(image_instance, instantiator, | |
1659 pointer_fg, pointer_bg, | |
1660 dest_mask, domain); | |
1661 #endif | |
1662 | 1572 |
1663 if (!DEVICE_X_P (XDEVICE (device))) | 1573 if (!DEVICE_X_P (XDEVICE (device))) |
1664 signal_simple_error ("Not an X device", device); | 1574 signal_simple_error ("Not an X device", device); |
1665 | 1575 |
1666 dpy = DEVICE_X_DISPLAY (XDEVICE (device)); | 1576 dpy = DEVICE_X_DISPLAY (XDEVICE (device)); |
4600 defkeyword (&Q_mask_data, ":mask-data"); | 4510 defkeyword (&Q_mask_data, ":mask-data"); |
4601 defkeyword (&Q_hotspot_x, ":hotspot-x"); | 4511 defkeyword (&Q_hotspot_x, ":hotspot-x"); |
4602 defkeyword (&Q_hotspot_y, ":hotspot-y"); | 4512 defkeyword (&Q_hotspot_y, ":hotspot-y"); |
4603 defkeyword (&Q_foreground, ":foreground"); | 4513 defkeyword (&Q_foreground, ":foreground"); |
4604 defkeyword (&Q_background, ":background"); | 4514 defkeyword (&Q_background, ":background"); |
4605 | |
4606 #ifdef HAVE_XPM | |
4607 defkeyword (&Q_color_symbols, ":color-symbols"); | |
4608 #endif | |
4609 } | 4515 } |
4610 | 4516 |
4611 void | 4517 void |
4612 console_type_create_glyphs_x (void) | 4518 console_type_create_glyphs_x (void) |
4613 { | 4519 { |
4707 | 4613 |
4708 IIFORMAT_VALID_KEYWORD (tiff, Q_data, check_valid_string); | 4614 IIFORMAT_VALID_KEYWORD (tiff, Q_data, check_valid_string); |
4709 IIFORMAT_VALID_KEYWORD (tiff, Q_file, check_valid_string); | 4615 IIFORMAT_VALID_KEYWORD (tiff, Q_file, check_valid_string); |
4710 #endif | 4616 #endif |
4711 | 4617 |
4712 #ifdef HAVE_XPM | |
4713 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (xpm, "xpm"); | |
4714 | |
4715 IIFORMAT_HAS_METHOD (xpm, validate); | |
4716 IIFORMAT_HAS_METHOD (xpm, normalize); | |
4717 IIFORMAT_HAS_METHOD (xpm, possible_dest_types); | |
4718 IIFORMAT_HAS_METHOD (xpm, instantiate); | |
4719 | |
4720 IIFORMAT_VALID_KEYWORD (xpm, Q_data, check_valid_string); | |
4721 IIFORMAT_VALID_KEYWORD (xpm, Q_file, check_valid_string); | |
4722 IIFORMAT_VALID_KEYWORD (xpm, Q_color_symbols, check_valid_xpm_color_symbols); | |
4723 #endif | |
4724 | |
4725 #ifdef HAVE_XFACE | 4618 #ifdef HAVE_XFACE |
4726 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (xface, "xface"); | 4619 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (xface, "xface"); |
4727 | 4620 |
4728 IIFORMAT_HAS_METHOD (xface, validate); | 4621 IIFORMAT_HAS_METHOD (xface, validate); |
4729 IIFORMAT_HAS_METHOD (xface, normalize); | 4622 IIFORMAT_HAS_METHOD (xface, normalize); |
4764 Fprovide (Qpng); | 4657 Fprovide (Qpng); |
4765 #endif | 4658 #endif |
4766 | 4659 |
4767 #ifdef HAVE_TIFF | 4660 #ifdef HAVE_TIFF |
4768 Fprovide (Qtiff); | 4661 Fprovide (Qtiff); |
4769 #endif | |
4770 | |
4771 #ifdef HAVE_XPM | |
4772 Fprovide (Qxpm); | |
4773 | |
4774 DEFVAR_LISP ("xpm-color-symbols", &Vxpm_color_symbols /* | |
4775 Definitions of logical color-names used when reading XPM files. | |
4776 Elements of this list should be of the form (COLOR-NAME FORM-TO-EVALUATE). | |
4777 The COLOR-NAME should be a string, which is the name of the color to define; | |
4778 the FORM should evaluate to a `color' specifier object, or a string to be | |
4779 passed to `make-color-instance'. If a loaded XPM file references a symbolic | |
4780 color called COLOR-NAME, it will display as the computed color instead. | |
4781 | |
4782 The default value of this variable defines the logical color names | |
4783 \"foreground\" and \"background\" to be the colors of the `default' face. | |
4784 */ ); | |
4785 Vxpm_color_symbols = Qnil; /* initialized in x-faces.el */ | |
4786 #endif | 4662 #endif |
4787 | 4663 |
4788 #ifdef HAVE_XFACE | 4664 #ifdef HAVE_XFACE |
4789 Fprovide (Qxface); | 4665 Fprovide (Qxface); |
4790 #endif | 4666 #endif |