annotate src/glyphs-gtk.c @ 4952:19a72041c5ed

Mule-izing, various fixes related to char * arguments -------------------- ChangeLog entries follow: -------------------- modules/ChangeLog addition: 2010-01-26 Ben Wing <ben@xemacs.org> * postgresql/postgresql.c: * postgresql/postgresql.c (CHECK_LIVE_CONNECTION): * postgresql/postgresql.c (print_pgresult): * postgresql/postgresql.c (Fpq_conn_defaults): * postgresql/postgresql.c (Fpq_connectdb): * postgresql/postgresql.c (Fpq_connect_start): * postgresql/postgresql.c (Fpq_result_status): * postgresql/postgresql.c (Fpq_res_status): Mule-ize large parts of it. 2010-01-26 Ben Wing <ben@xemacs.org> * ldap/eldap.c (print_ldap): * ldap/eldap.c (allocate_ldap): Use write_ascstring(). src/ChangeLog addition: 2010-01-26 Ben Wing <ben@xemacs.org> * alloc.c: * alloc.c (build_ascstring): * alloc.c (build_msg_cistring): * alloc.c (staticpro_1): * alloc.c (staticpro_name): * alloc.c (staticpro_nodump_1): * alloc.c (staticpro_nodump_name): * alloc.c (unstaticpro_nodump_1): * alloc.c (mcpro_1): * alloc.c (mcpro_name): * alloc.c (object_memory_usage_stats): * alloc.c (common_init_alloc_early): * alloc.c (init_alloc_once_early): * buffer.c (print_buffer): * buffer.c (vars_of_buffer): * buffer.c (common_init_complex_vars_of_buffer): * buffer.c (init_initial_directory): * bytecode.c (invalid_byte_code): * bytecode.c (print_compiled_function): * bytecode.c (mark_compiled_function): * chartab.c (print_table_entry): * chartab.c (print_char_table): * config.h.in: * console-gtk.c: * console-gtk.c (gtk_device_to_console_connection): * console-gtk.c (gtk_semi_canonicalize_console_connection): * console-gtk.c (gtk_canonicalize_console_connection): * console-gtk.c (gtk_semi_canonicalize_device_connection): * console-gtk.c (gtk_canonicalize_device_connection): * console-stream.c (stream_init_frame_1): * console-stream.c (vars_of_console_stream): * console-stream.c (init_console_stream): * console-x.c (x_semi_canonicalize_console_connection): * console-x.c (x_semi_canonicalize_device_connection): * console-x.c (x_canonicalize_device_connection): * console-x.h: * data.c (eq_with_ebola_notice): * data.c (Fsubr_interactive): * data.c (Fnumber_to_string): * data.c (digit_to_number): * device-gtk.c (gtk_init_device): * device-msw.c (print_devmode): * device-x.c (x_event_name): * dialog-msw.c (handle_directory_dialog_box): * dialog-msw.c (handle_file_dialog_box): * dialog-msw.c (vars_of_dialog_mswindows): * doc.c (weird_doc): * doc.c (Fsnarf_documentation): * doc.c (vars_of_doc): * dumper.c (pdump): * dynarr.c: * dynarr.c (Dynarr_realloc): * editfns.c (Fuser_real_login_name): * editfns.c (get_home_directory): * elhash.c (print_hash_table_data): * elhash.c (print_hash_table): * emacs.c (main_1): * emacs.c (vars_of_emacs): * emodules.c: * emodules.c (_emodules_list): * emodules.c (Fload_module): * emodules.c (Funload_module): * emodules.c (Flist_modules): * emodules.c (find_make_module): * emodules.c (attempt_module_delete): * emodules.c (emodules_load): * emodules.c (emodules_doc_subr): * emodules.c (emodules_doc_sym): * emodules.c (syms_of_module): * emodules.c (vars_of_module): * emodules.h: * eval.c (print_subr): * eval.c (signal_call_debugger): * eval.c (build_error_data): * eval.c (signal_error): * eval.c (maybe_signal_error): * eval.c (signal_continuable_error): * eval.c (maybe_signal_continuable_error): * eval.c (signal_error_2): * eval.c (maybe_signal_error_2): * eval.c (signal_continuable_error_2): * eval.c (maybe_signal_continuable_error_2): * eval.c (signal_ferror): * eval.c (maybe_signal_ferror): * eval.c (signal_continuable_ferror): * eval.c (maybe_signal_continuable_ferror): * eval.c (signal_ferror_with_frob): * eval.c (maybe_signal_ferror_with_frob): * eval.c (signal_continuable_ferror_with_frob): * eval.c (maybe_signal_continuable_ferror_with_frob): * eval.c (syntax_error): * eval.c (syntax_error_2): * eval.c (maybe_syntax_error): * eval.c (sferror): * eval.c (sferror_2): * eval.c (maybe_sferror): * eval.c (invalid_argument): * eval.c (invalid_argument_2): * eval.c (maybe_invalid_argument): * eval.c (invalid_constant): * eval.c (invalid_constant_2): * eval.c (maybe_invalid_constant): * eval.c (invalid_operation): * eval.c (invalid_operation_2): * eval.c (maybe_invalid_operation): * eval.c (invalid_change): * eval.c (invalid_change_2): * eval.c (maybe_invalid_change): * eval.c (invalid_state): * eval.c (invalid_state_2): * eval.c (maybe_invalid_state): * eval.c (wtaerror): * eval.c (stack_overflow): * eval.c (out_of_memory): * eval.c (print_multiple_value): * eval.c (issue_call_trapping_problems_warning): * eval.c (backtrace_specials): * eval.c (backtrace_unevalled_args): * eval.c (Fbacktrace): * eval.c (warn_when_safe): * event-Xt.c (modwarn): * event-Xt.c (modbarf): * event-Xt.c (check_modifier): * event-Xt.c (store_modifier): * event-Xt.c (emacs_Xt_format_magic_event): * event-Xt.c (describe_event): * event-gtk.c (dragndrop_data_received): * event-gtk.c (store_modifier): * event-gtk.c (gtk_reset_modifier_mapping): * event-msw.c (dde_eval_string): * event-msw.c (Fdde_alloc_advise_item): * event-msw.c (mswindows_dde_callback): * event-msw.c (FROB): * event-msw.c (emacs_mswindows_format_magic_event): * event-stream.c (external_debugging_print_event): * event-stream.c (execute_help_form): * event-stream.c (vars_of_event_stream): * events.c (print_event_1): * events.c (print_event): * events.c (event_equal): * extents.c (print_extent_1): * extents.c (print_extent): * extents.c (vars_of_extents): * faces.c (print_face): * faces.c (complex_vars_of_faces): * file-coding.c: * file-coding.c (print_coding_system): * file-coding.c (print_coding_system_in_print_method): * file-coding.c (default_query_method): * file-coding.c (find_coding_system): * file-coding.c (make_coding_system_1): * file-coding.c (chain_print): * file-coding.c (undecided_print): * file-coding.c (gzip_print): * file-coding.c (vars_of_file_coding): * file-coding.c (complex_vars_of_file_coding): * fileio.c: * fileio.c (report_file_type_error): * fileio.c (report_error_with_errno): * fileio.c (report_file_error): * fileio.c (barf_or_query_if_file_exists): * fileio.c (vars_of_fileio): * floatfns.c (matherr): * fns.c (print_bit_vector): * fns.c (Fmapconcat): * fns.c (add_suffix_to_symbol): * fns.c (add_prefix_to_symbol): * frame-gtk.c: * frame-gtk.c (Fgtk_window_id): * frame-x.c (def): * frame-x.c (x_cde_transfer_callback): * frame.c: * frame.c (Fmake_frame): * gc.c (show_gc_cursor_and_message): * gc.c (vars_of_gc): * glyphs-eimage.c (png_instantiate): * glyphs-eimage.c (tiff_instantiate): * glyphs-gtk.c (gtk_print_image_instance): * glyphs-msw.c (mswindows_print_image_instance): * glyphs-x.c (x_print_image_instance): * glyphs-x.c (update_widget_face): * glyphs.c (make_string_from_file): * glyphs.c (print_image_instance): * glyphs.c (signal_image_error): * glyphs.c (signal_image_error_2): * glyphs.c (signal_double_image_error): * glyphs.c (signal_double_image_error_2): * glyphs.c (xbm_mask_file_munging): * glyphs.c (pixmap_to_lisp_data): * glyphs.h: * gui.c (gui_item_display_flush_left): * hpplay.c (player_error_internal): * hpplay.c (myHandler): * intl-win32.c: * intl-win32.c (langcode_to_lang): * intl-win32.c (sublangcode_to_lang): * intl-win32.c (Fmswindows_get_locale_info): * intl-win32.c (lcid_to_locale_mule_or_no): * intl-win32.c (mswindows_multibyte_to_unicode_print): * intl-win32.c (complex_vars_of_intl_win32): * keymap.c: * keymap.c (print_keymap): * keymap.c (ensure_meta_prefix_char_keymapp): * keymap.c (Fkey_description): * keymap.c (Ftext_char_description): * lisp.h: * lisp.h (struct): * lisp.h (DECLARE_INLINE_HEADER): * lread.c (Fload_internal): * lread.c (locate_file): * lread.c (read_escape): * lread.c (read_raw_string): * lread.c (read1): * lread.c (read_list): * lread.c (read_compiled_function): * lread.c (init_lread): * lrecord.h: * marker.c (print_marker): * marker.c (marker_equal): * menubar-msw.c (displayable_menu_item): * menubar-x.c (command_builder_operate_menu_accelerator): * menubar.c (vars_of_menubar): * minibuf.c (reinit_complex_vars_of_minibuf): * minibuf.c (complex_vars_of_minibuf): * mule-charset.c (Fmake_charset): * mule-charset.c (complex_vars_of_mule_charset): * mule-coding.c (iso2022_print): * mule-coding.c (fixed_width_query): * number.c (bignum_print): * number.c (ratio_print): * number.c (bigfloat_print): * number.c (bigfloat_finalize): * objects-msw.c: * objects-msw.c (mswindows_color_to_string): * objects-msw.c (mswindows_color_list): * objects-tty.c: * objects-tty.c (tty_font_list): * objects-tty.c (tty_find_charset_font): * objects-xlike-inc.c (xft_find_charset_font): * objects-xlike-inc.c (endif): * print.c: * print.c (write_istring): * print.c (write_ascstring): * print.c (Fterpri): * print.c (Fprint): * print.c (print_error_message): * print.c (print_vector_internal): * print.c (print_cons): * print.c (print_string): * print.c (printing_unreadable_object): * print.c (print_internal): * print.c (print_float): * print.c (print_symbol): * process-nt.c (mswindows_report_winsock_error): * process-nt.c (nt_canonicalize_host_name): * process-unix.c (unix_canonicalize_host_name): * process.c (print_process): * process.c (report_process_error): * process.c (report_network_error): * process.c (make_process_internal): * process.c (Fstart_process_internal): * process.c (status_message): * process.c (putenv_internal): * process.c (vars_of_process): * process.h: * profile.c (vars_of_profile): * rangetab.c (print_range_table): * realpath.c (vars_of_realpath): * redisplay.c (vars_of_redisplay): * search.c (wordify): * search.c (Freplace_match): * sheap.c (sheap_adjust_h): * sound.c (report_sound_error): * sound.c (Fplay_sound_file): * specifier.c (print_specifier): * symbols.c (Fsubr_name): * symbols.c (do_symval_forwarding): * symbols.c (set_default_buffer_slot_variable): * symbols.c (set_default_console_slot_variable): * symbols.c (store_symval_forwarding): * symbols.c (default_value): * symbols.c (defsymbol_massage_name_1): * symbols.c (defsymbol_massage_name_nodump): * symbols.c (defsymbol_massage_name): * symbols.c (defsymbol_massage_multiword_predicate_nodump): * symbols.c (defsymbol_massage_multiword_predicate): * symbols.c (defsymbol_nodump): * symbols.c (defsymbol): * symbols.c (defkeyword): * symbols.c (defkeyword_massage_name): * symbols.c (check_module_subr): * symbols.c (deferror_1): * symbols.c (deferror): * symbols.c (deferror_massage_name): * symbols.c (deferror_massage_name_and_message): * symbols.c (defvar_magic): * symeval.h: * symeval.h (DEFVAR_SYMVAL_FWD): * sysdep.c: * sysdep.c (init_system_name): * sysdll.c: * sysdll.c (MAYBE_PREPEND_UNDERSCORE): * sysdll.c (dll_function): * sysdll.c (dll_variable): * sysdll.c (dll_error): * sysdll.c (dll_open): * sysdll.c (dll_close): * sysdll.c (image_for_address): * sysdll.c (my_find_image): * sysdll.c (search_linked_libs): * sysdll.h: * sysfile.h: * sysfile.h (DEFAULT_DIRECTORY_FALLBACK): * syswindows.h: * tests.c (DFC_CHECK_LENGTH): * tests.c (DFC_CHECK_CONTENT): * tests.c (Ftest_hash_tables): * text.c (vars_of_text): * text.h: * tooltalk.c (tt_opnum_string): * tooltalk.c (tt_message_arg_ival_string): * tooltalk.c (Ftooltalk_default_procid): * tooltalk.c (Ftooltalk_default_session): * tooltalk.c (init_tooltalk): * tooltalk.c (vars_of_tooltalk): * ui-gtk.c (Fdll_load): * ui-gtk.c (type_to_marshaller_type): * ui-gtk.c (Fgtk_import_function_internal): * ui-gtk.c (emacs_gtk_object_printer): * ui-gtk.c (emacs_gtk_boxed_printer): * unicode.c (unicode_to_ichar): * unicode.c (unicode_print): * unicode.c (unicode_query): * unicode.c (vars_of_unicode): * unicode.c (complex_vars_of_unicode): * win32.c: * win32.c (mswindows_report_process_error): * window.c (print_window): * xemacs.def.in.in: BASIC IDEA: Further fixing up uses of char * and CIbyte * to reflect their actual semantics; Mule-izing some code; redoing of the not-yet-working code to handle message translation. Clean up code to handle message-translation (not yet working). Create separate versions of build_msg_string() for working with Ibyte *, CIbyte *, and Ascbyte * arguments. Assert that Ascbyte * arguments are pure-ASCII. Make build_msg_string() be the same as build_msg_ascstring(). Create same three versions of GETTEXT() and DEFER_GETTEXT(). Also create build_defer_string() and variants for the equivalent of DEFER_GETTEXT() when building a string. Remove old CGETTEXT(). Clean up code where GETTEXT(), DEFER_GETTEXT(), build_msg_string(), etc. was being called and introduce some new calls to build_msg_string(), etc. Remove GETTEXT() from calls to weird_doc() -- we assume that the message snarfer knows about weird_doc(). Remove uses of DEFER_GETTEXT() from error messages in sysdep.c and instead use special comments /* @@@begin-snarf@@@ */ and /* @@@end-snarf@@@ */ that the message snarfer presumably knows about. Create build_ascstring() and use it in many instances in place of build_string(). The purpose of having Ascbyte * variants is to make the code more self-documenting in terms of what sort of semantics is expected for char * strings. In fact in the process of looking for uses of build_string(), much improperly Mule-ized was discovered. Mule-ize a lot of code as described in previous paragraph, e.g. in sysdep.c. Make the error functions take Ascbyte * strings and fix up a couple of places where non-pure-ASCII strings were being passed in (file-coding.c, mule-coding.c, unicode.c). (It's debatable whether we really need to make the error functions work this way. It helps catch places where code is written in a way that message translation won't work, but we may well never implement message translation.) Make staticpro() and friends take Ascbyte * strings instead of raw char * strings. Create a const_Ascbyte_ptr dynarr type to describe what's held by staticpro_names[] and friends, create pdump descriptions for const_Ascbyte_ptr dynarrs, and use them in place of specially-crafted staticpro descriptions. Mule-ize certain other functions (e.g. x_event_name) by correcting raw use of char * to Ascbyte *, Rawbyte * or another such type, and raw use of char[] buffers to another type (usually Ascbyte[]). Change many uses of write_c_string() to write_msg_string(), write_ascstring(), etc. Mule-ize emodules.c, emodules.h, sysdll.h. Fix some un-Mule-ized code in intl-win32.c. A comment in event-Xt.c and the limitations of the message snarfer (make-msgfile or whatever) is presumably incorrect -- it should be smart enough to handle function calls spread over more than one line. Clean up code in event-Xt.c that was written awkwardly for this reason. In config.h.in, instead of NEED_ERROR_CHECK_TYPES_INLINES, create a more general XEMACS_DEFS_NEEDS_INLINE_DECLS to indicate when inlined functions need to be declared in xemacs.defs.in.in, and make use of it in xemacs.defs.in.in. We need to do this because postgresql.c now calls qxestrdup(), which is an inline function. Make nconc2() and other such functions MODULE_API and put them in xemacs.defs.in.in since postgresql.c now uses them. Clean up indentation in lread.c and a few other places. In text.h, document ASSERT_ASCTEXT_ASCII() and ASSERT_ASCTEXT_ASCII_LEN(), group together the stand-in encodings and add some more for DLL symbols, function and variable names, etc.
author Ben Wing <ben@xemacs.org>
date Tue, 26 Jan 2010 23:22:30 -0600
parents ef70ee47d287
children 304aebb79cd3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
714
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 691
diff changeset
1 /* GTK-specific Lisp objects.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3 Copyright (C) 1995 Board of Trustees, University of Illinois.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
4 Copyright (C) 1995 Tinker Systems
2959
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
5 Copyright (C) 1995, 1996, 2001, 2002, 2004, 2005 Ben Wing
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
6 Copyright (C) 1995 Sun Microsystems
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
7
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
8 This file is part of XEmacs.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
9
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
10 XEmacs is free software; you can redistribute it and/or modify it
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
11 under the terms of the GNU General Public License as published by the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
12 Free Software Foundation; either version 2, or (at your option) any
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
13 later version.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
14
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
15 XEmacs is distributed in the hope that it will be useful, but WITHOUT
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
18 for more details.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
19
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
20 You should have received a copy of the GNU General Public License
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
21 along with XEmacs; see the file COPYING. If not, write to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
23 Boston, MA 02111-1307, USA. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
24
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
25 /* Synched up with: Not in FSF. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
26
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
27 /* Original author: Jamie Zawinski for 19.8
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
28 font-truename stuff added by Jamie Zawinski for 19.10
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
29 subwindow support added by Chuck Thompson
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
30 additional XPM support added by Chuck Thompson
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
31 initial X-Face support added by Stig
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
32 rewritten/restructured by Ben Wing for 19.12/19.13
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
33 GIF/JPEG support added by Ben Wing for 19.14
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
34 PNG support added by Bill Perry for 19.14
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
35 Improved GIF/JPEG support added by Bill Perry for 19.14
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
36 Cleanup/simplification of error handling by Ben Wing for 19.14
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
37 Pointer/icon overhaul, more restructuring by Ben Wing for 19.14
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
38 GIF support changed to external GIFlib 3.1 by Jareth Hein for 21.0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
39 Many changes for color work and optimizations by Jareth Hein for 21.0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
40 Switch of GIF/JPEG/PNG to new EImage intermediate code by Jareth Hein for 21.0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
41 TIFF code by Jareth Hein for 21.0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
42 GIF/JPEG/PNG/TIFF code moved to new glyph-eimage.c for 21.0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
43 Gtk version by William Perry for 21.1
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
44
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
45 TODO:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
46 Support the GrayScale, StaticColor and StaticGray visual classes.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
47 Convert images.el to C and stick it in here?
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
48 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
49
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
50 #include <config.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
51 #include "lisp.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
52
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
53 #include "buffer.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
54 #include "device-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
55 #include "faces.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
56 #include "file-coding.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
57 #include "frame-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
58 #include "glyphs.h"
809
285f13b079f3 [xemacs-hg @ 2002-04-07 16:01:30 by wmperry]
wmperry
parents: 800
diff changeset
59 #include "gui.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
60 #include "imgproc.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
61 #include "insdel.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
62 #include "lstream.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
63 #include "opaque.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
64 #include "window.h"
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
65 #include "elhash.h"
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
66 #include "events.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
67
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
68 #include "console-gtk-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
69 #include "glyphs-gtk.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
70 #include "objects-gtk-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
71 #include "ui-gtk.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
72
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
73 #include "sysfile.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
74
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
75 #include <setjmp.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
76
2082
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
77 #if defined (HAVE_XPM)
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
78 #include <X11/xpm.h>
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
79 #endif
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
80
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
81 /* Widget callback hash table callback slot. */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
82 #define WIDGET_GLYPH_SLOT 0
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
83
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
84 DECLARE_IMAGE_INSTANTIATOR_FORMAT (nothing);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
85 DECLARE_IMAGE_INSTANTIATOR_FORMAT (string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
86 DECLARE_IMAGE_INSTANTIATOR_FORMAT (formatted_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
87 DECLARE_IMAGE_INSTANTIATOR_FORMAT (inherit);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
88 #ifdef HAVE_JPEG
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
89 DECLARE_IMAGE_INSTANTIATOR_FORMAT (jpeg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
90 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
91 #ifdef HAVE_TIFF
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
92 DECLARE_IMAGE_INSTANTIATOR_FORMAT (tiff);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
93 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
94 #ifdef HAVE_PNG
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
95 DECLARE_IMAGE_INSTANTIATOR_FORMAT (png);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
96 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
97 #ifdef HAVE_GIF
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
98 DECLARE_IMAGE_INSTANTIATOR_FORMAT (gif);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
99 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
100
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
101 #ifdef HAVE_XFACE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
102 DEFINE_DEVICE_IIFORMAT (gtk, xface);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
103 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
104
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
105 #ifdef HAVE_XPM
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
106 DEFINE_DEVICE_IIFORMAT (gtk, xpm);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
107 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
108
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
109 DEFINE_DEVICE_IIFORMAT (gtk, xbm);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
110 DEFINE_DEVICE_IIFORMAT (gtk, subwindow);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
111
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
112 DEFINE_IMAGE_INSTANTIATOR_FORMAT (cursor_font);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
113 Lisp_Object Qcursor_font;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
114
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
115 DEFINE_IMAGE_INSTANTIATOR_FORMAT (font);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
116
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
117 DEFINE_IMAGE_INSTANTIATOR_FORMAT (autodetect);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
118
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
119 #ifdef HAVE_WIDGETS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
120 DECLARE_IMAGE_INSTANTIATOR_FORMAT (layout);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
121 DEFINE_DEVICE_IIFORMAT (gtk, widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
122 DEFINE_DEVICE_IIFORMAT (gtk, native_layout);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
123 DEFINE_DEVICE_IIFORMAT (gtk, button);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
124 DEFINE_DEVICE_IIFORMAT (gtk, progress_gauge);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
125 DEFINE_DEVICE_IIFORMAT (gtk, edit_field);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
126 DEFINE_DEVICE_IIFORMAT (gtk, combo_box);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
127 DEFINE_DEVICE_IIFORMAT (gtk, tab_control);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
128 DEFINE_DEVICE_IIFORMAT (gtk, label);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
129 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
130
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
131 static void update_widget_face (GtkWidget *w, Lisp_Image_Instance *ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
132 Lisp_Object domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
133 static void cursor_font_instantiate (Lisp_Object image_instance,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
134 Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
135 Lisp_Object pointer_fg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
136 Lisp_Object pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
137 int dest_mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
138 Lisp_Object domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
139
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
140 static GdkCursorType cursor_name_to_index (const char *name);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
141
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
142 #ifndef BitmapSuccess
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
143 #define BitmapSuccess 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
144 #define BitmapOpenFailed 1
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
145 #define BitmapFileInvalid 2
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
146 #define BitmapNoMemory 3
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
147 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
148
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
149 #include "bitmaps.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
150
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
151 DEFINE_IMAGE_INSTANTIATOR_FORMAT (gtk_resource);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
152 Lisp_Object Qgtk_resource;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
153 #ifdef HAVE_WIDGETS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
154 Lisp_Object Qgtk_widget_instantiate_internal, Qgtk_widget_property_internal;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
155 Lisp_Object Qgtk_widget_redisplay_internal, Qgtk_widget_set_style;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
156 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
157
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
158
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
159 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
160 /* image instance methods */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
161 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
162
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
163 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
164 /* convert from a series of RGB triples to an XImage formated for the */
4252
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
165 /* proper display */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
166 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
167 static GdkImage *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
168 convert_EImage_to_GDKImage (Lisp_Object device, int width, int height,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
169 unsigned char *pic, unsigned long **pixtbl,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
170 int *npixels)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
171 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
172 GdkColormap *cmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
173 GdkVisual *vis;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
174 GdkImage *outimg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
175 int depth, byte_cnt, i, j;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
176 int rd,gr,bl,q;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
177 unsigned char *data, *ip, *dp = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
178 quant_table *qtable = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
179 union {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 809
diff changeset
180 UINT_32_BIT val;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
181 char cp[4];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
182 } conv;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
183
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
184 cmap = DEVICE_GTK_COLORMAP (XDEVICE(device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
185 vis = DEVICE_GTK_VISUAL (XDEVICE(device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
186 depth = DEVICE_GTK_DEPTH(XDEVICE(device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
187
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
188 if (vis->type == GDK_VISUAL_GRAYSCALE || vis->type == GDK_VISUAL_STATIC_COLOR ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
189 vis->type == GDK_VISUAL_STATIC_GRAY)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
190 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
191 /* #### Implement me!!! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
192 return NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
193 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
194
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
195 if (vis->type == GDK_VISUAL_PSEUDO_COLOR)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
196 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
197 /* Quantize the image and get a histogram while we're at it.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
198 Do this first to save memory */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
199 qtable = build_EImage_quantable(pic, width, height, 256);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
200 if (qtable == NULL) return NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
201 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
202
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
203 /* The first parameter (GdkWindow *) is allowed to be NULL if we
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
204 ** specify the depth */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
205 outimg = gdk_image_new (GDK_IMAGE_FASTEST, vis, width, height);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
206
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
207 if (!outimg) return NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
208
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
209 byte_cnt = outimg->bpp;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
210
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
211 data = (unsigned char *) outimg->mem;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
212
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
213 if (!data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
214 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
215 gdk_image_destroy (outimg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
216 return NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
217 }
4252
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
218
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
219 if (vis->type == GDK_VISUAL_PSEUDO_COLOR)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
220 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
221 unsigned long pixarray[256];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
222 int pixcount, n;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
223 /* use our quantize table to allocate the colors */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
224 pixcount = 32;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
225 *pixtbl = xnew_array (unsigned long, pixcount);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
226 *npixels = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
227
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
228 /* ### should implement a sort by popularity to assure proper allocation */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
229 n = *npixels;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
230 for (i = 0; i < qtable->num_active_colors; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
231 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
232 GdkColor color;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
233 int res;
4252
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
234
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
235 color.red = qtable->rm[i] ? qtable->rm[i] << 8 : 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
236 color.green = qtable->gm[i] ? qtable->gm[i] << 8 : 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
237 color.blue = qtable->bm[i] ? qtable->bm[i] << 8 : 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
238 res = allocate_nearest_color (cmap, vis, &color);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
239 if (res > 0 && res < 3)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
240 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
241 DO_REALLOC(*pixtbl, pixcount, n+1, unsigned long);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
242 (*pixtbl)[n] = color.pixel;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
243 n++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
244 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
245 pixarray[i] = color.pixel;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
246 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
247 *npixels = n;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
248 ip = pic;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
249 for (i = 0; i < height; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
250 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
251 dp = data + (i * outimg->bpl);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
252 for (j = 0; j < width; j++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
253 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
254 rd = *ip++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
255 gr = *ip++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
256 bl = *ip++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
257 conv.val = pixarray[QUANT_GET_COLOR(qtable,rd,gr,bl)];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
258 #if WORDS_BIGENDIAN
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
259 if (outimg->byte_order == GDK_MSB_FIRST)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
260 for (q = 4-byte_cnt; q < 4; q++) *dp++ = conv.cp[q];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
261 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
262 for (q = 3; q >= 4-byte_cnt; q--) *dp++ = conv.cp[q];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
263 #else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
264 if (outimg->byte_order == GDK_MSB_FIRST)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
265 for (q = byte_cnt-1; q >= 0; q--) *dp++ = conv.cp[q];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
266 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
267 for (q = 0; q < byte_cnt; q++) *dp++ = conv.cp[q];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
268 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
269 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
270 }
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1346
diff changeset
271 xfree(qtable, quant_table *);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
272 } else {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
273 unsigned long rshift,gshift,bshift,rbits,gbits,bbits,junk;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
274 junk = vis->red_mask;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
275 rshift = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
276 while ((junk & 0x1) == 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
277 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
278 junk = junk >> 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
279 rshift ++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
280 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
281 rbits = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
282 while (junk != 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
283 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
284 junk = junk >> 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
285 rbits++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
286 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
287 junk = vis->green_mask;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
288 gshift = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
289 while ((junk & 0x1) == 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
290 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
291 junk = junk >> 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
292 gshift ++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
293 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
294 gbits = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
295 while (junk != 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
296 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
297 junk = junk >> 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
298 gbits++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
299 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
300 junk = vis->blue_mask;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
301 bshift = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
302 while ((junk & 0x1) == 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
303 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
304 junk = junk >> 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
305 bshift ++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
306 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
307 bbits = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
308 while (junk != 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
309 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
310 junk = junk >> 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
311 bbits++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
312 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
313 ip = pic;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
314 for (i = 0; i < height; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
315 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
316 dp = data + (i * outimg->bpl);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
317 for (j = 0; j < width; j++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
318 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
319 if (rbits > 8)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
320 rd = *ip++ << (rbits - 8);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
321 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
322 rd = *ip++ >> (8 - rbits);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
323 if (gbits > 8)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
324 gr = *ip++ << (gbits - 8);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
325 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
326 gr = *ip++ >> (8 - gbits);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
327 if (bbits > 8)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
328 bl = *ip++ << (bbits - 8);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
329 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
330 bl = *ip++ >> (8 - bbits);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
331
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
332 conv.val = (rd << rshift) | (gr << gshift) | (bl << bshift);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
333 #if WORDS_BIGENDIAN
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
334 if (outimg->byte_order == GDK_MSB_FIRST)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
335 for (q = 4-byte_cnt; q < 4; q++) *dp++ = conv.cp[q];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
336 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
337 for (q = 3; q >= 4-byte_cnt; q--) *dp++ = conv.cp[q];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
338 #else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
339 if (outimg->byte_order == GDK_MSB_FIRST)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
340 for (q = byte_cnt-1; q >= 0; q--) *dp++ = conv.cp[q];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
341 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
342 for (q = 0; q < byte_cnt; q++) *dp++ = conv.cp[q];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
343 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
344 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
345 }
4252
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
346 }
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
347 return outimg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
348 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
349
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
350 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
351 gtk_print_image_instance (struct Lisp_Image_Instance *p,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
352 Lisp_Object printcharfun,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
353 int UNUSED (escapeflag))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
354 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
355 switch (IMAGE_INSTANCE_TYPE (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
356 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
357 case IMAGE_MONO_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
358 case IMAGE_COLOR_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
359 case IMAGE_POINTER:
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
360 write_fmt_string (printcharfun, " (0x%lx",
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
361 (unsigned long) IMAGE_INSTANCE_GTK_PIXMAP (p));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
362 if (IMAGE_INSTANCE_GTK_MASK (p))
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
363 write_fmt_string (printcharfun, "/0x%lx",
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
364 (unsigned long) IMAGE_INSTANCE_GTK_MASK (p));
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4700
diff changeset
365 write_ascstring (printcharfun, ")");
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
366 break;
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
367 #ifdef HAVE_SUBWINDOWS
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
368 case IMAGE_SUBWINDOW:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
369 /* #### implement me */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
370 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
371 default:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
372 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
373 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
374 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
375
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
376 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
377 gtk_finalize_image_instance (struct Lisp_Image_Instance *p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
378 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
379 if (!p->data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
380 return;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
381
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
382 if (DEVICE_LIVE_P (XDEVICE (p->device)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
383 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
384 if (0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
385 ;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
386 #ifdef HAVE_WIDGETS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
387 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
388 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
389 if (IMAGE_INSTANCE_SUBWINDOW_ID (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
390 {
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
391 gtk_widget_destroy ((GtkWidget*) IMAGE_INSTANCE_SUBWINDOW_ID (p));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
392
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
393 /* We can release the callbacks again. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
394 /* #### FIXME! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
395 /* ungcpro_popup_callbacks (...); */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
396
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
397 /* IMAGE_INSTANCE_GTK_WIDGET_ID (p) = 0; */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
398 IMAGE_INSTANCE_GTK_CLIPWIDGET (p) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
399 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
400 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
401 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
402 else if (IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
403 {
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2421
diff changeset
404 ABORT();
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
405 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
406 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
407 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
408 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
409 if (IMAGE_INSTANCE_PIXMAP_TIMEOUT (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
410 disable_glyph_animated_timeout (IMAGE_INSTANCE_PIXMAP_TIMEOUT (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
411
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
412 if (IMAGE_INSTANCE_GTK_MASK (p) &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
413 IMAGE_INSTANCE_GTK_MASK (p) != IMAGE_INSTANCE_GTK_PIXMAP (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
414 gdk_pixmap_unref (IMAGE_INSTANCE_GTK_MASK (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
415 IMAGE_INSTANCE_PIXMAP_MASK (p) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
416
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
417 if (IMAGE_INSTANCE_GTK_PIXMAP_SLICES (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
418 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
419 for (i = 0; i < IMAGE_INSTANCE_PIXMAP_MAXSLICE (p); i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
420 if (IMAGE_INSTANCE_GTK_PIXMAP_SLICE (p,i))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
421 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
422 gdk_pixmap_unref (IMAGE_INSTANCE_GTK_PIXMAP_SLICE (p,i));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
423 IMAGE_INSTANCE_GTK_PIXMAP_SLICE (p, i) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
424 }
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1346
diff changeset
425 xfree (IMAGE_INSTANCE_GTK_PIXMAP_SLICES (p), GdkPixmap **);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
426 IMAGE_INSTANCE_GTK_PIXMAP_SLICES (p) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
427 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
428
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
429 if (IMAGE_INSTANCE_GTK_CURSOR (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
430 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
431 gdk_cursor_destroy (IMAGE_INSTANCE_GTK_CURSOR (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
432 IMAGE_INSTANCE_GTK_CURSOR (p) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
433 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
434 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
435
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
436 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
437 /* #### BILL!!! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
438 if (IMAGE_INSTANCE_GTK_NPIXELS (p) != 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
439 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
440 XFreeColors (dpy,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
441 IMAGE_INSTANCE_GTK_COLORMAP (p),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
442 IMAGE_INSTANCE_GTK_PIXELS (p),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
443 IMAGE_INSTANCE_GTK_NPIXELS (p), 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
444 IMAGE_INSTANCE_GTK_NPIXELS (p) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
445 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
446 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
447 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
448
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
449 if (IMAGE_INSTANCE_TYPE (p) != IMAGE_WIDGET
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
450 && IMAGE_INSTANCE_TYPE (p) != IMAGE_SUBWINDOW
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
451 && IMAGE_INSTANCE_GTK_PIXELS (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
452 {
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1346
diff changeset
453 xfree (IMAGE_INSTANCE_GTK_PIXELS (p), unsigned long *);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
454 IMAGE_INSTANCE_GTK_PIXELS (p) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
455 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
456
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1346
diff changeset
457 xfree (p->data, void *);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
458 p->data = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
459 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
460
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
461 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
462 gtk_image_instance_equal (struct Lisp_Image_Instance *p1,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
463 struct Lisp_Image_Instance *p2, int UNUSED (depth))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
464 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
465 switch (IMAGE_INSTANCE_TYPE (p1))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
466 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
467 case IMAGE_MONO_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
468 case IMAGE_COLOR_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
469 case IMAGE_POINTER:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
470 if (IMAGE_INSTANCE_GTK_COLORMAP (p1) != IMAGE_INSTANCE_GTK_COLORMAP (p2) ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
471 IMAGE_INSTANCE_GTK_NPIXELS (p1) != IMAGE_INSTANCE_GTK_NPIXELS (p2))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
472 return 0;
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
473 #ifdef HAVE_SUBWINDOWS
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
474 case IMAGE_SUBWINDOW:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
475 /* #### implement me */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
476 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
477 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
478 default:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
479 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
480 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
481
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
482 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
483 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
484
2515
de9952d2ed18 [xemacs-hg @ 2005-01-26 10:22:19 by ben]
ben
parents: 2500
diff changeset
485 static Hashcode
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
486 gtk_image_instance_hash (struct Lisp_Image_Instance *p, int UNUSED (depth))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
487 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
488 switch (IMAGE_INSTANCE_TYPE (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
489 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
490 case IMAGE_MONO_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
491 case IMAGE_COLOR_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
492 case IMAGE_POINTER:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
493 return IMAGE_INSTANCE_GTK_NPIXELS (p);
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
494 #ifdef HAVE_SUBWINDOWS
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
495 case IMAGE_SUBWINDOW:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
496 /* #### implement me */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
497 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
498 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
499 default:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
500 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
501 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
502 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
503
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
504 /* Set all the slots in an image instance structure to reasonable
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
505 default values. This is used somewhere within an instantiate
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
506 method. It is assumed that the device slot within the image
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
507 instance is already set -- this is the case when instantiate
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
508 methods are called. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
509
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
510 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
511 gtk_initialize_pixmap_image_instance (struct Lisp_Image_Instance *ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
512 int slices,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
513 enum image_instance_type type)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
514 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
515 ii->data = xnew_and_zero (struct gtk_image_instance_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
516 IMAGE_INSTANCE_PIXMAP_MAXSLICE (ii) = slices;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
517 IMAGE_INSTANCE_GTK_PIXMAP_SLICES (ii) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
518 xnew_array_and_zero (GdkPixmap *, slices);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
519 IMAGE_INSTANCE_TYPE (ii) = type;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
520 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
521 IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (ii) = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
522 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
523 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
524 IMAGE_INSTANCE_PIXMAP_FG (ii) = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
525 IMAGE_INSTANCE_PIXMAP_BG (ii) = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
526 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
527
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
528
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
529 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
530 /* pixmap file functions */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
531 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
532
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
533 /* Where bitmaps are; initialized from resource database */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
534 Lisp_Object Vgtk_bitmap_file_path;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
535
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
536 #ifndef BITMAPDIR
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
537 #define BITMAPDIR "/usr/include/X11/bitmaps"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
538 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
539
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
540 /* Given a pixmap filename, look through all of the "standard" places
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
541 where the file might be located. Return a full pathname if found;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
542 otherwise, return Qnil. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
543
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
544 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
545 gtk_locate_pixmap_file (Lisp_Object name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
546 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
547 /* This function can GC if IN_REDISPLAY is false */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
548
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
549 /* Check non-absolute pathnames with a directory component relative to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
550 the search path; that's the way Xt does it. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
551 /* #### Unix-specific */
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 809
diff changeset
552 if (string_byte (name, 0) == '/' ||
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 809
diff changeset
553 (string_byte (name, 0) == '.' &&
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 809
diff changeset
554 (string_byte (name, 1) == '/' ||
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 809
diff changeset
555 (string_byte (name, 1) == '.' &&
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 809
diff changeset
556 (string_byte (name, 2) == '/')))))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
557 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
558 if (!NILP (Ffile_readable_p (name)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
559 return name;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
560 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
561 return Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
562 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
563
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
564 if (NILP (Vgtk_bitmap_file_path))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
565 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
566 Vgtk_bitmap_file_path = nconc2 (Vgtk_bitmap_file_path,
778
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 771
diff changeset
567 (split_external_path (BITMAPDIR)));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
568 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
569
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
570 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
571 Lisp_Object found;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
572 if (locate_file (Vgtk_bitmap_file_path, name, Qnil, &found, R_OK) < 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
573 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
574 Lisp_Object temp = list1 (Vdata_directory);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
575 struct gcpro gcpro1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
576
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
577 GCPRO1 (temp);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
578 locate_file (temp, name, Qnil, &found, R_OK);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
579 UNGCPRO;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
580 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
581
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
582 return found;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
583 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
584 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
585
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
586 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
587 locate_pixmap_file (Lisp_Object name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
588 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
589 return gtk_locate_pixmap_file (name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
590 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
591
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
592
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
593 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
594 /* cursor functions */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
595 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
596
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
597 /* Check that this server supports cursors of size WIDTH * HEIGHT. If
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
598 not, signal an error. INSTANTIATOR is only used in the error
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
599 message. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
600
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
601 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
602 check_pointer_sizes (unsigned int UNUSED (width), unsigned int UNUSED (height),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
603 Lisp_Object UNUSED (instantiator))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
604 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
605 /* #### BILL!!! There is no way to call XQueryBestCursor from Gdk! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
606 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
607 unsigned int best_width, best_height;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
608 if (! XQueryBestCursor (DisplayOfScreen (xs), RootWindowOfScreen (xs),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
609 width, height, &best_width, &best_height))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
610 /* this means that an X error of some sort occurred (we trap
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
611 these so they're not fatal). */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
612 gui_error ("XQueryBestCursor() failed?", instantiator);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
613
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
614 if (width > best_width || height > best_height)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
615 signal_ferror_with_frob (Qgui_error, instantiator,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
616 "pointer too large (%dx%d): "
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
617 "server requires %dx%d or smaller",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
618 width, height, best_width, best_height);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
619 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
620 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
621
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
622 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
623 generate_cursor_fg_bg (Lisp_Object device, Lisp_Object *foreground,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
624 Lisp_Object *background, GdkColor *xfg, GdkColor *xbg)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
625 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
626 if (!NILP (*foreground) && !COLOR_INSTANCEP (*foreground))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
627 *foreground =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
628 Fmake_color_instance (*foreground, device,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
629 encode_error_behavior_flag (ERROR_ME));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
630 if (COLOR_INSTANCEP (*foreground))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
631 *xfg = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (*foreground));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
632 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
633 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
634 xfg->pixel = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
635 xfg->red = xfg->green = xfg->blue = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
636 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
637
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
638 if (!NILP (*background) && !COLOR_INSTANCEP (*background))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
639 *background =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
640 Fmake_color_instance (*background, device,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
641 encode_error_behavior_flag (ERROR_ME));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
642 if (COLOR_INSTANCEP (*background))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
643 *xbg = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (*background));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
644 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
645 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
646 xbg->pixel = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
647 xbg->red = xbg->green = xbg->blue = ~0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
648 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
649 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
650
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
651 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
652 maybe_recolor_cursor (Lisp_Object UNUSED (image_instance),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
653 Lisp_Object UNUSED (foreground),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
654 Lisp_Object UNUSED (background))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
655 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
656 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
657 /* #### BILL!!! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
658 Lisp_Object device = XIMAGE_INSTANCE_DEVICE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
659 GdkColor xfg, xbg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
660
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
661 generate_cursor_fg_bg (device, &foreground, &background, &xfg, &xbg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
662 if (!NILP (foreground) || !NILP (background))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
663 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
664 XRecolorCursor (DEVICE_X_DISPLAY (XDEVICE (device)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
665 XIMAGE_INSTANCE_GTK_CURSOR (image_instance),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
666 &xfg, &xbg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
667 XIMAGE_INSTANCE_PIXMAP_FG (image_instance) = foreground;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
668 XIMAGE_INSTANCE_PIXMAP_BG (image_instance) = background;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
669 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
670 #else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
671 /* stderr_out ("Don't know how to recolor cursors in Gtk!\n"); */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
672 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
673 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
674
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
675
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
676 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
677 /* color pixmap functions */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
678 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
679
2959
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
680 /* Create a pointer from a color pixmap. */
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
681
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
682 static void
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
683 image_instance_convert_to_pointer (Lisp_Image_Instance *ii,
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
684 Lisp_Object instantiator,
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
685 Lisp_Object pointer_fg,
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
686 Lisp_Object pointer_bg)
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
687 {
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
688 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
3087
dbd2a866e38a [xemacs-hg @ 2005-11-22 11:24:40 by malcolmp]
malcolmp
parents: 2959
diff changeset
689 GdkPixmap *pixmap = IMAGE_INSTANCE_GTK_PIXMAP (ii);
dbd2a866e38a [xemacs-hg @ 2005-11-22 11:24:40 by malcolmp]
malcolmp
parents: 2959
diff changeset
690 GdkPixmap *mask = (GdkPixmap *) IMAGE_INSTANCE_GTK_MASK (ii);
2959
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
691 GdkColor fg, bg;
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
692 int xhot = 0, yhot = 0;
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
693 int w, h;
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
694
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
695 if (INTP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii)))
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
696 xhot = XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii));
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
697 if (INTP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii)))
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
698 yhot = XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii));
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
699 w = IMAGE_INSTANCE_PIXMAP_WIDTH (ii);
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
700 h = IMAGE_INSTANCE_PIXMAP_HEIGHT (ii);
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
701
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
702 check_pointer_sizes (w, h, instantiator);
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
703
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
704 /* If the loaded pixmap has colors allocated (meaning it came from an
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
705 XPM file), then use those as the default colors for the cursor we
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
706 create. Otherwise, default to pointer_fg and pointer_bg.
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
707 */
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
708 if (DEVICE_GTK_DEPTH (XDEVICE (device)) > 1)
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
709 {
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
710 warn_when_safe (Qunimplemented, Qnotice,
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
711 "GTK does not support XPM cursors...\n");
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
712 IMAGE_INSTANCE_GTK_CURSOR (ii) = gdk_cursor_new (GDK_COFFEE_MUG);
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
713 }
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
714 else
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
715 {
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
716 generate_cursor_fg_bg (device, &pointer_fg, &pointer_bg,
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
717 &fg, &bg);
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
718 IMAGE_INSTANCE_PIXMAP_FG (ii) = pointer_fg;
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
719 IMAGE_INSTANCE_PIXMAP_BG (ii) = pointer_bg;
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
720 IMAGE_INSTANCE_GTK_CURSOR (ii) =
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
721 gdk_cursor_new_from_pixmap (pixmap, mask, &fg, &bg, xhot, yhot);
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
722 }
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
723 }
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
724
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
725 /* Initialize an image instance from an XImage.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
726
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
727 DEST_MASK specifies the mask of allowed image types.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
728
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
729 PIXELS and NPIXELS specify an array of pixels that are used in
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
730 the image. These need to be kept around for the duration of the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
731 image. When the image instance is freed, XFreeColors() will
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
732 automatically be called on all the pixels specified here; thus,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
733 you should have allocated the pixels yourself using XAllocColor()
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
734 or the like. The array passed in is used directly without
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
735 being copied, so it should be heap data created with xmalloc().
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
736 It will be freed using xfree() when the image instance is
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
737 destroyed.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
738
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
739 If this fails, signal an error. INSTANTIATOR is only used
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
740 in the error message.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
741
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
742 #### This should be able to handle conversion into `pointer'.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
743 Use the same code as for `xpm'. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
744
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
745 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
746 init_image_instance_from_gdk_image (struct Lisp_Image_Instance *ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
747 GdkImage *gdk_image,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
748 int dest_mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
749 GdkColormap *cmap,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
750 unsigned long *pixels,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
751 int npixels,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
752 int slices,
2959
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
753 Lisp_Object instantiator,
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
754 Lisp_Object pointer_fg,
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
755 Lisp_Object pointer_bg)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
756 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
757 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
758 GdkGC *gc;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
759 GdkWindow *d;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
760 GdkPixmap *pixmap;
2959
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
761 enum image_instance_type type;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
762
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
763 if (!DEVICE_GTK_P (XDEVICE (device)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
764 gui_error ("Not a Gtk device", device);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
765
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
766 d = GET_GTK_WIDGET_WINDOW (DEVICE_GTK_APP_SHELL (XDEVICE (device)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
767
2959
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
768 if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
769 type = IMAGE_COLOR_PIXMAP;
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
770 else if (dest_mask & IMAGE_POINTER_MASK)
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
771 type = IMAGE_POINTER;
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
772 else
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
773 incompatible_image_types (instantiator, dest_mask,
2959
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
774 IMAGE_COLOR_PIXMAP_MASK
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
775 | IMAGE_POINTER_MASK);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
776
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
777 pixmap = gdk_pixmap_new (d, gdk_image->width, gdk_image->height, gdk_image->depth);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
778 if (!pixmap)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
779 gui_error ("Unable to create pixmap", instantiator);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
780
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
781 gc = gdk_gc_new (pixmap);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
782 if (!gc)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
783 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
784 gdk_pixmap_unref (pixmap);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
785 gui_error ("Unable to create GC", instantiator);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
786 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
787
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
788 gdk_draw_image (GDK_DRAWABLE (pixmap), gc, gdk_image,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
789 0, 0, 0, 0, gdk_image->width, gdk_image->height);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
790
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
791 gdk_gc_destroy (gc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
792
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
793 gtk_initialize_pixmap_image_instance (ii, slices, IMAGE_COLOR_PIXMAP);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
794
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
795 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
796 find_keyword_in_vector (instantiator, Q_file);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
797
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
798 IMAGE_INSTANCE_GTK_PIXMAP (ii) = pixmap;
4433
1bf48c59700e Fix old use of rvalue on lhs to placate gcc >4.0.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4252
diff changeset
799 IMAGE_INSTANCE_PIXMAP_MASK (ii) = 0;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
800 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = gdk_image->width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
801 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = gdk_image->height;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
802 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = gdk_image->depth;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
803 IMAGE_INSTANCE_GTK_COLORMAP (ii) = cmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
804 IMAGE_INSTANCE_GTK_PIXELS (ii) = pixels;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
805 IMAGE_INSTANCE_GTK_NPIXELS (ii) = npixels;
2959
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
806
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
807 if (type == IMAGE_POINTER)
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
808 image_instance_convert_to_pointer (ii, instantiator, pointer_fg,
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
809 pointer_bg);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
810 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
811
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
812 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
813 void init_image_instance_from_gdk_pixmap (struct Lisp_Image_Instance *ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
814 struct device *device,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
815 GdkPixmap *gdk_pixmap,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
816 int dest_mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
817 Lisp_Object instantiator)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
818 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
819 GdkWindow *d;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
820 gint width, height, depth;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
821
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
822 if (!DEVICE_GTK_P (device))
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2421
diff changeset
823 ABORT ();
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
824
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
825 IMAGE_INSTANCE_DEVICE (ii) = device;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
826 IMAGE_INSTANCE_TYPE (ii) = IMAGE_COLOR_PIXMAP;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
827
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
828 d = GET_GTK_WIDGET_WINDOW (DEVICE_GTK_APP_SHELL (device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
829
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
830 if (!(dest_mask & IMAGE_COLOR_PIXMAP_MASK))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
831 incompatible_image_types (instantiator, dest_mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
832 IMAGE_COLOR_PIXMAP_MASK);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
833
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
834 gtk_initialize_pixmap_image_instance (ii, IMAGE_COLOR_PIXMAP);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
835
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
836 gdk_window_get_geometry (gdk_pixmap, NULL, NULL, &width, &height, &depth);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
837
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
838 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
839 IMAGE_INSTANCE_GTK_PIXMAP (ii) = gdk_pixmap;
4629
a1dd514df5c6 Apply the 2008-03-05 change from Dominique Quatravaux in init_image_instance_from_gdk_pixmap as well even though the code is not enabled at the moment
"Ville Skyttä <scop@xemacs.org>"
parents: 4433
diff changeset
840 IMAGE_INSTANCE_PIXMAP_MASK (ii) = 0;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
841 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
842 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = height;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
843 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = depth;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
844 IMAGE_INSTANCE_GTK_COLORMAP (ii) = gdk_window_get_colormap (gdk_pixmap);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
845 IMAGE_INSTANCE_GTK_PIXELS (ii) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
846 IMAGE_INSTANCE_GTK_NPIXELS (ii) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
847 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
848 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
849
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
850 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
851 image_instance_add_gdk_image (Lisp_Image_Instance *ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
852 GdkImage *gdk_image,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
853 int slice,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
854 Lisp_Object instantiator)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
855 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
856 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
857 GdkWindow *d;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
858 GdkPixmap *pixmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
859 GdkGC *gc;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
860
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
861 d = GET_GTK_WIDGET_WINDOW (DEVICE_GTK_APP_SHELL (XDEVICE (device)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
862
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
863 pixmap = gdk_pixmap_new (d, gdk_image->width, gdk_image->height, gdk_image->depth);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
864
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
865 if (!pixmap)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
866 gui_error ("Unable to create pixmap", instantiator);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
867
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
868 gc = gdk_gc_new (pixmap);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
869
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
870 if (!gc)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
871 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
872 gdk_pixmap_unref (pixmap);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
873 gui_error ("Unable to create GC", instantiator);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
874 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
875
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
876 gdk_draw_image (GDK_DRAWABLE (pixmap), gc, gdk_image, 0, 0, 0, 0,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
877 gdk_image->width, gdk_image->height);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
878
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
879 gdk_gc_destroy (gc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
880
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
881 IMAGE_INSTANCE_GTK_PIXMAP_SLICE (ii, slice) = pixmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
882 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
883
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
884 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
885 gtk_init_image_instance_from_eimage (struct Lisp_Image_Instance *ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
886 int width, int height,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
887 int slices,
4252
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
888 unsigned char *eimage,
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
889 int dest_mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
890 Lisp_Object instantiator,
2959
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
891 Lisp_Object pointer_fg,
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
892 Lisp_Object pointer_bg,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
893 Lisp_Object UNUSED (domain))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
894 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
895 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
896 GdkColormap *cmap = DEVICE_GTK_COLORMAP (XDEVICE(device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
897 unsigned long *pixtbl = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
898 int npixels = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
899 int slice;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
900 GdkImage* gdk_image;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
901
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
902
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
903 for (slice = 0; slice < slices; slice++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
904 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
905 gdk_image = convert_EImage_to_GDKImage (device, width, height, eimage,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
906 &pixtbl, &npixels);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
907 if (!gdk_image)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
908 {
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1346
diff changeset
909 if (pixtbl)
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1346
diff changeset
910 xfree (pixtbl, unsigned long *);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
911 signal_image_error("EImage to GdkImage conversion failed", instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
912 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
913
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
914 if (slice == 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
915 /* Now create the pixmap and set up the image instance */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
916 init_image_instance_from_gdk_image (ii, gdk_image, dest_mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
917 cmap, pixtbl, npixels, slices,
2959
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
918 instantiator, pointer_fg,
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
919 pointer_bg);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
920 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
921 image_instance_add_gdk_image (ii, gdk_image, slice, instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
922
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
923 if (gdk_image)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
924 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
925 gdk_image_destroy (gdk_image);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
926 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
927 gdk_image = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
928 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
929 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
930
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
931 /* Given inline data for a mono pixmap, create and return the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
932 corresponding X object. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
933
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
934 static GdkPixmap *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
935 pixmap_from_xbm_inline (Lisp_Object device, int width, int height,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
936 /* Note that data is in ext-format! */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
937 const Extbyte *bits)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
938 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
939 return (gdk_bitmap_create_from_data (GET_GTK_WIDGET_WINDOW (DEVICE_GTK_APP_SHELL (XDEVICE (device))),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
940 (char *) bits, width, height));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
941 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
942
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
943 /* Given inline data for a mono pixmap, initialize the given
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
944 image instance accordingly. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
945
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
946 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
947 init_image_instance_from_xbm_inline (struct Lisp_Image_Instance *ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
948 int width, int height,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
949 /* Note that data is in ext-format! */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
950 const char *bits,
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
951 Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
952 Lisp_Object pointer_fg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
953 Lisp_Object pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
954 int dest_mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
955 GdkPixmap *mask,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
956 Lisp_Object UNUSED (mask_filename))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
957 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
958 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
959 Lisp_Object foreground = find_keyword_in_vector (instantiator, Q_foreground);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
960 Lisp_Object background = find_keyword_in_vector (instantiator, Q_background);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
961 GdkColor fg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
962 GdkColor bg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
963 enum image_instance_type type;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
964 GdkWindow *draw = GET_GTK_WIDGET_WINDOW (DEVICE_GTK_APP_SHELL (XDEVICE (device)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
965 GdkColormap *cmap = DEVICE_GTK_COLORMAP (XDEVICE(device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
966 GdkColor black;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
967 GdkColor white;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
968
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
969 gdk_color_black(cmap, &black);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
970 gdk_color_white(cmap, &white);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
971
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
972 if (!DEVICE_GTK_P (XDEVICE (device)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
973 gui_error ("Not a Gtk device", device);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
974
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
975 if ((dest_mask & IMAGE_MONO_PIXMAP_MASK) &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
976 (dest_mask & IMAGE_COLOR_PIXMAP_MASK))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
977 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
978 if (!NILP (foreground) || !NILP (background))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
979 type = IMAGE_COLOR_PIXMAP;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
980 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
981 type = IMAGE_MONO_PIXMAP;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
982 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
983 else if (dest_mask & IMAGE_MONO_PIXMAP_MASK)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
984 type = IMAGE_MONO_PIXMAP;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
985 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
986 type = IMAGE_COLOR_PIXMAP;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
987 else if (dest_mask & IMAGE_POINTER_MASK)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
988 type = IMAGE_POINTER;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
989 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
990 incompatible_image_types (instantiator, dest_mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
991 IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
992 | IMAGE_POINTER_MASK);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
993
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
994 gtk_initialize_pixmap_image_instance (ii, 1, type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
995 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
996 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = height;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
997 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
998 find_keyword_in_vector (instantiator, Q_file);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
999
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1000 switch (type)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1001 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1002 case IMAGE_MONO_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1003 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1004 IMAGE_INSTANCE_GTK_PIXMAP (ii) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1005 pixmap_from_xbm_inline (device, width, height, (Extbyte *) bits);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1006 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1007 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1008
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1009 case IMAGE_COLOR_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1010 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1011 gint d = DEVICE_GTK_DEPTH (XDEVICE(device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1012
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1013 if (!NILP (foreground) && !COLOR_INSTANCEP (foreground))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1014 foreground =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1015 Fmake_color_instance (foreground, device,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1016 encode_error_behavior_flag (ERROR_ME));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1017
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1018 if (COLOR_INSTANCEP (foreground))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1019 fg = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (foreground));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1020
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1021 if (!NILP (background) && !COLOR_INSTANCEP (background))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1022 background =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1023 Fmake_color_instance (background, device,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1024 encode_error_behavior_flag (ERROR_ME));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1025
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1026 if (COLOR_INSTANCEP (background))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1027 bg = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (background));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1028
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1029 /* We used to duplicate the pixels using XAllocColor(), to protect
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1030 against their getting freed. Just as easy to just store the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1031 color instances here and GC-protect them, so this doesn't
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1032 happen. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1033 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1034 IMAGE_INSTANCE_PIXMAP_BG (ii) = background;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1035 IMAGE_INSTANCE_GTK_PIXMAP (ii) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1036 gdk_pixmap_create_from_data (draw, (char *) bits, width, height, d, &fg, &bg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1037 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = d;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1038 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1039 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1040
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1041 case IMAGE_POINTER:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1042 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1043 GdkColor fg_color, bg_color;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1044 GdkPixmap *source;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1045
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1046 check_pointer_sizes (width, height, instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1047
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1048 source = gdk_pixmap_create_from_data (draw, (char *) bits, width, height, 1, &black, &white);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1049
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1050 if (NILP (foreground))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1051 foreground = pointer_fg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1052 if (NILP (background))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1053 background = pointer_bg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1054 generate_cursor_fg_bg (device, &foreground, &background,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1055 &fg_color, &bg_color);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1056
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1057 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1058 IMAGE_INSTANCE_PIXMAP_BG (ii) = background;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1059 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1060 find_keyword_in_vector (instantiator, Q_hotspot_x);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1061 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1062 find_keyword_in_vector (instantiator, Q_hotspot_y);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1063 IMAGE_INSTANCE_GTK_CURSOR (ii) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1064 gdk_cursor_new_from_pixmap (source, mask, &fg_color, &bg_color,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1065 !NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii)) ?
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1066 XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii)) : 0,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1067 !NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii)) ?
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1068 XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii)) : 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1069 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1070 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1071
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1072 default:
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2421
diff changeset
1073 ABORT ();
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1074 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1075 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1076
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1077 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1078 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1079 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1080 int dest_mask, int width, int height,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1081 /* Note that data is in ext-format! */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1082 const char *bits)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1083 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1084 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1085 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1086 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1087 GdkPixmap *mask = 0;
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
1088 const Extbyte *gcc_may_you_rot_in_hell;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1089
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1090 if (!NILP (mask_data))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1091 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1092 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (mask_data))),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1093 C_STRING_ALLOCA, gcc_may_you_rot_in_hell,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1094 Qfile_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1095 mask =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1096 pixmap_from_xbm_inline (IMAGE_INSTANCE_DEVICE (ii),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1097 XINT (XCAR (mask_data)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1098 XINT (XCAR (XCDR (mask_data))),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1099 gcc_may_you_rot_in_hell);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1100 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1101
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1102 init_image_instance_from_xbm_inline (ii, width, height, bits,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1103 instantiator, pointer_fg, pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1104 dest_mask, mask, mask_file);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1105 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1106
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1107 /* Instantiate method for XBM's. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1108
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1109 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1110 gtk_xbm_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1111 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
1112 int dest_mask, Lisp_Object UNUSED (domain))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1113 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1114 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1115 const char *gcc_go_home;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1116
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1117 assert (!NILP (data));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1118
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1119 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (data))),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1120 C_STRING_ALLOCA, gcc_go_home,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1121 Qbinary);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1122
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1123 xbm_instantiate_1 (image_instance, instantiator, pointer_fg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1124 pointer_bg, dest_mask, XINT (XCAR (data)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1125 XINT (XCAR (XCDR (data))), gcc_go_home);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1126 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1127
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1128
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1129 #ifdef HAVE_XPM
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1130 /**********************************************************************
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1131 * XPM *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1132 **********************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1133
739
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1134 struct color_symbol
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1135 {
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
1136 Ibyte* name;
739
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1137 GdkColor color;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1138 };
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1139
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1140 static struct color_symbol*
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1141 extract_xpm_color_names (Lisp_Object device,
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1142 Lisp_Object domain,
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1143 Lisp_Object color_symbol_alist,
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1144 int* nsymbols)
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1145 {
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1146 /* This function can GC */
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1147 Lisp_Object rest;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1148 Lisp_Object results = Qnil;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1149 int i, j;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1150 struct color_symbol *colortbl;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1151 struct gcpro gcpro1, gcpro2;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1152
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1153 GCPRO2 (results, device);
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1154
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1155 /* We built up results to be (("name" . #<color>) ...) so that if an
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1156 error happens we don't lose any malloc()ed data, or more importantly,
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1157 leave any pixels allocated in the server. */
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1158 i = 0;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1159 LIST_LOOP (rest, color_symbol_alist)
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1160 {
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1161 Lisp_Object cons = XCAR (rest);
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1162 Lisp_Object name = XCAR (cons);
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1163 Lisp_Object value = XCDR (cons);
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1164 if (NILP (value))
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1165 continue;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1166 if (STRINGP (value))
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1167 value =
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1168 Fmake_color_instance
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 778
diff changeset
1169 (value, device, encode_error_behavior_flag (ERROR_ME_DEBUG_WARN));
739
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1170 else
4252
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
1171 {
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
1172 assert (COLOR_SPECIFIERP (value));
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
1173 value = Fspecifier_instance (value, domain, Qnil, Qnil);
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
1174 }
739
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1175
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1176 if (NILP (value))
4252
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
1177 continue;
739
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1178 results = noseeum_cons (noseeum_cons (name, value), results);
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1179 i++;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1180 }
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1181 UNGCPRO; /* no more evaluation */
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1182
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1183 *nsymbols=i;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1184 if (i == 0) return 0;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1185
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1186 colortbl = xnew_array_and_zero (struct color_symbol, i);
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1187
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1188 for (j=0; j<i; j++)
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1189 {
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1190 Lisp_Object cons = XCAR (results);
4252
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
1191 colortbl[j].color =
739
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1192 * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (XCDR (cons)));
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1193
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
1194 colortbl[j].name = XSTRING_DATA (XCAR (cons));
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
1195 free_cons (cons);
739
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1196 cons = results;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1197 results = XCDR (results);
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
1198 free_cons (cons);
739
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1199 }
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1200 return colortbl;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1201 }
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1202
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1203 static void
739
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1204 gtk_xpm_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1205 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1206 int dest_mask, Lisp_Object domain)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1207 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1208 /* This function can GC */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1209 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1210 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1211 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1212 GdkColormap *cmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1213 int depth;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1214 GdkVisual *visual;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1215 GdkPixmap *pixmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1216 GdkPixmap *mask = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1217 GdkWindow *window = 0;
739
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1218 int nsymbols = 0, i = 0;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1219 struct color_symbol *color_symbols = NULL;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1220 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1221 Q_color_symbols);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1222 enum image_instance_type type;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1223 int force_mono;
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
1224 gint w, h;
2082
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1225 struct gcpro gcpro1, gcpro2, gcpro3;
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
1226 const Binbyte * volatile dstring;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1227
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1228 if (!DEVICE_GTK_P (XDEVICE (device)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1229 gui_error ("Not a Gtk device", device);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1230
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1231 if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1232 type = IMAGE_COLOR_PIXMAP;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1233 else if (dest_mask & IMAGE_MONO_PIXMAP_MASK)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1234 type = IMAGE_MONO_PIXMAP;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1235 else if (dest_mask & IMAGE_POINTER_MASK)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1236 type = IMAGE_POINTER;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1237 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1238 incompatible_image_types (instantiator, dest_mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1239 IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1240 | IMAGE_POINTER_MASK);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1241 force_mono = (type != IMAGE_COLOR_PIXMAP);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1242
2082
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1243 GCPRO3 (device, data, color_symbol_alist);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1244
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1245 window = GET_GTK_WIDGET_WINDOW (DEVICE_GTK_APP_SHELL (XDEVICE (device)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1246 cmap = DEVICE_GTK_COLORMAP (XDEVICE (device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1247 depth = DEVICE_GTK_DEPTH (XDEVICE (device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1248 visual = DEVICE_GTK_VISUAL (XDEVICE (device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1249
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1250 gtk_initialize_pixmap_image_instance (ii, 1, type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1251
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1252 assert (!NILP (data));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1253
2082
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1254 /* Extract all the entries from xpm-color-symbols */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1255 color_symbols = extract_xpm_color_names (device, domain, color_symbol_alist,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1256 &nsymbols);
2082
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1257 assert (!NILP (data));
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1258
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1259 LISP_STRING_TO_EXTERNAL(data, dstring, Qbinary);
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1260
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1261 /*
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1262 * GTK only uses the 'c' color entry of an XPM and doesn't use the symbolic
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1263 * color names at all. This is unfortunate because the way to change the
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1264 * colors from lisp is by adding the symbolic names, and the new colors, to
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1265 * the variable xpm-color-symbols.
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1266 *
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1267 * To get around this decode the XPM, add a 'c' entry of the desired color
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1268 * for each matching symbolic color, recode the XPM and pass it to GTK. The
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1269 * decode and recode stages aren't too bad because this also performs the
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1270 * external to internal format translation, which avoids contortions like
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1271 * writing the XPM back to disk in order to get it processed.
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1272 */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1273 {
2082
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1274 XpmImage image;
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1275 XpmInfo info;
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1276 char** data;
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1277
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1278 XpmCreateXpmImageFromBuffer ((char*) dstring, &image, &info);
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1279
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1280 for (i = 0; i < nsymbols; i++)
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1281 {
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1282 unsigned j;
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1283
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1284 for (j = 0; j < image.ncolors; j++)
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1285 {
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1286 if (image.colorTable[j].symbolic != NULL &&
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
1287 !qxestrcasecmp_ascii(color_symbols[i].name, image.colorTable[j].symbolic))
2082
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1288 {
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
1289 image.colorTable[j].c_color = xnew_ascbytes (16);
2082
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1290
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1291 sprintf(image.colorTable[j].c_color, "#%.4x%.4x%.4x",
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1292 color_symbols[i].color.red, color_symbols[i].color.green,
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1293 color_symbols[i].color.blue);
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1294 }
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1295 }
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1296 }
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1297
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1298 XpmCreateDataFromXpmImage (&data, &image, &info);
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1299
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1300 pixmap = gdk_pixmap_create_from_xpm_d (window, &mask, NULL,
16489ca72b3d [xemacs-hg @ 2004-05-15 07:43:05 by malcolmp]
malcolmp
parents: 2054
diff changeset
1301 data);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1302 }
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1303
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1346
diff changeset
1304 if (color_symbols)
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1346
diff changeset
1305 xfree (color_symbols, struct color_symbol *);
739
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1306
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1307 if (!pixmap)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1308 signal_image_error ("Error reading pixmap", data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1309
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1310 gdk_window_get_geometry (pixmap, NULL, NULL, &w, &h, &depth);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1311
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1312 IMAGE_INSTANCE_GTK_PIXMAP (ii) = pixmap;
3087
dbd2a866e38a [xemacs-hg @ 2005-11-22 11:24:40 by malcolmp]
malcolmp
parents: 2959
diff changeset
1313 IMAGE_INSTANCE_PIXMAP_MASK (ii) = mask;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1314 IMAGE_INSTANCE_GTK_COLORMAP (ii) = cmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1315 IMAGE_INSTANCE_GTK_PIXELS (ii) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1316 IMAGE_INSTANCE_GTK_NPIXELS (ii) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1317 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = w;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1318 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = h;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1319 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1320 find_keyword_in_vector (instantiator, Q_file);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1321
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1322 switch (type)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1323 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1324 case IMAGE_MONO_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1325 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1326
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1327 case IMAGE_COLOR_PIXMAP:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1328 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = depth;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1329 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1330
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1331 case IMAGE_POINTER:
4700
ef70ee47d287 Image instantiator pixmap hotspots are Lisp integers; make it so in GTK.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4629
diff changeset
1332 /* #### Gtk does not give us access to the hotspots of a pixmap */
ef70ee47d287 Image instantiator pixmap hotspots are Lisp integers; make it so in GTK.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4629
diff changeset
1333
ef70ee47d287 Image instantiator pixmap hotspots are Lisp integers; make it so in GTK.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4629
diff changeset
1334 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = make_int(1);
ef70ee47d287 Image instantiator pixmap hotspots are Lisp integers; make it so in GTK.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4629
diff changeset
1335 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = make_int(1);
3087
dbd2a866e38a [xemacs-hg @ 2005-11-22 11:24:40 by malcolmp]
malcolmp
parents: 2959
diff changeset
1336
4252
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
1337
2959
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
1338 image_instance_convert_to_pointer (ii, instantiator, pointer_fg,
4eb2a8c07cb3 [xemacs-hg @ 2005-09-27 05:48:22 by ben]
ben
parents: 2515
diff changeset
1339 pointer_bg);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1340 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1341
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1342 default:
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2421
diff changeset
1343 ABORT ();
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1344 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1345
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1346 UNGCPRO;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1347 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1348 #endif /* HAVE_XPM */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1349
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1350
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1351 #ifdef HAVE_XFACE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1352
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1353 /**********************************************************************
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1354 * X-Face *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1355 **********************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1356 #if defined(EXTERN)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1357 /* This is about to get redefined! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1358 #undef EXTERN
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1359 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1360 /* We have to define SYSV32 so that compface.h includes string.h
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1361 instead of strings.h. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1362 #define SYSV32
1743
543769b89fed [xemacs-hg @ 2003-10-14 05:02:57 by james]
james
parents: 1726
diff changeset
1363 BEGIN_C_DECLS
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1364 #include <compface.h>
1743
543769b89fed [xemacs-hg @ 2003-10-14 05:02:57 by james]
james
parents: 1726
diff changeset
1365 END_C_DECLS
543769b89fed [xemacs-hg @ 2003-10-14 05:02:57 by james]
james
parents: 1726
diff changeset
1366
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1367 /* JMP_BUF cannot be used here because if it doesn't get defined
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1368 to jmp_buf we end up with a conflicting type error with the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1369 definition in compface.h */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1370 extern jmp_buf comp_env;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1371 #undef SYSV32
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1372
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1373 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1374 gtk_xface_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
1375 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
1376 int dest_mask, Lisp_Object UNUSED (domain))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1377 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1378 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1379 int i, stattis;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1380 char *p, *bits, *bp;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1381 const char * volatile emsg = 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1382 const char * volatile dstring;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1383
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1384 assert (!NILP (data));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1385
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1386 LISP_STRING_TO_EXTERNAL (data, dstring, Qbinary);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1387
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1388 if ((p = strchr (dstring, ':')))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1389 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1390 dstring = p + 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1391 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1392
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1393 /* Must use setjmp not SETJMP because we used jmp_buf above not JMP_BUF */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1394 if (!(stattis = setjmp (comp_env)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1395 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1396 UnCompAll ((char *) dstring);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1397 UnGenFace ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1398 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1399
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1400 switch (stattis)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1401 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1402 case -2:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1403 emsg = "uncompface: internal error";
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1404 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1405 case -1:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1406 emsg = "uncompface: insufficient or invalid data";
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1407 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1408 case 1:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1409 emsg = "uncompface: excess data ignored";
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1410 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1411 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1412
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1413 if (emsg)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1414 gui_error_2 (emsg, data, Qimage);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1415
851
e7ee5f8bde58 [xemacs-hg @ 2002-05-23 11:46:08 by ben]
ben
parents: 826
diff changeset
1416 bp = bits = (char *) ALLOCA (PIXELS / 8);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1417
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1418 /* the compface library exports char F[], which uses a single byte per
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1419 pixel to represent a 48x48 bitmap. Yuck. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1420 for (i = 0, p = F; i < (PIXELS / 8); ++i)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1421 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1422 int n, b;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1423 /* reverse the bit order of each byte... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1424 for (b = n = 0; b < 8; ++b)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1425 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1426 n |= ((*p++) << b);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1427 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1428 *bp++ = (char) n;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1429 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1430
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1431 xbm_instantiate_1 (image_instance, instantiator, pointer_fg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1432 pointer_bg, dest_mask, 48, 48, bits);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1433 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1434
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1435 #endif /* HAVE_XFACE */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1436
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1437 /**********************************************************************
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1438 * RESOURCES *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1439 **********************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1440
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1441 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1442 gtk_resource_validate (Lisp_Object instantiator)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1443 {
4252
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
1444 if ((NILP (find_keyword_in_vector (instantiator, Q_file))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1445 &&
4252
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
1446 NILP (find_keyword_in_vector (instantiator, Q_resource_id)))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1447 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1448 NILP (find_keyword_in_vector (instantiator, Q_resource_type)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1449 sferror ("Must supply :file, :resource-id and :resource-type",
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1450 instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1451 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1452
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1453 static Lisp_Object
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1454 gtk_resource_normalize (Lisp_Object inst, Lisp_Object console_type,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1455 Lisp_Object dest_mask)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1456 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1457 return shared_resource_normalize (inst, console_type, dest_mask,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1458 Qgtk_resource);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1459 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1460
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1461 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1462 gtk_resource_possible_dest_types (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1463 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1464 return IMAGE_POINTER_MASK | IMAGE_COLOR_PIXMAP_MASK;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1465 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1466
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1467 extern guint symbol_to_enum (Lisp_Object, GtkType);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1468
2272
4ec724310f33 [xemacs-hg @ 2004-09-14 20:54:29 by james]
james
parents: 2168
diff changeset
1469 static guint resource_name_to_resource (Lisp_Object name,
4ec724310f33 [xemacs-hg @ 2004-09-14 20:54:29 by james]
james
parents: 2168
diff changeset
1470 enum image_instance_type type)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1471 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1472 if (type == IMAGE_POINTER)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1473 return (symbol_to_enum (name, GTK_TYPE_GDK_CURSOR_TYPE));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1474 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1475 return (0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1476 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1477
2272
4ec724310f33 [xemacs-hg @ 2004-09-14 20:54:29 by james]
james
parents: 2168
diff changeset
1478 static enum image_instance_type
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1479 resource_symbol_to_type (Lisp_Object data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1480 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1481 if (EQ (data, Qcursor))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1482 return IMAGE_POINTER;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1483 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1484 else if (EQ (data, Qicon))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1485 return IMAGE_ICON;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1486 else if (EQ (data, Qbitmap))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1487 return IMAGE_BITMAP;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1488 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1489 else
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
1490 return IMAGE_UNKNOWN;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1491 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1492
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1493 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1494 gtk_resource_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
1495 Lisp_Object UNUSED (pointer_fg),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
1496 Lisp_Object UNUSED (pointer_bg),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
1497 int UNUSED (dest_mask), Lisp_Object UNUSED (domain))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1498 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1499 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1500 GdkCursor *c = NULL;
2272
4ec724310f33 [xemacs-hg @ 2004-09-14 20:54:29 by james]
james
parents: 2168
diff changeset
1501 enum image_instance_type type;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1502 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1503 Lisp_Object resource_type = find_keyword_in_vector (instantiator, Q_resource_type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1504 Lisp_Object resource_id = find_keyword_in_vector (instantiator, Q_resource_id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1505
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1506 if (!DEVICE_GTK_P (XDEVICE (device)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1507 gui_error ("Not a GTK device", device);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1508
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1509 type = resource_symbol_to_type (resource_type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1510
595
fec27b06b4e5 [xemacs-hg @ 2001-05-31 14:45:08 by wmperry]
wmperry
parents: 563
diff changeset
1511 #if 0
fec27b06b4e5 [xemacs-hg @ 2001-05-31 14:45:08 by wmperry]
wmperry
parents: 563
diff changeset
1512 if (dest_mask & IMAGE_POINTER_MASK && type == IMAGE_POINTER_MASK)
fec27b06b4e5 [xemacs-hg @ 2001-05-31 14:45:08 by wmperry]
wmperry
parents: 563
diff changeset
1513 iitype = IMAGE_POINTER;
fec27b06b4e5 [xemacs-hg @ 2001-05-31 14:45:08 by wmperry]
wmperry
parents: 563
diff changeset
1514 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
fec27b06b4e5 [xemacs-hg @ 2001-05-31 14:45:08 by wmperry]
wmperry
parents: 563
diff changeset
1515 iitype = IMAGE_COLOR_PIXMAP;
4252
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
1516 else
595
fec27b06b4e5 [xemacs-hg @ 2001-05-31 14:45:08 by wmperry]
wmperry
parents: 563
diff changeset
1517 incompatible_image_types (instantiator, dest_mask,
4252
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
1518 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK);
595
fec27b06b4e5 [xemacs-hg @ 2001-05-31 14:45:08 by wmperry]
wmperry
parents: 563
diff changeset
1519 #endif
4252
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
1520
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1521 /* mess with the keyword info we were provided with */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1522 gtk_initialize_pixmap_image_instance (ii, 1, type);
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
1523 c = gdk_cursor_new ((GdkCursorType) resource_name_to_resource (resource_id, type));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1524 IMAGE_INSTANCE_GTK_CURSOR (ii) = c;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1525 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = resource_id;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1526 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = 10;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1527 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = 10;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1528 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1529 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1530
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1531 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1532 check_valid_resource_symbol (Lisp_Object data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1533 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1534 CHECK_SYMBOL (data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1535 if (!resource_symbol_to_type (data))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1536 invalid_constant ("invalid resource type", data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1537 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1538
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1539 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1540 check_valid_resource_id (Lisp_Object data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1541 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1542 if (!resource_name_to_resource (data, IMAGE_POINTER)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1543 &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1544 !resource_name_to_resource (data, IMAGE_COLOR_PIXMAP)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1545 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1546 &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1547 !resource_name_to_resource (data, IMAGE_BITMAP)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1548 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1549 )
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1550 invalid_constant ("invalid resource identifier", data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1551 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1552
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1553 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1554 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1555 check_valid_string_or_int (Lisp_Object data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1556 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1557 if (!INTP (data))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1558 CHECK_STRING (data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1559 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1560 CHECK_INT (data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1561 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1562 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1563
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1564
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1565 /**********************************************************************
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1566 * Autodetect *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1567 **********************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1568
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1569 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1570 autodetect_validate (Lisp_Object instantiator)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1571 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1572 data_must_be_present (instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1573 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1574
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1575 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1576 autodetect_normalize (Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1577 Lisp_Object console_type,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
1578 Lisp_Object UNUSED (dest_mask))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1579 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1580 Lisp_Object file = find_keyword_in_vector (instantiator, Q_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1581 Lisp_Object filename = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1582 Lisp_Object data = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1583 struct gcpro gcpro1, gcpro2, gcpro3;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1584 Lisp_Object alist = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1585
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1586 GCPRO3 (filename, data, alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1587
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1588 if (NILP (file)) /* no conversion necessary */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1589 RETURN_UNGCPRO (instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1590
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1591 alist = tagged_vector_to_alist (instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1592
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1593 filename = locate_pixmap_file (file);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1594 if (!NILP (filename))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1595 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1596 int xhot, yhot;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1597 /* #### Apparently some versions of XpmReadFileToData, which is
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1598 called by pixmap_to_lisp_data, don't return an error value
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1599 if the given file is not a valid XPM file. Instead, they
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1600 just seg fault. It is definitely caused by passing a
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1601 bitmap. To try and avoid this we check for bitmaps first. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1602
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1603 data = bitmap_to_lisp_data (filename, &xhot, &yhot, 1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1604
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1605 if (!EQ (data, Qt))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1606 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1607 alist = remassq_no_quit (Q_data, alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1608 alist = Fcons (Fcons (Q_file, filename),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1609 Fcons (Fcons (Q_data, data), alist));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1610 if (xhot != -1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1611 alist = Fcons (Fcons (Q_hotspot_x, make_int (xhot)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1612 alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1613 if (yhot != -1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1614 alist = Fcons (Fcons (Q_hotspot_y, make_int (yhot)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1615 alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1616
4252
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
1617 alist = xbm_mask_file_munging (alist, filename, Qt, console_type);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1618
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1619 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1620 Lisp_Object result = alist_to_tagged_vector (Qxbm, alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1621 free_alist (alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1622 RETURN_UNGCPRO (result);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1623 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1624 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1625
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1626 #ifdef HAVE_XPM
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1627 data = pixmap_to_lisp_data (filename, 1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1628
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1629 if (!EQ (data, Qt))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1630 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1631 alist = remassq_no_quit (Q_data, alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1632 alist = Fcons (Fcons (Q_file, filename),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1633 Fcons (Fcons (Q_data, data), alist));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1634 alist = Fcons (Fcons (Q_color_symbols,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1635 evaluate_xpm_color_symbols ()),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1636 alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1637 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1638 Lisp_Object result = alist_to_tagged_vector (Qxpm, alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1639 free_alist (alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1640 RETURN_UNGCPRO (result);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1641 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1642 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1643 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1644 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1645
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1646 /* If we couldn't convert it, just put it back as it is.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1647 We might try to further frob it later as a cursor-font
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1648 specification. (We can't do that now because we don't know
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1649 what dest-types it's going to be instantiated into.) */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1650 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1651 Lisp_Object result = alist_to_tagged_vector (Qautodetect, alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1652 free_alist (alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1653 RETURN_UNGCPRO (result);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1654 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1655 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1656
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1657 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1658 autodetect_possible_dest_types (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1659 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1660 return
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1661 IMAGE_MONO_PIXMAP_MASK |
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1662 IMAGE_COLOR_PIXMAP_MASK |
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1663 IMAGE_POINTER_MASK |
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1664 IMAGE_TEXT_MASK;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1665 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1666
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1667 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1668 autodetect_instantiate (Lisp_Object image_instance,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1669 Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1670 Lisp_Object pointer_fg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1671 Lisp_Object pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1672 int dest_mask, Lisp_Object domain)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1673 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1674 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1675 struct gcpro gcpro1, gcpro2, gcpro3;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1676 Lisp_Object alist = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1677 Lisp_Object result = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1678 int is_cursor_font = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1679
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1680 GCPRO3 (data, alist, result);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1681
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1682 alist = tagged_vector_to_alist (instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1683 if (dest_mask & IMAGE_POINTER_MASK)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1684 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1685 const char *name_ext;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1686
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1687 TO_EXTERNAL_FORMAT (LISP_STRING, data,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1688 C_STRING_ALLOCA, name_ext,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1689 Qfile_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1690
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1691 if (cursor_name_to_index (name_ext) != -1)
4252
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
1692 {
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
1693 result = alist_to_tagged_vector (Qcursor_font, alist);
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
1694 is_cursor_font = 1;
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
1695 }
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1696 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1697
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1698 if (!is_cursor_font)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1699 result = alist_to_tagged_vector (Qstring, alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1700 free_alist (alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1701
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1702 if (is_cursor_font)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1703 cursor_font_instantiate (image_instance, result, pointer_fg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1704 pointer_bg, dest_mask, domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1705 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1706 string_instantiate (image_instance, result, pointer_fg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1707 pointer_bg, dest_mask, domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1708
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1709 UNGCPRO;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1710 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1711
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1712
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1713 /**********************************************************************
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1714 * Font *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1715 **********************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1716
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1717 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1718 font_validate (Lisp_Object instantiator)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1719 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1720 data_must_be_present (instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1721 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1722
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1723 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1724 font_possible_dest_types (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1725 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1726 return IMAGE_POINTER_MASK;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1727 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1728
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1729 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1730 font_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1731 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
1732 int dest_mask, Lisp_Object UNUSED (domain))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1733 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1734 /* This function can GC */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1735 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1736 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1737 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1738 GdkColor fg, bg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1739 GdkFont *source, *mask;
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
1740 char source_name[PATH_MAX_INTERNAL], mask_name[PATH_MAX_INTERNAL], dummy;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1741 int source_char, mask_char;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1742 int count;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1743 Lisp_Object foreground, background;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1744
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1745 if (!DEVICE_GTK_P (XDEVICE (device)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1746 gui_error ("Not a Gtk device", device);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1747
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1748 if (!STRINGP (data) ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1749 strncmp ("FONT ", (char *) XSTRING_DATA (data), 5))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1750 invalid_argument ("Invalid font-glyph instantiator",
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1751 instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1752
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1753 if (!(dest_mask & IMAGE_POINTER_MASK))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1754 incompatible_image_types (instantiator, dest_mask, IMAGE_POINTER_MASK);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1755
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1756 foreground = find_keyword_in_vector (instantiator, Q_foreground);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1757 if (NILP (foreground))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1758 foreground = pointer_fg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1759 background = find_keyword_in_vector (instantiator, Q_background);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1760 if (NILP (background))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1761 background = pointer_bg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1762
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1763 generate_cursor_fg_bg (device, &foreground, &background, &fg, &bg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1764
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1765 count = sscanf ((char *) XSTRING_DATA (data),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1766 "FONT %s %d %s %d %c",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1767 source_name, &source_char,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1768 mask_name, &mask_char, &dummy);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1769 /* Allow "%s %d %d" as well... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1770 if (count == 3 && (1 == sscanf (mask_name, "%d %c", &mask_char, &dummy)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1771 count = 4, mask_name[0] = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1772
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1773 if (count != 2 && count != 4)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1774 syntax_error ("invalid cursor specification", data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1775 source = gdk_font_load (source_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1776 if (! source)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1777 gui_error_2 ("couldn't load font",
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1778 build_string (source_name),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1779 data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1780 if (count == 2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1781 mask = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1782 else if (!mask_name[0])
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1783 mask = source;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1784 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1785 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1786 mask = gdk_font_load (mask_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1787 if (!mask)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1788 /* continuable */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1789 Fsignal (Qgui_error, list3 (build_msg_string ("couldn't load font"),
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1790 build_string (mask_name), data));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1791 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1792 if (!mask)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1793 mask_char = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1794
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1795 /* #### call XQueryTextExtents() and check_pointer_sizes() here. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1796
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1797 gtk_initialize_pixmap_image_instance (ii, 1, IMAGE_POINTER);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1798
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1799 IMAGE_INSTANCE_GTK_CURSOR (ii) = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1800
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1801 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1802 /* #### BILL!!! There is no way to call this function from Gdk */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1803 XCreateGlyphCursor (dpy, source, mask, source_char, mask_char,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1804 &fg, &bg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1805 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1806 XIMAGE_INSTANCE_PIXMAP_FG (image_instance) = foreground;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1807 XIMAGE_INSTANCE_PIXMAP_BG (image_instance) = background;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1808
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1809 gdk_font_unref (source);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1810 if (mask && mask != source) gdk_font_unref (mask);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1811 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1812
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1813
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1814 /**********************************************************************
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1815 * Cursor-Font *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1816 **********************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1817
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1818 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1819 cursor_font_validate (Lisp_Object instantiator)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1820 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1821 data_must_be_present (instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1822 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1823
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1824 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1825 cursor_font_possible_dest_types (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1826 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1827 return IMAGE_POINTER_MASK;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1828 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1829
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1830 static char *__downcase (const char *name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1831 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1832 char *converted = strdup(name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1833 char *work = converted;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1834
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1835 while (*work)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1836 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1837 *work = tolower(*work);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1838 work++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1839 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1840 return(converted);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1841 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1842
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1843 /* This is basically the equivalent of XmuCursorNameToIndex */
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
1844 static GdkCursorType
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1845 cursor_name_to_index (const char *name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1846 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1847 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1848 static char *the_gdk_cursors[GDK_NUM_GLYPHS];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1849
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1850 if (!the_gdk_cursors[GDK_BASED_ARROW_UP])
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1851 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1852 /* Need to initialize the array */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1853 /* Supposedly since this array is static it should be
4252
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
1854 initialized to NULLs for us, but I'm very paranoid. */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1855 for (i = 0; i < GDK_NUM_GLYPHS; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1856 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1857 the_gdk_cursors[i] = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1858 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1859
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1860 #define FROB_CURSOR(x) the_gdk_cursors[GDK_##x] = __downcase(#x)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1861 FROB_CURSOR(ARROW); FROB_CURSOR(BASED_ARROW_DOWN);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1862 FROB_CURSOR(BASED_ARROW_UP); FROB_CURSOR(BOAT);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1863 FROB_CURSOR(BOGOSITY); FROB_CURSOR(BOTTOM_LEFT_CORNER);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1864 FROB_CURSOR(BOTTOM_RIGHT_CORNER); FROB_CURSOR(BOTTOM_SIDE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1865 FROB_CURSOR(BOTTOM_TEE); FROB_CURSOR(BOX_SPIRAL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1866 FROB_CURSOR(CENTER_PTR); FROB_CURSOR(CIRCLE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1867 FROB_CURSOR(CLOCK); FROB_CURSOR(COFFEE_MUG);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1868 FROB_CURSOR(CROSS); FROB_CURSOR(CROSS_REVERSE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1869 FROB_CURSOR(CROSSHAIR); FROB_CURSOR(DIAMOND_CROSS);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1870 FROB_CURSOR(DOT); FROB_CURSOR(DOTBOX);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1871 FROB_CURSOR(DOUBLE_ARROW); FROB_CURSOR(DRAFT_LARGE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1872 FROB_CURSOR(DRAFT_SMALL); FROB_CURSOR(DRAPED_BOX);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1873 FROB_CURSOR(EXCHANGE); FROB_CURSOR(FLEUR);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1874 FROB_CURSOR(GOBBLER); FROB_CURSOR(GUMBY);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1875 FROB_CURSOR(HAND1); FROB_CURSOR(HAND2);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1876 FROB_CURSOR(HEART); FROB_CURSOR(ICON);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1877 FROB_CURSOR(IRON_CROSS); FROB_CURSOR(LEFT_PTR);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1878 FROB_CURSOR(LEFT_SIDE); FROB_CURSOR(LEFT_TEE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1879 FROB_CURSOR(LEFTBUTTON); FROB_CURSOR(LL_ANGLE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1880 FROB_CURSOR(LR_ANGLE); FROB_CURSOR(MAN);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1881 FROB_CURSOR(MIDDLEBUTTON); FROB_CURSOR(MOUSE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1882 FROB_CURSOR(PENCIL); FROB_CURSOR(PIRATE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1883 FROB_CURSOR(PLUS); FROB_CURSOR(QUESTION_ARROW);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1884 FROB_CURSOR(RIGHT_PTR); FROB_CURSOR(RIGHT_SIDE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1885 FROB_CURSOR(RIGHT_TEE); FROB_CURSOR(RIGHTBUTTON);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1886 FROB_CURSOR(RTL_LOGO); FROB_CURSOR(SAILBOAT);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1887 FROB_CURSOR(SB_DOWN_ARROW); FROB_CURSOR(SB_H_DOUBLE_ARROW);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1888 FROB_CURSOR(SB_LEFT_ARROW); FROB_CURSOR(SB_RIGHT_ARROW);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1889 FROB_CURSOR(SB_UP_ARROW); FROB_CURSOR(SB_V_DOUBLE_ARROW);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1890 FROB_CURSOR(SHUTTLE); FROB_CURSOR(SIZING);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1891 FROB_CURSOR(SPIDER); FROB_CURSOR(SPRAYCAN);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1892 FROB_CURSOR(STAR); FROB_CURSOR(TARGET);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1893 FROB_CURSOR(TCROSS); FROB_CURSOR(TOP_LEFT_ARROW);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1894 FROB_CURSOR(TOP_LEFT_CORNER); FROB_CURSOR(TOP_RIGHT_CORNER);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1895 FROB_CURSOR(TOP_SIDE); FROB_CURSOR(TOP_TEE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1896 FROB_CURSOR(TREK); FROB_CURSOR(UL_ANGLE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1897 FROB_CURSOR(UMBRELLA); FROB_CURSOR(UR_ANGLE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1898 FROB_CURSOR(WATCH); FROB_CURSOR(XTERM);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1899 FROB_CURSOR(X_CURSOR);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1900 #undef FROB_CURSOR
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1901 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1902
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1903 for (i = 0; i < GDK_NUM_GLYPHS; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1904 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1905 if (!the_gdk_cursors[i]) continue;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1906 if (!strcmp (the_gdk_cursors[i], name))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1907 {
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
1908 return (GdkCursorType) i;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1909 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1910 }
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
1911 return (GdkCursorType) -1;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1912 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1913
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1914 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1915 cursor_font_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1916 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
1917 int dest_mask, Lisp_Object UNUSED (domain))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1918 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1919 /* This function can GC */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1920 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1921 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1922 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
1923 GdkCursorType i;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1924 const char *name_ext;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1925 Lisp_Object foreground, background;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1926
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1927 if (!DEVICE_GTK_P (XDEVICE (device)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1928 gui_error ("Not a Gtk device", device);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1929
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1930 if (!(dest_mask & IMAGE_POINTER_MASK))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1931 incompatible_image_types (instantiator, dest_mask, IMAGE_POINTER_MASK);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1932
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1933 TO_EXTERNAL_FORMAT (LISP_STRING, data,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1934 C_STRING_ALLOCA, name_ext,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1935 Qfile_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1936
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1937 if ((i = cursor_name_to_index (name_ext)) == -1)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1938 invalid_argument ("Unrecognized cursor-font name", data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1939
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1940 gtk_initialize_pixmap_image_instance (ii, 1, IMAGE_POINTER);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1941 IMAGE_INSTANCE_GTK_CURSOR (ii) = gdk_cursor_new (i);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1942 foreground = find_keyword_in_vector (instantiator, Q_foreground);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1943 if (NILP (foreground))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1944 foreground = pointer_fg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1945 background = find_keyword_in_vector (instantiator, Q_background);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1946 if (NILP (background))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1947 background = pointer_bg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1948 maybe_recolor_cursor (image_instance, foreground, background);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1949 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1950
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1951 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1952 gtk_colorize_image_instance (Lisp_Object image_instance,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1953 Lisp_Object foreground, Lisp_Object background);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1954
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1955
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1956 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1957 /* subwindow and widget support */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1958 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1959
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1960 /* unmap the image if it is a widget. This is used by redisplay via
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1961 redisplay_unmap_subwindows */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1962 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1963 gtk_unmap_subwindow (Lisp_Image_Instance *p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1964 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1965 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1966 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1967 /* We don't support subwindows, but we do support widgets... */
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2421
diff changeset
1968 ABORT ();
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1969 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1970 else /* must be a widget */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1971 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1972 /* Since we are being unmapped we want the enclosing frame to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1973 get focus. The losing with simple scrolling but is the safest
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1974 thing to do. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1975 if (IMAGE_INSTANCE_GTK_CLIPWIDGET (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1976 gtk_widget_unmap (IMAGE_INSTANCE_GTK_CLIPWIDGET (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1977 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1978 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1979
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1980 /* map the subwindow. This is used by redisplay via
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1981 redisplay_output_subwindow */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1982 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1983 gtk_map_subwindow (Lisp_Image_Instance *p, int x, int y,
691
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
1984 struct display_glyph_area* dga)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1985 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1986 assert (dga->width > 0 && dga->height > 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1987
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1988 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1989 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1990 /* No subwindow support... */
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2421
diff changeset
1991 ABORT ();
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1992 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1993 else /* must be a widget */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1994 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1995 struct frame *f = XFRAME (IMAGE_INSTANCE_FRAME (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1996 GtkWidget *wid = IMAGE_INSTANCE_GTK_CLIPWIDGET (p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1997 GtkAllocation a;
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
1998 int moving;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1999
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2000 if (!wid) return;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2001
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2002 a.x = x + IMAGE_INSTANCE_GTK_WIDGET_XOFFSET (p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2003 a.y = y + IMAGE_INSTANCE_GTK_WIDGET_YOFFSET (p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2004 a.width = dga->width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2005 a.height = dga->height;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2006
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2007 /* Is the widget cganging position? */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2008 moving = (a.x != wid->allocation.x) ||
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2009 (a.y != wid->allocation.y);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2010
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2011 if ((a.width != wid->allocation.width) ||
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2012 (a.height != wid->allocation.height) ||
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2013 moving)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2014 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2015 gtk_widget_size_allocate (IMAGE_INSTANCE_GTK_CLIPWIDGET (p), &a);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2016 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2017
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2018 if (moving)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2019 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2020 guint32 old_flags = GTK_WIDGET_FLAGS (FRAME_GTK_TEXT_WIDGET (f));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2021
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2022 /* GtkFixed widget queues a resize when you add a widget.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2023 ** But only if it is visible.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2024 ** losers.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2025 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2026 GTK_WIDGET_FLAGS(FRAME_GTK_TEXT_WIDGET (f)) &= ~GTK_VISIBLE;
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2027
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2028 if (IMAGE_INSTANCE_GTK_ALREADY_PUT(p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2029 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2030 gtk_fixed_move (GTK_FIXED (FRAME_GTK_TEXT_WIDGET (f)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2031 wid,
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2032 a.x, a.y);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2033 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2034 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2035 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2036 IMAGE_INSTANCE_GTK_ALREADY_PUT(p) = TRUE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2037 gtk_fixed_put (GTK_FIXED (FRAME_GTK_TEXT_WIDGET (f)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2038 wid,
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2039 a.x, a.y);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2040 }
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2041
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2042 GTK_WIDGET_FLAGS(FRAME_GTK_TEXT_WIDGET (f)) = old_flags;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2043 }
691
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2044 else
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2045 {
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2046 if (IMAGE_INSTANCE_GTK_ALREADY_PUT(p))
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2047 {
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2048 /* Do nothing... */
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2049 }
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2050 else
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2051 {
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2052 /* Must make sure we have put the image at least once! */
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2053 IMAGE_INSTANCE_GTK_ALREADY_PUT(p) = TRUE;
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2054 gtk_fixed_put (GTK_FIXED (FRAME_GTK_TEXT_WIDGET (f)),
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2055 wid,
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2056 a.x, a.y);
691
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2057 }
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2058 }
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2059
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2060 if (!IMAGE_INSTANCE_SUBWINDOW_DISPLAYEDP (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2061 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2062 gtk_widget_map (wid);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2063 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2064
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2065 gtk_widget_draw (wid, NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2066 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2067 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2068
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2069 /* when you click on a widget you may activate another widget this
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2070 needs to be checked and all appropriate widgets updated */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2071 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2072 gtk_redisplay_subwindow (Lisp_Image_Instance *p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2073 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2074 /* Update the subwindow size if necessary. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2075 if (IMAGE_INSTANCE_SIZE_CHANGED (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2076 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2077 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2078 XResizeWindow (IMAGE_INSTANCE_X_SUBWINDOW_DISPLAY (p),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2079 IMAGE_INSTANCE_X_SUBWINDOW_ID (p),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2080 IMAGE_INSTANCE_WIDTH (p),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2081 IMAGE_INSTANCE_HEIGHT (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2082 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2083 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2084 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2085
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2086 /* Update all attributes that have changed. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2087 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2088 gtk_redisplay_widget (Lisp_Image_Instance *p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2089 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2090 /* This function can GC if IN_REDISPLAY is false. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2091
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2092 if (!IMAGE_INSTANCE_GTK_CLIPWIDGET (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2093 return;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2094
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2095 #ifdef HAVE_WIDGETS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2096 /* First get the items if they have changed since this is a
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2097 structural change. As such it will nuke all added values so we
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2098 need to update most other things after the items have changed.*/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2099 gtk_widget_show_all (IMAGE_INSTANCE_GTK_CLIPWIDGET (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2100 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2101 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2102 /* Need to update GtkArgs that might have changed... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2103 /* #### FIXME!!! */
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
2104 /*Lisp_Object image_instance = wrap_image_instance (p); */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2105 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2106 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2107 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2108 /* #### FIXME!!! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2109 /* No items changed, so do nothing, right? */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2110 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2111
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2112 /* Possibly update the colors and font */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2113 if (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2114 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2115 /* #### This is not sufficient because it will not cope with widgets
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2116 that are not currently visible. Once redisplay has done the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2117 visible ones it will clear this flag so that when new ones
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2118 become visible they will not be updated. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2119 XFRAME (IMAGE_INSTANCE_FRAME (p))->faces_changed
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2120 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2121 XFRAME (IMAGE_INSTANCE_FRAME (p))->frame_changed
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2122 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2123 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2124 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2125 /* #### Write this function BILL! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2126 update_widget_face (NULL, p, IMAGE_INSTANCE_FRAME (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2127 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2128
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2129 /* Possibly update the text. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2130 if (IMAGE_INSTANCE_TEXT_CHANGED (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2131 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2132 char* str;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2133 Lisp_Object val = IMAGE_INSTANCE_WIDGET_TEXT (p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2134 LISP_STRING_TO_EXTERNAL (val, str, Qnative);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2135
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2136 /* #### Need to special case each type of GtkWidget here! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2137 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2138
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2139 /* Possibly update the size. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2140 if (IMAGE_INSTANCE_SIZE_CHANGED (p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2141 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2142 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2143 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2144 IMAGE_INSTANCE_TEXT_CHANGED (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2145 {
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2146 GtkRequisition r;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2147 GtkAllocation a = IMAGE_INSTANCE_GTK_CLIPWIDGET (p)->allocation;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2148
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2149 assert (IMAGE_INSTANCE_GTK_WIDGET_ID (p) &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2150 IMAGE_INSTANCE_GTK_CLIPWIDGET (p)) ;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2151
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2152 a.width = r.width = IMAGE_INSTANCE_WIDTH (p);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2153 a.height = r.height = IMAGE_INSTANCE_HEIGHT (p);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2154
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2155 /* Force the widget's preferred and actual size to what we say it shall
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2156 be. */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2157 gtk_widget_size_request (IMAGE_INSTANCE_GTK_CLIPWIDGET (p), &r);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2158 gtk_widget_size_allocate (IMAGE_INSTANCE_GTK_CLIPWIDGET (p), &a);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2159 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2160
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2161 /* Adjust offsets within the frame. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2162 if (XFRAME (IMAGE_INSTANCE_FRAME (p))->size_changed)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2163 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2164 /* I don't think we need to do anything for Gtk here... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2165 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2166
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2167 /* now modify the widget */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2168 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2169 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2170
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2171 /* instantiate and gtk type subwindow */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2172 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
2173 gtk_subwindow_instantiate (Lisp_Object image_instance,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
2174 Lisp_Object UNUSED (instantiator),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
2175 Lisp_Object UNUSED (pointer_fg),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
2176 Lisp_Object UNUSED (pointer_bg),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
2177 int UNUSED (dest_mask), Lisp_Object UNUSED (domain))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2178 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2179 /* This function can GC */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2180 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2181 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2182
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2183 if (!DEVICE_GTK_P (XDEVICE (device)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2184 gui_error ("Not a GTK device", device);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2185
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2186 IMAGE_INSTANCE_TYPE (ii) = IMAGE_SUBWINDOW;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2187
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2188 ii->data = xnew_and_zero (struct gtk_subwindow_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2189
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2190 /* Create a window for clipping */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2191 IMAGE_INSTANCE_GTK_CLIPWINDOW (ii) = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2192
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2193 /* Now put the subwindow inside the clip window. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2194 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = (void *) NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2195 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2196
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2197 #ifdef HAVE_WIDGETS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2198
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2199 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2200 /* widgets */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2201 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2202 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2203 update_widget_face (GtkWidget *w, Lisp_Image_Instance *ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2204 Lisp_Object domain)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2205 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2206 if (0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2207 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2208 GtkStyle *style = gtk_widget_get_style (w);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2209 Lisp_Object pixel = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2210 GdkColor *fcolor, *bcolor;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2211
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2212 style = gtk_style_copy (style);
4252
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
2213
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2214 /* Update the foreground. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2215 pixel = FACE_FOREGROUND (IMAGE_INSTANCE_WIDGET_FACE (ii), domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2216 fcolor = COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (pixel));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2217
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2218 /* Update the background. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2219 pixel = FACE_BACKGROUND (IMAGE_INSTANCE_WIDGET_FACE (ii), domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2220 bcolor = COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (pixel));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2221
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2222 /* Update the font */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2223 /* #### FIXME!!! Need to copy the widgets style, dick with it, and
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2224 ** set the widgets style to the new style...
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2225 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2226 gtk_widget_set_style (w, style);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2227
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2228 /* #### Megahack - but its just getting too complicated to do this
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2229 in the right place. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2230 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2231 if (EQ (IMAGE_INSTANCE_WIDGET_TYPE (ii), Qtab_control))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2232 update_tab_widget_face (wv, ii, domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2233 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2234 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2235 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2236
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2237 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2238 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2239 update_tab_widget_face (GtkWidget *w, Lisp_Image_Instance *ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2240 Lisp_Object domain)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2241 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2242 if (wv->contents)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2243 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2244 widget_value* val = wv->contents, *cur;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2245
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2246 /* Give each child label the correct foreground color. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2247 Lisp_Object pixel = FACE_FOREGROUND
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2248 (IMAGE_INSTANCE_WIDGET_FACE (ii),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2249 domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2250 XColor fcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (pixel));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2251 lw_add_widget_value_arg (val, XtNtabForeground, fcolor.pixel);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2252 wv->change = VISIBLE_CHANGE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2253 val->change = VISIBLE_CHANGE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2254
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2255 for (cur = val->next; cur; cur = cur->next)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2256 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2257 cur->change = VISIBLE_CHANGE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2258 if (cur->value)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2259 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2260 lw_copy_widget_value_args (val, cur);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2261 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2262 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2263 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2264 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2265 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2266
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2267 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2268 gtk_widget_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2269 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2270 Lisp_Object domain)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2271 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2272 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2273 Lisp_Object widget = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2274 char *nm = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2275 GtkWidget *w = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2276 struct gcpro gcpro1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2277
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2278 IMAGE_INSTANCE_TYPE (ii) = IMAGE_WIDGET;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2279
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2280 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2281 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2282 LISP_STRING_TO_EXTERNAL (IMAGE_INSTANCE_WIDGET_TEXT (ii), nm, Qnative);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2283 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2284
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2285 ii->data = xnew_and_zero (struct gtk_subwindow_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2286
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2287 /* Create a clipping widget */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2288 IMAGE_INSTANCE_GTK_CLIPWIDGET (ii) = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2289 IMAGE_INSTANCE_GTK_ALREADY_PUT(ii) = FALSE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2290
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2291 /* Create the actual widget */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2292 GCPRO1 (widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2293 widget = call5 (Qgtk_widget_instantiate_internal,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2294 image_instance, instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2295 pointer_fg, pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2296 domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2297
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2298 if (!NILP (widget))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2299 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2300 CHECK_GTK_OBJECT (widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2301 w = GTK_WIDGET (XGTK_OBJECT (widget)->object);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2302 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2303 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2304 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2305 stderr_out ("Lisp-level creation of widget failed... falling back\n");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2306 w = gtk_label_new ("Widget Creation Failed...");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2307 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2308
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2309 UNGCPRO;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2310
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2311 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = (void *) w;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2312
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2313 /* #### HACK!!!! We should make this do the right thing if we
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2314 ** really need a clip widget!
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2315 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2316 IMAGE_INSTANCE_GTK_CLIPWIDGET (ii) = w;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2317
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2318 /* The current theme may produce a widget of a different size that what we
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2319 expect so force reconsideration of the widget's size. */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2320 IMAGE_INSTANCE_LAYOUT_CHANGED (ii) = 1;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2321
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2322 return (Qt);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2323 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2324
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2325 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2326 gtk_widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2327 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
2328 int UNUSED (dest_mask), Lisp_Object domain)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2329 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2330 call_with_suspended_errors ((lisp_fn_t) gtk_widget_instantiate_1,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2331 Qnil, Qimage,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2332 ERROR_ME_WARN, 5,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2333 image_instance, instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2334 pointer_fg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2335 pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2336 domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2337 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2338
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2339 /* get properties of a control */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2340 static Lisp_Object
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
2341 gtk_widget_property (Lisp_Object UNUSED (image_instance), Lisp_Object prop)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2342 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2343 /* Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2344
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2345 /* get the text from a control */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2346 if (EQ (prop, Q_text))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2347 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2348 return Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2349 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2350 return Qunbound;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2351 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2352
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2353 #define FAKE_GTK_WIDGET_INSTANTIATOR(x) \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2354 static void \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2355 gtk_##x##_instantiate (Lisp_Object image_instance, \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2356 Lisp_Object instantiator, \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2357 Lisp_Object pointer_fg, \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2358 Lisp_Object pointer_bg, \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2359 int dest_mask, Lisp_Object domain) \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2360 { \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2361 gtk_widget_instantiate (image_instance, instantiator, pointer_fg, \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2362 pointer_bg, dest_mask, domain); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2363 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2364
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2365 FAKE_GTK_WIDGET_INSTANTIATOR(native_layout);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2366 FAKE_GTK_WIDGET_INSTANTIATOR(button);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2367 FAKE_GTK_WIDGET_INSTANTIATOR(progress_gauge);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2368 FAKE_GTK_WIDGET_INSTANTIATOR(edit_field);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2369 FAKE_GTK_WIDGET_INSTANTIATOR(combo_box);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2370 FAKE_GTK_WIDGET_INSTANTIATOR(label);
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2371 /* Note: tab_control has a custom instantiator (see below) */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2372
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2373 /*
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2374 Ask the widget to return it's preferred size. This device method must
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2375 defined for all widgets that also have format specific version of
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2376 query_geometry defined in glyphs-widget.c. This is because those format
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2377 specific versions return sizes that are appropriate for the X widgets. For
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2378 GTK, the size of a widget can change at runtime due to the user changing
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2379 their theme.
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2380
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2381 This method can be called before the widget is instantiated. This is
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2382 because instantiate_image_instantiator() is tying to be helpful to other
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2383 toolkits and supply sane geometry values to them. This is not appropriate
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2384 for GTK and can be ignored.
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2385
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2386 This method can be used by all widgets.
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2387 */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2388 static void
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2389 gtk_widget_query_geometry (Lisp_Object image_instance,
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2390 int* width, int* height,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
2391 enum image_instance_geometry UNUSED (disp),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
2392 Lisp_Object UNUSED (domain))
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2393 {
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2394 Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2395
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2396 if (p->data != NULL)
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2397 {
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2398 GtkWidget *w = IMAGE_INSTANCE_GTK_CLIPWIDGET (p);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2399 GtkRequisition r;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2400
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2401 gtk_widget_size_request(w, &r);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2402 *height= r.height;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2403 *width = r.width;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2404 }
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2405 }
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2406
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2407
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2408 /* Button functions. */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2409
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2410 /* Update a button's clicked state. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2411 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2412 gtk_button_redisplay (Lisp_Object image_instance)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2413 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2414 /* This function can GC if IN_REDISPLAY is false. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2415 Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2416 GtkWidget *w = IMAGE_INSTANCE_GTK_CLIPWIDGET (p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2417
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2418 if (GTK_WIDGET_TYPE (w) == gtk_button_get_type ())
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2419 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2420 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2421 else if (GTK_WIDGET_TYPE (w) == gtk_check_button_get_type ())
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2422 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2423 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2424 else if (GTK_WIDGET_TYPE (w) == gtk_radio_button_get_type ())
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2425 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2426 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2427 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2428 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2429 /* Unknown button type... */
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2421
diff changeset
2430 ABORT();
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2431 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2432 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2433
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2434 /* get properties of a button */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2435 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2436 gtk_button_property (Lisp_Object image_instance, Lisp_Object prop)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2437 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2438 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2439
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2440 /* check the state of a button */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2441 if (EQ (prop, Q_selected))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2442 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2443 if (GTK_WIDGET_HAS_FOCUS (IMAGE_INSTANCE_SUBWINDOW_ID (ii)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2444 return Qt;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2445 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2446 return Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2447 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2448 return Qunbound;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2449 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2450
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2451
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2452 /* Progress gauge functions. */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2453
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2454 /* set the properties of a progress gauge */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2455 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2456 gtk_progress_gauge_redisplay (Lisp_Object image_instance)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2457 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2458 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2459
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2460 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2461 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2462 gfloat f;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2463 Lisp_Object val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2464
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2465 val = XGUI_ITEM (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))->value;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2466 f = XFLOATINT (val);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2467
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2468 gtk_progress_set_value (GTK_PROGRESS (IMAGE_INSTANCE_SUBWINDOW_ID (ii)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2469 f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2470 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2471 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2472
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2473
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2474 /* Tab Control functions. */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2475
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2476 /*
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2477 Register a widget's callbacks with the frame's hashtable. The hashtable is
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2478 weak so deregistration is handled automatically. Tab controls have per-tab
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2479 callback list functions and the GTK callback architecture is not
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2480 sufficiently flexible to deal with this. Instead, the functions are
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2481 registered here and the id is passed through the callback loop.
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2482 */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2483 static int
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2484 gtk_register_gui_item (Lisp_Object image_instance, Lisp_Object gui,
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2485 Lisp_Object domain)
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2486 {
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2487 struct frame *f = XFRAME(DOMAIN_FRAME(domain));
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2488 int id = gui_item_id_hash(FRAME_GTK_WIDGET_CALLBACK_HASH_TABLE(f),
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2489 gui, WIDGET_GLYPH_SLOT);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2490
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2491 Fputhash(make_int(id), image_instance,
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2492 FRAME_GTK_WIDGET_INSTANCE_HASH_TABLE (f));
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2493 Fputhash(make_int(id), XGUI_ITEM (gui)->callback,
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2494 FRAME_GTK_WIDGET_CALLBACK_HASH_TABLE (f));
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2495 Fputhash(make_int(id), XGUI_ITEM (gui)->callback_ex,
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2496 FRAME_GTK_WIDGET_CALLBACK_EX_HASH_TABLE (f));
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2497 return id;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2498 }
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2499
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2500 /*
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2501 Append the given item as a tab to the notebook. Callbacks, etc are all
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2502 setup.
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2503 */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2504 static void
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2505 gtk_add_tab_item(Lisp_Object image_instance,
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2506 GtkNotebook* nb, Lisp_Object item,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
2507 Lisp_Object domain, int UNUSED (i))
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2508 {
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2509 Lisp_Object name;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2510 int hash_id = 0;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2511 char *c_name = NULL;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2512 GtkWidget* box;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2513
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2514 if (GUI_ITEMP (item))
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2515 {
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2516 Lisp_Gui_Item *pgui = XGUI_ITEM (item);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2517
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2518 if (!STRINGP (pgui->name))
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2519 pgui->name = eval_within_redisplay (pgui->name);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2520
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2521 if (!STRINGP (pgui->name)) {
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2522 warn_when_safe (Qredisplay, Qwarning,
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2523 "Name does not evaluate to string");
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2524
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2525 return;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2526 }
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2527
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2528 hash_id = gtk_register_gui_item (image_instance, item, domain);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2529 name = pgui->name;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2530 }
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2531 else
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2532 {
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2533 CHECK_STRING (item);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2534 name = item;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2535 }
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2536
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2537 TO_EXTERNAL_FORMAT (LISP_STRING, name,
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2538 C_STRING_ALLOCA, c_name,
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2539 Qctext);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2540
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2541 /* Dummy widget that the notbook wants to display when a tab is selected. */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2542 box = gtk_vbox_new (FALSE, 3);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2543
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2544 /*
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2545 Store the per-tab callback data id in the tab. The callback functions
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2546 themselves could have been stored in the widget but this avoids having to
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2547 worry about the garbage collector running between here and the callback
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2548 function.
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2549 */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2550 gtk_object_set_data(GTK_OBJECT(box), GTK_DATA_TAB_HASHCODE_IDENTIFIER,
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2551 (gpointer) hash_id);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2552
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2553 gtk_notebook_append_page (nb, box, gtk_label_new (c_name));
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2554 }
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2555
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2556 /* Signal handler for the switch-page signal. */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2557 static void gtk_tab_control_callback(GtkNotebook *notebook,
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2558 GtkNotebookPage *page,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
2559 gint UNUSED (page_num),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2272
diff changeset
2560 gpointer UNUSED (user_data))
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2561 {
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2562 /*
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2563 This callback is called for every selection, not just user selection.
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2564 We're only interested in user selection, which occurs outside of
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2565 redisplay.
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2566 */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2567
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2568 if (!in_display)
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2569 {
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2570 Lisp_Object image_instance, callback, callback_ex;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2571 Lisp_Object frame, event;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2572 int update_subwindows_p = 0;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2573 struct frame *f = gtk_widget_to_frame(GTK_WIDGET(notebook));
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2574 int id;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2575
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2576 if (!f)
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2577 return;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2578 frame = wrap_frame (f);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2579
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2580 id = (int) gtk_object_get_data(GTK_OBJECT(page->child),
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2581 GTK_DATA_TAB_HASHCODE_IDENTIFIER);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2582 image_instance = Fgethash(make_int_verify(id),
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2583 FRAME_GTK_WIDGET_INSTANCE_HASH_TABLE(f), Qnil);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2584 callback = Fgethash(make_int(id),
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2585 FRAME_GTK_WIDGET_CALLBACK_HASH_TABLE(f), Qnil);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2586 callback_ex = Fgethash(make_int(id),
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2587 FRAME_GTK_WIDGET_CALLBACK_EX_HASH_TABLE(f), Qnil);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2588 update_subwindows_p = 1;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2589
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2590 /* It is possible for a widget action to cause it to get out of
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2591 sync with its instantiator. Thus it is necessary to signal
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2592 this possibility. */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2593 if (IMAGE_INSTANCEP (image_instance))
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2594 XIMAGE_INSTANCE_WIDGET_ACTION_OCCURRED (image_instance) = 1;
4252
8475ff9c49ea [xemacs-hg @ 2007-11-05 14:59:20 by didierv]
didierv
parents: 3087
diff changeset
2595
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2596 if (!NILP (callback_ex) && !UNBOUNDP (callback_ex))
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2597 {
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2598 event = Fmake_event (Qnil, Qnil);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2599
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2600 XSET_EVENT_TYPE (event, misc_user_event);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2601 XSET_EVENT_CHANNEL (event, frame);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2602 XSET_EVENT_MISC_USER_FUNCTION (event, Qeval);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2603 XSET_EVENT_MISC_USER_OBJECT (event, list4 (Qfuncall, callback_ex, image_instance, event));
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2604 }
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2605 else if (NILP (callback) || UNBOUNDP (callback))
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2606 event = Qnil;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2607 else
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2608 {
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2609 Lisp_Object fn, arg;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2610
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2611 event = Fmake_event (Qnil, Qnil);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2612
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2613 get_gui_callback (callback, &fn, &arg);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2614 XSET_EVENT_TYPE (event, misc_user_event);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2615 XSET_EVENT_CHANNEL (event, frame);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2616 XSET_EVENT_MISC_USER_FUNCTION (event, fn);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2617 XSET_EVENT_MISC_USER_OBJECT (event, arg);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2618 }
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2619
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2620 if (!NILP (event))
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2621 enqueue_dispatch_event (event);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2622
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2623 /* The result of this evaluation could cause other instances to change so
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2624 enqueue an update callback to check this. */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2625 if (update_subwindows_p && !NILP (event))
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2626 enqueue_magic_eval_event (update_widget_instances, frame);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2627 }
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2628 }
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2629
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2630 /* Create a tab_control widget. The special handling of the individual tabs
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2631 means that the normal instantiation code cannot be used. */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2632 static void
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2633 gtk_tab_control_instantiate (Lisp_Object image_instance,
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2634 Lisp_Object instantiator,
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2635 Lisp_Object pointer_fg,
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2636 Lisp_Object pointer_bg,
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2637 int dest_mask, Lisp_Object domain)
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2638 {
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2639 Lisp_Object rest;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2640 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2641 int i = 0;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2642 int selected = 0;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2643 GtkNotebook *nb;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2644
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2645 /* The normal instantiation is still needed. */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2646 gtk_widget_instantiate (image_instance, instantiator, pointer_fg,
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2647 pointer_bg, dest_mask, domain);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2648
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2649 nb = GTK_NOTEBOOK (IMAGE_INSTANCE_GTK_CLIPWIDGET (ii));
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2650
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2651 /* Add items to the tab, find the current selection */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2652 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2653 {
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2654 gtk_add_tab_item (image_instance, nb, XCAR (rest), domain, i);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2655
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2656 if (gui_item_selected_p (XCAR (rest)))
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2657 selected = i;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2658
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2659 i++;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2660 }
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2661
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2662 gtk_notebook_set_page(nb, selected);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2663
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2664 /* Call per-tab lisp callback when a tab is pressed. */
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2665 gtk_signal_connect (GTK_OBJECT (nb), "switch-page",
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2666 GTK_SIGNAL_FUNC (gtk_tab_control_callback), NULL);
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2667 }
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2668
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2669 /* Set the properties of a tab control */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2670 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2671 gtk_tab_control_redisplay (Lisp_Object image_instance)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2672 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2673 /* #### Convert this to GTK baby! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2674 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2675
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2676 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii) ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2677 IMAGE_INSTANCE_WIDGET_ACTION_OCCURRED (ii))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2678 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2679 /* If only the order has changed then simply select the first
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2680 one of the pending set. This stops horrendous rebuilding -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2681 and hence flicker - of the tabs each time you click on
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2682 one. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2683 if (tab_control_order_only_changed (image_instance))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2684 {
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2685 int i = 0;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2686 Lisp_Object rest, selected =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2687 gui_item_list_find_selected
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2688 (NILP (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)) ?
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2689 XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)) :
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2690 XCDR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2691
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2692 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2693 {
1913
7473844a83d3 [xemacs-hg @ 2004-02-17 15:20:41 by james]
james
parents: 1743
diff changeset
2694 if (gui_item_equal_sans_selected (XCAR (rest), selected, 0))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2695 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2696 Lisp_Object old_selected =gui_item_list_find_selected
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2697 (XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2698
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2699 /* Pick up the new selected item. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2700 XGUI_ITEM (old_selected)->selected =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2701 XGUI_ITEM (XCAR (rest))->selected;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2702 XGUI_ITEM (XCAR (rest))->selected =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2703 XGUI_ITEM (selected)->selected;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2704 /* We're not actually changing the items anymore. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2705 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2706 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) = Qnil;
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2707
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2708 gtk_notebook_set_page(GTK_NOTEBOOK (IMAGE_INSTANCE_GTK_CLIPWIDGET (ii)),
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2709 i);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2710 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2711 }
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2712
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2713 i++;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2714 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2715 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2716 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2717 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2718 /* More than just the order has changed... let's get busy! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2719 GtkNotebook *nb = GTK_NOTEBOOK (IMAGE_INSTANCE_GTK_CLIPWIDGET (ii));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2720 guint num_pages = g_list_length (nb->children);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2721 Lisp_Object rest;
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2722 int i;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2723
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2724 /* Why is there no API to remove everything from a notebook? */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2725 if (num_pages >= 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2726 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2727 for (i = num_pages; i >= 0; --i)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2728 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2729 gtk_notebook_remove_page (nb, i);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2730 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2731 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2732
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2733 i = 0;
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2734
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2735 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2736 {
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2737 gtk_add_tab_item(image_instance, nb, XCAR(rest),
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2738 IMAGE_INSTANCE_FRAME(ii), i);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2739 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2740
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2741 /* Show all the new widgets we just added... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2742 gtk_widget_show_all (GTK_WIDGET (nb));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2743 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2744 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2745
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2746 /* Possibly update the face. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2747 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2748 if (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (ii)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2749 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2750 XFRAME (IMAGE_INSTANCE_FRAME (ii))->faces_changed
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2751 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2752 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2753 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2754 update_tab_widget_face (wv, ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2755 IMAGE_INSTANCE_FRAME (ii));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2756 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2757 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2758 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2759 #endif /* HAVE_WIDGETS */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2760
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2761
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2762 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2763 /* initialization */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2764 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2765 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2766 syms_of_glyphs_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2767 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2768 #ifdef HAVE_WIDGETS
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2769 DEFSYMBOL (Qgtk_widget_instantiate_internal);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2770 DEFSYMBOL (Qgtk_widget_property_internal);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2771 DEFSYMBOL (Qgtk_widget_redisplay_internal);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2772 DEFSYMBOL (Qgtk_widget_set_style);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2773 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2774 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2775
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2776 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2777 console_type_create_glyphs_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2778 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2779 /* image methods */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2780 CONSOLE_HAS_METHOD (gtk, print_image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2781 CONSOLE_HAS_METHOD (gtk, finalize_image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2782 CONSOLE_HAS_METHOD (gtk, image_instance_equal);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2783 CONSOLE_HAS_METHOD (gtk, image_instance_hash);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2784 CONSOLE_HAS_METHOD (gtk, colorize_image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2785 CONSOLE_HAS_METHOD (gtk, init_image_instance_from_eimage);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2786 CONSOLE_HAS_METHOD (gtk, locate_pixmap_file);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2787 CONSOLE_HAS_METHOD (gtk, unmap_subwindow);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2788 CONSOLE_HAS_METHOD (gtk, map_subwindow);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2789 CONSOLE_HAS_METHOD (gtk, redisplay_widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2790 CONSOLE_HAS_METHOD (gtk, redisplay_subwindow);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2791 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2792
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2793 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2794 image_instantiator_format_create_glyphs_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2795 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2796 IIFORMAT_VALID_CONSOLE (gtk, nothing);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2797 IIFORMAT_VALID_CONSOLE (gtk, string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2798 #ifdef HAVE_WIDGETS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2799 IIFORMAT_VALID_CONSOLE (gtk, layout);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2800 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2801 IIFORMAT_VALID_CONSOLE (gtk, formatted_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2802 IIFORMAT_VALID_CONSOLE (gtk, inherit);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2803 #ifdef HAVE_XPM
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2804 INITIALIZE_DEVICE_IIFORMAT (gtk, xpm);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2805 IIFORMAT_HAS_DEVMETHOD (gtk, xpm, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2806 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2807 #ifdef HAVE_JPEG
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2808 IIFORMAT_VALID_CONSOLE (gtk, jpeg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2809 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2810 #ifdef HAVE_TIFF
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2811 IIFORMAT_VALID_CONSOLE (gtk, tiff);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2812 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2813 #ifdef HAVE_PNG
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2814 IIFORMAT_VALID_CONSOLE (gtk, png);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2815 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2816 #ifdef HAVE_GIF
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2817 IIFORMAT_VALID_CONSOLE (gtk, gif);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2818 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2819
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2820 INITIALIZE_DEVICE_IIFORMAT (gtk, subwindow);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2821 IIFORMAT_HAS_DEVMETHOD (gtk, subwindow, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2822
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2823 #ifdef HAVE_WIDGETS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2824 /* layout widget */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2825 INITIALIZE_DEVICE_IIFORMAT (gtk, native_layout);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2826 IIFORMAT_HAS_DEVMETHOD (gtk, native_layout, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2827
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2828 /* button widget */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2829 INITIALIZE_DEVICE_IIFORMAT (gtk, button);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2830 IIFORMAT_HAS_DEVMETHOD (gtk, button, property);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2831 IIFORMAT_HAS_DEVMETHOD (gtk, button, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2832 IIFORMAT_HAS_DEVMETHOD (gtk, button, redisplay);
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2833 IIFORMAT_HAS_SHARED_DEVMETHOD (gtk, button, query_geometry, widget);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2834 /* general widget methods. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2835 INITIALIZE_DEVICE_IIFORMAT (gtk, widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2836 IIFORMAT_HAS_DEVMETHOD (gtk, widget, property);
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2837 IIFORMAT_HAS_DEVMETHOD (gtk, widget, query_geometry);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2838
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2839 /* progress gauge */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2840 INITIALIZE_DEVICE_IIFORMAT (gtk, progress_gauge);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2841 IIFORMAT_HAS_DEVMETHOD (gtk, progress_gauge, redisplay);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2842 IIFORMAT_HAS_DEVMETHOD (gtk, progress_gauge, instantiate);
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2843 IIFORMAT_HAS_SHARED_DEVMETHOD (gtk, progress_gauge, query_geometry, widget);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2844 /* text field */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2845 INITIALIZE_DEVICE_IIFORMAT (gtk, edit_field);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2846 IIFORMAT_HAS_DEVMETHOD (gtk, edit_field, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2847 INITIALIZE_DEVICE_IIFORMAT (gtk, combo_box);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2848 IIFORMAT_HAS_DEVMETHOD (gtk, combo_box, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2849 IIFORMAT_HAS_SHARED_DEVMETHOD (gtk, combo_box, redisplay, tab_control);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2850 /* tab control widget */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2851 INITIALIZE_DEVICE_IIFORMAT (gtk, tab_control);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2852 IIFORMAT_HAS_DEVMETHOD (gtk, tab_control, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2853 IIFORMAT_HAS_DEVMETHOD (gtk, tab_control, redisplay);
2168
95fee4a1420e [xemacs-hg @ 2004-07-07 12:00:58 by malcolmp]
malcolmp
parents: 2082
diff changeset
2854 IIFORMAT_HAS_SHARED_DEVMETHOD (gtk, tab_control, query_geometry, widget);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2855 /* label */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2856 INITIALIZE_DEVICE_IIFORMAT (gtk, label);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2857 IIFORMAT_HAS_DEVMETHOD (gtk, label, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2858 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2859
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2860 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (cursor_font, "cursor-font");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2861 IIFORMAT_VALID_CONSOLE (gtk, cursor_font);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2862
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2863 IIFORMAT_HAS_METHOD (cursor_font, validate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2864 IIFORMAT_HAS_METHOD (cursor_font, possible_dest_types);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2865 IIFORMAT_HAS_METHOD (cursor_font, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2866
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2867 IIFORMAT_VALID_KEYWORD (cursor_font, Q_data, check_valid_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2868 IIFORMAT_VALID_KEYWORD (cursor_font, Q_foreground, check_valid_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2869 IIFORMAT_VALID_KEYWORD (cursor_font, Q_background, check_valid_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2870
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2871 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (font, "font");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2872 IIFORMAT_VALID_CONSOLE (gtk, font);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2873
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2874 IIFORMAT_HAS_METHOD (font, validate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2875 IIFORMAT_HAS_METHOD (font, possible_dest_types);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2876 IIFORMAT_HAS_METHOD (font, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2877
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2878 IIFORMAT_VALID_KEYWORD (font, Q_data, check_valid_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2879 IIFORMAT_VALID_KEYWORD (font, Q_foreground, check_valid_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2880 IIFORMAT_VALID_KEYWORD (font, Q_background, check_valid_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2881
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2882 #ifdef HAVE_XPM
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2883 INITIALIZE_DEVICE_IIFORMAT (gtk, xpm);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2884 IIFORMAT_HAS_DEVMETHOD (gtk, xpm, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2885 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2886
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2887 #ifdef HAVE_XFACE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2888 INITIALIZE_DEVICE_IIFORMAT (gtk, xface);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2889 IIFORMAT_HAS_DEVMETHOD (gtk, xface, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2890 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2891
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2892 INITIALIZE_DEVICE_IIFORMAT (gtk, xbm);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2893 IIFORMAT_HAS_DEVMETHOD (gtk, xbm, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2894 IIFORMAT_VALID_CONSOLE (gtk, xbm);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2895
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2896 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (gtk_resource, "gtk-resource");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2897 IIFORMAT_VALID_CONSOLE (gtk, gtk_resource);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2898
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2899 IIFORMAT_HAS_METHOD (gtk_resource, validate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2900 IIFORMAT_HAS_METHOD (gtk_resource, normalize);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2901 IIFORMAT_HAS_METHOD (gtk_resource, possible_dest_types);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2902 IIFORMAT_HAS_METHOD (gtk_resource, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2903
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2904 IIFORMAT_VALID_KEYWORD (gtk_resource, Q_resource_type, check_valid_resource_symbol);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2905 IIFORMAT_VALID_KEYWORD (gtk_resource, Q_resource_id, check_valid_resource_id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2906 IIFORMAT_VALID_KEYWORD (gtk_resource, Q_file, check_valid_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2907
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2908 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (autodetect, "autodetect");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2909 IIFORMAT_VALID_CONSOLE (gtk, autodetect);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2910
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2911 IIFORMAT_HAS_METHOD (autodetect, validate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2912 IIFORMAT_HAS_METHOD (autodetect, normalize);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2913 IIFORMAT_HAS_METHOD (autodetect, possible_dest_types);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2914 IIFORMAT_HAS_METHOD (autodetect, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2915
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2916 IIFORMAT_VALID_KEYWORD (autodetect, Q_data, check_valid_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2917 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2918
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2919 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2920 vars_of_glyphs_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2921 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2922 #ifdef HAVE_XFACE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2923 Fprovide (Qxface);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2924 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2925
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2926 DEFVAR_LISP ("gtk-bitmap-file-path", &Vgtk_bitmap_file_path /*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2927 A list of the directories in which X bitmap files may be found.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2928 If nil, this is initialized from the "*bitmapFilePath" resource.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2929 This is used by the `make-image-instance' function (however, note that if
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2930 the environment variable XBMLANGPATH is set, it is consulted first).
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2931 */ );
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2932 Vgtk_bitmap_file_path = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2933 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2934
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2935 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2936 complex_vars_of_glyphs_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2937 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2938 #define BUILD_GLYPH_INST(variable, name) \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2939 Fadd_spec_to_specifier \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2940 (GLYPH_IMAGE (XGLYPH (variable)), \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2941 vector3 (Qxbm, Q_data, \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2942 list3 (make_int (name##_width), \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2943 make_int (name##_height), \
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
2944 make_ext_string ((Extbyte*) name##_bits, \
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2945 sizeof (name##_bits), \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2946 Qbinary))), \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2947 Qglobal, Qgtk, Qnil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2948
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2949 BUILD_GLYPH_INST (Vtruncation_glyph, truncator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2950 BUILD_GLYPH_INST (Vcontinuation_glyph, continuer);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2951 BUILD_GLYPH_INST (Vxemacs_logo, xemacs);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2952 BUILD_GLYPH_INST (Vhscroll_glyph, hscroll);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2953
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2954 #undef BUILD_GLYPH_INST
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2955 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2956
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2957 /* X specific crap */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2958 #include <gdk/gdkx.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2959 /* #### Should remove all this X specific stuff when GTK/GDK matures a
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2960 bit more and provides an abstraction for it. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2961 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2962 gtk_colorize_image_instance (Lisp_Object image_instance,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2963 Lisp_Object foreground, Lisp_Object background)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2964 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2965 struct Lisp_Image_Instance *p;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2966
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2967 p = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2968
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2969 switch (IMAGE_INSTANCE_TYPE (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2970 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2971 case IMAGE_MONO_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2972 IMAGE_INSTANCE_TYPE (p) = IMAGE_COLOR_PIXMAP;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2973 /* Make sure there aren't two pointers to the same mask, causing
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2974 it to get freed twice. */
4433
1bf48c59700e Fix old use of rvalue on lhs to placate gcc >4.0.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4252
diff changeset
2975 IMAGE_INSTANCE_PIXMAP_MASK (p) = 0;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2976 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2977
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2978 default:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2979 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2980 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2981
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2982 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2983 GdkWindow *draw = GET_GTK_WIDGET_WINDOW (DEVICE_GTK_APP_SHELL (XDEVICE (IMAGE_INSTANCE_DEVICE (p))));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2984 GdkPixmap *new_pxmp = gdk_pixmap_new (draw,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2985 IMAGE_INSTANCE_PIXMAP_WIDTH (p),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2986 IMAGE_INSTANCE_PIXMAP_HEIGHT (p),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2987 DEVICE_GTK_DEPTH (XDEVICE (IMAGE_INSTANCE_DEVICE (p))));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2988 GdkGCValues gcv;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2989 GdkGC *gc;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2990
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2991 gcv.foreground = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (foreground));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2992 gcv.background = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (background));
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
2993 gc = gdk_gc_new_with_values (new_pxmp, &gcv,
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1913
diff changeset
2994 (GdkGCValuesMask) (GDK_GC_BACKGROUND | GDK_GC_FOREGROUND));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2995
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2996 XCopyPlane (GDK_WINDOW_XDISPLAY (draw),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2997 GDK_WINDOW_XWINDOW (IMAGE_INSTANCE_GTK_PIXMAP (p)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2998 GDK_WINDOW_XWINDOW (new_pxmp),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2999 GDK_GC_XGC (gc), 0, 0,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3000 IMAGE_INSTANCE_PIXMAP_WIDTH (p),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3001 IMAGE_INSTANCE_PIXMAP_HEIGHT (p),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3002 0, 0, 1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3003
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3004 gdk_gc_destroy (gc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3005 IMAGE_INSTANCE_GTK_PIXMAP (p) = new_pxmp;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3006 IMAGE_INSTANCE_PIXMAP_DEPTH (p) = DEVICE_GTK_DEPTH (XDEVICE (IMAGE_INSTANCE_DEVICE (p)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3007 IMAGE_INSTANCE_PIXMAP_FG (p) = foreground;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3008 IMAGE_INSTANCE_PIXMAP_BG (p) = background;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3009 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3010 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3011 }