annotate src/w32menu.c @ 109165:750db9f3e6d8

Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp * alloc.c (overrun_check_malloc, overrun_check_realloc) (overrun_check_free, xstrdup, allocate_string) (allocate_string_data, compact_small_strings, Fmake_string) (make_unibyte_string, make_multibyte_string) (make_string_from_bytes, make_specified_string, make_float) (Fcons, allocate_terminal, allocate_frame, make_pure_string) (Fgarbage_collect): Replace bcopy, safe_bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp. * atimer.c (start_atimer, set_alarm): Likewise. * buffer.c (clone_per_buffer_values, report_overlay_modification) (mmap_realloc, init_buffer_once): Likewise. * callint.c (Fcall_interactively): Likewise. * callproc.c (Fcall_process, Fcall_process_region, child_setup) (getenv_internal_1): Likewise. * casefiddle.c (casify_object): Likewise. * ccl.c (ccl_driver): Likewise. * character.c (str_as_multibyte, str_to_multibyte): Likewise. * charset.c (load_charset_map_from_file) (load_charset_map_from_file, load_charset_map_from_vector) (Fdefine_charset_internal): Likewise. * cm.c (Wcm_clear): Likewise. * coding.c (decode_eol, decode_coding_object) (Fset_coding_system_priority, make_subsidiaries): Likewise. * data.c (Faset): Likewise. * dired.c (directory_files_internal, file_name_completion_stat): Likewise. * dispnew.c (new_glyph_matrix, adjust_glyph_matrix) (clear_glyph_row, copy_row_except_pointers) (copy_glyph_row_contents, new_glyph_pool, realloc_glyph_pool) (save_current_matrix, restore_current_matrix) (build_frame_matrix_from_leaf_window, mirrored_line_dance) (mirror_line_dance, scrolling_window): Likewise. * doc.c (Fsnarf_documentation, Fsubstitute_command_keys): Likewise. * doprnt.c (doprnt): Likewise. * editfns.c (Fuser_full_name, make_buffer_string_both) (Fmessage_box, Fformat, Ftranspose_regions): Likewise. * emacs.c (sort_args): Likewise. * eval.c (Fapply, Ffuncall): Likewise. * fileio.c (Ffile_name_directory, make_temp_name) (Fexpand_file_name, search_embedded_absfilename) (Fsubstitute_in_file_name, Ffile_symlink_p, Finsert_file_contents) (auto_save_error): Likewise. * fns.c (Fstring_equal, Fcopy_sequence, concat) (string_to_multibyte, Fstring_as_unibyte, Fstring_as_multibyte) (internal_equal, Fclear_string, larger_vector, copy_hash_table) (Fmake_hash_table): Likewise. * fringe.c (Fdefine_fringe_bitmap): Likewise. * ftfont.c (ftfont_text_extents): Likewise. * getloadavg.c (getloadavg): Likewise. * image.c (define_image_type, make_image, make_image_cache) (x_create_x_image_and_pixmap, xbm_image_p) (w32_create_pixmap_from_bitmap_data, xbm_load, xpm_lookup_color) (xpm_image_p, x_create_bitmap_from_xpm_data, xpm_load) (init_color_table, x_build_heuristic_mask, pbm_image_p, pbm_load) (png_image_p, png_read_from_memory, png_load, jpeg_image_p) (tiff_image_p, tiff_read_from_memory, gif_image_p) (gif_read_from_memory, gif_load, svg_image_p, gs_image_p): Likewise. * indent.c (scan_for_column, compute_motion): Likewise. * insdel.c (gap_left, gap_right, make_gap_smaller, copy_text) (insert_1_both, insert_from_gap, replace_range_2): Likewise. * intervals.c (reproduce_tree, reproduce_tree_obj): Likewise. * keyboard.c (echo_char, save_getcjmp, restore_getcjmp) (kbd_buffer_store_event_hold, apply_modifiers_uncached) (store_user_signal_events, menu_bar_items, tool_bar_items) (process_tool_bar_item, append_tool_bar_item) (read_char_minibuf_menu_prompt, read_key_sequence) (Fread_key_sequence, Fread_key_sequence_vector, Frecent_keys): Likewise. * keymap.c (current_minor_maps, Fdescribe_buffer_bindings): Likewise. * lisp.h (STRING_COPYIN): Likewise. * lread.c (Fload, read1, oblookup): Likewise. * msdos.c (Frecent_doskeys): Likewise. * nsfns.m (Fx_create_frame): Likewise. * nsfont.m (nsfont_open, nsfont_text_extents, ns_glyph_metrics): Likewise. * nsimage.m (EmacsImage-initFromSkipXBM:width:height:) (EmacsImage-initForXPMWithDepth:width:height:flip:length:): Likewise. * nsmenu.m (ns_update_menubar): Likewise. * nsterm.m (ns_draw_fringe_bitmap, ns_term_init): Likewise. * print.c (print_unwind, printchar, strout, print_string) (print_error_message): Likewise. * process.c (conv_lisp_to_sockaddr, set_socket_option) (Fmake_network_process, Fnetwork_interface_list) (Fnetwork_interface_info, read_process_output, Fprocess_send_eof) (init_process): Likewise. * ralloc.c (resize_bloc, r_alloc_sbrk, r_alloc_init): Likewise. * regex.c (init_syntax_once, regex_compile, re_compile_fastmap): Likewise. * scroll.c (do_scrolling, do_direct_scrolling) (scrolling_max_lines_saved): Likewise. * search.c (search_buffer, wordify, Freplace_match): Likewise. * sound.c (wav_init, au_init, Fplay_sound_internal): Likewise. * syntax.c (skip_chars, skip_syntaxes): Likewise. * sysdep.c (child_setup_tty, sys_subshell, emacs_get_tty) (emacs_set_tty): Likewise. * term.c (encode_terminal_code, calculate_costs) (produce_special_glyphs, create_tty_output, init_tty, delete_tty): Likewise. * termcap.c (tgetst1, gobble_line): Likewise. * termhooks.h (EVENT_INIT): Likewise. * tparam.c (tparam1): Likewise. * unexalpha.c (unexec): Likewise. * unexec.c (write_segment): Likewise. * unexmacosx.c (unexec_write_zero): Likewise. * w32fns.c (w32_wnd_proc, Fx_create_frame, x_create_tip_frame) (Fx_file_dialog, Fsystem_move_file_to_trash): Likewise. * w32font.c (w32font_list_family, w32font_text_extents) (w32font_list_internal, w32font_match_internal) (w32font_open_internal, compute_metrics, Fx_select_font): Likewise. * w32menu.c (set_frame_menubar, add_menu_item) (w32_menu_display_help, w32_free_submenu_strings): Likewise. * w32term.c (XCreateGC, w32_initialize_display_info): Likewise. * w32uniscribe.c (uniscribe_list_family): Likewise. * w32xfns.c (get_next_msg, post_msg, prepend_msg): Likewise. * window.c (make_window, replace_window, set_window_buffer) (Fsplit_window): Likewise. * xdisp.c (init_iterator, RECORD_OVERLAY_STRING, reseat_to_string) (add_to_log, message3, x_consider_frame_title) (append_space_for_newline, extend_face_to_end_of_line) (decode_mode_spec_coding, init_glyph_string): Likewise. * xfaces.c (x_create_gc, get_lface_attributes_no_remap) (Finternal_copy_lisp_face, Finternal_merge_in_global_face) (face_attr_equal_p, make_realized_face, make_face_cache) (free_realized_faces, lookup_named_face, smaller_face) (face_with_height, lookup_derived_face) (x_supports_face_attributes_p, Finternal_set_font_selection_order) (Finternal_set_font_selection_order, realize_default_face) (compute_char_face, face_at_buffer_position) (face_for_overlay_string, face_at_string_position, merge_faces): Likewise. * xfns.c (xic_create_fontsetname, Fx_create_frame) (Fx_window_property, x_create_tip_frame) (Fx_backspace_delete_keys_p): Likewise. * xfont.c (xfont_list, xfont_match, xfont_list_family) (xfont_text_extents): Likewise. * xmenu.c (set_frame_menubar, xmenu_show): Likewise. * xrdb.c (magic_file_p, x_get_resource): Likewise. * xselect.c (x_queue_event, x_get_window_property) (receive_incremental_selection): Likewise. * xsmfns.c (x_session_check_input): Likewise. * xterm.c (x_send_scroll_bar_event, SET_SAVED_MENU_EVENT) (handle_one_xevent, x_check_errors, xim_initialize, x_term_init): Likewise. * character.h (BCOPY_SHORT): Removed. * config.in: Regenerate. * dispnew.c (safe_bcopy): Only define as dummy if PROFILING. * emacs.c (main) [PROFILING]: Don't declare dump_opcode_frequencies. * lisp.h (safe_bcopy): Remove declaration. (memset) [!HAVE_MEMSET]: Declare. (memcpy) [!HAVE_MEMCPY]: Likewise. (memmove) [!HAVE_MEMMOVE]: Likewise. (memcmp) [!HAVE_MEMCMP]: Likewise. * s/ms-w32.h (bzero, bcopy, bcmp, GAP_USE_BCOPY) (BCOPY_UPWARD_SAFE, BCOPY_DOWNWARD_SAFE, HAVE_BCOPY, HAVE_BCMP): Don't define. (HAVE_MEMCMP, HAVE_MEMCPY, HAVE_MEMMOVE, HAVE_MEMSET): Define. * s/msdos.h (GAP_USE_BCOPY, BCOPY_UPWARD_SAFE) (BCOPY_DOWNWARD_SAFE): Don't define. * sysdep.c (memset) [!HAVE_MEMSET]: Define. (memcpy) [!HAVE_MEMCPY]: Define. (memmove) [!HAVE_MEMMOVE]: Define. (memcmp) [!HAVE_MEMCMP]: Define. * config.nt (HAVE_BCOPY, HAVE_BCMP): Remove undefs. (HAVE_MEMCPY, HAVE_MEMMOVE, HAVE_MEMSET, HAVE_MEMCMP): Add undefs. * sed2v2.inp (HAVE_MEMCPY, HAVE_MEMSET): Edit to 1. (HAVE_BZERO): Don't edit. * lwlib.c (lwlib_memset, lwlib_bcopy): Remove. (malloc_widget_value, free_widget_info, allocate_widget_instance) (lw_separator_p): Replace lwlib_memset, lwlib_bcopy, bzero, bcmp by memset, memcpy, memcmp. * lwlib-utils.c (XtApplyToWidgets): Likewise. * xlwmenu.c (XlwMenuInitialize): Likewise. * lwlib.h (lwlib_bcopy): Remove declaration. * ebrowse.c (add_sym, make_namespace): Replace bcopy, bzero by memcpy, memmove, memset. * pop.c (pop_retrieve, socket_connection, pop_getline): Likewise. * CPP-DEFINES (BCOPY_DOWNWARD_SAFE, BCOPY_UPWARD_SAFE) (GAP_USE_BCOPY, HAVE_BCMP, HAVE_BCOPY, bcmp, bcopy, bzero): Remove. * configure.in: Don't check for bcopy, bcmp, bzero. Don't include <strings.h> and don't define bcopy, bzero, BCMP in config.h.
author Andreas Schwab <schwab@linux-m68k.org>
date Thu, 08 Jul 2010 00:18:28 +0200
parents f8660b83cdbf
children 8cfee7d2955f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16884
36babc489b0c Change all uses of win95, winnt, and win32
Geoff Voelker <voelker@cs.washington.edu>
parents: 16860
diff changeset
1 /* Menu support for GNU Emacs on the Microsoft W32 API.
75227
e90d04cd455a Update copyright for years from Emacs 21 to present (mainly adding
Glenn Morris <rgm@gnu.org>
parents: 73788
diff changeset
2 Copyright (C) 1986, 1988, 1993, 1994, 1996, 1998, 1999, 2001, 2002,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105923
diff changeset
3 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
79759
fc2bcd2a8aad Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78260
diff changeset
4 Free Software Foundation, Inc.
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
5
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6 This file is part of GNU Emacs.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
7
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93979
diff changeset
8 GNU Emacs is free software: you can redistribute it and/or modify
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93979
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93979
diff changeset
11 (at your option) any later version.
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
12
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
13 GNU Emacs is distributed in the hope that it will be useful,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
16 GNU General Public License for more details.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
17
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93979
diff changeset
19 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
20
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25646
diff changeset
21 #include <config.h>
83572
244d6216c056 (Fx_popup_menu): Use terminal specific mouse_position_hook.
Jason Rumney <jasonr@gnu.org>
parents: 76086
diff changeset
22
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
23 #include <signal.h>
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
24 #include <stdio.h>
78015
cf89ff54912e (add_menu_item): Escape `&' characters in menu items and their keybindings.
Eli Zaretskii <eliz@gnu.org>
parents: 76086
diff changeset
25 #include <mbstring.h>
105669
68dd71358159 * alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 100951
diff changeset
26 #include <setjmp.h>
83572
244d6216c056 (Fx_popup_menu): Use terminal specific mouse_position_hook.
Jason Rumney <jasonr@gnu.org>
parents: 76086
diff changeset
27
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
28 #include "lisp.h"
31114
cd392fdf0e9f Include keyboard.h before frame.h. Fix compile
Andrew Innes <andrewi@gnu.org>
parents: 30989
diff changeset
29 #include "keyboard.h"
39690
38c1890338cc (keymap_panes, Fx_popup_menu): Use Fkeymap_prompt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39682
diff changeset
30 #include "keymap.h"
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
31 #include "frame.h"
83572
244d6216c056 (Fx_popup_menu): Use terminal specific mouse_position_hook.
Jason Rumney <jasonr@gnu.org>
parents: 76086
diff changeset
32 #include "termhooks.h"
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
33 #include "window.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
34 #include "blockinput.h"
15276
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
35 #include "buffer.h"
29320
33aa00975055 (single_submenu, w32_menu_show): Call ENCODE_SYSTEM on menu strings.
Jason Rumney <jasonr@gnu.org>
parents: 28275
diff changeset
36 #include "charset.h"
90928
14fbdb070a2f Include character.h
Jason Rumney <jasonr@gnu.org>
parents: 90920
diff changeset
37 #include "character.h"
29320
33aa00975055 (single_submenu, w32_menu_show): Call ENCODE_SYSTEM on menu strings.
Jason Rumney <jasonr@gnu.org>
parents: 28275
diff changeset
38 #include "coding.h"
105923
1011707400d3 * menu.c (Fx_popup_menu): Consolidate versions from xmenu.c,
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105669
diff changeset
39 #include "menu.h"
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
40
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
41 /* This may include sys/types.h, and that somehow loses
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
42 if this is not done before the other system files. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
43 #include "w32term.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
44
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
45 /* Load sys/types.h if not already loaded.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
46 In some systems loading it twice is suicidal. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
47 #ifndef makedev
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
48 #include <sys/types.h>
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
49 #endif
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
50
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
51 #include "dispextern.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
52
33971
c33b80a45f6a (add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents: 32988
diff changeset
53 #undef HAVE_DIALOGS /* TODO: Implement native dialogs. */
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
54
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
55 #ifndef TRUE
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
56 #define TRUE 1
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
57 #define FALSE 0
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
58 #endif /* no TRUE */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
59
76074
5978a80d504e (current_popup_menu): Make available globally.
Jason Rumney <jasonr@gnu.org>
parents: 75227
diff changeset
60 HMENU current_popup_menu;
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
61
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
62 void syms_of_w32menu (void);
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
63 void globals_of_w32menu (void);
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
64
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
65 typedef BOOL (WINAPI * GetMenuItemInfoA_Proc) (
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
66 IN HMENU,
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
67 IN UINT,
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
68 IN BOOL,
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
69 IN OUT LPMENUITEMINFOA);
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
70 typedef BOOL (WINAPI * SetMenuItemInfoA_Proc) (
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
71 IN HMENU,
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
72 IN UINT,
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
73 IN BOOL,
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
74 IN LPCMENUITEMINFOA);
48375
4d7b83cc03aa Added a partial implementation of play-sound-internal for Windows. Fixed the following entry in etc/PROBLEMS: Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs built on XP crashes at startup on Windows 9x/ME.
Ben Key <bkey1@tampabay.rr.com>
parents: 46815
diff changeset
75
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
76 GetMenuItemInfoA_Proc get_menu_item_info = NULL;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
77 SetMenuItemInfoA_Proc set_menu_item_info = NULL;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
78 AppendMenuW_Proc unicode_append_menu = NULL;
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
79
72773
15d914de92fd * src/macmenu.c (Vmenu_updating_frame, syms_of_xmenu):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72260
diff changeset
80 Lisp_Object Qdebug_on_next_call;
21612
24a01af0cd38 (Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 21450
diff changeset
81
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
82 extern Lisp_Object Qmenu_bar;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
83
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
84 extern Lisp_Object QCtoggle, QCradio;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
85
15276
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
86 extern Lisp_Object Voverriding_local_map;
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
87 extern Lisp_Object Voverriding_local_map_menu_flag;
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
88
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
89 extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map;
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
90
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
91 extern Lisp_Object Qmenu_bar_update_hook;
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
92
109100
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
93 void set_frame_menubar (FRAME_PTR, int, int);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
94
41637
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
95 #ifdef HAVE_DIALOGS
109100
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
96 static Lisp_Object w32_dialog_show (FRAME_PTR, int, Lisp_Object, char**);
93979
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
97 #else
109100
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
98 static int is_simple_dialog (Lisp_Object);
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
99 static Lisp_Object simple_dialog_show (FRAME_PTR, Lisp_Object, Lisp_Object);
41637
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
100 #endif
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
101
109100
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
102 void w32_free_menu_strings (HWND);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
103
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
104
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
105 /* This is set nonzero after the user activates the menu bar, and set
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
106 to zero again after the menu bars are redisplayed by prepare_menu_bar.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
107 While it is nonzero, all calls to set_frame_menubar go deep.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
108
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
109 I don't understand why this is needed, but it does seem to be
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
110 needed on Motif, according to Marcus Daniels <marcus@sysc.pdx.edu>. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
111
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
112 int pending_menu_activation;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
113
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
114
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
115 /* Return the frame whose ->output_data.w32->menubar_widget equals
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
116 ID, or 0 if none. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
117
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
118 static struct frame *
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
119 menubar_id_to_frame (HMENU id)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
120 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
121 Lisp_Object tail, frame;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
122 FRAME_PTR f;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
123
90970
3371fc48749b Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 90951
diff changeset
124 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
125 {
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 22750
diff changeset
126 frame = XCAR (tail);
90970
3371fc48749b Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 90951
diff changeset
127 if (!FRAMEP (frame))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
128 continue;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
129 f = XFRAME (frame);
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
130 if (!FRAME_WINDOW_P (f))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
131 continue;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
132 if (f->output_data.w32->menubar_widget == id)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
133 return f;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
134 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
135 return 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
136 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
137
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
138 #ifdef HAVE_MENUS
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
139
62670
5ba03d610746 (Fx_popup_dialog): Allow 3rd optional argument.
Nick Roberts <nickrob@snap.net.nz>
parents: 62668
diff changeset
140 DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 3, 0,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
141 doc: /* Pop up a dialog box and return user's selection.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
142 POSITION specifies which frame to use.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
143 This is normally a mouse button event or a window or frame.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
144 If POSITION is t, it means to use the frame the mouse is on.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
145 The dialog box appears in the middle of the specified frame.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
146
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
147 CONTENTS specifies the alternatives to display in the dialog box.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
148 It is a list of the form (TITLE ITEM1 ITEM2...).
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
149 Each ITEM is a cons cell (STRING . VALUE).
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
150 The return value is VALUE from the chosen item.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
151
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
152 An ITEM may also be just a string--that makes a nonselectable item.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
153 An ITEM may also be nil--that means to put all preceding items
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
154 on the left of the dialog box and all following items on the right.
62668
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
155 \(By default, approximately half appear on each side.)
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
156
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
157 If HEADER is non-nil, the frame title for the box is "Information",
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
158 otherwise it is "Question". */)
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
159 (position, contents, header)
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
160 Lisp_Object position, contents, header;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
161 {
40476
18b1b133e5c1 (Fx_popup_menu): Explicitly init f, xpos, and ypos.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40119
diff changeset
162 FRAME_PTR f = NULL;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
163 Lisp_Object window;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
164
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
165 check_w32 ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
166
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
167 /* Decode the first argument: find the window or frame to use. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
168 if (EQ (position, Qt)
32671
bbd3be4db5f2 (add_menu_item): Do not use MF_OWNERDRAW for titles, as it has stopped working.
Jason Rumney <jasonr@gnu.org>
parents: 31114
diff changeset
169 || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar)
bbd3be4db5f2 (add_menu_item): Do not use MF_OWNERDRAW for titles, as it has stopped working.
Jason Rumney <jasonr@gnu.org>
parents: 31114
diff changeset
170 || EQ (XCAR (position), Qtool_bar))))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
171 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
172 #if 0 /* Using the frame the mouse is on may not be right. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
173 /* Use the mouse's current position. */
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
174 FRAME_PTR new_f = SELECTED_FRAME ();
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
175 Lisp_Object bar_window;
31114
cd392fdf0e9f Include keyboard.h before frame.h. Fix compile
Andrew Innes <andrewi@gnu.org>
parents: 30989
diff changeset
176 enum scroll_bar_part part;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
177 unsigned long time;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
178 Lisp_Object x, y;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
179
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
180 (*mouse_position_hook) (&new_f, 1, &bar_window, &part, &x, &y, &time);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
181
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
182 if (new_f != 0)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
183 XSETFRAME (window, new_f);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
184 else
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
185 window = selected_window;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
186 #endif
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
187 window = selected_window;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
188 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
189 else if (CONSP (position))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
190 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
191 Lisp_Object tem;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
192 tem = Fcar (position);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
193 if (CONSP (tem))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
194 window = Fcar (Fcdr (position));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
195 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
196 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
197 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
198 window = Fcar (tem); /* POSN_WINDOW (tem) */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
199 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
200 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
201 else if (WINDOWP (position) || FRAMEP (position))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
202 window = position;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
203 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
204 window = Qnil;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
205
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
206 /* Decode where to put the menu. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
207
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
208 if (FRAMEP (window))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
209 f = XFRAME (window);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
210 else if (WINDOWP (window))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
211 {
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
212 CHECK_LIVE_WINDOW (window);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
213 f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
214 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
215 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
216 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
217 but I don't want to make one now. */
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
218 CHECK_WINDOW (window);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
219
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
220 #ifndef HAVE_DIALOGS
93979
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
221
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
222 {
93979
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
223 /* Handle simple Yes/No choices as MessageBox popups. */
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
224 if (is_simple_dialog (contents))
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
225 return simple_dialog_show (f, contents, header);
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
226 else
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
227 {
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
228 /* Display a menu with these alternatives
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
229 in the middle of frame F. */
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
230 Lisp_Object x, y, frame, newpos;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
231 XSETFRAME (frame, f);
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
232 XSETINT (x, x_pixel_width (f) / 2);
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
233 XSETINT (y, x_pixel_height (f) / 2);
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
234 newpos = Fcons (Fcons (x, Fcons (y, Qnil)), Fcons (frame, Qnil));
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
235 return Fx_popup_menu (newpos,
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
236 Fcons (Fcar (contents), Fcons (contents, Qnil)));
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
237 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
238 }
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
239 #else /* HAVE_DIALOGS */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
240 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
241 Lisp_Object title;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
242 char *error_name;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
243 Lisp_Object selection;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
244
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
245 /* Decode the dialog items from what was specified. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
246 title = Fcar (contents);
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40476
diff changeset
247 CHECK_STRING (title);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
248
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
249 list_of_panes (Fcons (contents, Qnil));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
250
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
251 /* Display them in a dialog box. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
252 BLOCK_INPUT;
62668
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
253 selection = w32_dialog_show (f, 0, title, header, &error_name);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
254 UNBLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
255
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
256 discard_menu_items ();
80759
c3bd08b7c78d (Fx_popup_menu, Fx_popup_dialog, w32_menu_show): Ensure mouse is not
Jason Rumney <jasonr@gnu.org>
parents: 79759
diff changeset
257 FRAME_X_DISPLAY_INFO (f)->grabbed = 0;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
258
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
259 if (error_name) error (error_name);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
260 return selection;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
261 }
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
262 #endif /* HAVE_DIALOGS */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
263 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
264
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
265 /* Activate the menu bar of frame F.
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
266 This is called from keyboard.c when it gets the
45803
9484de301252 Rename enum event_kind items.
Pavel Janík <Pavel@Janik.cz>
parents: 43471
diff changeset
267 MENU_BAR_ACTIVATE_EVENT out of the Emacs event queue.
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
268
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
269 To activate the menu bar, we signal to the input thread that it can
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
270 return from the WM_INITMENU message, allowing the normal Windows
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
271 processing of the menus.
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
272
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
273 But first we recompute the menu bar contents (the whole tree).
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
274
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
275 This way we can safely execute Lisp code. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
276
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
277 void
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
278 x_activate_menubar (FRAME_PTR f)
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
279 {
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
280 set_frame_menubar (f, 0, 1);
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
281
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
282 /* Lock out further menubar changes while active. */
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
283 f->output_data.w32->menubar_active = 1;
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
284
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
285 /* Signal input thread to return from WM_INITMENU. */
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
286 complete_deferred_msg (FRAME_W32_WINDOW (f), WM_INITMENU, 0);
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
287 }
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
288
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
289 /* This callback is called from the menu bar pulldown menu
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
290 when the user makes a selection.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
291 Figure out what the user chose
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
292 and put the appropriate events into the keyboard buffer. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
293
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
294 void
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
295 menubar_selection_callback (FRAME_PTR f, void * client_data)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
296 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
297 Lisp_Object prefix, entry;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
298 Lisp_Object vector;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
299 Lisp_Object *subprefix_stack;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
300 int submenu_depth = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
301 int i;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
302
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
303 if (!f)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
304 return;
38371
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
305 entry = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
306 subprefix_stack = (Lisp_Object *) alloca (f->menu_bar_items_used * sizeof (Lisp_Object));
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
307 vector = f->menu_bar_vector;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
308 prefix = Qnil;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
309 i = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
310 while (i < f->menu_bar_items_used)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
311 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
312 if (EQ (AREF (vector, i), Qnil))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
313 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
314 subprefix_stack[submenu_depth++] = prefix;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
315 prefix = entry;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
316 i++;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
317 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
318 else if (EQ (AREF (vector, i), Qlambda))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
319 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
320 prefix = subprefix_stack[--submenu_depth];
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
321 i++;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
322 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
323 else if (EQ (AREF (vector, i), Qt))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
324 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
325 prefix = AREF (vector, i + MENU_ITEMS_PANE_PREFIX);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
326 i += MENU_ITEMS_PANE_LENGTH;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
327 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
328 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
329 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
330 entry = AREF (vector, i + MENU_ITEMS_ITEM_VALUE);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
331 /* The EMACS_INT cast avoids a warning. There's no problem
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
332 as long as pointers have enough bits to hold small integers. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
333 if ((int) (EMACS_INT) client_data == i)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
334 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
335 int j;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
336 struct input_event buf;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
337 Lisp_Object frame;
51573
861a49cd70cf (menubar_selection_callback): Don't pass uninitialized
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51206
diff changeset
338 EVENT_INIT (buf);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
339
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
340 XSETFRAME (frame, f);
30178
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
341 buf.kind = MENU_BAR_EVENT;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
342 buf.frame_or_window = frame;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
343 buf.arg = frame;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
344 kbd_buffer_store_event (&buf);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
345
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
346 for (j = 0; j < submenu_depth; j++)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
347 if (!NILP (subprefix_stack[j]))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
348 {
30178
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
349 buf.kind = MENU_BAR_EVENT;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
350 buf.frame_or_window = frame;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
351 buf.arg = subprefix_stack[j];
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
352 kbd_buffer_store_event (&buf);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
353 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
354
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
355 if (!NILP (prefix))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
356 {
30178
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
357 buf.kind = MENU_BAR_EVENT;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
358 buf.frame_or_window = frame;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
359 buf.arg = prefix;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
360 kbd_buffer_store_event (&buf);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
361 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
362
30178
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
363 buf.kind = MENU_BAR_EVENT;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
364 buf.frame_or_window = frame;
6d045b9631ad (menubar_selection_callback): Use the `arg' slot of
Gerd Moellmann <gerd@gnu.org>
parents: 30145
diff changeset
365 buf.arg = entry;
76074
5978a80d504e (current_popup_menu): Make available globally.
Jason Rumney <jasonr@gnu.org>
parents: 75227
diff changeset
366 /* Free memory used by owner-drawn and help-echo strings. */
5978a80d504e (current_popup_menu): Make available globally.
Jason Rumney <jasonr@gnu.org>
parents: 75227
diff changeset
367 w32_free_menu_strings (FRAME_W32_WINDOW (f));
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
368 kbd_buffer_store_event (&buf);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
369
43471
20574c51c791 (menubar_selection_callback): Free the menu and
Jason Rumney <jasonr@gnu.org>
parents: 42613
diff changeset
370 f->output_data.w32->menubar_active = 0;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
371 return;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
372 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
373 i += MENU_ITEMS_ITEM_LENGTH;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
374 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
375 }
43471
20574c51c791 (menubar_selection_callback): Free the menu and
Jason Rumney <jasonr@gnu.org>
parents: 42613
diff changeset
376 /* Free memory used by owner-drawn and help-echo strings. */
20574c51c791 (menubar_selection_callback): Free the menu and
Jason Rumney <jasonr@gnu.org>
parents: 42613
diff changeset
377 w32_free_menu_strings (FRAME_W32_WINDOW (f));
20574c51c791 (menubar_selection_callback): Free the menu and
Jason Rumney <jasonr@gnu.org>
parents: 42613
diff changeset
378 f->output_data.w32->menubar_active = 0;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
379 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
380
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
381
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
382 /* Set the contents of the menubar widgets of frame F.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
383 The argument FIRST_TIME is currently ignored;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
384 it is set the first time this is called, from initialize_frame_menubar. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
385
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
386 void
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
387 set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
388 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
389 HMENU menubar_widget = f->output_data.w32->menubar_widget;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
390 Lisp_Object items;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
391 widget_value *wv, *first_wv, *prev_wv = 0;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
392 int i, last_i;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
393 int *submenu_start, *submenu_end;
49348
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
394 int *submenu_top_level_items, *submenu_n_panes;
21612
24a01af0cd38 (Vmenu_updating_frame): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 21450
diff changeset
395
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
396 /* We must not change the menubar when actually in use. */
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
397 if (f->output_data.w32->menubar_active)
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
398 return;
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
399
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
400 XSETFRAME (Vmenu_updating_frame, f);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
401
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
402 if (! menubar_widget)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
403 deep_p = 1;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
404 else if (pending_menu_activation && !deep_p)
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
405 deep_p = 1;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
406
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
407 if (deep_p)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
408 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
409 /* Make a widget-value tree representing the entire menu trees. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
410
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
411 struct buffer *prev = current_buffer;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
412 Lisp_Object buffer;
46293
1fb8f75062c6 Use macro SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents: 45803
diff changeset
413 int specpdl_count = SPECPDL_INDEX ();
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
414 int previous_menu_items_used = f->menu_bar_items_used;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
415 Lisp_Object *previous_items
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
416 = (Lisp_Object *) alloca (previous_menu_items_used
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
417 * sizeof (Lisp_Object));
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
418
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
419 /* If we are making a new widget, its contents are empty,
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
420 do always reinitialize them. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
421 if (! menubar_widget)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
422 previous_menu_items_used = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
423
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
424 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
425 specbind (Qinhibit_quit, Qt);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
426 /* Don't let the debugger step into this code
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
427 because it is not reentrant. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
428 specbind (Qdebug_on_next_call, Qnil);
15276
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
429
63147
9bde03db5726 * composite.c (compose_chars_in_text):
Kim F. Storm <storm@cua.dk>
parents: 62670
diff changeset
430 record_unwind_save_match_data ();
9bde03db5726 * composite.c (compose_chars_in_text):
Kim F. Storm <storm@cua.dk>
parents: 62670
diff changeset
431
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
432 if (NILP (Voverriding_local_map_menu_flag))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
433 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
434 specbind (Qoverriding_terminal_local_map, Qnil);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
435 specbind (Qoverriding_local_map, Qnil);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
436 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
437
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
438 set_buffer_internal_1 (XBUFFER (buffer));
15276
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
439
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
440 /* Run the Lucid hook. */
36313
77093a87f2de * w32menu.c (set_frame_menubar): Run activate-menu-bar-hook with
Jason Rumney <jasonr@gnu.org>
parents: 33971
diff changeset
441 safe_run_hooks (Qactivate_menubar_hook);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
442 /* If it has changed current-menubar from previous value,
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
443 really recompute the menubar from the value. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
444 if (! NILP (Vlucid_menu_bar_dirty_flag))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
445 call0 (Qrecompute_lucid_menubar);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
446 safe_run_hooks (Qmenu_bar_update_hook);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
447 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
448
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
449 items = FRAME_MENU_BAR_ITEMS (f);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
450
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
451 /* Save the frame's previous menu bar contents data. */
39507
24530f82048e (set_frame_menubar): Take into account that
Andrew Innes <andrewi@gnu.org>
parents: 38371
diff changeset
452 if (previous_menu_items_used)
109165
750db9f3e6d8 Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents: 109160
diff changeset
453 memcpy (previous_items, XVECTOR (f->menu_bar_vector)->contents,
750db9f3e6d8 Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents: 109160
diff changeset
454 previous_menu_items_used * sizeof (Lisp_Object));
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
455
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
456 /* Fill in menu_items with the current menu bar contents.
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
457 This can evaluate Lisp code. */
95732
6488b258c0aa (set_frame_menubar): Sync with version in xmenu.c.
Jason Rumney <jasonr@gnu.org>
parents: 95728
diff changeset
458 save_menu_items ();
6488b258c0aa (set_frame_menubar): Sync with version in xmenu.c.
Jason Rumney <jasonr@gnu.org>
parents: 95728
diff changeset
459
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
460 menu_items = f->menu_bar_vector;
39507
24530f82048e (set_frame_menubar): Take into account that
Andrew Innes <andrewi@gnu.org>
parents: 38371
diff changeset
461 menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
462 submenu_start = (int *) alloca (XVECTOR (items)->size * sizeof (int *));
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
463 submenu_end = (int *) alloca (XVECTOR (items)->size * sizeof (int *));
49348
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
464 submenu_n_panes = (int *) alloca (XVECTOR (items)->size * sizeof (int));
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
465 submenu_top_level_items
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
466 = (int *) alloca (XVECTOR (items)->size * sizeof (int *));
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
467 init_menu_items ();
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
468 for (i = 0; i < ASIZE (items); i += 4)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
469 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
470 Lisp_Object key, string, maps;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
471
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
472 last_i = i;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
473
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
474 key = AREF (items, i);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
475 string = AREF (items, i + 1);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
476 maps = AREF (items, i + 2);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
477 if (NILP (string))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
478 break;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
479
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
480 submenu_start[i] = menu_items_used;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
481
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
482 menu_items_n_panes = 0;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
483 submenu_top_level_items[i]
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
484 = parse_single_submenu (key, string, maps);
49348
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
485 submenu_n_panes[i] = menu_items_n_panes;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
486
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
487 submenu_end[i] = menu_items_used;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
488 }
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
489
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
490 finish_menu_items ();
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
491
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
492 /* Convert menu_items into widget_value trees
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
493 to display the menu. This cannot evaluate Lisp code. */
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
494
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
495 wv = xmalloc_widget_value ();
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
496 wv->name = "menubar";
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
497 wv->value = 0;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
498 wv->enabled = 1;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
499 wv->button_type = BUTTON_TYPE_NONE;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
500 wv->help = Qnil;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
501 first_wv = wv;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
502
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
503 for (i = 0; i < last_i; i += 4)
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
504 {
49348
08ac5c346b16 (digest_single_submenu): Declare all args.
Jason Rumney <jasonr@gnu.org>
parents: 48888
diff changeset
505 menu_items_n_panes = submenu_n_panes[i];
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
506 wv = digest_single_submenu (submenu_start[i], submenu_end[i],
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
507 submenu_top_level_items[i]);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
508 if (prev_wv)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
509 prev_wv->next = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
510 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
511 first_wv->contents = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
512 /* Don't set wv->name here; GC during the loop might relocate it. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
513 wv->enabled = 1;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
514 wv->button_type = BUTTON_TYPE_NONE;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
515 prev_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
516 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
517
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
518 set_buffer_internal_1 (prev);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
519
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
520 /* If there has been no change in the Lisp-level contents
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
521 of the menu bar, skip redisplaying it. Just exit. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
522
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
523 for (i = 0; i < previous_menu_items_used; i++)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
524 if (menu_items_used == i
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
525 || (!EQ (previous_items[i], AREF (menu_items, i))))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
526 break;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
527 if (i == menu_items_used && i == previous_menu_items_used && i != 0)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
528 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
529 free_menubar_widget_value_tree (first_wv);
95732
6488b258c0aa (set_frame_menubar): Sync with version in xmenu.c.
Jason Rumney <jasonr@gnu.org>
parents: 95728
diff changeset
530 discard_menu_items ();
6488b258c0aa (set_frame_menubar): Sync with version in xmenu.c.
Jason Rumney <jasonr@gnu.org>
parents: 95728
diff changeset
531 unbind_to (specpdl_count, Qnil);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
532 return;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
533 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
534
95732
6488b258c0aa (set_frame_menubar): Sync with version in xmenu.c.
Jason Rumney <jasonr@gnu.org>
parents: 95728
diff changeset
535 f->menu_bar_vector = menu_items;
6488b258c0aa (set_frame_menubar): Sync with version in xmenu.c.
Jason Rumney <jasonr@gnu.org>
parents: 95728
diff changeset
536 f->menu_bar_items_used = menu_items_used;
6488b258c0aa (set_frame_menubar): Sync with version in xmenu.c.
Jason Rumney <jasonr@gnu.org>
parents: 95728
diff changeset
537
6488b258c0aa (set_frame_menubar): Sync with version in xmenu.c.
Jason Rumney <jasonr@gnu.org>
parents: 95728
diff changeset
538 /* This undoes save_menu_items. */
6488b258c0aa (set_frame_menubar): Sync with version in xmenu.c.
Jason Rumney <jasonr@gnu.org>
parents: 95728
diff changeset
539 unbind_to (specpdl_count, Qnil);
6488b258c0aa (set_frame_menubar): Sync with version in xmenu.c.
Jason Rumney <jasonr@gnu.org>
parents: 95728
diff changeset
540
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
541 /* Now GC cannot happen during the lifetime of the widget_value,
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
542 so it's safe to store data from a Lisp_String, as long as
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
543 local copies are made when the actual menu is created.
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
544 Windows takes care of this for normal string items, but
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
545 not for owner-drawn items or additional item-info. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
546 wv = first_wv->contents;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
547 for (i = 0; i < ASIZE (items); i += 4)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
548 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
549 Lisp_Object string;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
550 string = AREF (items, i + 1);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
551 if (NILP (string))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
552 break;
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
553 wv->name = (char *) SDATA (string);
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
554 update_submenu_strings (wv->contents);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
555 wv = wv->next;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
556 }
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
557 }
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
558 else
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
559 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
560 /* Make a widget-value tree containing
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
561 just the top level menu bar strings. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
562
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
563 wv = xmalloc_widget_value ();
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
564 wv->name = "menubar";
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
565 wv->value = 0;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
566 wv->enabled = 1;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
567 wv->button_type = BUTTON_TYPE_NONE;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
568 wv->help = Qnil;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
569 first_wv = wv;
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
570
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
571 items = FRAME_MENU_BAR_ITEMS (f);
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
572 for (i = 0; i < ASIZE (items); i += 4)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
573 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
574 Lisp_Object string;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
575
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
576 string = AREF (items, i + 1);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
577 if (NILP (string))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
578 break;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
579
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
580 wv = xmalloc_widget_value ();
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
581 wv->name = (char *) SDATA (string);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
582 wv->value = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
583 wv->enabled = 1;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
584 wv->button_type = BUTTON_TYPE_NONE;
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
585 wv->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
586 /* This prevents lwlib from assuming this
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
587 menu item is really supposed to be empty. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
588 /* The EMACS_INT cast avoids a warning.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
589 This value just has to be different from small integers. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
590 wv->call_data = (void *) (EMACS_INT) (-1);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
591
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
592 if (prev_wv)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
593 prev_wv->next = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
594 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
595 first_wv->contents = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
596 prev_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
597 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
598
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
599 /* Forget what we thought we knew about what is in the
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
600 detailed contents of the menu bar menus.
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
601 Changing the top level always destroys the contents. */
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
602 f->menu_bar_items_used = 0;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
603 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
604
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
605 /* Create or update the menu bar widget. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
606
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
607 BLOCK_INPUT;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
608
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
609 if (menubar_widget)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
610 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
611 /* Empty current menubar, rather than creating a fresh one. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
612 while (DeleteMenu (menubar_widget, 0, MF_BYPOSITION))
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
613 ;
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
614 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
615 else
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
616 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
617 menubar_widget = CreateMenu ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
618 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
619 fill_in_menu (menubar_widget, first_wv->contents);
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
620
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
621 free_menubar_widget_value_tree (first_wv);
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
622
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
623 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
624 HMENU old_widget = f->output_data.w32->menubar_widget;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
625
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
626 f->output_data.w32->menubar_widget = menubar_widget;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
627 SetMenu (FRAME_W32_WINDOW (f), f->output_data.w32->menubar_widget);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
628 /* Causes flicker when menu bar is updated
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
629 DrawMenuBar (FRAME_W32_WINDOW (f)); */
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
630
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
631 /* Force the window size to be recomputed so that the frame's text
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
632 area remains the same, if menubar has just been created. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
633 if (old_widget == NULL)
51206
22a5614b558f Make (few) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
634 x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
635 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
636
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
637 UNBLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
638 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
639
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
640 /* Called from Fx_create_frame to create the initial menubar of a frame
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
641 before it is mapped, so that the window is mapped with the menubar already
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
642 there instead of us tacking it on later and thrashing the window after it
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
643 is visible. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
644
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
645 void
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
646 initialize_frame_menubar (FRAME_PTR f)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
647 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
648 /* This function is called before the first chance to redisplay
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
649 the frame. It has to be, so the frame will have the right size. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
650 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
651 set_frame_menubar (f, 1, 1);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
652 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
653
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
654 /* Get rid of the menu bar of frame F, and free its storage.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
655 This is used when deleting a frame, and when turning off the menu bar. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
656
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
657 void
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
658 free_frame_menubar (FRAME_PTR f)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
659 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
660 BLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
661
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
662 {
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15276
diff changeset
663 HMENU old = GetMenu (FRAME_W32_WINDOW (f));
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15276
diff changeset
664 SetMenu (FRAME_W32_WINDOW (f), NULL);
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
665 f->output_data.w32->menubar_widget = NULL;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
666 DestroyMenu (old);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
667 }
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
668
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
669 UNBLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
670 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
671
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
672
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
673 /* w32_menu_show actually displays a menu using the panes and items in
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
674 menu_items and returns the value selected from it; we assume input
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
675 is blocked by the caller. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
676
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
677 /* F is the frame the menu is for.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
678 X and Y are the frame-relative specified position,
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
679 relative to the inside upper left corner of the frame F.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
680 FOR_CLICK is nonzero if this menu was invoked for a mouse click.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
681 KEYMAPS is 1 if this menu was specified with keymaps;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
682 in that case, we return a list containing the chosen item's value
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
683 and perhaps also the pane's prefix.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
684 TITLE is the specified menu title.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
685 ERROR is a place to store an error message string in case of failure.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
686 (We return nil on failure, but the value doesn't actually matter.) */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
687
105923
1011707400d3 * menu.c (Fx_popup_menu): Consolidate versions from xmenu.c,
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105669
diff changeset
688 Lisp_Object
1011707400d3 * menu.c (Fx_popup_menu): Consolidate versions from xmenu.c,
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105669
diff changeset
689 w32_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
1011707400d3 * menu.c (Fx_popup_menu): Consolidate versions from xmenu.c,
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105669
diff changeset
690 Lisp_Object title, char **error)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
691 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
692 int i;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
693 int menu_item_selection;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
694 HMENU menu;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
695 POINT pos;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
696 widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
697 widget_value **submenu_stack
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
698 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *));
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
699 Lisp_Object *subprefix_stack
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
700 = (Lisp_Object *) alloca (menu_items_used * sizeof (Lisp_Object));
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
701 int submenu_depth = 0;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
702 int first_pane;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
703
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
704 *error = NULL;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
705
95732
6488b258c0aa (set_frame_menubar): Sync with version in xmenu.c.
Jason Rumney <jasonr@gnu.org>
parents: 95728
diff changeset
706 if (menu_items_n_panes == 0)
6488b258c0aa (set_frame_menubar): Sync with version in xmenu.c.
Jason Rumney <jasonr@gnu.org>
parents: 95728
diff changeset
707 return Qnil;
6488b258c0aa (set_frame_menubar): Sync with version in xmenu.c.
Jason Rumney <jasonr@gnu.org>
parents: 95728
diff changeset
708
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
709 if (menu_items_used <= MENU_ITEMS_PANE_LENGTH)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
710 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
711 *error = "Empty menu";
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
712 return Qnil;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
713 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
714
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
715 /* Create a tree of widget_value objects
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
716 representing the panes and their items. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
717 wv = xmalloc_widget_value ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
718 wv->name = "menu";
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
719 wv->value = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
720 wv->enabled = 1;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
721 wv->button_type = BUTTON_TYPE_NONE;
42613
a5eb47b53761 Fix typo in last checkin
Jason Rumney <jasonr@gnu.org>
parents: 42589
diff changeset
722 wv->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
723 first_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
724 first_pane = 1;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
725
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
726 /* Loop over all panes and items, filling in the tree. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
727 i = 0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
728 while (i < menu_items_used)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
729 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
730 if (EQ (AREF (menu_items, i), Qnil))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
731 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
732 submenu_stack[submenu_depth++] = save_wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
733 save_wv = prev_wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
734 prev_wv = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
735 first_pane = 1;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
736 i++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
737 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
738 else if (EQ (AREF (menu_items, i), Qlambda))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
739 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
740 prev_wv = save_wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
741 save_wv = submenu_stack[--submenu_depth];
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
742 first_pane = 0;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
743 i++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
744 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
745 else if (EQ (AREF (menu_items, i), Qt)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
746 && submenu_depth != 0)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
747 i += MENU_ITEMS_PANE_LENGTH;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
748 /* Ignore a nil in the item list.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
749 It's meaningful only for dialog boxes. */
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
750 else if (EQ (AREF (menu_items, i), Qquote))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
751 i += 1;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
752 else if (EQ (AREF (menu_items, i), Qt))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
753 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
754 /* Create a new pane. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
755 Lisp_Object pane_name, prefix;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
756 char *pane_string;
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
757 pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
758 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
759
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
760 if (STRINGP (pane_name))
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
761 {
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
762 if (unicode_append_menu)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
763 pane_name = ENCODE_UTF_8 (pane_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
764 else if (STRING_MULTIBYTE (pane_name))
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
765 pane_name = ENCODE_SYSTEM (pane_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
766
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
767 ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
768 }
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
769
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
770 pane_string = (NILP (pane_name)
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
771 ? "" : (char *) SDATA (pane_name));
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
772 /* If there is just one top-level pane, put all its items directly
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
773 under the top-level menu. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
774 if (menu_items_n_panes == 1)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
775 pane_string = "";
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
776
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
777 /* If the pane has a meaningful name,
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
778 make the pane a top-level menu item
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
779 with its items as a submenu beneath it. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
780 if (!keymaps && strcmp (pane_string, ""))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
781 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
782 wv = xmalloc_widget_value ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
783 if (save_wv)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
784 save_wv->next = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
785 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
786 first_wv->contents = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
787 wv->name = pane_string;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
788 if (keymaps && !NILP (prefix))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
789 wv->name++;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
790 wv->value = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
791 wv->enabled = 1;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
792 wv->button_type = BUTTON_TYPE_NONE;
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
793 wv->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
794 save_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
795 prev_wv = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
796 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
797 else if (first_pane)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
798 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
799 save_wv = wv;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
800 prev_wv = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
801 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
802 first_pane = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
803 i += MENU_ITEMS_PANE_LENGTH;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
804 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
805 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
806 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
807 /* Create a new item within current pane. */
27896
75f296b1a872 (single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents: 27400
diff changeset
808 Lisp_Object item_name, enable, descrip, def, type, selected, help;
75f296b1a872 (single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents: 27400
diff changeset
809
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
810 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
811 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
812 descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
813 def = AREF (menu_items, i + MENU_ITEMS_ITEM_DEFINITION);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
814 type = AREF (menu_items, i + MENU_ITEMS_ITEM_TYPE);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
815 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
816 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
817
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
818 if (STRINGP (item_name))
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
819 {
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
820 if (unicode_append_menu)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
821 item_name = ENCODE_UTF_8 (item_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
822 else if (STRING_MULTIBYTE (item_name))
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
823 item_name = ENCODE_SYSTEM (item_name);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
824
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
825 ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name);
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
826 }
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
827
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
828 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
829 {
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
830 descrip = ENCODE_SYSTEM (descrip);
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
831 ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
40119
bf81460680f2 (single_submenu, w32_menu_show) [!HAVE_MULTILINGUAL_MENU]:
Jason Rumney <jasonr@gnu.org>
parents: 39690
diff changeset
832 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
833
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
834 wv = xmalloc_widget_value ();
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
835 if (prev_wv)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
836 prev_wv->next = wv;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
837 else
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
838 save_wv->contents = wv;
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
839 wv->name = (char *) SDATA (item_name);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
840 if (!NILP (descrip))
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
841 wv->key = (char *) SDATA (descrip);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
842 wv->value = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
843 /* Use the contents index as call_data, since we are
41251
e6612d08452f (w32_menu_show, push_menu_pane): Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 41108
diff changeset
844 restricted to 16-bits. */
22737
41e01b5de7cc (w32_menu_show): Set widget call_data to 0 if definition is nil.
Andrew Innes <andrewi@gnu.org>
parents: 21741
diff changeset
845 wv->call_data = !NILP (def) ? (void *) (EMACS_INT) i : 0;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
846 wv->enabled = !NILP (enable);
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
847
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
848 if (NILP (type))
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
849 wv->button_type = BUTTON_TYPE_NONE;
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
850 else if (EQ (type, QCtoggle))
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
851 wv->button_type = BUTTON_TYPE_TOGGLE;
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
852 else if (EQ (type, QCradio))
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
853 wv->button_type = BUTTON_TYPE_RADIO;
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
854 else
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
855 abort ();
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
856
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
857 wv->selected = !NILP (selected);
95732
6488b258c0aa (set_frame_menubar): Sync with version in xmenu.c.
Jason Rumney <jasonr@gnu.org>
parents: 95728
diff changeset
858
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
859 if (!STRINGP (help))
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
860 help = Qnil;
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
861
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
862 wv->help = help;
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
863
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
864 prev_wv = wv;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
865
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
866 i += MENU_ITEMS_ITEM_LENGTH;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
867 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
868 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
869
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
870 /* Deal with the title, if it is non-nil. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
871 if (!NILP (title))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
872 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
873 widget_value *wv_title = xmalloc_widget_value ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
874 widget_value *wv_sep = xmalloc_widget_value ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
875
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
876 /* Maybe replace this separator with a bitmap or owner-draw item
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
877 so that it looks better. Having two separators looks odd. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
878 wv_sep->name = "--";
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
879 wv_sep->next = first_wv->contents;
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
880 wv_sep->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
881
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
882 if (unicode_append_menu)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
883 title = ENCODE_UTF_8 (title);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
884 else if (STRING_MULTIBYTE (title))
29320
33aa00975055 (single_submenu, w32_menu_show): Call ENCODE_SYSTEM on menu strings.
Jason Rumney <jasonr@gnu.org>
parents: 28275
diff changeset
885 title = ENCODE_SYSTEM (title);
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
886
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
887 wv_title->name = (char *) SDATA (title);
32988
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32671
diff changeset
888 wv_title->enabled = TRUE;
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32671
diff changeset
889 wv_title->title = TRUE;
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
890 wv_title->button_type = BUTTON_TYPE_NONE;
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
891 wv_title->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
892 wv_title->next = wv_sep;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
893 first_wv->contents = wv_title;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
894 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
895
95732
6488b258c0aa (set_frame_menubar): Sync with version in xmenu.c.
Jason Rumney <jasonr@gnu.org>
parents: 95728
diff changeset
896 /* No selection has been chosen yet. */
6488b258c0aa (set_frame_menubar): Sync with version in xmenu.c.
Jason Rumney <jasonr@gnu.org>
parents: 95728
diff changeset
897 menu_item_selection = 0;
6488b258c0aa (set_frame_menubar): Sync with version in xmenu.c.
Jason Rumney <jasonr@gnu.org>
parents: 95728
diff changeset
898
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
899 /* Actually create the menu. */
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
900 current_popup_menu = menu = CreatePopupMenu ();
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
901 fill_in_menu (menu, first_wv->contents);
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
902
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
903 /* Adjust coordinates to be root-window-relative. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
904 pos.x = x;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
905 pos.y = y;
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15276
diff changeset
906 ClientToScreen (FRAME_W32_WINDOW (f), &pos);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
907
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
908 /* Display the menu. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
909 menu_item_selection = SendMessage (FRAME_W32_WINDOW (f),
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
910 WM_EMACS_TRACKPOPUPMENU,
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
911 (WPARAM)menu, (LPARAM)&pos);
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
912
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
913 /* Clean up extraneous mouse events which might have been generated
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
914 during the call. */
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
915 discard_mouse_events ();
80759
c3bd08b7c78d (Fx_popup_menu, Fx_popup_dialog, w32_menu_show): Ensure mouse is not
Jason Rumney <jasonr@gnu.org>
parents: 79759
diff changeset
916 FRAME_X_DISPLAY_INFO (f)->grabbed = 0;
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
917
30238
4a3b87cc6f04 (w32_menu_show): Call free_menubar_widget_value_tree after menu is
Jason Rumney <jasonr@gnu.org>
parents: 30178
diff changeset
918 /* Free the widget_value objects we used to specify the contents. */
4a3b87cc6f04 (w32_menu_show): Call free_menubar_widget_value_tree after menu is
Jason Rumney <jasonr@gnu.org>
parents: 30178
diff changeset
919 free_menubar_widget_value_tree (first_wv);
4a3b87cc6f04 (w32_menu_show): Call free_menubar_widget_value_tree after menu is
Jason Rumney <jasonr@gnu.org>
parents: 30178
diff changeset
920
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
921 DestroyMenu (menu);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
922
76080
077c9ec8eca6 * w32menu.c (Fx_popup_menu): Don't free menu strings here.
Jason Rumney <jasonr@gnu.org>
parents: 76074
diff changeset
923 /* Free the owner-drawn and help-echo menu strings. */
077c9ec8eca6 * w32menu.c (Fx_popup_menu): Don't free menu strings here.
Jason Rumney <jasonr@gnu.org>
parents: 76074
diff changeset
924 w32_free_menu_strings (FRAME_W32_WINDOW (f));
76086
da9b24e47b34 (w32_menu_show): Mark the frame's menu as inactive when popup menu
Jason Rumney <jasonr@gnu.org>
parents: 76080
diff changeset
925 f->output_data.w32->menubar_active = 0;
76080
077c9ec8eca6 * w32menu.c (Fx_popup_menu): Don't free menu strings here.
Jason Rumney <jasonr@gnu.org>
parents: 76074
diff changeset
926
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
927 /* Find the selected item, and its pane, to return
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
928 the proper value. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
929 if (menu_item_selection != 0)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
930 {
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
931 Lisp_Object prefix, entry;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
932
38371
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
933 prefix = entry = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
934 i = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
935 while (i < menu_items_used)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
936 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
937 if (EQ (AREF (menu_items, i), Qnil))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
938 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
939 subprefix_stack[submenu_depth++] = prefix;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
940 prefix = entry;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
941 i++;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
942 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
943 else if (EQ (AREF (menu_items, i), Qlambda))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
944 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
945 prefix = subprefix_stack[--submenu_depth];
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
946 i++;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
947 }
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
948 else if (EQ (AREF (menu_items, i), Qt))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
949 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
950 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
951 i += MENU_ITEMS_PANE_LENGTH;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
952 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
953 /* Ignore a nil in the item list.
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
954 It's meaningful only for dialog boxes. */
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
955 else if (EQ (AREF (menu_items, i), Qquote))
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
956 i += 1;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
957 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
958 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
959 entry = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
960 if (menu_item_selection == i)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
961 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
962 if (keymaps != 0)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
963 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
964 int j;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
965
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
966 entry = Fcons (entry, Qnil);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
967 if (!NILP (prefix))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
968 entry = Fcons (prefix, entry);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
969 for (j = submenu_depth - 1; j >= 0; j--)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
970 if (!NILP (subprefix_stack[j]))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
971 entry = Fcons (subprefix_stack[j], entry);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
972 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
973 return entry;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
974 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
975 i += MENU_ITEMS_ITEM_LENGTH;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
976 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
977 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
978 }
72260
6e63f47b8977 (w32_menu_show, w32_dialog_show): Call Fsignal to quit
Jason Rumney <jasonr@gnu.org>
parents: 69443
diff changeset
979 else if (!for_click)
6e63f47b8977 (w32_menu_show, w32_dialog_show): Call Fsignal to quit
Jason Rumney <jasonr@gnu.org>
parents: 69443
diff changeset
980 /* Make "Cancel" equivalent to C-g. */
6e63f47b8977 (w32_menu_show, w32_dialog_show): Call Fsignal to quit
Jason Rumney <jasonr@gnu.org>
parents: 69443
diff changeset
981 Fsignal (Qquit, Qnil);
19711
dc9694ee3f70 (init_menu_items): Disable code.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
982
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
983 return Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
984 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
985
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
986
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
987 #ifdef HAVE_DIALOGS
93979
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
988 /* TODO: On Windows, there are two ways of defining a dialog.
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
989
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
990 1. Create a predefined dialog resource and include it in nt/emacs.rc.
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
991 Using this method, we could then set the titles and make unneeded
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
992 buttons invisible before displaying the dialog. Everything would
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
993 be a fixed size though, so there is a risk that text does not
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
994 fit on a button.
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
995 2. Create the dialog template in memory on the fly. This allows us
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
996 to size the dialog and buttons dynamically, probably giving more
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
997 natural looking results for dialogs with few buttons, and eliminating
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
998 the problem of text overflowing the buttons. But the API for this is
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
999 quite complex - structures have to be allocated in particular ways,
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1000 text content is tacked onto the end of structures in variable length
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1001 arrays with further structures tacked on after these, there are
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1002 certain alignment requirements for all this, and we have to
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1003 measure all the text and convert to "dialog coordinates" to figure
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1004 out how big to make everything.
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1005
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1006 For now, we'll just stick with menus for dialogs that are more
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1007 complicated than simple yes/no type questions for which we can use
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1008 the MessageBox function.
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1009 */
95735
bc8db28659e5 (digest_single_submenu): Declare extern.
Juanma Barranquero <lekktu@gmail.com>
parents: 95732
diff changeset
1010
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1011 static char * button_names [] = {
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1012 "button1", "button2", "button3", "button4", "button5",
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1013 "button6", "button7", "button8", "button9", "button10" };
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1014
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1015 static Lisp_Object
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
1016 w32_dialog_show (FRAME_PTR f, int keymaps,
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
1017 Lisp_Object title, Lisp_Object header,
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
1018 char **error)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1019 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1020 int i, nb_buttons=0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1021 char dialog_name[6];
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1022 int menu_item_selection;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1023
38371
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
1024 widget_value *wv, *first_wv = 0, *prev_wv = 0;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1025
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1026 /* Number of elements seen so far, before boundary. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1027 int left_count = 0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1028 /* 1 means we've seen the boundary between left-hand elts and right-hand. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1029 int boundary_seen = 0;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1030
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1031 *error = NULL;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1032
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1033 if (menu_items_n_panes > 1)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1034 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1035 *error = "Multiple panes in dialog box";
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1036 return Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1037 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1038
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1039 /* Create a tree of widget_value objects
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1040 representing the text label and buttons. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1041 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1042 Lisp_Object pane_name, prefix;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1043 char *pane_string;
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1044 pane_name = AREF (menu_items, MENU_ITEMS_PANE_NAME);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1045 prefix = AREF (menu_items, MENU_ITEMS_PANE_PREFIX);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1046 pane_string = (NILP (pane_name)
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1047 ? "" : (char *) SDATA (pane_name));
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1048 prev_wv = xmalloc_widget_value ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1049 prev_wv->value = pane_string;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1050 if (keymaps && !NILP (prefix))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1051 prev_wv->name++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1052 prev_wv->enabled = 1;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1053 prev_wv->name = "message";
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
1054 prev_wv->help = Qnil;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1055 first_wv = prev_wv;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1056
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1057 /* Loop over all panes and items, filling in the tree. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1058 i = MENU_ITEMS_PANE_LENGTH;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1059 while (i < menu_items_used)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1060 {
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1061
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1062 /* Create a new item within current pane. */
27896
75f296b1a872 (single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents: 27400
diff changeset
1063 Lisp_Object item_name, enable, descrip, help;
75f296b1a872 (single_submenu): Set up help string.
Jason Rumney <jasonr@gnu.org>
parents: 27400
diff changeset
1064
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1065 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1066 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1067 descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1068 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1069
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1070 if (NILP (item_name))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1071 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1072 free_menubar_widget_value_tree (first_wv);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1073 *error = "Submenu in dialog items";
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1074 return Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1075 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1076 if (EQ (item_name, Qquote))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1077 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1078 /* This is the boundary between left-side elts
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1079 and right-side elts. Stop incrementing right_count. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1080 boundary_seen = 1;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1081 i++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1082 continue;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1083 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1084 if (nb_buttons >= 9)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1085 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1086 free_menubar_widget_value_tree (first_wv);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1087 *error = "Too many dialog items";
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1088 return Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1089 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1090
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1091 wv = xmalloc_widget_value ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1092 prev_wv->next = wv;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1093 wv->name = (char *) button_names[nb_buttons];
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1094 if (!NILP (descrip))
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
1095 wv->key = (char *) SDATA (descrip);
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
1096 wv->value = (char *) SDATA (item_name);
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1097 wv->call_data = (void *) &AREF (menu_items, i);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1098 wv->enabled = !NILP (enable);
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
1099 wv->help = Qnil;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1100 prev_wv = wv;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1101
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1102 if (! boundary_seen)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1103 left_count++;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1104
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1105 nb_buttons++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1106 i += MENU_ITEMS_ITEM_LENGTH;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1107 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1108
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1109 /* If the boundary was not specified,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1110 by default put half on the left and half on the right. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1111 if (! boundary_seen)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1112 left_count = nb_buttons - nb_buttons / 2;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1113
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1114 wv = xmalloc_widget_value ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1115 wv->name = dialog_name;
42589
ac09ecabe088 (single_submenu, set_frame_menubar, w32_menu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42584
diff changeset
1116 wv->help = Qnil;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1117
62668
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
1118 /* Frame title: 'Q' = Question, 'I' = Information.
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
1119 Can also have 'E' = Error if, one day, we want
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
1120 a popup for errors. */
109160
f8660b83cdbf Fix whitespace to follow coding guidelines.
Juanma Barranquero <lekktu@gmail.com>
parents: 109152
diff changeset
1121 if (NILP (header))
62668
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
1122 dialog_name[0] = 'Q';
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
1123 else
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
1124 dialog_name[0] = 'I';
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
1125
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1126 /* Dialog boxes use a really stupid name encoding
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1127 which specifies how many buttons to use
62668
d126643d7af1 (Fx_popup_dialog): Add a third boolean argument to select frame title
Nick Roberts <nickrob@snap.net.nz>
parents: 56973
diff changeset
1128 and how many buttons are on the right. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1129 dialog_name[1] = '0' + nb_buttons;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1130 dialog_name[2] = 'B';
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1131 dialog_name[3] = 'R';
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1132 /* Number of buttons to put on the right. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1133 dialog_name[4] = '0' + nb_buttons - left_count;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1134 dialog_name[5] = 0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1135 wv->contents = first_wv;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1136 first_wv = wv;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1137 }
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1138
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1139 /* Actually create the dialog. */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1140 dialog_id = widget_id_tick++;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1141 menu = lw_create_widget (first_wv->name, "dialog", dialog_id, first_wv,
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15276
diff changeset
1142 f->output_data.w32->widget, 1, 0,
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1143 dialog_selection_callback, 0);
32988
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32671
diff changeset
1144 lw_modify_all_widgets (dialog_id, first_wv->contents, TRUE);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1145
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1146 /* Free the widget_value objects we used to specify the contents. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1147 free_menubar_widget_value_tree (first_wv);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1148
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1149 /* No selection has been chosen yet. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1150 menu_item_selection = 0;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1151
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1152 /* Display the menu. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1153 lw_pop_up_all_widgets (dialog_id);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1154
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1155 /* Process events that apply to the menu. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1156 popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), dialog_id);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1157
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1158 lw_destroy_all_widgets (dialog_id);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1159
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1160 /* Find the selected item, and its pane, to return
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1161 the proper value. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1162 if (menu_item_selection != 0)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1163 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1164 Lisp_Object prefix;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1165
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1166 prefix = Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1167 i = 0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1168 while (i < menu_items_used)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1169 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1170 Lisp_Object entry;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1171
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1172 if (EQ (AREF (menu_items, i), Qt))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1173 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1174 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1175 i += MENU_ITEMS_PANE_LENGTH;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1176 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1177 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1178 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1179 entry = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1180 if (menu_item_selection == i)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1181 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1182 if (keymaps != 0)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1183 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1184 entry = Fcons (entry, Qnil);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1185 if (!NILP (prefix))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1186 entry = Fcons (prefix, entry);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1187 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1188 return entry;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1189 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1190 i += MENU_ITEMS_ITEM_LENGTH;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1191 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1192 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1193 }
72260
6e63f47b8977 (w32_menu_show, w32_dialog_show): Call Fsignal to quit
Jason Rumney <jasonr@gnu.org>
parents: 69443
diff changeset
1194 else
6e63f47b8977 (w32_menu_show, w32_dialog_show): Call Fsignal to quit
Jason Rumney <jasonr@gnu.org>
parents: 69443
diff changeset
1195 /* Make "Cancel" equivalent to C-g. */
6e63f47b8977 (w32_menu_show, w32_dialog_show): Call Fsignal to quit
Jason Rumney <jasonr@gnu.org>
parents: 69443
diff changeset
1196 Fsignal (Qquit, Qnil);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1197
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1198 return Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1199 }
93979
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1200 #else /* !HAVE_DIALOGS */
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1201
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1202 /* Currently we only handle Yes No dialogs (y-or-n-p and yes-or-no-p) as
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1203 simple dialogs. We could handle a few more, but I'm not aware of
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1204 anywhere in Emacs that uses the other specific dialog choices that
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1205 MessageBox provides. */
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1206
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
1207 static int
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
1208 is_simple_dialog (Lisp_Object contents)
93979
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1209 {
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1210 Lisp_Object options = XCDR (contents);
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1211 Lisp_Object name, yes, no, other;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1212
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1213 yes = build_string ("Yes");
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1214 no = build_string ("No");
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1215
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1216 if (!CONSP (options))
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1217 return 0;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1218
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1219 name = XCAR (XCAR (options));
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1220 if (!CONSP (options))
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1221 return 0;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1222
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1223 if (!NILP (Fstring_equal (name, yes)))
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1224 other = no;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1225 else if (!NILP (Fstring_equal (name, no)))
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1226 other = yes;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1227 else
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1228 return 0;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1229
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1230 options = XCDR (options);
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1231 if (!CONSP (options))
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1232 return 0;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1233
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1234 name = XCAR (XCAR (options));
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1235 if (NILP (Fstring_equal (name, other)))
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1236 return 0;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1237
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1238 /* Check there are no more options. */
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1239 options = XCDR (options);
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1240 return !(CONSP (options));
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1241 }
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1242
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
1243 static Lisp_Object
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
1244 simple_dialog_show (FRAME_PTR f, Lisp_Object contents, Lisp_Object header)
93979
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1245 {
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1246 int answer;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1247 UINT type;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1248 char *text, *title;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1249 Lisp_Object lispy_answer = Qnil, temp = XCAR (contents);
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1250
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1251 if (STRINGP (temp))
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1252 text = SDATA (temp);
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1253 else
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1254 text = "";
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1255
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1256 if (NILP (header))
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1257 {
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1258 title = "Question";
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1259 type = MB_ICONQUESTION;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1260 }
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1261 else
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1262 {
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1263 title = "Information";
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1264 type = MB_ICONINFORMATION;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1265 }
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1266 type |= MB_YESNO;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1267
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1268 /* Since we only handle Yes/No dialogs, and we already checked
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1269 is_simple_dialog, we don't need to worry about checking contents
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1270 to see what type of dialog to use. */
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1271 answer = MessageBox (FRAME_W32_WINDOW (f), text, title, type);
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1272
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1273 if (answer == IDYES)
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1274 lispy_answer = build_string ("Yes");
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1275 else if (answer == IDNO)
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1276 lispy_answer = build_string ("No");
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1277 else
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1278 Fsignal (Qquit, Qnil);
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1279
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1280 for (temp = XCDR (contents); CONSP (temp); temp = XCDR (temp))
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1281 {
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1282 Lisp_Object item, name, value;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1283 item = XCAR (temp);
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1284 if (CONSP (item))
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1285 {
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1286 name = XCAR (item);
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1287 value = XCDR (item);
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1288 }
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1289 else
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1290 {
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1291 name = item;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1292 value = Qnil;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1293 }
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1294
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1295 if (!NILP (Fstring_equal (name, lispy_answer)))
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1296 {
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1297 return value;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1298 }
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1299 }
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1300 Fsignal (Qquit, Qnil);
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1301 return Qnil;
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1302 }
b8d983c8a6d0 (is_simple_dialog, simple_dialog_show): New functions.
Jason Rumney <jasonr@gnu.org>
parents: 91773
diff changeset
1303 #endif /* !HAVE_DIALOGS */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1304
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1305
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1306 /* Is this item a separator? */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1307 static int
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
1308 name_is_separator (char *name)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1309 {
38371
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
1310 char *start = name;
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
1311
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
1312 /* Check if name string consists of only dashes ('-'). */
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1313 while (*name == '-') name++;
38371
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
1314 /* Separators can also be of the form "--:TripleSuperMegaEtched"
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
1315 or "--deep-shadow". We don't implement them yet, se we just treat
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
1316 them like normal separators. */
eb915f0b1d6e (menubar_selection_callback, w32_menu_show): Initialize `entry' to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36677
diff changeset
1317 return (*name == '\0' || start + 2 == name);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1318 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1319
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1320
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1321 /* Indicate boundary between left and right. */
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1322 static int
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1323 add_left_right_boundary (HMENU menu)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1324 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1325 return AppendMenu (menu, MF_MENUBARBREAK, 0, NULL);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1326 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1327
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1328 /* UTF8: 0xxxxxxx, 110xxxxx 10xxxxxx, 1110xxxx, 10xxxxxx, 10xxxxxx */
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1329 static void
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1330 utf8to16 (unsigned char * src, int len, WCHAR * dest)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1331 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1332 while (len > 0)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1333 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1334 int utf16;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1335 if (*src < 0x80)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1336 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1337 *dest = (WCHAR) *src;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1338 dest++; src++; len--;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1339 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1340 /* Since we might get >3 byte sequences which we don't handle, ignore the extra parts. */
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1341 else if (*src < 0xC0)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1342 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1343 src++; len--;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1344 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1345 /* 2 char UTF-8 sequence. */
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1346 else if (*src < 0xE0)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1347 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1348 *dest = (WCHAR) (((*src & 0x1f) << 6)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1349 | (*(src + 1) & 0x3f));
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1350 src += 2; len -= 2; dest++;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1351 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1352 else if (*src < 0xF0)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1353 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1354 *dest = (WCHAR) (((*src & 0x0f) << 12)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1355 | ((*(src + 1) & 0x3f) << 6)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1356 | (*(src + 2) & 0x3f));
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1357 src += 3; len -= 3; dest++;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1358 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1359 else /* Not encodable. Insert Unicode Substitution char. */
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1360 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1361 *dest = (WCHAR) 0xfffd;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1362 src++; len--; dest++;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1363 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1364 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1365 *dest = 0;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1366 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1367
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1368 static int
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1369 add_menu_item (HMENU menu, widget_value *wv, HMENU item)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1370 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1371 UINT fuFlags;
78015
cf89ff54912e (add_menu_item): Escape `&' characters in menu items and their keybindings.
Eli Zaretskii <eliz@gnu.org>
parents: 76086
diff changeset
1372 char *out_string, *p, *q;
27932
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
1373 int return_value;
78015
cf89ff54912e (add_menu_item): Escape `&' characters in menu items and their keybindings.
Eli Zaretskii <eliz@gnu.org>
parents: 76086
diff changeset
1374 size_t nlen, orig_len;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1375
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1376 if (name_is_separator (wv->name))
33971
c33b80a45f6a (add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents: 32988
diff changeset
1377 {
c33b80a45f6a (add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents: 32988
diff changeset
1378 fuFlags = MF_SEPARATOR;
c33b80a45f6a (add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents: 32988
diff changeset
1379 out_string = NULL;
c33b80a45f6a (add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents: 32988
diff changeset
1380 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49348
diff changeset
1381 else
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1382 {
22750
b38cb406ed80 (add_menu_item): Draw menu items like titles if call_data is 0.
Andrew Innes <andrewi@gnu.org>
parents: 22737
diff changeset
1383 if (wv->enabled)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1384 fuFlags = MF_STRING;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1385 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1386 fuFlags = MF_STRING | MF_GRAYED;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1387
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1388 if (wv->key != NULL)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1389 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1390 out_string = alloca (strlen (wv->name) + strlen (wv->key) + 2);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1391 strcpy (out_string, wv->name);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1392 strcat (out_string, "\t");
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1393 strcat (out_string, wv->key);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1394 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1395 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1396 out_string = wv->name;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1397
78015
cf89ff54912e (add_menu_item): Escape `&' characters in menu items and their keybindings.
Eli Zaretskii <eliz@gnu.org>
parents: 76086
diff changeset
1398 /* Quote any special characters within the menu item's text and
cf89ff54912e (add_menu_item): Escape `&' characters in menu items and their keybindings.
Eli Zaretskii <eliz@gnu.org>
parents: 76086
diff changeset
1399 key binding. */
cf89ff54912e (add_menu_item): Escape `&' characters in menu items and their keybindings.
Eli Zaretskii <eliz@gnu.org>
parents: 76086
diff changeset
1400 nlen = orig_len = strlen (out_string);
78022
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1401 if (unicode_append_menu)
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1402 {
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1403 /* With UTF-8, & cannot be part of a multibyte character. */
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1404 for (p = out_string; *p; p++)
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1405 {
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1406 if (*p == '&')
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1407 nlen++;
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1408 }
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1409 }
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1410 else
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1411 {
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1412 /* If encoded with the system codepage, use multibyte string
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1413 functions in case of multibyte characters that contain '&'. */
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1414 for (p = out_string; *p; p = _mbsinc (p))
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1415 {
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1416 if (_mbsnextc (p) == '&')
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1417 nlen++;
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1418 }
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1419 }
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1420
78015
cf89ff54912e (add_menu_item): Escape `&' characters in menu items and their keybindings.
Eli Zaretskii <eliz@gnu.org>
parents: 76086
diff changeset
1421 if (nlen > orig_len)
78022
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1422 {
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1423 p = out_string;
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1424 out_string = alloca (nlen + 1);
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1425 q = out_string;
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1426 while (*p)
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1427 {
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1428 if (unicode_append_menu)
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1429 {
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1430 if (*p == '&')
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1431 *q++ = *p;
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1432 *q++ = *p++;
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1433 }
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1434 else
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1435 {
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1436 if (_mbsnextc (p) == '&')
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1437 {
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1438 _mbsncpy (q, p, 1);
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1439 q = _mbsinc (q);
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1440 }
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1441 _mbsncpy (q, p, 1);
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1442 p = _mbsinc (p);
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1443 q = _mbsinc (q);
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1444 }
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1445 }
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1446 *q = '\0';
349c82ee7ef7 (add_menu_item): Don't use multibyte string functions on
Jason Rumney <jasonr@gnu.org>
parents: 78015
diff changeset
1447 }
78015
cf89ff54912e (add_menu_item): Escape `&' characters in menu items and their keybindings.
Eli Zaretskii <eliz@gnu.org>
parents: 76086
diff changeset
1448
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1449 if (item != NULL)
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1450 fuFlags = MF_POPUP;
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1451 else if (wv->title || wv->call_data == 0)
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1452 {
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1453 /* Only use MF_OWNERDRAW if GetMenuItemInfo is usable, since
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1454 we can't deallocate the memory otherwise. */
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1455 if (get_menu_item_info)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1456 {
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1457 out_string = (char *) local_alloc (strlen (wv->name) + 1);
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1458 strcpy (out_string, wv->name);
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1459 #ifdef MENU_DEBUG
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1460 DebPrint ("Menu: allocing %ld for owner-draw", out_string);
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1461 #endif
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1462 fuFlags = MF_OWNERDRAW | MF_DISABLED;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1463 }
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1464 else
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1465 fuFlags = MF_DISABLED;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1466 }
41637
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
1467
27400
da3ee40952bf Add skeleton support for help strings on menus.
Jason Rumney <jasonr@gnu.org>
parents: 26729
diff changeset
1468 /* Draw radio buttons and tickboxes. */
36677
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1469 else if (wv->selected && (wv->button_type == BUTTON_TYPE_TOGGLE ||
41108
ef7a153a2c68 (add-menu-item): Make help_echo and radio buttons
Jason Rumney <jasonr@gnu.org>
parents: 40962
diff changeset
1470 wv->button_type == BUTTON_TYPE_RADIO))
36677
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1471 fuFlags |= MF_CHECKED;
27932
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
1472 else
36677
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1473 fuFlags |= MF_UNCHECKED;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1474 }
36677
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1475
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1476 if (unicode_append_menu && out_string)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1477 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1478 /* Convert out_string from UTF-8 to UTF-16-LE. */
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1479 int utf8_len = strlen (out_string);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1480 WCHAR * utf16_string;
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1481 if (fuFlags & MF_OWNERDRAW)
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1482 utf16_string = local_alloc ((utf8_len + 1) * sizeof (WCHAR));
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1483 else
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1484 utf16_string = alloca ((utf8_len + 1) * sizeof (WCHAR));
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1485
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1486 utf8to16 (out_string, utf8_len, utf16_string);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1487 return_value = unicode_append_menu (menu, fuFlags,
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1488 item != NULL ? (UINT) item
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1489 : (UINT) wv->call_data,
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1490 utf16_string);
65301
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
1491 if (!return_value)
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
1492 {
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
1493 /* On W9x/ME, unicode menus are not supported, though AppendMenuW
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
1494 apparently does exist at least in some cases and appears to be
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
1495 stubbed out to do nothing. out_string is UTF-8, but since
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
1496 our standard menus are in English and this is only going to
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
1497 happen the first time a menu is used, the encoding is
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
1498 of minor importance compared with menus not working at all. */
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
1499 return_value =
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
1500 AppendMenu (menu, fuFlags,
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
1501 item != NULL ? (UINT) item: (UINT) wv->call_data,
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
1502 out_string);
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
1503 /* Don't use unicode menus in future. */
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
1504 unicode_append_menu = NULL;
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
1505 }
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
1506
c0c0b5bf96ab (add_menu_item): If unicode_append_menu returns an
Jason Rumney <jasonr@gnu.org>
parents: 64770
diff changeset
1507 if (unicode_append_menu && (fuFlags & MF_OWNERDRAW))
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1508 local_free (out_string);
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1509 }
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1510 else
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1511 {
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1512 return_value =
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1513 AppendMenu (menu,
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1514 fuFlags,
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1515 item != NULL ? (UINT) item : (UINT) wv->call_data,
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1516 out_string );
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1517 }
27932
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
1518
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
1519 /* This must be done after the menu item is created. */
41108
ef7a153a2c68 (add-menu-item): Make help_echo and radio buttons
Jason Rumney <jasonr@gnu.org>
parents: 40962
diff changeset
1520 if (!wv->title && wv->call_data != 0)
36677
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1521 {
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1522 if (set_menu_item_info)
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1523 {
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1524 MENUITEMINFO info;
109165
750db9f3e6d8 Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents: 109160
diff changeset
1525 memset (&info, 0, sizeof (info));
36677
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1526 info.cbSize = sizeof (info);
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1527 info.fMask = MIIM_DATA;
32671
bbd3be4db5f2 (add_menu_item): Do not use MF_OWNERDRAW for titles, as it has stopped working.
Jason Rumney <jasonr@gnu.org>
parents: 31114
diff changeset
1528
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1529 /* Set help string for menu item. Leave it as a Lisp_Object
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1530 until it is ready to be displayed, since GC can happen while
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1531 menus are active. */
55671
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
1532 if (!NILP (wv->help))
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
1533 #ifdef USE_LISP_UNION_TYPE
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
1534 info.dwItemData = (DWORD) (wv->help).i;
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
1535 #else
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
1536 info.dwItemData = (DWORD) (wv->help);
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
1537 #endif
36677
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1538 if (wv->button_type == BUTTON_TYPE_RADIO)
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1539 {
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1540 /* CheckMenuRadioItem allows us to differentiate TOGGLE and
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1541 RADIO items, but is not available on NT 3.51 and earlier. */
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1542 info.fMask |= MIIM_TYPE | MIIM_STATE;
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1543 info.fType = MFT_RADIOCHECK | MFT_STRING;
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1544 info.dwTypeData = out_string;
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1545 info.fState = wv->selected ? MFS_CHECKED : MFS_UNCHECKED;
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1546 }
33971
c33b80a45f6a (add_menu_item): Reset menu item text when changing type to radio button.
Jason Rumney <jasonr@gnu.org>
parents: 32988
diff changeset
1547
36677
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1548 set_menu_item_info (menu,
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1549 item != NULL ? (UINT) item : (UINT) wv->call_data,
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1550 FALSE, &info);
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1551 }
eb7af01c7f27 (add_menu_item): Fix problems with using ownerdraw for
Andrew Innes <andrewi@gnu.org>
parents: 36313
diff changeset
1552 }
27932
a590f8d0dbd2 [HAVE_BOXES]: Remove #undef.
Jason Rumney <jasonr@gnu.org>
parents: 27896
diff changeset
1553 return return_value;
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1554 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1555
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1556 /* Construct native Windows menu(bar) based on widget_value tree. */
31114
cd392fdf0e9f Include keyboard.h before frame.h. Fix compile
Andrew Innes <andrewi@gnu.org>
parents: 30989
diff changeset
1557 int
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1558 fill_in_menu (HMENU menu, widget_value *wv)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1559 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1560 int items_added = 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1561
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1562 for ( ; wv != NULL; wv = wv->next)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1563 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1564 if (wv->contents)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1565 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1566 HMENU sub_menu = CreatePopupMenu ();
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1567
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1568 if (sub_menu == NULL)
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1569 return 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1570
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1571 if (!fill_in_menu (sub_menu, wv->contents) ||
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1572 !add_menu_item (menu, wv, sub_menu))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1573 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1574 DestroyMenu (sub_menu);
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1575 return 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1576 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1577 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1578 else
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1579 {
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1580 if (!add_menu_item (menu, wv, NULL))
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1581 return 0;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1582 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1583 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1584 return 1;
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1585 }
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1586
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
1587 /* Display help string for currently pointed to menu item. Not
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
1588 supported on NT 3.51 and earlier, as GetMenuItemInfo is not
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
1589 available. */
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
1590 void
41646
258fa72efab7 (w32_menu_display_help): Actually add the new argument
Andrew Innes <andrewi@gnu.org>
parents: 41637
diff changeset
1591 w32_menu_display_help (HWND owner, HMENU menu, UINT item, UINT flags)
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
1592 {
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
1593 if (get_menu_item_info)
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
1594 {
41637
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
1595 struct frame *f = x_window_to_frame (&one_w32_display_info, owner);
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
1596 Lisp_Object frame, help;
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
1597
64632
13b6920b1146 (w32_menu_display_help): Suppress tooltip when navigating menus with
Jason Rumney <jasonr@gnu.org>
parents: 64084
diff changeset
1598 /* No help echo on owner-draw menu items, or when the keyboard is used
13b6920b1146 (w32_menu_display_help): Suppress tooltip when navigating menus with
Jason Rumney <jasonr@gnu.org>
parents: 64084
diff changeset
1599 to navigate the menus, since tooltips are distracting if they pop
13b6920b1146 (w32_menu_display_help): Suppress tooltip when navigating menus with
Jason Rumney <jasonr@gnu.org>
parents: 64084
diff changeset
1600 up elsewhere. */
13b6920b1146 (w32_menu_display_help): Suppress tooltip when navigating menus with
Jason Rumney <jasonr@gnu.org>
parents: 64084
diff changeset
1601 if (flags & MF_OWNERDRAW || flags & MF_POPUP
13b6920b1146 (w32_menu_display_help): Suppress tooltip when navigating menus with
Jason Rumney <jasonr@gnu.org>
parents: 64084
diff changeset
1602 || !(flags & MF_MOUSESELECT))
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1603 help = Qnil;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1604 else
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1605 {
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1606 MENUITEMINFO info;
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
1607
109165
750db9f3e6d8 Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents: 109160
diff changeset
1608 memset (&info, 0, sizeof (info));
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1609 info.cbSize = sizeof (info);
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1610 info.fMask = MIIM_DATA;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1611 get_menu_item_info (menu, item, FALSE, &info);
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1612
55671
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
1613 #ifdef USE_LISP_UNION_TYPE
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
1614 help = info.dwItemData ? (Lisp_Object) ((EMACS_INT) info.dwItemData)
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
1615 : Qnil;
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
1616 #else
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1617 help = info.dwItemData ? (Lisp_Object) info.dwItemData : Qnil;
55671
6817f9469688 (add_menu_item, w32_menu_display_help) [USE_LISP_UNION_TYPE]: Cast
Jason Rumney <jasonr@gnu.org>
parents: 53326
diff changeset
1618 #endif
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1619 }
30989
2152817050ff (keymap_panes): Pass the keymap's prompt as the pane name to
Jason Rumney <jasonr@gnu.org>
parents: 30238
diff changeset
1620
41637
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
1621 /* Store the help echo in the keyboard buffer as the X toolkit
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
1622 version does, rather than directly showing it. This seems to
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
1623 solve the GC problems that were present when we based the
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
1624 Windows code on the non-toolkit version. */
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
1625 if (f)
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
1626 {
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
1627 XSETFRAME (frame, f);
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
1628 kbd_buffer_store_help_event (frame, help);
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
1629 }
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
1630 else
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
1631 /* X version has a loop through frames here, which doesn't
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
1632 appear to do anything, unless it has some side effect. */
d797ce338b4b (add_menu_item): Do not use owner-draw for disabled menu items.
Jason Rumney <jasonr@gnu.org>
parents: 41251
diff changeset
1633 show_help_echo (help, Qnil, Qnil, Qnil, 1);
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
1634 }
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
1635 }
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
1636
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1637 /* Free memory used by owner-drawn strings. */
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1638 static void
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
1639 w32_free_submenu_strings (HMENU menu)
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1640 {
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1641 int i, num = GetMenuItemCount (menu);
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1642 for (i = 0; i < num; i++)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1643 {
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1644 MENUITEMINFO info;
109165
750db9f3e6d8 Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents: 109160
diff changeset
1645 memset (&info, 0, sizeof (info));
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1646 info.cbSize = sizeof (info);
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1647 info.fMask = MIIM_DATA | MIIM_TYPE | MIIM_SUBMENU;
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1648
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1649 get_menu_item_info (menu, i, TRUE, &info);
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1650
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1651 /* Owner-drawn names are held in dwItemData. */
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1652 if ((info.fType & MF_OWNERDRAW) && info.dwItemData)
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1653 {
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1654 #ifdef MENU_DEBUG
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1655 DebPrint ("Menu: freeing %ld for owner-draw", info.dwItemData);
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1656 #endif
46815
52f36f4b0e4f (local_heap, local_alloc, local_free): New macros.
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1657 local_free (info.dwItemData);
41908
4d8905b9ee49 (_widget_value): Make `help' field a Lisp_Object. Add
Jason Rumney <jasonr@gnu.org>
parents: 41733
diff changeset
1658 }
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1659
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1660 /* Recurse down submenus. */
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1661 if (info.hSubMenu)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1662 w32_free_submenu_strings (info.hSubMenu);
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1663 }
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1664 }
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1665
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1666 void
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
1667 w32_free_menu_strings (HWND hwnd)
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1668 {
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1669 HMENU menu = current_popup_menu;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1670
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1671 if (get_menu_item_info)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1672 {
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1673 /* If there is no popup menu active, free the strings from the frame's
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1674 menubar. */
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1675 if (!menu)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1676 menu = GetMenu (hwnd);
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1677
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1678 if (menu)
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1679 w32_free_submenu_strings (menu);
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1680 }
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1681
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1682 current_popup_menu = NULL;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1683 }
28275
2c8492145fc8 (single_submenu): Set help string to NULL if none.
Jason Rumney <jasonr@gnu.org>
parents: 27932
diff changeset
1684
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1685 #endif /* HAVE_MENUS */
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1686
73788
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
1687 /* The following is used by delayed window autoselection. */
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
1688
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
1689 DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, Smenu_or_popup_active_p, 0, 0, 0,
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
1690 doc: /* Return t if a menu or popup dialog is active on selected frame. */)
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
1691 ()
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
1692 {
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
1693 #ifdef HAVE_MENUS
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
1694 FRAME_PTR f;
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
1695 f = SELECTED_FRAME ();
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
1696 return (f->output_data.w32->menubar_active > 0) ? Qt : Qnil;
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
1697 #else
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
1698 return Qnil;
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
1699 #endif /* HAVE_MENUS */
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
1700 }
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73695
diff changeset
1701
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
1702 void
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
1703 syms_of_w32menu (void)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1704 {
90920
b3ae82a0a4fd (syms_of_w32menu): Use DEFSYM macro.
Jason Rumney <jasonr@gnu.org>
parents: 90776
diff changeset
1705 globals_of_w32menu ();
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1706
41733
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1707 current_popup_menu = NULL;
917737801660 (current_popup_menu, get_menu_item_info):
Jason Rumney <jasonr@gnu.org>
parents: 41646
diff changeset
1708
90920
b3ae82a0a4fd (syms_of_w32menu): Use DEFSYM macro.
Jason Rumney <jasonr@gnu.org>
parents: 90776
diff changeset
1709 DEFSYM (Qdebug_on_next_call, "debug-on-next-call");
15276
07341673efa6 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 15110
diff changeset
1710
73695
3901ff3eaf2c (Fmenu_or_popup_active_p): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 72773
diff changeset
1711 defsubr (&Smenu_or_popup_active_p);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1712 #ifdef HAVE_MENUS
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1713 defsubr (&Sx_popup_dialog);
21741
3d1ce72aa7b9 Replace code with a new version written from scratch
Geoff Voelker <voelker@cs.washington.edu>
parents: 21612
diff changeset
1714 #endif
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1715 }
48888
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
1716
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
1717 /*
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
1718 globals_of_w32menu is used to initialize those global variables that
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
1719 must always be initialized on startup even when the global variable
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
1720 initialized is non zero (see the function main in emacs.c).
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
1721 globals_of_w32menu is called from syms_of_w32menu when the global
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
1722 variable initialized is 0 and directly from main when initialized
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
1723 is non zero.
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
1724 */
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
1725 void
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 109100
diff changeset
1726 globals_of_w32menu (void)
48888
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
1727 {
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
1728 /* See if Get/SetMenuItemInfo functions are available. */
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
1729 HMODULE user32 = GetModuleHandle ("user32.dll");
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
1730 get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA");
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
1731 set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA");
56897
1fa5ffcb2ac8 (_widget_value): Added lname and lkey.
Jason Rumney <jasonr@gnu.org>
parents: 55671
diff changeset
1732 unicode_append_menu = (AppendMenuW_Proc) GetProcAddress (user32, "AppendMenuW");
48888
f0df5f687c15 Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Ben Key <bkey1@tampabay.rr.com>
parents: 48375
diff changeset
1733 }
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51573
diff changeset
1734
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51573
diff changeset
1735 /* arch-tag: 0eaed431-bb4e-4aac-a527-95a1b4f1fed0
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51573
diff changeset
1736 (do not change this comment) */