comparison src/glyphs-msw.c @ 563:183866b06e0b

[xemacs-hg @ 2001-05-24 07:50:48 by ben] Makefile.in.in, abbrev.c, alloc.c, buffer.c, bytecode.c, callint.c, callproc.c, casetab.c, chartab.c, cmdloop.c, cmds.c, console-msw.c, console-msw.h, console-stream.c, console-tty.c, console-x.c, console.c, data.c, database.c, debug.c, device-gtk.c, device-msw.c, device-tty.c, device-x.c, device.c, dialog-gtk.c, dialog-msw.c, dialog-x.c, dialog.c, dired-msw.c, dired.c, doc.c, doprnt.c, dragdrop.c, editfns.c, eldap.c, eldap.h, elhash.c, emacs-widget-accessors.c, emacs.c, emodules.c, esd.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, events.c, extents.c, faces.c, file-coding.c, fileio.c, filelock.c, floatfns.c, fns.c, font-lock.c, frame-gtk.c, frame-x.c, frame.c, general-slots.h, glade.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gui-gtk.c, gui-x.c, gui.c, gutter.c, hpplay.c, indent.c, input-method-xlib.c, insdel.c, intl.c, keymap.c, libsst.c, libsst.h, linuxplay.c, lisp.h, lread.c, lstream.c, lstream.h, macros.c, marker.c, md5.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, miscplay.c, miscplay.h, mule-ccl.c, mule-charset.c, mule-wnnfns.c, mule.c, nas.c, ntplay.c, ntproc.c, objects-gtk.c, objects-msw.c, objects-x.c, objects.c, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, ralloc.c, rangetab.c, redisplay.c, scrollbar.c, search.c, select-gtk.c, select-x.c, select.c, sgiplay.c, sheap.c, sound.c, specifier.c, sunplay.c, symbols.c, symeval.h, symsinit.h, syntax.c, sysdep.c, toolbar-msw.c, toolbar.c, tooltalk.c, ui-byhand.c, ui-gtk.c, undo.c, unexaix.c, unexapollo.c, unexconvex.c, unexec.c, widget.c, win32.c, window.c: -- defsymbol -> DEFSYMBOL. -- add an error type to all errors. -- eliminate the error functions in eval.c that let you just use Qerror as the type. -- redo the error API to be more consistent, sensibly named, and easier to use. -- redo the error hierarchy somewhat. create new errors: structure-formation-error, gui-error, invalid-constant, stack-overflow, out-of-memory, process-error, network-error, sound-error, printing-unreadable-object, base64-conversion- error; coding-system-error renamed to text-conversion error; some others. -- fix Mule problems in error strings in emodules.c, tooltalk.c. -- fix error handling in mswin open-network-stream. -- Mule-ize all sound files and clean up the headers. -- nativesound.h -> sound.h and used for all sound files. -- move some shared stuff into glyphs-shared.c: first attempt at eliminating some of the massive GTK code duplication. xemacs.mak: add glyphs-shared.c. xemacs-faq.texi: document how to debug X errors subr.el: fix doc string to reflect reality
author ben
date Thu, 24 May 2001 07:51:33 +0000
parents ed498ef2108b
children 5fd7ba8b56e7
comparison
equal deleted inserted replaced
562:c775bd016b32 563:183866b06e0b
92 Lisp_Object Qbmp; 92 Lisp_Object Qbmp;
93 Lisp_Object Vmswindows_bitmap_file_path; 93 Lisp_Object Vmswindows_bitmap_file_path;
94 static COLORREF transparent_color = RGB (1,1,1); 94 static COLORREF transparent_color = RGB (1,1,1);
95 95
96 DEFINE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource); 96 DEFINE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource);
97 Lisp_Object Q_resource_type, Q_resource_id;
98 Lisp_Object Qmswindows_resource; 97 Lisp_Object Qmswindows_resource;
99 98
100 static void 99 static void
101 mswindows_initialize_dibitmap_image_instance (Lisp_Image_Instance *ii, 100 mswindows_initialize_dibitmap_image_instance (Lisp_Image_Instance *ii,
102 int slices, 101 int slices,
365 DIB_RGB_COLORS, 364 DIB_RGB_COLORS,
366 &bmp_buf, 365 &bmp_buf,
367 0, 0); 366 0, 0);
368 367
369 if (!bitmap || !bmp_buf) 368 if (!bitmap || !bmp_buf)
370 signal_simple_error ("Unable to create bitmap", instantiator); 369 signal_image_error ("Unable to create bitmap", instantiator);
371 370
372 /* copy in the actual bitmap */ 371 /* copy in the actual bitmap */
373 memcpy (bmp_buf, bmp_data, bmp_bits); 372 memcpy (bmp_buf, bmp_data, bmp_bits);
374 373
375 mswindows_initialize_dibitmap_image_instance (ii, slices, type); 374 mswindows_initialize_dibitmap_image_instance (ii, slices, type);
417 DIB_RGB_COLORS, 416 DIB_RGB_COLORS,
418 &bmp_buf, 417 &bmp_buf,
419 0,0); 418 0,0);
420 419
421 if (!bitmap || !bmp_buf) 420 if (!bitmap || !bmp_buf)
422 signal_simple_error ("Unable to create bitmap", instantiator); 421 signal_image_error ("Unable to create bitmap", instantiator);
423 422
424 /* copy in the actual bitmap */ 423 /* copy in the actual bitmap */
425 memcpy (bmp_buf, bmp_data, bmp_bits); 424 memcpy (bmp_buf, bmp_data, bmp_bits);
426 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (ii, slice) = bitmap; 425 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (ii, slice) = bitmap;
427 } 426 }
454 /* build a bitmap from the eimage */ 453 /* build a bitmap from the eimage */
455 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, 454 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height,
456 eimage + (width * height * 3 * slice), 455 eimage + (width * height * 3 * slice),
457 &bmp_bits, &bmp_data))) 456 &bmp_bits, &bmp_data)))
458 { 457 {
459 signal_simple_error ("EImage to DIBitmap conversion failed", 458 signal_image_error ("EImage to DIBitmap conversion failed",
460 instantiator); 459 instantiator);
461 } 460 }
462 461
463 /* Now create the pixmap and set up the image instance */ 462 /* Now create the pixmap and set up the image instance */
464 if (slice == 0) 463 if (slice == 0)
465 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, 464 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
814 { 813 {
815 case XpmSuccess: 814 case XpmSuccess:
816 break; 815 break;
817 case XpmFileInvalid: 816 case XpmFileInvalid:
818 { 817 {
819 signal_simple_error ("Invalid XPM data", image); 818 signal_image_error ("Invalid XPM data", image);
820 } 819 }
821 case XpmNoMemory: 820 case XpmNoMemory:
822 { 821 {
823 signal_double_file_error ("Parsing pixmap data", 822 signal_double_image_error ("Parsing pixmap data",
824 "out of memory", image); 823 "out of memory", image);
825 } 824 }
826 default: 825 default:
827 { 826 {
828 signal_double_file_error_2 ("Parsing pixmap data", 827 signal_double_image_error_2 ("Parsing pixmap data",
829 "unknown error", 828 "unknown error",
830 make_int (result), image); 829 make_int (result), image);
831 } 830 }
832 } 831 }
833 832
834 *width = xpmimage.width; 833 *width = xpmimage.width;
835 *height = xpmimage.height; 834 *height = xpmimage.height;
970 969
971 /* convert to an eimage to make processing easier */ 970 /* convert to an eimage to make processing easier */
972 if (!xpm_to_eimage (image_instance, bytes, &eimage, &width, &height, 971 if (!xpm_to_eimage (image_instance, bytes, &eimage, &width, &height,
973 &x_hot, &y_hot, &transp, color_symbols, nsymbols)) 972 &x_hot, &y_hot, &transp, color_symbols, nsymbols))
974 { 973 {
975 signal_simple_error ("XPM to EImage conversion failed", 974 signal_image_error ("XPM to EImage conversion failed",
976 image_instance); 975 image_instance);
977 } 976 }
978 977
979 if (color_symbols) 978 if (color_symbols)
980 { 979 {
981 while (nsymbols--) 980 while (nsymbols--)
987 986
988 /* build a bitmap from the eimage */ 987 /* build a bitmap from the eimage */
989 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage, 988 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage,
990 &bmp_bits, &bmp_data))) 989 &bmp_bits, &bmp_data)))
991 { 990 {
992 signal_simple_error ("XPM to EImage conversion failed", 991 signal_image_error ("XPM to EImage conversion failed",
993 image_instance); 992 image_instance);
994 } 993 }
995 xfree (eimage); 994 xfree (eimage);
996 995
997 /* Now create the pixmap and set up the image instance */ 996 /* Now create the pixmap and set up the image instance */
998 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, 997 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
1071 **********************************************************************/ 1070 **********************************************************************/
1072 1071
1073 static void 1072 static void
1074 mswindows_resource_validate (Lisp_Object instantiator) 1073 mswindows_resource_validate (Lisp_Object instantiator)
1075 { 1074 {
1076 if ((NILP (find_keyword_in_vector (instantiator, Q_file)) 1075 shared_resource_validate (instantiator);
1077 &&
1078 NILP (find_keyword_in_vector (instantiator, Q_resource_id)))
1079 ||
1080 NILP (find_keyword_in_vector (instantiator, Q_resource_type)))
1081 signal_simple_error ("Must supply :file, :resource-id and :resource-type",
1082 instantiator);
1083 } 1076 }
1084 1077
1085 static Lisp_Object 1078 static Lisp_Object
1086 mswindows_resource_normalize (Lisp_Object inst, Lisp_Object console_type, 1079 mswindows_resource_normalize (Lisp_Object inst, Lisp_Object console_type,
1087 Lisp_Object dest_mask) 1080 Lisp_Object dest_mask)
1088 { 1081 {
1089 /* This function can call lisp */ 1082 return shared_resource_normalize (inst, console_type, dest_mask,
1090 Lisp_Object file = Qnil; 1083 Qmswindows_resource);
1091 struct gcpro gcpro1, gcpro2;
1092 Lisp_Object alist = Qnil;
1093
1094 GCPRO2 (file, alist);
1095
1096 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data,
1097 console_type);
1098
1099 if (CONSP (file)) /* failure locating filename */
1100 signal_double_file_error ("Opening pixmap file",
1101 "no such file or directory",
1102 Fcar (file));
1103
1104 if (NILP (file)) /* no conversion necessary */
1105 RETURN_UNGCPRO (inst);
1106
1107 alist = tagged_vector_to_alist (inst);
1108
1109 {
1110 alist = remassq_no_quit (Q_file, alist);
1111 alist = Fcons (Fcons (Q_file, file), alist);
1112 }
1113
1114 {
1115 Lisp_Object result = alist_to_tagged_vector (Qmswindows_resource, alist);
1116 free_alist (alist);
1117 RETURN_UNGCPRO (result);
1118 }
1119 } 1084 }
1120 1085
1121 static int 1086 static int
1122 mswindows_resource_possible_dest_types (void) 1087 mswindows_resource_possible_dest_types (void)
1123 { 1088 {
1216 { 1181 {
1217 return XINT (name); 1182 return XINT (name);
1218 } 1183 }
1219 else if (!STRINGP (name)) 1184 else if (!STRINGP (name))
1220 { 1185 {
1221 signal_simple_error ("invalid resource identifier", name); 1186 invalid_argument ("invalid resource identifier", name);
1222 } 1187 }
1223 1188
1224 do { 1189 do {
1225 Extbyte* nm=0; 1190 Extbyte* nm=0;
1226 TO_EXTERNAL_FORMAT (LISP_STRING, name, 1191 TO_EXTERNAL_FORMAT (LISP_STRING, name,
1309 Qnative); 1274 Qnative);
1310 } 1275 }
1311 } 1276 }
1312 else if (!(resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id, 1277 else if (!(resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id,
1313 type)))) 1278 type))))
1314 signal_simple_error ("Invalid resource identifier", resource_id); 1279 invalid_argument ("Invalid resource identifier", resource_id);
1315 1280
1316 /* load the image */ 1281 /* load the image */
1317 if (xLoadImageA) /* not in NT 3.5 */ 1282 if (xLoadImageA) /* not in NT 3.5 */
1318 { 1283 {
1319 if (!(himage = xLoadImageA (hinst, resid, type, 0, 0, 1284 if (!(himage = xLoadImageA (hinst, resid, type, 0, 0,
1320 LR_CREATEDIBSECTION | LR_DEFAULTSIZE | 1285 LR_CREATEDIBSECTION | LR_DEFAULTSIZE |
1321 LR_SHARED | 1286 LR_SHARED |
1322 (!NILP (file) ? LR_LOADFROMFILE : 0)))) 1287 (!NILP (file) ? LR_LOADFROMFILE : 0))))
1323 signal_simple_error ("Cannot load image", instantiator); 1288 signal_image_error ("Cannot load image", instantiator);
1324 } 1289 }
1325 else 1290 else
1326 { 1291 {
1327 /* Is this correct? I don't really care. */ 1292 /* Is this correct? I don't really care. */
1328 switch (type) 1293 switch (type)
1337 himage = LoadIcon (hinst, resid); 1302 himage = LoadIcon (hinst, resid);
1338 break; 1303 break;
1339 } 1304 }
1340 1305
1341 if (!himage) 1306 if (!himage)
1342 signal_simple_error ("Cannot load image", instantiator); 1307 signal_image_error ("Cannot load image", instantiator);
1343 } 1308 }
1344 1309
1345 if (hinst) 1310 if (hinst)
1346 FreeLibrary (hinst); 1311 FreeLibrary (hinst);
1347 1312
1379 static void 1344 static void
1380 check_valid_resource_symbol (Lisp_Object data) 1345 check_valid_resource_symbol (Lisp_Object data)
1381 { 1346 {
1382 CHECK_SYMBOL (data); 1347 CHECK_SYMBOL (data);
1383 if (!resource_symbol_to_type (data)) 1348 if (!resource_symbol_to_type (data))
1384 signal_simple_error ("invalid resource type", data); 1349 invalid_constant ("invalid resource type", data);
1385 } 1350 }
1386 1351
1387 static void 1352 static void
1388 check_valid_resource_id (Lisp_Object data) 1353 check_valid_resource_id (Lisp_Object data)
1389 { 1354 {
1390 if (!resource_name_to_resource (data, IMAGE_CURSOR) 1355 if (!resource_name_to_resource (data, IMAGE_CURSOR)
1391 && 1356 &&
1392 !resource_name_to_resource (data, IMAGE_ICON) 1357 !resource_name_to_resource (data, IMAGE_ICON)
1393 && 1358 &&
1394 !resource_name_to_resource (data, IMAGE_BITMAP)) 1359 !resource_name_to_resource (data, IMAGE_BITMAP))
1395 signal_simple_error ("invalid resource identifier", data); 1360 invalid_constant ("invalid resource identifier", data);
1396 } 1361 }
1397 1362
1398 /********************************************************************** 1363 /**********************************************************************
1399 * XBM * 1364 * XBM *
1400 **********************************************************************/ 1365 **********************************************************************/
2026 emsg = "uncompface: excess data ignored"; 1991 emsg = "uncompface: excess data ignored";
2027 break; 1992 break;
2028 } 1993 }
2029 1994
2030 if (emsg) 1995 if (emsg)
2031 signal_simple_error_2 (emsg, data, Qimage); 1996 signal_image_error_2 (emsg, data, Qimage);
2032 1997
2033 bp = bits = (char *) alloca (PIXELS / 8); 1998 bp = bits = (char *) alloca (PIXELS / 8);
2034 1999
2035 /* the compface library exports char F[], which uses a single byte per 2000 /* the compface library exports char F[], which uses a single byte per
2036 pixel to represent a 48x48 bitmap. Yuck. */ 2001 pixel to represent a 48x48 bitmap. Yuck. */
2406 /* parent window */ 2371 /* parent window */
2407 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), 2372 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
2408 NULL, /* No menu */ 2373 NULL, /* No menu */
2409 NULL, /* must be null for this class */ 2374 NULL, /* must be null for this class */
2410 NULL)) == NULL) 2375 NULL)) == NULL)
2411 signal_simple_error ("window creation failed with code", 2376 gui_error ("window creation failed with code",
2412 make_int (GetLastError())); 2377 make_int (GetLastError()));
2413 2378
2414 wnd = CreateWindow( "STATIC", 2379 wnd = CreateWindow( "STATIC",
2415 "", 2380 "",
2416 WS_CHILD, 2381 WS_CHILD,
2417 0, /* starting x position */ 2382 0, /* starting x position */
2545 /* parent window */ 2510 /* parent window */
2546 DOMAIN_MSWINDOWS_HANDLE (domain), 2511 DOMAIN_MSWINDOWS_HANDLE (domain),
2547 (HMENU)id, /* No menu */ 2512 (HMENU)id, /* No menu */
2548 NULL, /* must be null for this class */ 2513 NULL, /* must be null for this class */
2549 NULL)) == NULL) 2514 NULL)) == NULL)
2550 signal_simple_error ("window creation failed with code", 2515 gui_error ("window creation failed with code",
2551 make_int (GetLastError())); 2516 make_int (GetLastError()));
2552 2517
2553 if ((wnd = CreateWindowEx( 2518 if ((wnd = CreateWindowEx(
2554 exflags /* | WS_EX_NOPARENTNOTIFY*/, 2519 exflags /* | WS_EX_NOPARENTNOTIFY*/,
2555 class, 2520 class,
2556 nm, 2521 nm,
2565 (HINSTANCE) 2530 (HINSTANCE)
2566 GetWindowLong 2531 GetWindowLong
2567 (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), 2532 (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
2568 GWL_HINSTANCE), 2533 GWL_HINSTANCE),
2569 NULL)) == NULL) 2534 NULL)) == NULL)
2570 signal_simple_error ("window creation failed with code", 2535 gui_error ("window creation failed with code",
2571 make_int (GetLastError())); 2536 make_int (GetLastError()));
2572 2537
2573 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; 2538 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd;
2574 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); 2539 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance));
2575 /* set the widget font from the widget face */ 2540 /* set the widget font from the widget face */
2576 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) 2541 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii)))
2777 2742
2778 tvitem.item.cchTextMax = strlen (tvitem.item.pszText); 2743 tvitem.item.cchTextMax = strlen (tvitem.item.pszText);
2779 2744
2780 if ((ret = (HTREEITEM)SendMessage (wnd, TVM_INSERTITEM, 2745 if ((ret = (HTREEITEM)SendMessage (wnd, TVM_INSERTITEM,
2781 0, (LPARAM)&tvitem)) == 0) 2746 0, (LPARAM)&tvitem)) == 0)
2782 signal_simple_error ("error adding tree view entry", item); 2747 gui_error ("error adding tree view entry", item);
2783 2748
2784 return ret; 2749 return ret;
2785 } 2750 }
2786 2751
2787 static void add_tree_item_list (Lisp_Object image_instance, 2752 static void add_tree_item_list (Lisp_Object image_instance,
2900 2865
2901 tvitem.cchTextMax = strlen (tvitem.pszText); 2866 tvitem.cchTextMax = strlen (tvitem.pszText);
2902 2867
2903 if ((ret = SendMessage (wnd, TCM_INSERTITEM, 2868 if ((ret = SendMessage (wnd, TCM_INSERTITEM,
2904 i, (LPARAM)&tvitem)) < 0) 2869 i, (LPARAM)&tvitem)) < 0)
2905 signal_simple_error ("error adding tab entry", item); 2870 gui_error ("error adding tab entry", item);
2906 2871
2907 return ret; 2872 return ret;
2908 } 2873 }
2909 2874
2910 static void 2875 static void
3101 Extbyte* lparam; 3066 Extbyte* lparam;
3102 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (rest), 3067 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (rest),
3103 C_STRING_ALLOCA, lparam, 3068 C_STRING_ALLOCA, lparam,
3104 Qnative); 3069 Qnative);
3105 if (SendMessage (wnd, CB_ADDSTRING, 0, (LPARAM)lparam) == CB_ERR) 3070 if (SendMessage (wnd, CB_ADDSTRING, 0, (LPARAM)lparam) == CB_ERR)
3106 signal_simple_error ("error adding combo entries", instantiator); 3071 gui_error ("error adding combo entries", instantiator);
3107 } 3072 }
3108 } 3073 }
3109 3074
3110 /* get properties of a control */ 3075 /* get properties of a control */
3111 static Lisp_Object 3076 static Lisp_Object
3212 /************************************************************************/ 3177 /************************************************************************/
3213 3178
3214 void 3179 void
3215 syms_of_glyphs_mswindows (void) 3180 syms_of_glyphs_mswindows (void)
3216 { 3181 {
3217 defkeyword (&Q_resource_id, ":resource-id");
3218 defkeyword (&Q_resource_type, ":resource-type");
3219 } 3182 }
3220 3183
3221 void 3184 void
3222 console_type_create_glyphs_mswindows (void) 3185 console_type_create_glyphs_mswindows (void)
3223 { 3186 {