annotate src/device-msw.c @ 1204:e22b0213b713

[xemacs-hg @ 2003-01-12 11:07:58 by michaels] modules/ChangeLog: 2002-12-16 Ben Wing <ben@xemacs.org> * postgresql/postgresql.c: remove ifdef USE_KKCC. src/ChangeLog: 2003-01-08 Mike Sperber <mike@xemacs.org> * console.h (CDFW_CONSOLE): Don't lead to a crash if we're dealing with a dead window/frame/device/console. 2002-12-20 Mike Sperber <mike@xemacs.org> * ui-gtk.c: Fix typo from Ben's patch: emacs_ffi_data is a typedef, not a struct. emacs_gtk_object_data is a typedef, not a struct. * gtk-glue.c (gdk_event_to_emacs_event): Fix typos from Ben's patch: le -> emacs_event + rearrange the code. * event-gtk.c (gtk_event_to_emacs_event): Fix typos from Ben's patch: ..._UNDERLYING_GDK_EVENT -> ..._GDK_EVENT, ev -> key_event. * device-gtk.c: Fix typo from Ben's patch: x_keysym_map_hash_table -> x_keysym_map_hashtable. 2002-12-19 Mike Sperber <mike@xemacs.org> * menubar-x.c (set_frame_menubar): Initialize protect_me field of popup_data. 2002-12-16 Ben Wing <ben@xemacs.org> Major cleanup of KKCC, etc. KKCC, pdump-related: -- descriptions are written for all objects. this required some changes in the format of some objects, e.g. extents, popup-data, coding system, lstream, lcrecord-list. -- KKCC now handles weakness in markers, hash tables, elsewhere correctly (formerly, you'd eventually get a stack overflow due to endlessly expanding markers). -- textual changes: lrecord_description -> memory_description, struct_description -> sized_memory_description. -- extensive comment describing descriptions and pdump. -- redo XD_UNION so it works inline and change its format to provide sufficient info for pdump. implement XD_UNION in pdump. also add XD_UNION_DYNAMIC_SIZE, which works like XD_UNION except for when auto-computing structure sizes. -- add support for XD_INDIRECT in description offsets (used by extents). -- add support for "description maps", allowing for indirect descriptions that are retrieved from an object at run-time. this generalizes XD_CODING_SYSTEM_END, XD_SPECIFIER_END, etc., which have now been eliminated. -- add a fifth field "flags" to memory_description, to support flags that can be specified for this particular line. Currently defined flags are XD_FLAG_NO_KKCC (KKCC should ignore this entry; useful for the weakness above in markers, etc.), XD_FLAG_NO_PDUMP (pdump should ignore this entry), XD_FLAG_UNION_DEFAULT_ENTRY (in union maps, this specifies a "default" entry for all remaining values), and XD_FLAG_FREE_LISP_OBJECT (for use with lcrecord-lists). -- clean up the kkcc-itis in events, so that the differences between event data as separate objects and as a union are now minimized to a small number of places. with the new XD_UNION, we no longer need event data as separate objects, so this code is no longer ifdef USE_KKCC, but instead ifdef EVENT_DATA_AS_OBJECTS, not used by default. make sure that we explicitly free the separate event data objects when no longer in use, to maintain the invariant the event processing causes no consing. -- also remove other USE_KKCC ifdefs when not necessary. -- allow for KKCC compilation under MS Windows. -- fix README.kkcc. -- dump_add_root_object -> dump_add_root_lisp_object. -- implement dump_add_root_block and use this to handle dump_add_opaque. -- factor out some code duplicated in kkcc and pdump. Other allocation/object-related: -- change various *slots.h so MARKED_SLOT() call no longer includes semicolon. -- free_marker() takes a Lisp_Object not a direct pointer. -- make bit vectors lcrecords, like vectors, and eliminate code that essentially duplicated the lcrecord handling. -- additional asserts in FREE_FIXED_TYPE, formerly duplicated in the various callers of this. -- all lcrecord allocation functions now zero out the returned lcrecords. unnecessary calls to zero_lcrecord removed. add long comment describing these functions. -- extract out process and coding system slots, like for buffers, frames, etc. -- lcrecords now set the type of items sitting on the free list to lcrecord_type_free. -- changes to the way that gap arrays are allocated, for kkcc's benefit -- now, one single memory block with a stretchy array on the end, instead of a separate block holding the array. Error-checking-related: -- now can compile with C++ under MS Windows. clean up compile errors discovered that way. (a few were real problems) -- add C++ error-checking code to verify problems with mismatched GCPRO/UNGCPRO. (there were a few in the kkcc code.) add long comment about how to catch insufficient GCPRO (yes, it's possible using C++). -- add debug_p4(), a simple object printer, when debug_print() doesn't work. -- add dp() and db() as short synonyms of debug_print(), debug_backtrace(). -- `print' tries EXTREMELY hard to avoid core dumping when printing when crashing or from debug_print(), and tries as hard as it reasonably can in other situations. -- Correct the message output upon crashing to be more up-to-date. Event-related: -- document event-matches-key-specifier-p better. -- generalize the dispatch queues formerly duplicated in the various event implementations. add event methods to drain pending events. generalize and clean up QUIT handling, removing event-specific quit processing. allow arbitrary keystrokes, not just ASCII, to be the QUIT char. among other things, this should fix some longstanding bugs in X quit handling. long comment describing the various event queues. -- implement delaying of XFlush() if there are pending expose events. SOMEONE PLEASE TRY THIS OUT. -- Fix `xemacs -batch -l dunnet' under Cygwin. Try to fix under MS Windows but not quite there yet. Other: -- class -> class_ and no more C++ games with this item. new -> new_ in the lwlib code, so far not elsewhere. -- use `struct htentry' not `struct hentry' in elhash.c to avoid debugger confusion with hash.c. -- new macros ALIST_LOOP_3, ALIST_LOOP_4. * README.kkcc: * alloc.c: * alloc.c (deadbeef_memory): * alloc.c (allocate_lisp_storage): * alloc.c (copy_lisp_object): * alloc.c (ALLOCATE_FIXED_TYPE_1): * alloc.c (FREE_FIXED_TYPE): * alloc.c (make_vector_internal): * alloc.c (make_bit_vector_internal): * alloc.c (make_key_data): * alloc.c (make_button_data): * alloc.c (make_motion_data): * alloc.c (make_process_data): * alloc.c (make_timeout_data): * alloc.c (make_magic_data): * alloc.c (make_magic_eval_data): * alloc.c (make_eval_data): * alloc.c (make_misc_user_data): * alloc.c (struct string_chars_block): * alloc.c (mark_lcrecord_list): * alloc.c (make_lcrecord_list): * alloc.c (alloc_managed_lcrecord): * alloc.c (free_managed_lcrecord): * alloc.c (alloc_automanaged_lcrecord): * alloc.c (staticpro_1): * alloc.c (staticpro): * alloc.c (lispdesc_indirect_count_1): * alloc.c (lispdesc_indirect_description_1): * alloc.c (lispdesc_one_description_line_size): * alloc.c (lispdesc_structure_size): * alloc.c (mark_object_maybe_checking_free): * alloc.c (mark_with_description): * alloc.c (mark_struct_contents): * alloc.c (mark_object): * alloc.c (tick_lcrecord_stats): * alloc.c (free_cons): * alloc.c (free_key_data): * alloc.c (free_button_data): * alloc.c (free_motion_data): * alloc.c (free_process_data): * alloc.c (free_timeout_data): * alloc.c (free_magic_data): * alloc.c (free_magic_eval_data): * alloc.c (free_eval_data): * alloc.c (free_misc_user_data): * alloc.c (free_marker): * alloc.c (compact_string_chars): * alloc.c (gc_sweep): * alloc.c (garbage_collect_1): * alloc.c (Fgarbage_collect): * alloc.c (common_init_alloc_early): * alloc.c (init_alloc_early): * alloc.c (init_alloc_once_early): * buffer.c: * buffer.c (mark_buffer): * buffer.c (MARKED_SLOT): * buffer.c (cleanup_buffer_undo_lists): * buffer.c (Fget_file_buffer): * buffer.h (MARKED_SLOT): * bufslots.h: * bytecode.c: * callint.c: * casetab.c: * chartab.c: * chartab.c (symbol_to_char_table_type): * cmdloop.c: * cmdloop.c (Fcommand_loop_1): * config.h.in (new): * conslots.h: * console-gtk-impl.h (struct gtk_frame): * console-impl.h: * console-impl.h (struct console): * console-impl.h (MARKED_SLOT): * console-impl.h (CONSOLE_QUIT_EVENT): * console-msw-impl.h (XM_BUMPQUEUE): * console-msw.c (write_string_to_mswindows_debugging_output): * console-msw.h: * console-stream-impl.h: * console-stream-impl.h (struct stream_console): * console-stream.c: * console-stream.c (stream_init_console): * console-stream.h: * console-tty.c: * console-tty.h: * console-x.h: * console.c: * console.c (mark_console): * console.c (MARKED_SLOT): * console.c (allocate_console): * console.c (get_console_variant): * console.c (create_console): * console.c (delete_console_internal): * console.c (Fset_input_mode): * console.c (Fcurrent_input_mode): * console.c (common_init_complex_vars_of_console): * console.h: * console.h (console_variant): * console.h (device_metrics): * data.c: * data.c (Faref): * data.c (Faset): * data.c (decode_weak_list_type): * database.c: * debug.c (xemacs_debug_loop): * debug.c (FROB): * debug.c (Fadd_debug_class_to_check): * debug.c (Fdelete_debug_class_to_check): * debug.c (Fset_debug_classes_to_check): * debug.c (Fset_debug_class_types_to_check): * debug.c (Fdebug_types_being_checked): * debug.h (DASSERT): * device-gtk.c: * device-impl.h (struct device): * device-impl.h (MARKED_SLOT): * device-msw.c: * device-x.c: * device-x.c (x_init_device_class): * device-x.c (x_comp_visual_info): * device-x.c (x_try_best_visual_class): * device-x.c (x_init_device): * device-x.c (construct_name_list): * device-x.c (x_get_resource_prefix): * device-x.c (Fx_get_resource): * device-x.c (Fx_display_visual_class): * device.c: * device.c (MARKED_SLOT): * device.c (allocate_device): * device.c (Fmake_device): * device.c (delete_device_internal): * device.c (Fset_device_class): * device.h: * devslots.h: * devslots.h (MARKED_SLOT): * dialog-msw.c: * dired-msw.c (mswindows_ls_sort_fcn): * dired-msw.c (mswindows_get_files): * dired-msw.c (mswindows_format_file): * doprnt.c (parse_doprnt_spec): * dumper.c: * dumper.c (struct): * dumper.c (dump_add_root_block): * dumper.c (dump_add_root_struct_ptr): * dumper.c (dump_add_root_lisp_object): * dumper.c (pdump_struct_list_elt): * dumper.c (pdump_get_entry_list): * dumper.c (pdump_backtrace): * dumper.c (pdump_bump_depth): * dumper.c (pdump_register_sub): * dumper.c (pdump_register_object): * dumper.c (pdump_register_struct_contents): * dumper.c (pdump_register_struct): * dumper.c (pdump_store_new_pointer_offsets): * dumper.c (pdump_dump_data): * dumper.c (pdump_reloc_one): * dumper.c (pdump_allocate_offset): * dumper.c (pdump_scan_by_alignment): * dumper.c (pdump_dump_root_blocks): * dumper.c (pdump_dump_rtables): * dumper.c (pdump_dump_root_lisp_objects): * dumper.c (pdump): * dumper.c (pdump_load_finish): * dumper.c (pdump_file_get): * dumper.c (pdump_resource_get): * dumper.c (pdump_load): * editfns.c (save_excursion_restore): * editfns.c (user_login_name): * editfns.c (save_restriction_restore): * elhash.c: * elhash.c (htentry): * elhash.c (struct Lisp_Hash_Table): * elhash.c (HTENTRY_CLEAR_P): * elhash.c (LINEAR_PROBING_LOOP): * elhash.c (check_hash_table_invariants): * elhash.c (mark_hash_table): * elhash.c (hash_table_equal): * elhash.c (print_hash_table_data): * elhash.c (free_hentries): * elhash.c (make_general_lisp_hash_table): * elhash.c (decode_hash_table_weakness): * elhash.c (decode_hash_table_test): * elhash.c (Fcopy_hash_table): * elhash.c (resize_hash_table): * elhash.c (pdump_reorganize_hash_table): * elhash.c (find_htentry): * elhash.c (Fgethash): * elhash.c (Fputhash): * elhash.c (remhash_1): * elhash.c (Fremhash): * elhash.c (Fclrhash): * elhash.c (copy_compress_hentries): * elhash.c (elisp_maphash_unsafe): * elhash.c (finish_marking_weak_hash_tables): * elhash.c (prune_weak_hash_tables): * elhash.h: * emacs.c: * emacs.c (main_1): * emacs.c (main): * emacs.c (shut_down_emacs): * emodules.h (dump_add_root_lisp_object): * eval.c: * eval.c (unwind_to_catch): * eval.c (maybe_signal_error_1): * eval.c (maybe_signal_continuable_error_1): * eval.c (maybe_signal_error): * eval.c (maybe_signal_continuable_error): * eval.c (maybe_signal_error_2): * eval.c (maybe_signal_continuable_error_2): * eval.c (maybe_signal_ferror): * eval.c (maybe_signal_continuable_ferror): * eval.c (maybe_signal_ferror_with_frob): * eval.c (maybe_signal_continuable_ferror_with_frob): * eval.c (maybe_syntax_error): * eval.c (maybe_sferror): * eval.c (maybe_invalid_argument): * eval.c (maybe_invalid_constant): * eval.c (maybe_invalid_operation): * eval.c (maybe_invalid_change): * eval.c (maybe_invalid_state): * eval.c (Feval): * eval.c (call_trapping_problems): * eval.c (call_with_suspended_errors): * eval.c (warn_when_safe_lispobj): * eval.c (warn_when_safe): * eval.c (vars_of_eval): * event-Xt.c: * event-Xt.c (maybe_define_x_key_as_self_inserting_character): * event-Xt.c (x_to_emacs_keysym): * event-Xt.c (x_event_to_emacs_event): * event-Xt.c (emacs_Xt_enqueue_focus_event): * event-Xt.c (emacs_Xt_format_magic_event): * event-Xt.c (emacs_Xt_compare_magic_event): * event-Xt.c (emacs_Xt_hash_magic_event): * event-Xt.c (emacs_Xt_handle_magic_event): * event-Xt.c (Xt_timeout_to_emacs_event): * event-Xt.c (Xt_process_to_emacs_event): * event-Xt.c (signal_special_Xt_user_event): * event-Xt.c (emacs_Xt_next_event): * event-Xt.c (emacs_Xt_event_handler): * event-Xt.c (emacs_Xt_drain_queue): * event-Xt.c (emacs_Xt_event_pending_p): * event-Xt.c (check_if_pending_expose_event): * event-Xt.c (reinit_vars_of_event_Xt): * event-Xt.c (vars_of_event_Xt): * event-gtk.c: * event-gtk.c (IS_MODIFIER_KEY): * event-gtk.c (emacs_gtk_format_magic_event): * event-gtk.c (emacs_gtk_compare_magic_event): * event-gtk.c (emacs_gtk_hash_magic_event): * event-gtk.c (emacs_gtk_handle_magic_event): * event-gtk.c (gtk_to_emacs_keysym): * event-gtk.c (gtk_timeout_to_emacs_event): * event-gtk.c (gtk_process_to_emacs_event): * event-gtk.c (dragndrop_data_received): * event-gtk.c (signal_special_gtk_user_event): * event-gtk.c (emacs_gtk_next_event): * event-gtk.c (gtk_event_to_emacs_event): * event-gtk.c (generic_event_handler): * event-gtk.c (emacs_shell_event_handler): * event-gtk.c (emacs_gtk_drain_queue): * event-gtk.c (emacs_gtk_event_pending_p): * event-gtk.c (reinit_vars_of_event_gtk): * event-gtk.c (vars_of_event_gtk): * event-msw.c: * event-msw.c (struct winsock_stream): * event-msw.c (winsock_reader): * event-msw.c (winsock_writer): * event-msw.c (mswindows_enqueue_dispatch_event): * event-msw.c (mswindows_enqueue_misc_user_event): * event-msw.c (mswindows_enqueue_magic_event): * event-msw.c (mswindows_enqueue_process_event): * event-msw.c (mswindows_enqueue_mouse_button_event): * event-msw.c (mswindows_enqueue_keypress_event): * event-msw.c (mswindows_dequeue_dispatch_event): * event-msw.c (emacs_mswindows_drain_queue): * event-msw.c (mswindows_need_event_in_modal_loop): * event-msw.c (mswindows_need_event): * event-msw.c (mswindows_wm_timer_callback): * event-msw.c (dde_eval_string): * event-msw.c (Fdde_alloc_advise_item): * event-msw.c (mswindows_dde_callback): * event-msw.c (mswindows_wnd_proc): * event-msw.c (remove_timeout_mapper): * event-msw.c (emacs_mswindows_remove_timeout): * event-msw.c (emacs_mswindows_event_pending_p): * event-msw.c (emacs_mswindows_format_magic_event): * event-msw.c (emacs_mswindows_compare_magic_event): * event-msw.c (emacs_mswindows_hash_magic_event): * event-msw.c (emacs_mswindows_handle_magic_event): * event-msw.c (emacs_mswindows_select_console): * event-msw.c (emacs_mswindows_unselect_console): * event-msw.c (reinit_vars_of_event_mswindows): * event-msw.c (vars_of_event_mswindows): * event-stream.c: * event-stream.c (mark_command_builder): * event-stream.c (reset_command_builder_event_chain): * event-stream.c (allocate_command_builder): * event-stream.c (copy_command_builder): * event-stream.c (command_builder_append_event): * event-stream.c (event_stream_event_pending_p): * event-stream.c (event_stream_force_event_pending): * event-stream.c (maybe_read_quit_event): * event-stream.c (event_stream_drain_queue): * event-stream.c (remove_quit_p_event): * event-stream.c (event_stream_quit_p): * event-stream.c (echo_key_event): * event-stream.c (maybe_kbd_translate): * event-stream.c (execute_help_form): * event-stream.c (event_stream_generate_wakeup): * event-stream.c (enqueue_dispatch_event): * event-stream.c (enqueue_magic_eval_event): * event-stream.c (Fenqueue_eval_event): * event-stream.c (enqueue_misc_user_event): * event-stream.c (enqueue_misc_user_event_pos): * event-stream.c (next_event_internal): * event-stream.c (Fnext_event): * event-stream.c (Faccept_process_output): * event-stream.c (execute_internal_event): * event-stream.c (munge_keymap_translate): * event-stream.c (command_builder_find_leaf_no_mule_processing): * event-stream.c (command_builder_find_leaf): * event-stream.c (lookup_command_event): * event-stream.c (is_scrollbar_event): * event-stream.c (execute_command_event): * event-stream.c (Fdispatch_event): * event-stream.c (Fread_key_sequence): * event-stream.c (dribble_out_event): * event-stream.c (vars_of_event_stream): * event-tty.c (tty_timeout_to_emacs_event): * event-tty.c (emacs_tty_next_event): * event-tty.c (emacs_tty_drain_queue): * event-tty.c (reinit_vars_of_event_tty): * event-unixoid.c: * event-unixoid.c (find_tty_or_stream_console_from_fd): * event-unixoid.c (read_event_from_tty_or_stream_desc): * event-unixoid.c (drain_tty_devices): * event-unixoid.c (poll_fds_for_input): * events.c: * events.c (deinitialize_event): * events.c (zero_event): * events.c (mark_event): * events.c (print_event_1): * events.c (print_event): * events.c (event_equal): * events.c (event_hash): * events.c (Fmake_event): * events.c (Fdeallocate_event): * events.c (Fcopy_event): * events.c (map_event_chain_remove): * events.c (character_to_event): * events.c (event_to_character): * events.c (Fevent_to_character): * events.c (format_event_object): * events.c (upshift_event): * events.c (downshift_event): * events.c (event_upshifted_p): * events.c (Fevent_live_p): * events.c (Fevent_type): * events.c (Fevent_timestamp): * events.c (CHECK_EVENT_TYPE): * events.c (CHECK_EVENT_TYPE2): * events.c (CHECK_EVENT_TYPE3): * events.c (Fevent_key): * events.c (Fevent_button): * events.c (Fevent_modifier_bits): * events.c (event_x_y_pixel_internal): * events.c (event_pixel_translation): * events.c (Fevent_process): * events.c (Fevent_function): * events.c (Fevent_object): * events.c (Fevent_properties): * events.c (syms_of_events): * events.c (vars_of_events): * events.h: * events.h (struct event_stream): * events.h (struct Lisp_Key_Data): * events.h (KEY_DATA_KEYSYM): * events.h (EVENT_KEY_KEYSYM): * events.h (struct Lisp_Button_Data): * events.h (EVENT_BUTTON_BUTTON): * events.h (struct Lisp_Motion_Data): * events.h (EVENT_MOTION_X): * events.h (struct Lisp_Process_Data): * events.h (EVENT_PROCESS_PROCESS): * events.h (struct Lisp_Timeout_Data): * events.h (EVENT_TIMEOUT_INTERVAL_ID): * events.h (struct Lisp_Eval_Data): * events.h (EVENT_EVAL_FUNCTION): * events.h (struct Lisp_Misc_User_Data): * events.h (EVENT_MISC_USER_FUNCTION): * events.h (struct Lisp_Magic_Eval_Data): * events.h (EVENT_MAGIC_EVAL_INTERNAL_FUNCTION): * events.h (struct Lisp_Magic_Data): * events.h (EVENT_MAGIC_UNDERLYING): * events.h (EVENT_MAGIC_GDK_EVENT): * events.h (struct Lisp_Event): * events.h (XEVENT_CHANNEL): * events.h (SET_EVENT_TIMESTAMP_ZERO): * events.h (SET_EVENT_CHANNEL): * events.h (SET_EVENT_NEXT): * events.h (XSET_EVENT_TYPE): * events.h (struct command_builder): * extents.c: * extents.c (gap_array_adjust_markers): * extents.c (gap_array_recompute_derived_values): * extents.c (gap_array_move_gap): * extents.c (gap_array_make_gap): * extents.c (gap_array_insert_els): * extents.c (gap_array_delete_els): * extents.c (gap_array_make_marker): * extents.c (gap_array_delete_marker): * extents.c (gap_array_move_marker): * extents.c (make_gap_array): * extents.c (free_gap_array): * extents.c (extent_list_num_els): * extents.c (extent_list_insert): * extents.c (mark_extent_auxiliary): * extents.c (allocate_extent_auxiliary): * extents.c (decode_extent_at_flag): * extents.c (verify_extent_mapper): * extents.c (symbol_to_glyph_layout): * extents.c (syms_of_extents): * faces.c: * file-coding.c: * file-coding.c (struct_detector_category_description =): * file-coding.c (detector_category_dynarr_description_1): * file-coding.c (struct_detector_description =): * file-coding.c (detector_dynarr_description_1): * file-coding.c (MARKED_SLOT): * file-coding.c (mark_coding_system): * file-coding.c (coding_system_extra_description_map): * file-coding.c (coding_system_description): * file-coding.c (allocate_coding_system): * file-coding.c (symbol_to_eol_type): * file-coding.c (Fcoding_system_aliasee): * file-coding.c (set_coding_stream_coding_system): * file-coding.c (struct convert_eol_coding_system): * file-coding.c (struct undecided_coding_system): * file-coding.c (undecided_mark_coding_stream): * file-coding.c (coding_category_symbol_to_id): * file-coding.c (struct gzip_coding_system): * file-coding.c (coding_system_type_create): * file-coding.h: * file-coding.h (struct Lisp_Coding_System): * file-coding.h (CODING_SYSTEM_SLOT_DECLARATION): * file-coding.h (coding_system_variant): * file-coding.h (struct coding_system_methods): * file-coding.h (DEFINE_CODING_SYSTEM_TYPE_WITH_DATA): * file-coding.h (INITIALIZE_CODING_SYSTEM_TYPE_WITH_DATA): * file-coding.h (struct coding_stream): * fileio.c (Fsubstitute_in_file_name): * floatfns.c: * fns.c: * fns.c (base64_encode_1): * frame-gtk.c: * frame-gtk.c (Fgtk_start_drag_internal): * frame-impl.h (struct frame): * frame-impl.h (MARKED_SLOT): * frame-msw.c: * frame-x.c: * frame-x.c (Fcde_start_drag_internal): * frame-x.c (Foffix_start_drag_internal): * frame.c: * frame.c (MARKED_SLOT): * frame.c (allocate_frame_core): * frame.c (delete_frame_internal): * frame.c (Fmouse_position_as_motion_event): * frameslots.h: * frameslots.h (MARKED_SLOT_ARRAY): * free-hook.c: * glyphs-msw.c (mswindows_widget_instantiate): * glyphs-x.c: * glyphs-x.c (convert_EImage_to_XImage): * glyphs.c: * glyphs.c (process_image_string_instantiator): * glyphs.c (mark_image_instance): * glyphs.c (allocate_image_instance): * glyphs.c (unmap_subwindow): * glyphs.c (map_subwindow): * glyphs.c (syms_of_glyphs): * glyphs.c (specifier_type_create_image): * glyphs.h: * glyphs.h (struct text_image_instance): * glyphs.h (struct Lisp_Image_Instance): * gmalloc.c: * gmalloc.c ("C"): * gpmevent.c (Freceive_gpm_event): * gpmevent.c (gpm_next_event_cb): * gpmevent.c (vars_of_gpmevent): * gtk-glue.c (gdk_event_to_emacs_event): * gtk-xemacs.c (gtk_xemacs_class_init): * gui-msw.c: * gui-msw.c (mswindows_handle_gui_wm_command): * gui-msw.c (mswindows_translate_menu_or_dialog_item): * gui-x.c: * gui-x.c (mark_popup_data): * gui-x.c (snarf_widget_value_mapper): * gui-x.c (gcpro_popup_callbacks): * gui-x.c (ungcpro_popup_callbacks): * gui-x.c (free_popup_widget_value_tree): * gui-x.c (popup_selection_callback): * gui-x.h: * gui-x.h (struct popup_data): * gui.c: * gui.c (allocate_gui_item): * gutter.c (decode_gutter_position): * hash.c (NULL_ENTRY): * indent.c (vmotion_1): * indent.c (vmotion_pixels): * input-method-motif.c (res): * input-method-xlib.c (IMInstantiateCallback): * input-method-xlib.c (XIM_init_device): * input-method-xlib.c (res): * intl-encap-win32.c: * intl-encap-win32.c (qxeSHGetDataFromIDList): * intl-win32.c: * intl-win32.c (mswindows_multibyte_cp_type): * intl-win32.c (struct mswindows_multibyte_coding_system): * keymap.c: * keymap.c (make_key_description): * keymap.c (keymap_store): * keymap.c (get_keyelt): * keymap.c (keymap_lookup_1): * keymap.c (define_key_parser): * keymap.c (key_desc_list_to_event): * keymap.c (event_matches_key_specifier_p): * keymap.c (meta_prefix_char_p): * keymap.c (ensure_meta_prefix_char_keymapp): * keymap.c (Fdefine_key): * keymap.c (struct raw_lookup_key_mapper_closure): * keymap.c (raw_lookup_key): * keymap.c (raw_lookup_key_mapper): * keymap.c (lookup_keys): * keymap.c (lookup_events): * keymap.c (Flookup_key): * keymap.c (struct map_keymap_unsorted_closure): * keymap.c (map_keymap_unsorted_mapper): * keymap.c (map_keymap_sorted): * keymap.c (map_keymap_mapper): * keymap.c (map_keymap): * keymap.c (accessible_keymaps_mapper_1): * keymap.c (Faccessible_keymaps): * keymap.c (Fsingle_key_description): * keymap.c (raw_keys_to_keys): * keymap.c (format_raw_keys): * keymap.c (where_is_recursive_mapper): * keymap.c (where_is_internal): * keymap.c (describe_map_mapper_shadow_search): * keymap.c (keymap_lookup_inherited_mapper): * keymap.c (describe_map_mapper): * keymap.h (event_matches_key_specifier_p): * lisp.h: * lisp.h (this): * lisp.h (RETURN_NOT_REACHED): * lisp.h (struct Lisp_Vector): * lisp.h (struct Lisp_Bit_Vector): * lisp.h (UNGCPRO_1): * lisp.h (NUNGCPRO): * lisp.h (NNUNGCPRO): * lisp.h (DECLARE_INLINE_HEADER): * lrecord.h: * lrecord.h (struct lrecord_header): * lrecord.h (struct lcrecord_header): * lrecord.h (lrecord_type): * lrecord.h (struct lrecord_implementation): * lrecord.h (RECORD_DUMPABLE): * lrecord.h (memory_description_type): * lrecord.h (data_description_entry_flags): * lrecord.h (struct memory_description): * lrecord.h (struct sized_memory_description): * lrecord.h (XD_INDIRECT): * lrecord.h (XD_IS_INDIRECT): * lrecord.h (XD_DYNARR_DESC): * lrecord.h (DEFINE_BASIC_LRECORD_IMPLEMENTATION): * lrecord.h (MAKE_LRECORD_IMPLEMENTATION): * lrecord.h (MAKE_EXTERNAL_LRECORD_IMPLEMENTATION): * lrecord.h (alloc_lcrecord_type): * lstream.c: * lstream.c (Lstream_new): * lstream.c (lisp_buffer_marker): * lstream.h: * lstream.h (lstream_implementation): * lstream.h (DEFINE_LSTREAM_IMPLEMENTATION): * lstream.h (DEFINE_LSTREAM_IMPLEMENTATION_WITH_DATA): * marker.c: * marker.c (copy_marker_1): * mem-limits.h: * menubar-gtk.c: * menubar-gtk.c (gtk_popup_menu): * menubar-msw.c: * menubar-msw.c (mswindows_popup_menu): * menubar-x.c (make_dummy_xbutton_event): * menubar-x.c (command_builder_operate_menu_accelerator): * menubar-x.c (menu_accelerator_safe_compare): * menubar-x.c (menu_accelerator_safe_mod_compare): * mule-charset.c: * mule-charset.c (make_charset): * mule-charset.c (Fcharset_property): * mule-coding.c: * mule-coding.c (ccs_description_1): * mule-coding.c (ccs_description =): * mule-coding.c (ccsd_description_1): * mule-coding.c (ccsd_description =): * nt.c (getpwnam): * nt.c (init_mswindows_environment): * nt.c (get_cached_volume_information): * nt.c (mswindows_is_executable): * nt.c (read_unc_volume): * nt.c (mswindows_access): * nt.c (mswindows_link): * nt.c (mswindows_fstat): * nt.c (mswindows_stat): * nt.c (mswindows_executable_type): * nt.c (Fmswindows_short_file_name): * nt.c (Fmswindows_long_file_name): * objects-impl.h (struct Lisp_Color_Instance): * objects-impl.h (struct Lisp_Font_Instance): * objects-tty.c: * objects-x.c (allocate_nearest_color): * objects.c: * objects.c (Fmake_color_instance): * objects.c (Fmake_font_instance): * objects.c (font_instantiate): * opaque.c: * opaque.c (make_opaque): * opaque.c (make_opaque_ptr): * opaque.c (reinit_opaque_early): * opaque.c (init_opaque_once_early): * print.c: * print.c (printing_badness): * print.c (printing_major_badness): * print.c (print_internal): * print.c (debug_p4): * print.c (dp): * print.c (debug_backtrace): * process-nt.c (nt_create_process): * process-nt.c (get_internet_address): * process-unix.c: * process-unix.c (struct unix_process_data): * process-unix.c (get_internet_address): * process-unix.c (unix_alloc_process_data): * process-unix.c (unix_create_process): * process-unix.c (try_to_initialize_subtty): * process-unix.c (unix_kill_child_process): * process-unix.c (process_type_create_unix): * process.c: * process.c (mark_process): * process.c (MARKED_SLOT): * process.c (make_process_internal): * process.c (Fprocess_tty_name): * process.c (decode_signal): * process.h: * procimpl.h: * procimpl.h (struct process_methods): * procimpl.h (struct Lisp_Process): * rangetab.c: * realpath.c (readlink_and_correct_case): * redisplay-x.c (x_window_output_end): * redisplay-x.c (x_redraw_exposed_area): * redisplay-x.c (x_clear_frame): * redisplay.c: * redisplay.h: * redisplay.h (struct rune_dglyph): * redisplay.h (struct rune): * scrollbar.c: * scrollbar.c (create_scrollbar_instance): * specifier.c: * specifier.c (specifier_empty_extra_description_1): * specifier.c (make_specifier_internal): * specifier.c (decode_locale_type): * specifier.c (decode_how_to_add_specification): * specifier.h: * specifier.h (struct specifier_methods): * specifier.h (DEFINE_SPECIFIER_TYPE_WITH_DATA): * specifier.h (INITIALIZE_SPECIFIER_TYPE_WITH_DATA): * symbols.c: * symbols.c (Fsetplist): * symbols.c (default_value): * symbols.c (decode_magic_handler_type): * symbols.c (handler_type_from_function_symbol): * symbols.c (Fdefvaralias): * symbols.c (init_symbols_once_early): * symbols.c (reinit_symbols_early): * symsinit.h: * sysdep.c (sys_subshell): * sysdep.c (tty_init_sys_modes_on_device): * syswindows.h: * text.c (dfc_convert_to_external_format): * text.c (dfc_convert_to_internal_format): * text.c (reinit_eistring_early): * text.c (init_eistring_once_early): * text.c (reinit_vars_of_text): * text.h: * text.h (INC_IBYTEPTR_FMT): * text.h (DEC_IBYTEPTR_FMT): * toolbar.c: * toolbar.c (decode_toolbar_position): * tooltalk.c: * ui-gtk.c: * unexnt.c: * unexnt.c (_start): * unexnt.c (unexec): * unexnt.c (get_section_info): * unicode.c: * unicode.c (vars_of_unicode): * window.c: * window.c (allocate_window): * window.c (new_window_mirror): * window.c (update_mirror_internal): * winslots.h:
author michaels
date Sun, 12 Jan 2003 11:08:22 +0000
parents 8d610ea37af8
children 01c57eb70ae9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* device functions for mswindows.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1994, 1995 Free Software Foundation, Inc.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
4 Copyright (C) 2000, 2001, 2002 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
25 /* This file Mule-ized 8-11-2000. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
26
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 /* Authorship:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 Original authors: Jamie Zawinski and the FSF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 Rewritten by Ben Wing and Chuck Thompson.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 Rewritten for mswindows by Jonathan Harris, November 1997 for 21.0.
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
32 Print support added by Kirill Katsnelson, July 2000.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
35 #define NEED_MSWINDOWS_COMMCTRL
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
36 #define NEED_MSWINDOWS_OBJBASE /* for CoInitialize */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
41 #include "device-impl.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 798
diff changeset
42 #include "events.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 798
diff changeset
43 #include "faces.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 798
diff changeset
44 #include "frame.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 798
diff changeset
45
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
46 #include "console-msw-impl.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 #include "console-stream.h"
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
48 #include "objects-msw.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 798
diff changeset
49
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 #include "sysdep.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 /* win32 DDE management library globals */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 #ifdef HAVE_DRAGNDROP
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 DWORD mswindows_dde_mlid;
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
55 int mswindows_dde_enable;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 HSZ mswindows_dde_service;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 HSZ mswindows_dde_topic_system;
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
58 HSZ mswindows_dde_topic_eval;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
59 HSZ mswindows_dde_item_result;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 HSZ mswindows_dde_item_open;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 Lisp_Object Qinit_pre_mswindows_win, Qinit_post_mswindows_win;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
64 Lisp_Object Qdevmodep;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
66 static Lisp_Object Q_allow_selection;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
67 static Lisp_Object Q_allow_pages;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
68 static Lisp_Object Q_selected_page_button;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
69 static Lisp_Object Qselected_page_button;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
70
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
71 static const struct memory_description mswindows_device_data_description_1 [] = {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
72 { XD_LISP_OBJECT, offsetof (struct mswindows_device, fontlist) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
73 { XD_END }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
74 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
75
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
76 extern const struct sized_memory_description mswindows_device_data_description;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
77
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
78 const struct sized_memory_description mswindows_device_data_description = {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
79 sizeof (struct mswindows_device), mswindows_device_data_description_1
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
80 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
81
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
82 static Lisp_Object allocate_devmode (DEVMODEW *src_devmode, int do_copy,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
83 Lisp_Object src_name, struct device *d);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 /* helpers */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 static Lisp_Object
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
90 build_syscolor_string (int idx)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
92 return (idx < 0 ? Qnil : mswindows_color_to_string (GetSysColor (idx)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 build_syscolor_cons (int index1, int index2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 Lisp_Object color1, color2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 GCPRO1 (color1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 color1 = build_syscolor_string (index1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 color2 = build_syscolor_string (index2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 RETURN_UNGCPRO (Fcons (color1, color2));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 build_sysmetrics_cons (int index1, int index2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 return Fcons (index1 < 0 ? Qnil : make_int (GetSystemMetrics (index1)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 index2 < 0 ? Qnil : make_int (GetSystemMetrics (index2)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
113 static Lisp_Object
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
114 build_devicecaps_cons (HDC hdc, int index1, int index2)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
115 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
116 return Fcons (index1 < 0 ? Qnil : make_int (GetDeviceCaps (hdc, index1)),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
117 index2 < 0 ? Qnil : make_int (GetDeviceCaps (hdc, index2)));
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
118 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
119
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 /************************************************************************/
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
122 /* display methods */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 mswindows_init_device (struct device *d, Lisp_Object props)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 HDC hdc;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
129 WNDCLASSEXW wc;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 DEVICE_CLASS (d) = Qcolor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 init_baud_rate (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 init_one_device (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 d->device_data = xnew_and_zero (struct mswindows_device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 hdc = CreateCompatibleDC (NULL);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
138 assert (hdc != NULL);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
139 DEVICE_MSWINDOWS_HCDC (d) = hdc;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
140 DEVICE_MSWINDOWS_FONTLIST (d) = mswindows_enumerate_fonts (hdc);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
141 DEVICE_MSWINDOWS_UPDATE_TICK (d) = GetTickCount ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 /* Register the main window class */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
144 wc.cbSize = sizeof (wc);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 wc.style = CS_OWNDC; /* One DC per window */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 wc.lpfnWndProc = (WNDPROC) mswindows_wnd_proc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 wc.cbClsExtra = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 wc.cbWndExtra = MSWINDOWS_WINDOW_EXTRA_BYTES;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 /* This must match whatever is passed to CreateWIndowEx, NULL is ok
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 for this. */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
151 wc.hInstance = NULL;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
152 wc.hIcon = qxeLoadIcon (qxeGetModuleHandle (NULL), XETEXT (XEMACS_CLASS));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
153 wc.hCursor = qxeLoadCursor (NULL, IDC_ARROW);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 /* Background brush is only used during sizing, when XEmacs cannot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 take over */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
156 wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE + 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 wc.lpszMenuName = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
159 wc.lpszClassName = (XELPTSTR) XETEXT (XEMACS_CLASS);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
160 wc.hIconSm = (HICON) qxeLoadImage (qxeGetModuleHandle (NULL),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
161 XETEXT (XEMACS_CLASS),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
162 IMAGE_ICON, 16, 16, 0);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
163 qxeRegisterClassEx (&wc);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 #ifdef HAVE_WIDGETS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 xzero (wc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 /* Register the main window class */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
168 wc.cbSize = sizeof (wc);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 wc.lpfnWndProc = (WNDPROC) mswindows_control_wnd_proc;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
170 wc.lpszClassName = (XELPTSTR) XETEXT (XEMACS_CONTROL_CLASS);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 wc.hInstance = NULL;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
172 qxeRegisterClassEx (&wc);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
175 #if defined (HAVE_TOOLBARS) || defined (HAVE_WIDGETS)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 InitCommonControls ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
180 #ifdef HAVE_DRAGNDROP
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 static void
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
182 mswindows_init_dde (void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 /* Initialize DDE management library and our related globals. We execute a
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
185 * dde Open ("file") by simulating a drop, so this depends on dnd support. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
186
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 mswindows_dde_mlid = 0;
659
f1a615a0d9e0 [xemacs-hg @ 2001-09-10 19:31:41 by andyp]
andyp
parents: 657
diff changeset
188 mswindows_dde_enable = 0;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
189 qxeDdeInitialize (&mswindows_dde_mlid, (PFNCALLBACK)mswindows_dde_callback,
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
190 APPCMD_FILTERINITS|CBF_FAIL_SELFCONNECTIONS|
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
191 CBF_FAIL_POKES|CBF_SKIP_ALLNOTIFICATIONS,
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
192 0);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
193
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
194 mswindows_dde_service =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
195 qxeDdeCreateStringHandle (mswindows_dde_mlid,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
196 XETEXT (XEMACS_CLASS),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
197 XEUNICODE_P ? CP_WINUNICODE : CP_WINANSI);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
198 /* The following strings we Unicode-ize ourselves:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
199 -- SZDDESYS_TOPIC is system-provided
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
200 -- MSWINDOWS_DDE_TOPIC_EVAL is defined by us
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
201 -- MSWINDOWS_DDE_ITEM_RESULT is defined by us
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
202 -- MSWINDOWS_DDE_ITEM_OPEN is used in internal-format comparisons
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
203 */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
204 mswindows_dde_topic_system =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
205 qxeDdeCreateStringHandle (mswindows_dde_mlid,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
206 XETEXT (SZDDESYS_TOPIC),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
207 XEUNICODE_P ? CP_WINUNICODE : CP_WINANSI);
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
208 mswindows_dde_topic_eval =
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
209 qxeDdeCreateStringHandle (mswindows_dde_mlid,
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
210 XETEXT (MSWINDOWS_DDE_TOPIC_EVAL),
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
211 XEUNICODE_P ? CP_WINUNICODE : CP_WINANSI);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
212 mswindows_dde_item_result =
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
213 qxeDdeCreateStringHandle (mswindows_dde_mlid,
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
214 XETEXT (MSWINDOWS_DDE_ITEM_RESULT),
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
215 XEUNICODE_P ? CP_WINUNICODE : CP_WINANSI);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
216 mswindows_dde_item_open =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
217 qxeDdeCreateStringHandle (mswindows_dde_mlid,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
218 XETEXT (MSWINDOWS_DDE_ITEM_OPEN),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
219 XEUNICODE_P ? CP_WINUNICODE : CP_WINANSI);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 DdeNameService (mswindows_dde_mlid, mswindows_dde_service, 0L, DNS_REGISTER);
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
221 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
222 #endif /* HAVE_DRAGNDROP */
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
223
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
224 void
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
225 init_mswindows_dde_very_early (void)
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
226 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
227 #if !defined (NO_CYGWIN_COM_SUPPORT)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
228 /* Needed by SHBrowseForFolder, so do it always */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
229 CoInitialize (NULL);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
230 #endif
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
231
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
232 #ifdef HAVE_DRAGNDROP
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
233 /* Initializing dde when the device is created is too late - the
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
234 client will give up waiting. Instead we initialize here and tell
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
235 the client we're too busy until the rest of initialization has
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
236 happened. */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
237 mswindows_init_dde ();
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
238 #endif
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
239 }
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
240
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
241 static void
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
242 mswindows_finish_init_device (struct device *d, Lisp_Object props)
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
243 {
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
244 #ifdef HAVE_DRAGNDROP
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
245 /* Tell pending clients we are ready. */
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
246 mswindows_dde_enable = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 mswindows_delete_device (struct device *d)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 #ifdef HAVE_DRAGNDROP
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
254 DdeNameService (mswindows_dde_mlid, 0L, 0L, DNS_UNREGISTER);
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
255 DdeFreeStringHandle (mswindows_dde_mlid, mswindows_dde_item_result);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
256 DdeFreeStringHandle (mswindows_dde_mlid, mswindows_dde_item_open);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
257 DdeFreeStringHandle (mswindows_dde_mlid, mswindows_dde_topic_system);
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
258 DdeFreeStringHandle (mswindows_dde_mlid, mswindows_dde_topic_eval);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
259 DdeFreeStringHandle (mswindows_dde_mlid, mswindows_dde_service);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 DdeUninitialize (mswindows_dde_mlid);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
261
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
262 # if !defined (NO_CYGWIN_COM_SUPPORT)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
263 CoUninitialize ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
264 # endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
267 DeleteDC (DEVICE_MSWINDOWS_HCDC (d));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
268 xfree (d->device_data);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
269 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
270
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
271 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
272 mswindows_get_workspace_coords (RECT *rc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
273 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
274 qxeSystemParametersInfo (SPI_GETWORKAREA, 0, rc, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
277 static void
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
278 mswindows_mark_device (struct device *d)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
279 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
280 mark_object (DEVICE_MSWINDOWS_FONTLIST (d));
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
281 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
282
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 mswindows_device_system_metrics (struct device *d,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 enum device_metrics m)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
287 const HDC hdc = DEVICE_MSWINDOWS_HCDC(d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
288
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 switch (m)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 case DM_size_device:
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
292 return Fcons (make_int (GetDeviceCaps (hdc, HORZRES)),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
293 make_int (GetDeviceCaps (hdc, VERTRES)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 break;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
295 case DM_device_dpi:
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
296 return Fcons (make_int (GetDeviceCaps (hdc, LOGPIXELSX)),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
297 make_int (GetDeviceCaps (hdc, LOGPIXELSY)));
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
298 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 case DM_size_device_mm:
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
300 return Fcons (make_int (GetDeviceCaps (hdc, HORZSIZE)),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
301 make_int (GetDeviceCaps (hdc, VERTSIZE)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 case DM_num_bit_planes:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 /* this is what X means by bitplanes therefore we ought to be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 consistent. num planes is always 1 under mswindows and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 therefore useless */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
307 return make_int (GetDeviceCaps (hdc, BITSPIXEL));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 case DM_num_color_cells:
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
310 /* #### SIZEPALETTE only valid if RC_PALETTE bit set in RASTERCAPS,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
311 what should we return for a non-palette-based device? */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
312 return make_int (GetDeviceCaps (hdc, SIZEPALETTE));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 /*** Colors ***/
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
316 #define FROB(met, fore, back) \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 case DM_##met: \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
318 return build_syscolor_cons (fore, back);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
319
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
320 FROB (color_default, COLOR_WINDOWTEXT, COLOR_WINDOW);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
321 FROB (color_select, COLOR_HIGHLIGHTTEXT, COLOR_HIGHLIGHT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
322 FROB (color_balloon, COLOR_INFOTEXT, COLOR_INFOBK);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
323 FROB (color_3d_face, COLOR_BTNTEXT, COLOR_BTNFACE);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
324 FROB (color_3d_light, COLOR_3DHILIGHT, COLOR_3DLIGHT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
325 FROB (color_3d_dark, COLOR_3DDKSHADOW, COLOR_3DSHADOW);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
326 FROB (color_menu, COLOR_MENUTEXT, COLOR_MENU);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
327 FROB (color_menu_highlight, COLOR_HIGHLIGHTTEXT, COLOR_HIGHLIGHT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
328 FROB (color_menu_button, COLOR_MENUTEXT, COLOR_MENU);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
329 FROB (color_menu_disabled, COLOR_GRAYTEXT, COLOR_MENU);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
330 FROB (color_toolbar, COLOR_BTNTEXT, COLOR_BTNFACE);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
331 FROB (color_scrollbar, COLOR_CAPTIONTEXT, COLOR_SCROLLBAR);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 FROB (color_desktop, -1, COLOR_DESKTOP);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 FROB (color_workspace, -1, COLOR_APPWORKSPACE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 #undef FROB
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 /*** Sizes ***/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 #define FROB(met, index1, index2) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 case DM_##met: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 return build_sysmetrics_cons (index1, index2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 FROB (size_cursor, SM_CXCURSOR, SM_CYCURSOR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 FROB (size_scrollbar, SM_CXVSCROLL, SM_CYHSCROLL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 FROB (size_menu, -1, SM_CYMENU);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 FROB (size_icon, SM_CXICON, SM_CYICON);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 FROB (size_icon_small, SM_CXSMICON, SM_CYSMICON);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 #undef FROB
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 case DM_size_workspace:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 RECT rc;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
351 mswindows_get_workspace_coords (&rc);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 return Fcons (make_int (rc.right - rc.left),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 make_int (rc.bottom - rc.top));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
355
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
356 case DM_offset_workspace:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
357 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
358 RECT rc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
359 mswindows_get_workspace_coords (&rc);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
360 return Fcons (make_int (rc.left), make_int (rc.top));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
361 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
362
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 case DM_size_toolbar:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 case DM_size_toolbar_button:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 case DM_size_toolbar_border:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 /*** Features ***/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 #define FROB(met, index) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 case DM_##met: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 return make_int (GetSystemMetrics (index));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 FROB (mouse_buttons, SM_CMOUSEBUTTONS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 FROB (swap_buttons, SM_SWAPBUTTON);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 FROB (show_sounds, SM_SHOWSOUNDS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 FROB (slow_device, SM_SLOWMACHINE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 FROB (security, SM_SECURE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 #undef FROB
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 /* Do not know such property */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 return Qunbound;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 /************************************************************************/
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
389 /* printer helpers */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
390 /************************************************************************/
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
391
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
392 static void
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
393 signal_open_printer_error (struct device *d)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
394 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
395 invalid_operation ("Failed to open printer", DEVICE_CONNECTION (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
396 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
397
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
398
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
399 /* Helper function */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
400 static int
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
401 msprinter_init_device_internal (struct device *d, Lisp_Object printer_name)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
402 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
403 Extbyte *printer_ext;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
404 HDC hdc;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
405
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
406 DEVICE_MSPRINTER_NAME (d) = printer_name;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
407
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
408 LISP_STRING_TO_TSTR (printer_name, printer_ext);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
409
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
410 if (!qxeOpenPrinter (printer_ext, &DEVICE_MSPRINTER_HPRINTER (d), NULL))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
411 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
412 DEVICE_MSPRINTER_HPRINTER (d) = NULL;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
413 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
414 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
415
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
416 DEVICE_MSPRINTER_HDC (d) = qxeCreateDC (XETEXT ("WINSPOOL"), printer_ext,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
417 NULL, NULL);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
418 if (DEVICE_MSPRINTER_HDC (d) == NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
419 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
420
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
421 hdc = CreateCompatibleDC (DEVICE_MSPRINTER_HDC (d));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
422 DEVICE_MSPRINTER_HCDC (d) = hdc;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
423 DEVICE_MSPRINTER_FONTLIST (d) = mswindows_enumerate_fonts (hdc);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
424
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
425 DEVICE_CLASS (d) = (GetDeviceCaps (DEVICE_MSPRINTER_HDC (d), BITSPIXEL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
426 * GetDeviceCaps (DEVICE_MSPRINTER_HDC (d), PLANES)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
427 > 1) ? Qcolor : Qmono;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
428 return 1;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
429 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
430
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
431 static void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
432 msprinter_delete_device_internal (struct device *d)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
433 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
434 if (DEVICE_MSPRINTER_HPRINTER (d))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
435 ClosePrinter (DEVICE_MSPRINTER_HPRINTER (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
436 if (DEVICE_MSPRINTER_HDC (d))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
437 DeleteDC (DEVICE_MSPRINTER_HDC (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
438 if (DEVICE_MSPRINTER_HCDC (d))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
439 DeleteDC (DEVICE_MSPRINTER_HCDC (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
440
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
441 DEVICE_MSPRINTER_FONTLIST (d) = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
442 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
443
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
444 static int
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
445 msprinter_reinit_device (struct device *d, Lisp_Object devname)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
446 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
447 msprinter_delete_device_internal (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
448 return msprinter_init_device_internal (d, devname);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
449 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
450
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
451 Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
452 msprinter_default_printer (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
453 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
454 Extbyte name[666];
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
455 Ibyte *nameint;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
456
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
457 if (qxeGetProfileString (XETEXT ("windows"), XETEXT ("device"), NULL, name,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
458 sizeof (name) / XETCHAR_SIZE) <= 0)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
459 return Qnil;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
460 TSTR_TO_C_STRING (name, nameint);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
461
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
462 if (nameint[0] == '\0')
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
463 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
464
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
465 /* this is destructive, but that's ok because the string is either in
851
e7ee5f8bde58 [xemacs-hg @ 2002-05-23 11:46:08 by ben]
ben
parents: 850
diff changeset
466 name[] or ALLOCA ()ed */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
467 qxestrtok (nameint, ",");
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
468
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
469 return build_intstring (nameint);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
470 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
471
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
472
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
473 /************************************************************************/
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
474 /* printer methods */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
475 /************************************************************************/
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
476
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
477 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
478 msprinter_init_device (struct device *d, Lisp_Object props)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
479 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
480 DEVMODEW *pdm;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 593
diff changeset
481 LONG dm_size;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
482 Extbyte *printer_name;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
483
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
484 d->device_data = xnew_and_zero (struct msprinter_device);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
485
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
486 DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
487 DEVICE_MSPRINTER_DEVMODE (d) = Qnil;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
488 DEVICE_MSPRINTER_NAME (d) = Qnil;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
489
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
490 #if 0 /* @@#### deleted in new ikeyama ws */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
491 /* We do not use printer font list as we do with the display
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
492 device. Rather, we allow GDI to pick the closest match to the
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
493 display font. */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
494 DEVICE_MSPRINTER_FONTLIST (d) = Qnil;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
495 #endif /* 0 */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
496
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
497 CHECK_STRING (DEVICE_CONNECTION (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
498
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
499 if (!msprinter_init_device_internal (d, DEVICE_CONNECTION (d)))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
500 signal_open_printer_error (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
501
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
502 LISP_STRING_TO_TSTR (DEVICE_CONNECTION (d), printer_name);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
503 /* Determine DEVMODE size and store the default DEVMODE */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
504 dm_size = qxeDocumentProperties (NULL, DEVICE_MSPRINTER_HPRINTER (d),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
505 printer_name, NULL, NULL, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
506 if (dm_size <= 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
507 signal_open_printer_error (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
508
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
509 pdm = (DEVMODEW *) xmalloc (dm_size);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
510 if (qxeDocumentProperties (NULL, DEVICE_MSPRINTER_HPRINTER(d),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
511 printer_name, pdm,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
512 NULL, DM_OUT_BUFFER) < 0)
552
a3adcf42bcec [xemacs-hg @ 2001-05-21 06:19:40 by mta]
mta
parents: 545
diff changeset
513 signal_open_printer_error (d);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
514
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
515 assert (DEVMODE_SIZE (pdm) <= dm_size);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
516
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
517 DEVICE_MSPRINTER_DEVMODE (d) =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
518 allocate_devmode (pdm, 0, DEVICE_CONNECTION (d), d);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
519 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
520
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
521 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
522 msprinter_delete_device (struct device *d)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
523 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
524 if (d->device_data)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
525 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
526 msprinter_delete_device_internal (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
527
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
528 /* Disassociate the selected devmode with the device */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
529 if (!NILP (DEVICE_MSPRINTER_DEVMODE (d)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
530 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
531 XDEVMODE (DEVICE_MSPRINTER_DEVMODE (d))->device = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
532 DEVICE_MSPRINTER_DEVMODE (d) = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
533 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
534
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
535 xfree (d->device_data);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
536 }
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
537 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
538
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
539 static Lisp_Object
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
540 msprinter_device_system_metrics (struct device *d,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
541 enum device_metrics m)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
542 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
543 switch (m)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
544 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
545 /* Device sizes - pixel and mm */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
546 #define FROB(met, index1, index2) \
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
547 case DM_##met: \
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
548 return build_devicecaps_cons \
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
549 (DEVICE_MSPRINTER_HDC (d), index1, index2);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
550
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
551 FROB (size_device, PHYSICALWIDTH, PHYSICALHEIGHT);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
552 FROB (size_device_mm, HORZSIZE, VERTSIZE);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
553 FROB (size_workspace, HORZRES, VERTRES);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
554 FROB (offset_workspace, PHYSICALOFFSETX, PHYSICALOFFSETY);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
555 FROB (device_dpi, LOGPIXELSX, LOGPIXELSY);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
556 #undef FROB
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
557
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
558 case DM_num_bit_planes:
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
559 /* this is what X means by bitplanes therefore we ought to be
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
560 consistent. num planes is always 1 under mswindows and
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
561 therefore useless */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
562 return make_int (GetDeviceCaps (DEVICE_MSPRINTER_HDC (d), BITSPIXEL));
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
563
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
564 case DM_num_color_cells: /* Printers are non-palette devices */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
565 case DM_slow_device: /* Animation would be a really bad idea */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
566 case DM_security: /* Not provided by windows */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
567 return Qzero;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
568 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
569
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
570 /* Do not know such property */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
571 return Qunbound;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
572 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
573
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
574 static void
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
575 msprinter_mark_device (struct device *d)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
576 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
577 mark_object (DEVICE_MSPRINTER_FONTLIST (d));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
578 mark_object (DEVICE_MSPRINTER_DEVMODE (d));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
579 mark_object (DEVICE_MSPRINTER_NAME (d));
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
580 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
581
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
582
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
583 /************************************************************************/
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
584 /* printer Lisp subroutines */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
585 /************************************************************************/
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
586
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
587 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
588 global_free_2_maybe (HGLOBAL hg1, HGLOBAL hg2)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
589 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
590 if (hg1 != NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
591 GlobalFree (hg1);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
592 if (hg2 != NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
593 GlobalFree (hg2);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
594 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
595
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
596 static HGLOBAL
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
597 devmode_to_hglobal (Lisp_Devmode *ldm)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
598 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
599 HGLOBAL hg = GlobalAlloc (GHND, XDEVMODE_SIZE (ldm));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
600 memcpy (GlobalLock (hg), ldm->devmode, XDEVMODE_SIZE (ldm));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
601 GlobalUnlock (hg);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
602 return hg;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
603 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
604
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
605 /* Returns 0 if the printer has been deleted due to a fatal I/O error,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
606 1 otherwise. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
607 static int
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
608 sync_printer_with_devmode (struct device* d, DEVMODEW* devmode_in,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
609 DEVMODEW* devmode_out, Lisp_Object devname)
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
610 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
611 /* Change connection if the device changed */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
612 if (!NILP (devname)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
613 && lisp_strcasecmp (devname, DEVICE_MSPRINTER_NAME (d)) != 0)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
614 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
615 Lisp_Object new_connection = devname;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
616
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
617 DEVICE_CONNECTION (d) = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
618 if (!NILP (Ffind_device (new_connection, Qmsprinter)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
619 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
620 /* We are in trouble - second msprinter for the same device.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
621 Nothing wrong on the Windows side, just forge a unique
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
622 connection name. Use the memory address of d as a unique
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
623 suffix. */
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
624 Ibyte new_connext[20];
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
625
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
626 qxesprintf (new_connext, ":%X", d->header.uid);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
627 new_connection = concat2 (devname, build_intstring (new_connext));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
628 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
629 DEVICE_CONNECTION (d) = new_connection;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
630
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
631 /* Reinitialize printer. The device can pop off in process */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
632 if (!msprinter_reinit_device (d, devname))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
633 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
634 /* Kaboom! */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
635 delete_device_internal (d, 1, 0, 1);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
636 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
637 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
638 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
639 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
640 Extbyte *nameext;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
641
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
642 LISP_STRING_TO_TSTR (DEVICE_MSPRINTER_NAME (d), nameext);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
643
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
644 /* Apply the new devmode to the printer */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
645 qxeDocumentProperties (NULL, DEVICE_MSPRINTER_HPRINTER (d),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
646 nameext, devmode_out, devmode_in,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
647 DM_IN_BUFFER | DM_OUT_BUFFER);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
648
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
649 /* #### ResetDC fails sometimes, Bill only knows why.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
650 The solution below looks more like a workaround to me,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
651 although it might be fine. --kkm */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
652 if (qxeResetDC (DEVICE_MSPRINTER_HDC (d), devmode_out) == NULL)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
653 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
654 DeleteDC (DEVICE_MSPRINTER_HDC (d));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
655 DEVICE_MSPRINTER_HDC (d) =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
656 qxeCreateDC (XETEXT ("WINSPOOL"), nameext, NULL,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
657 devmode_out);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
658 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
659 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
660
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
661 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
662 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
663
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
664 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
665 handle_devmode_changes (Lisp_Devmode *ldm, HGLOBAL hDevNames, HGLOBAL hDevMode)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
666 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
667 DEVNAMES *devnames = (DEVNAMES *) GlobalLock (hDevNames);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
668 Extbyte *new_name =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
669 devnames ?
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
670 (Extbyte *) devnames + XETCHAR_SIZE * devnames->wDeviceOffset : NULL;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
671 DEVMODEW *devmode = (DEVMODEW *) GlobalLock (hDevMode);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
672
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
673 /* Size and name may have changed */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
674 ldm->devmode = (DEVMODEW *) xrealloc (ldm->devmode, DEVMODE_SIZE (devmode));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
675 if (new_name)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
676 ldm->printer_name = build_tstr_string (new_name);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
677
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
678 if (!NILP (ldm->device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
679 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
680 /* Apply the new devmode to the printer and get a compete one back */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
681 struct device *d = XDEVICE (ldm->device);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
682 if (!sync_printer_with_devmode (d, devmode, ldm->devmode,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
683 new_name ? ldm->printer_name : Qnil))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
684 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
685 global_free_2_maybe (hDevNames, hDevMode);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
686 signal_error
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
687 (Qio_error,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
688 "Printer device initialization I/O error, device deleted",
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
689 ldm->device);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
690 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
691 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
692 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
693 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
694 /* Just copy the devmode structure */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
695 memcpy (ldm->devmode, devmode, DEVMODE_SIZE (devmode));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
696 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
697 }
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
698
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
699 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
700 ensure_not_printing (struct device *d)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
701 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
702 if (!NILP (DEVICE_FRAME_LIST (d)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
703 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
704 Lisp_Object device = wrap_device (d);
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
705
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
706 invalid_operation ("Cannot change settings while print job is active",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
707 device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
708 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
709 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
710
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
711 static Lisp_Devmode *
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
712 decode_devmode (Lisp_Object dev)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
713 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
714 if (DEVMODEP (dev))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
715 return XDEVMODE (dev);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
716 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
717 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
718 ensure_not_printing (XDEVICE (dev));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
719 return XDEVMODE (DEVICE_MSPRINTER_DEVMODE (XDEVICE (dev)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
720 }
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
721 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
722
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
723 /*
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
724 * DEV can be either a printer or devmode
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
725 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
726 static Lisp_Object
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
727 print_dialog_worker (Lisp_Object dev, DWORD flags)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
728 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
729 Lisp_Devmode *ldm = decode_devmode (dev);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
730 PRINTDLGW pd;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
731
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
732 memset (&pd, 0, sizeof (pd));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
733 pd.lStructSize = sizeof (pd);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
734 pd.hwndOwner = mswindows_get_selected_frame_hwnd ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
735 pd.hDevMode = devmode_to_hglobal (ldm);
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
736 pd.Flags = flags | PD_USEDEVMODECOPIESANDCOLLATE;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
737 pd.nMinPage = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
738 pd.nMaxPage = 0xFFFF;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
739
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
740 if (!qxePrintDlg (&pd))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
741 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
742 global_free_2_maybe (pd.hDevNames, pd.hDevMode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
743 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
744 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
745
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
746 handle_devmode_changes (ldm, pd.hDevNames, pd.hDevMode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
747
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
748 /* Finally, build the resulting plist */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
749 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
750 Lisp_Object result = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
751 struct gcpro gcpro1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
752 GCPRO1 (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
753
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
754 /* Do consing in reverse order.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
755 Number of copies */
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
756 result = Fcons (Qcopies, Fcons (make_int (pd.nCopies), result));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
757
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
758 /* Page range */
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
759 if (pd.Flags & PD_PAGENUMS)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
760 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
761 result = Fcons (Qto_page, Fcons (make_int (pd.nToPage), result));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
762 result = Fcons (Qfrom_page, Fcons (make_int (pd.nFromPage), result));
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
763 result = Fcons (Qselected_page_button, Fcons (Qpages, result));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
764 }
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
765 else if (pd.Flags & PD_SELECTION)
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
766 result = Fcons (Qselected_page_button, Fcons (Qselection, result));
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
767 else
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
768 result = Fcons (Qselected_page_button, Fcons (Qall, result));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
769
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
770 /* Device name */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
771 result = Fcons (Qname, Fcons (ldm->printer_name, result));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
772 UNGCPRO;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
773
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
774 global_free_2_maybe (pd.hDevNames, pd.hDevMode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
775 return result;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
776 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
777 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
778
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
779 Lisp_Object
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
780 mswindows_handle_print_dialog_box (struct frame *f, Lisp_Object keys)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
781 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
782 Lisp_Object device = Qunbound, settings = Qunbound;
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
783 DWORD flags = PD_NOSELECTION;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
784
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
785 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
786 EXTERNAL_PROPERTY_LIST_LOOP_3 (key, value, keys)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
787 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
788 if (EQ (key, Q_device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
789 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
790 device = wrap_device (decode_device (value));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
791 CHECK_MSPRINTER_DEVICE (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
792 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
793 else if (EQ (key, Q_printer_settings))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
794 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
795 CHECK_DEVMODE (value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
796 settings = value;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
797 }
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
798 else if (EQ (key, Q_allow_pages))
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
799 {
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
800 if (NILP (value))
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
801 flags |= PD_NOPAGENUMS;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
802 }
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
803 else if (EQ (key, Q_allow_selection))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
804 {
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
805 if (!NILP (value))
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
806 flags &= ~PD_NOSELECTION;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
807 }
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
808 else if (EQ (key, Q_selected_page_button))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
809 {
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
810 if (EQ (value, Qselection))
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
811 flags |= PD_SELECTION;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
812 else if (EQ (value, Qpages))
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
813 flags |= PD_PAGENUMS;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
814 else if (!EQ (value, Qall))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
815 invalid_constant ("for :selected-page-button", value);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
816 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
817 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
818 invalid_constant ("Unrecognized print-dialog keyword", key);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
819 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
820 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
821
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
822 if ((UNBOUNDP (device) && UNBOUNDP (settings)) ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
823 (!UNBOUNDP (device) && !UNBOUNDP (settings)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
824 sferror ("Exactly one of :device and :printer-settings must be given",
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
825 keys);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
826
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
827 return print_dialog_worker (!UNBOUNDP (device) ? device : settings, flags);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
828 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
829
506
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
830 int
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
831 mswindows_get_default_margin (Lisp_Object prop)
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
832 {
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
833 if (EQ (prop, Qleft_margin)) return 1440;
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
834 if (EQ (prop, Qright_margin)) return 1440;
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
835 if (EQ (prop, Qtop_margin)) return 720;
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
836 if (EQ (prop, Qbottom_margin)) return 720;
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
837 abort ();
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
838 return 0;
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
839 }
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
840
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
841 static int
798
1f5108485fe7 [xemacs-hg @ 2002-03-29 18:26:33 by jhar]
jhar
parents: 793
diff changeset
842 plist_get_margin (Lisp_Object plist, Lisp_Object prop, int mm_p)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
843 {
506
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
844 Lisp_Object val =
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
845 Fplist_get (plist, prop, make_int (mswindows_get_default_margin (prop)));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
846 if (!INTP (val))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
847 invalid_argument ("Margin value must be an integer", val);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
848
798
1f5108485fe7 [xemacs-hg @ 2002-03-29 18:26:33 by jhar]
jhar
parents: 793
diff changeset
849 return MulDiv (XINT (val), mm_p ? 254 : 100, 144);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
850 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
851
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
852 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
853 plist_set_margin (Lisp_Object plist, Lisp_Object prop, int margin, int mm_p)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
854 {
798
1f5108485fe7 [xemacs-hg @ 2002-03-29 18:26:33 by jhar]
jhar
parents: 793
diff changeset
855 Lisp_Object val = make_int (MulDiv (margin, 144, mm_p ? 254 : 100));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
856 return Fcons (prop, Fcons (val, plist));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
857 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
858
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
859 Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
860 mswindows_handle_page_setup_dialog_box (struct frame *f, Lisp_Object keys)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
861 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
862 Lisp_Object device = Qunbound, settings = Qunbound;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
863 Lisp_Object plist = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
864
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
865 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
866 EXTERNAL_PROPERTY_LIST_LOOP_3 (key, value, keys)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
867 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
868 if (EQ (key, Q_device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
869 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
870 device = wrap_device (decode_device (value));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
871 CHECK_MSPRINTER_DEVICE (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
872 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
873 else if (EQ (key, Q_printer_settings))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
874 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
875 CHECK_DEVMODE (value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
876 settings = value;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
877 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
878 else if (EQ (key, Q_properties))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
879 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
880 CHECK_LIST (value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
881 plist = value;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
882 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
883 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
884 invalid_constant ("Unrecognized page-setup dialog keyword", key);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
885 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
886 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
887
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
888 if ((UNBOUNDP (device) && UNBOUNDP (settings)) ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
889 (!UNBOUNDP (device) && !UNBOUNDP (settings)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
890 sferror ("Exactly one of :device and :printer-settings must be given",
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 798
diff changeset
891 keys);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
892
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
893 if (UNBOUNDP (device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
894 device = settings;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
895
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
896 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
897 Lisp_Devmode *ldm = decode_devmode (device);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
898 PAGESETUPDLGW pd;
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
899 Extbyte measure[2 * MAX_XETCHAR_SIZE];
850
f915ad7befaf [xemacs-hg @ 2002-05-21 23:47:38 by jhar]
jhar
parents: 826
diff changeset
900 int data;
798
1f5108485fe7 [xemacs-hg @ 2002-03-29 18:26:33 by jhar]
jhar
parents: 793
diff changeset
901
850
f915ad7befaf [xemacs-hg @ 2002-05-21 23:47:38 by jhar]
jhar
parents: 826
diff changeset
902 qxeGetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_IMEASURE,
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
903 measure, sizeof (measure) / XETCHAR_SIZE);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
904 data = xetcscmp (measure, XETEXT ("0"));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
905
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
906 memset (&pd, 0, sizeof (pd));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
907 pd.lStructSize = sizeof (pd);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
908 pd.hwndOwner = mswindows_get_selected_frame_hwnd ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
909 pd.Flags = PSD_MARGINS;
798
1f5108485fe7 [xemacs-hg @ 2002-03-29 18:26:33 by jhar]
jhar
parents: 793
diff changeset
910 pd.rtMargin.left = plist_get_margin (plist, Qleft_margin, !data);
1f5108485fe7 [xemacs-hg @ 2002-03-29 18:26:33 by jhar]
jhar
parents: 793
diff changeset
911 pd.rtMargin.top = plist_get_margin (plist, Qtop_margin, !data);
1f5108485fe7 [xemacs-hg @ 2002-03-29 18:26:33 by jhar]
jhar
parents: 793
diff changeset
912 pd.rtMargin.right = plist_get_margin (plist, Qright_margin, !data);
1f5108485fe7 [xemacs-hg @ 2002-03-29 18:26:33 by jhar]
jhar
parents: 793
diff changeset
913 pd.rtMargin.bottom = plist_get_margin (plist, Qbottom_margin, !data);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
914 pd.hDevMode = devmode_to_hglobal (ldm);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
915
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
916 if (!qxePageSetupDlg (&pd))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
917 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
918 global_free_2_maybe (pd.hDevNames, pd.hDevMode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
919 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
920 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
921
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
922 if (pd.hDevMode)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
923 handle_devmode_changes (ldm, pd.hDevNames, pd.hDevMode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
924
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
925 /* Finally, build the resulting plist */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
926 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
927 Lisp_Object result = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
928 int mm_p = pd.Flags & PSD_INHUNDREDTHSOFMILLIMETERS;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
929 result = plist_set_margin (result, Qbottom_margin, pd.rtMargin.bottom,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
930 mm_p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
931 result = plist_set_margin (result, Qright_margin, pd.rtMargin.right,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
932 mm_p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
933 result = plist_set_margin (result, Qtop_margin, pd.rtMargin.top, mm_p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
934 result = plist_set_margin (result, Qleft_margin, pd.rtMargin.left, mm_p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
935 return result;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
936 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
937 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
938 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
939
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
940 DEFUN ("msprinter-get-settings", Fmsprinter_get_settings, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
941 Return the settings object currently used by DEVICE.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
942 The object returned is not a copy, but rather a pointer to the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
943 original one. Use `msprinter-settings-copy' to create a copy of it.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
944 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
945 (device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
946 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
947 struct device *d = decode_device (device);
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
948 device = wrap_device (d);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
949 CHECK_MSPRINTER_DEVICE (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
950 return DEVICE_MSPRINTER_DEVMODE (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
951 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
952
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
953 DEFUN ("msprinter-select-settings", Fmsprinter_select_settings, 2, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
954 Select SETTINGS object into a DEVICE.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
955 The settings from the settings object are immediately applied to the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
956 printer, possibly changing even the target printer itself, and all
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
957 future changes are applied synchronously to the printer device and the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
958 selected printer object, until a different settings object is selected
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
959 into the same printer.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
960
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
961 A settings object can be selected to no more than one printer at a time.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
962
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
963 If the supplied settings object is not specialized, it is specialized
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
964 for the printer immediately upon selection. The object can be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
965 despecialized after it is unselected by calling the function
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
966 `msprinter-settings-despecialize'.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
967
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
968 Return value is the previously selected settings object.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
969 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
970 (device, settings))
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
971 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
972 Lisp_Devmode *ldm;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
973 struct device *d = decode_device (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
974
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
975 struct gcpro gcpro1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
976 GCPRO1 (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
977
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
978 device = wrap_device (d);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
979 CHECK_MSPRINTER_DEVICE (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
980 CHECK_DEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
981 ldm = XDEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
982
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
983 if (!NILP (ldm->device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
984 invalid_operation ("The object is currently selected into a device",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
985 settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
986
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
987 /* If the object being selected is de-specialized, then its
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
988 size is perhaps not enough to receive the new devmode. We can ask
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
989 for printer's devmode size here, because despecialized settings
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
990 cannot force switching to a different printer, as they supply no
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
991 printer name at all. */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
992 if (NILP (ldm->printer_name))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
993 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
994 Extbyte *nameext;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
995 LONG dm_size;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
996
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
997 LISP_STRING_TO_TSTR (DEVICE_MSPRINTER_NAME (d), nameext);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
998 dm_size = qxeDocumentProperties (NULL, DEVICE_MSPRINTER_HPRINTER (d),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
999 nameext, NULL, NULL, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1000 if (dm_size <= 0)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
1001 signal_error (Qio_error,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
1002 "Unable to specialize settings, printer error",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
1003 device);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1004
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1005 assert (XDEVMODE_SIZE (ldm) <= dm_size);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1006 ldm->devmode = (DEVMODEW *) xrealloc (ldm->devmode, dm_size);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1007 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1008
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1009 /* If we bail out on signal here, no damage is done, except that
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1010 the storage for the DEVMODE structure might be reallocated to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1011 hold a larger one - not a big deal */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1012 if (!sync_printer_with_devmode (d, ldm->devmode, ldm->devmode,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1013 ldm->printer_name))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
1014 signal_error (Qio_error,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
1015 "Printer device initialization I/O error, device deleted",
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1016 device);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1017
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1018 if (NILP (ldm->printer_name ))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1019 ldm->printer_name = DEVICE_MSPRINTER_NAME (d);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1020
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1021 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1022 Lisp_Object old_mode = DEVICE_MSPRINTER_DEVMODE (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1023 ldm->device = device;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1024 XDEVMODE (old_mode)->device = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1025 DEVICE_MSPRINTER_DEVMODE (d) = settings;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1026 UNGCPRO;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1027 return old_mode;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1028 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1029 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1030
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1031 DEFUN ("msprinter-apply-settings", Fmsprinter_apply_settings, 2, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1032 Apply settings from a SETTINGS object to a 'msprinter DEVICE.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1033 The settings from the settings object are immediately applied to the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1034 printer, possibly changing even the target printer itself. The SETTING
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1035 object is not modified, unlike `msprinter-select-settings', and the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1036 supplied object is not changed. The changes are immediately recorded
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1037 into the settings object which is currently selected into the printer
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1038 device.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1039
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1040 Return value is the currently selected settings object.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1041 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1042 (device, settings))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1043 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1044 Lisp_Devmode *ldm_current, *ldm_new;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1045 struct device *d = decode_device (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1046
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1047 struct gcpro gcpro1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1048 GCPRO1 (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1049
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1050 device = wrap_device (d);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1051 CHECK_MSPRINTER_DEVICE (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1052 CHECK_DEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1053 ldm_new = XDEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1054 ldm_current = XDEVMODE (DEVICE_MSPRINTER_DEVMODE (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1055
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1056 /* If the supplied devmode is not specialized, then the current
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1057 devmode size will always be sufficient, as the printer does
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1058 not change. If it is specialized, we must reallocate the current
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1059 devmode storage to match with the supplied one, as it has the right
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1060 size for the new printer, if it is going to change. The correct
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1061 way is to use the largest of the two though, to keep the old
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1062 contents unchanged in case of preliminary exit.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1063 */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1064 if (!NILP (ldm_new->printer_name))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1065 ldm_current->devmode =
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1066 (DEVMODEW*) xrealloc (ldm_current->devmode,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1067 max (XDEVMODE_SIZE (ldm_new),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1068 XDEVMODE_SIZE (ldm_current)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1069
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1070 if (!sync_printer_with_devmode (d, ldm_new->devmode,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1071 ldm_current->devmode,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1072 ldm_new->printer_name))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1073 signal_error
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1074 (Qio_error,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1075 "Printer device initialization I/O error, device deleted", device);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1076
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1077 if (!NILP (ldm_new->printer_name))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1078 ldm_current->printer_name = ldm_new->printer_name;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1079
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1080 UNGCPRO;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1081 return DEVICE_MSPRINTER_DEVMODE (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1082 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1083
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1084 /************************************************************************/
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1085 /* devmode */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1086 /************************************************************************/
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1087
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
1088 static const struct memory_description devmode_description[] = {
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 903
diff changeset
1089 { XD_LISP_OBJECT, offsetof (struct Lisp_Devmode, printer_name) },
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 934
diff changeset
1090 { XD_LISP_OBJECT, offsetof (struct Lisp_Devmode, device) },
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 903
diff changeset
1091 { XD_END }
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 903
diff changeset
1092 };
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 903
diff changeset
1093
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1094 static Lisp_Object
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1095 mark_devmode (Lisp_Object obj)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1096 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1097 Lisp_Devmode *data = XDEVMODE (obj);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1098 mark_object (data->printer_name);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1099 return data->device;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1100 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1101
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1102 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1103 print_devmode (Lisp_Object obj, Lisp_Object printcharfun,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1104 int escapeflag)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1105 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1106 Lisp_Devmode *dm = XDEVMODE (obj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1107 if (print_readably)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
1108 printing_unreadable_object ("#<msprinter-settings 0x%x>",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
1109 dm->header.uid);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 800
diff changeset
1110 write_c_string (printcharfun, "#<msprinter-settings");
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1111 if (!NILP (dm->printer_name))
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 798
diff changeset
1112 write_fmt_string_lisp (printcharfun, " for %S", 1, dm->printer_name);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1113 if (!NILP (dm->device))
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 798
diff changeset
1114 write_fmt_string_lisp (printcharfun, " (currently on %s)", 1, dm->device);
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 798
diff changeset
1115 write_fmt_string (printcharfun, " 0x%x>", dm->header.uid);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1116 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1117
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1118 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1119 finalize_devmode (void *header, int for_disksave)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1120 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1121 Lisp_Devmode *dm = (Lisp_Devmode *) header;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1122
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1123 if (for_disksave)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1124 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1125 Lisp_Object devmode = wrap_devmode (dm);
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1126
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1127 invalid_operation
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1128 ("Cannot dump XEmacs containing an msprinter-settings object",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1129 devmode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1130 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1131
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1132 assert (NILP (dm->device));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1133 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1134
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1135 static int
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1136 equal_devmode (Lisp_Object obj1, Lisp_Object obj2, int depth)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1137 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1138 Lisp_Devmode *dm1 = XDEVMODE (obj1);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1139 Lisp_Devmode *dm2 = XDEVMODE (obj2);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1140
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1141 if ((dm1->devmode != NULL) != (dm1->devmode != NULL))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1142 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1143 if (dm1->devmode == NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1144 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1145 if (memcmp (dm1->devmode, dm2->devmode, XDEVMODE_SIZE (dm1)) != 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1146 return 0;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1147 if (NILP (dm1->printer_name) || NILP (dm2->printer_name))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1148 return 1;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1149 return lisp_strcasecmp (dm1->printer_name, dm2->printer_name) == 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1150 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1151
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 659
diff changeset
1152 static Hashcode
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1153 hash_devmode (Lisp_Object obj, int depth)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1154 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1155 Lisp_Devmode *dm = XDEVMODE (obj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1156
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1157 return HASH3 (XDEVMODE_SIZE (dm),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1158 dm->devmode ? memory_hash (dm->devmode, XDEVMODE_SIZE (dm))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1159 : 0,
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1160 internal_hash (dm->printer_name, depth + 1));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1161 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1162
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 903
diff changeset
1163 DEFINE_LRECORD_IMPLEMENTATION ("msprinter-settings", devmode,
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 934
diff changeset
1164 0, /*dumpable-flag*/
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 903
diff changeset
1165 mark_devmode, print_devmode, finalize_devmode,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 903
diff changeset
1166 equal_devmode, hash_devmode,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 903
diff changeset
1167 devmode_description,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 903
diff changeset
1168 Lisp_Devmode);
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 903
diff changeset
1169
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1170 static Lisp_Object
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1171 allocate_devmode (DEVMODEW* src_devmode, int do_copy,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1172 Lisp_Object src_name, struct device *d)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1173 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1174 Lisp_Devmode *dm;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1175
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1176 dm = alloc_lcrecord_type (Lisp_Devmode, &lrecord_devmode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1177
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1178 if (d)
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1179 dm->device = wrap_device (d);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1180 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1181 dm->device = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1182
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1183 dm->printer_name = src_name;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1184
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1185 if (src_devmode != NULL && do_copy)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1186 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1187 dm->devmode = (DEVMODEW*) xmalloc (DEVMODE_SIZE (src_devmode));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1188 memcpy (dm->devmode, src_devmode, DEVMODE_SIZE (src_devmode));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1189 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1190 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1191 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1192 dm->devmode = src_devmode;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1193 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1194
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1195 return wrap_devmode (dm);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1196 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1197
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1198 DEFUN ("msprinter-settings-copy", Fmsprinter_settings_copy, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1199 Create and returns an exact copy of a printer settings object.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1200 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1201 (settings))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1202 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1203 Lisp_Devmode *dm;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1204
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1205 CHECK_DEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1206 dm = XDEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1207
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1208 return allocate_devmode (dm->devmode, 1, dm->printer_name, NULL);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1209 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1210
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1211 DEFUN ("msprinter-settings-despecialize", Fmsprinter_settings_despecialize, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1212 Erase printer-specific settings from a printer settings object.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1213 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1214 (settings))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1215 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1216 Lisp_Devmode *ldm;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1217 DEVMODEW *dm;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1218
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1219 CHECK_DEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1220 ldm = XDEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1221
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1222 if (!NILP (ldm->device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1223 invalid_operation ("The object is currently selected into a device",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1224 settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1225
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1226 dm = ldm->devmode;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1227
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1228 /* #### TODO. Either remove references to device specific bins,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1229 paper sizes etc, or signal an error of they are present. */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1230
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1231 dm->dmDriverExtra = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1232 dm->dmDeviceName[0] = '\0';
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1233
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1234 ldm->printer_name = Qnil;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1235
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1236 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1237 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1238
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1239 DEFUN ("mswindows-get-default-printer", Fmswindows_get_default_printer, 0, 0, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1240 Return name of the default printer, as string, on nil if there is no default.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1241 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1242 ())
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1243 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1244 return msprinter_default_printer ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1245 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1246
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1247 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1248 signal_enum_printer_error (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1249 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1250 invalid_operation ("Error enumerating printers", make_int (GetLastError ()));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1251 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1252
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1253 DEFUN ("mswindows-printer-list", Fmswindows_printer_list, 0, 0, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1254 Return a list of string names of installed printers.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1255 If there is a default printer, it is returned as the first element of
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1256 the list. If there is no default printer, the first element of the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1257 list will be nil. The rest of elements are guaranteed to have string
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1258 values. Return value is nil if there are no printers installed.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1259 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1260 ())
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1261 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1262 int have_nt, ok;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1263 BYTE *data_buf, dummy_byte;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 659
diff changeset
1264 Bytecount enum_entry_size;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1265 DWORD enum_flags, enum_level, bytes_needed, num_printers;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1266 struct gcpro gcpro1, gcpro2;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1267 Lisp_Object result = Qnil, def_printer = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1268
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1269 /* Determine OS flavor, to use the fastest enumeration method available */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1270 have_nt = !mswindows_windows9x_p;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1271 enum_flags = PRINTER_ENUM_LOCAL | (have_nt ? PRINTER_ENUM_CONNECTIONS : 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1272 enum_level = have_nt ? 4 : 5;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1273 enum_entry_size = (have_nt ? sizeof (PRINTER_INFO_4) :
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1274 sizeof (PRINTER_INFO_5));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1275
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1276 /* Allocate memory for printer enum structure */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1277 ok = qxeEnumPrinters (enum_flags, NULL, enum_level, &dummy_byte, 1,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1278 &bytes_needed, &num_printers);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1279 if (ok)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1280 /* No printers, if just 1 byte is enough */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1281 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1282
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1283 if (GetLastError () != ERROR_INSUFFICIENT_BUFFER)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1284 signal_enum_printer_error ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1285
851
e7ee5f8bde58 [xemacs-hg @ 2002-05-23 11:46:08 by ben]
ben
parents: 850
diff changeset
1286 data_buf = (BYTE *) ALLOCA (bytes_needed);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1287 ok = qxeEnumPrinters (enum_flags, NULL, enum_level, data_buf, bytes_needed,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1288 &bytes_needed, &num_printers);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1289 if (!ok)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1290 signal_enum_printer_error ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1291
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1292 if (num_printers == 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1293 /* Strange but... */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1294 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1295
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1296 GCPRO2 (result, def_printer);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1297
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1298 while (num_printers--)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1299 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1300 Extbyte *printer_name;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1301 if (have_nt)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1302 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1303 PRINTER_INFO_4 *info = (PRINTER_INFO_4 *) data_buf;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1304 printer_name = (Extbyte *) info->pPrinterName;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1305 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1306 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1307 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1308 PRINTER_INFO_5 *info = (PRINTER_INFO_5 *) data_buf;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1309 printer_name = (Extbyte *) info->pPrinterName;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1310 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1311 data_buf += enum_entry_size;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1312
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1313 result = Fcons (build_tstr_string (printer_name), result);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1314 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1315
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1316 def_printer = msprinter_default_printer ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1317 result = Fdelete (def_printer, result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1318 result = Fcons (def_printer, result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1319
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1320 RETURN_UNGCPRO (result);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1321 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1322
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1323
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1324 /************************************************************************/
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1325 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1326 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1327
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1328 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1329 syms_of_device_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1330 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1331 INIT_LRECORD_IMPLEMENTATION (devmode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1332
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1333 DEFSUBR (Fmsprinter_get_settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1334 DEFSUBR (Fmsprinter_select_settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1335 DEFSUBR (Fmsprinter_apply_settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1336 DEFSUBR (Fmsprinter_settings_copy);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1337 DEFSUBR (Fmsprinter_settings_despecialize);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1338 DEFSUBR (Fmswindows_get_default_printer);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1339 DEFSUBR (Fmswindows_printer_list);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1340
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
1341 DEFKEYWORD (Q_allow_selection);
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
1342 DEFKEYWORD (Q_allow_pages);
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
1343 DEFKEYWORD (Q_selected_page_button);
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
1344 DEFSYMBOL (Qselected_page_button);
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
1345
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
1346 DEFSYMBOL (Qinit_pre_mswindows_win);
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
1347 DEFSYMBOL (Qinit_post_mswindows_win);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 console_type_create_device_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 CONSOLE_HAS_METHOD (mswindows, init_device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354 CONSOLE_HAS_METHOD (mswindows, finish_init_device);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1355 CONSOLE_HAS_METHOD (mswindows, mark_device);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 CONSOLE_HAS_METHOD (mswindows, delete_device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357 CONSOLE_HAS_METHOD (mswindows, device_system_metrics);
545
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 510
diff changeset
1358 CONSOLE_IMPLEMENTATION_FLAGS (mswindows, XDEVIMPF_PIXEL_GEOMETRY);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1359
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1360 CONSOLE_HAS_METHOD (msprinter, init_device);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1361 CONSOLE_HAS_METHOD (msprinter, mark_device);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1362 CONSOLE_HAS_METHOD (msprinter, delete_device);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1363 CONSOLE_HAS_METHOD (msprinter, device_system_metrics);
545
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 510
diff changeset
1364 CONSOLE_IMPLEMENTATION_FLAGS (msprinter, (XDEVIMPF_PIXEL_GEOMETRY
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 510
diff changeset
1365 | XDEVIMPF_IS_A_PRINTER
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 510
diff changeset
1366 | XDEVIMPF_NO_AUTO_REDISPLAY
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 510
diff changeset
1367 | XDEVIMPF_DONT_PREEMPT_REDISPLAY
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 510
diff changeset
1368 | XDEVIMPF_FRAMELESS_OK));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1371
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1372 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 vars_of_device_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 }