annotate lwlib/lwlib.c @ 4981:4aebb0131297

Cleanups/renaming of EXTERNAL_TO_C_STRING and friends -------------------- ChangeLog entries follow: -------------------- modules/ChangeLog addition: 2010-02-05 Ben Wing <ben@xemacs.org> * postgresql/postgresql.c: * postgresql/postgresql.c (CHECK_LIVE_CONNECTION): * postgresql/postgresql.c (Fpq_connectdb): * postgresql/postgresql.c (Fpq_connect_start): * postgresql/postgresql.c (Fpq_lo_import): * postgresql/postgresql.c (Fpq_lo_export): * ldap/eldap.c (Fldap_open): * ldap/eldap.c (Fldap_search_basic): * ldap/eldap.c (Fldap_add): * ldap/eldap.c (Fldap_modify): * ldap/eldap.c (Fldap_delete): * canna/canna_api.c (Fcanna_initialize): * canna/canna_api.c (Fcanna_store_yomi): * canna/canna_api.c (Fcanna_parse): * canna/canna_api.c (Fcanna_henkan_begin): EXTERNAL_TO_C_STRING returns its argument instead of storing it in a parameter, and is renamed to EXTERNAL_TO_ITEXT. Similar things happen to related macros. See entry in src/ChangeLog. More Mule-izing of postgresql.c. Extract out common code between `pq-connectdb' and `pq-connect-start'. Fix places that signal an error string using a formatted string to instead follow the standard and have a fixed reason followed by the particular error message stored as one of the frobs. src/ChangeLog addition: 2010-02-05 Ben Wing <ben@xemacs.org> * console-msw.c (write_string_to_mswindows_debugging_output): * console-msw.c (Fmswindows_message_box): * console-x.c (x_perhaps_init_unseen_key_defaults): * console.c: * database.c (dbm_get): * database.c (dbm_put): * database.c (dbm_remove): * database.c (berkdb_get): * database.c (berkdb_put): * database.c (berkdb_remove): * database.c (Fopen_database): * device-gtk.c (gtk_init_device): * device-msw.c (msprinter_init_device_internal): * device-msw.c (msprinter_default_printer): * device-msw.c (msprinter_init_device): * device-msw.c (sync_printer_with_devmode): * device-msw.c (Fmsprinter_select_settings): * device-x.c (sanity_check_geometry_resource): * device-x.c (Dynarr_add_validified_lisp_string): * device-x.c (x_init_device): * device-x.c (Fx_put_resource): * device-x.c (Fx_valid_keysym_name_p): * device-x.c (Fx_set_font_path): * dialog-msw.c (push_lisp_string_as_unicode): * dialog-msw.c (handle_directory_dialog_box): * dialog-msw.c (handle_file_dialog_box): * dialog-x.c (dbox_descriptor_to_widget_value): * editfns.c (Fformat_time_string): * editfns.c (Fencode_time): * editfns.c (Fset_time_zone_rule): * emacs.c (make_argc_argv): * emacs.c (Fdump_emacs): * emodules.c (emodules_load): * eval.c: * eval.c (maybe_signal_error_1): * event-msw.c (Fdde_alloc_advise_item): * event-msw.c (mswindows_dde_callback): * event-msw.c (mswindows_wnd_proc): * fileio.c (report_error_with_errno): * fileio.c (Fsysnetunam): * fileio.c (Fdo_auto_save): * font-mgr.c (extract_fcapi_string): * font-mgr.c (Ffc_config_app_font_add_file): * font-mgr.c (Ffc_config_app_font_add_dir): * font-mgr.c (Ffc_config_filename): * frame-gtk.c (gtk_set_frame_text_value): * frame-gtk.c (gtk_create_widgets): * frame-msw.c (mswindows_init_frame_1): * frame-msw.c (mswindows_set_title_from_ibyte): * frame-msw.c (msprinter_init_frame_3): * frame-x.c (x_set_frame_text_value): * frame-x.c (x_set_frame_properties): * frame-x.c (start_drag_internal_1): * frame-x.c (x_cde_transfer_callback): * frame-x.c (x_create_widgets): * glyphs-eimage.c (my_jpeg_output_message): * glyphs-eimage.c (jpeg_instantiate): * glyphs-eimage.c (gif_instantiate): * glyphs-eimage.c (png_instantiate): * glyphs-eimage.c (tiff_instantiate): * glyphs-gtk.c (xbm_instantiate_1): * glyphs-gtk.c (gtk_xbm_instantiate): * glyphs-gtk.c (gtk_xpm_instantiate): * glyphs-gtk.c (gtk_xface_instantiate): * glyphs-gtk.c (cursor_font_instantiate): * glyphs-gtk.c (gtk_redisplay_widget): * glyphs-gtk.c (gtk_widget_instantiate_1): * glyphs-gtk.c (gtk_add_tab_item): * glyphs-msw.c (mswindows_xpm_instantiate): * glyphs-msw.c (bmp_instantiate): * glyphs-msw.c (mswindows_resource_instantiate): * glyphs-msw.c (xbm_instantiate_1): * glyphs-msw.c (mswindows_xbm_instantiate): * glyphs-msw.c (mswindows_xface_instantiate): * glyphs-msw.c (mswindows_redisplay_widget): * glyphs-msw.c (mswindows_widget_instantiate): * glyphs-msw.c (add_tree_item): * glyphs-msw.c (add_tab_item): * glyphs-msw.c (mswindows_combo_box_instantiate): * glyphs-msw.c (mswindows_widget_query_string_geometry): * glyphs-x.c (x_locate_pixmap_file): * glyphs-x.c (xbm_instantiate_1): * glyphs-x.c (x_xbm_instantiate): * glyphs-x.c (extract_xpm_color_names): * glyphs-x.c (x_xpm_instantiate): * glyphs-x.c (x_xface_instantiate): * glyphs-x.c (autodetect_instantiate): * glyphs-x.c (safe_XLoadFont): * glyphs-x.c (cursor_font_instantiate): * glyphs-x.c (x_redisplay_widget): * glyphs-x.c (Fchange_subwindow_property): * glyphs-x.c (x_widget_instantiate): * glyphs-x.c (x_tab_control_redisplay): * glyphs.c (pixmap_to_lisp_data): * gui-x.c (menu_separator_style_and_to_external): * gui-x.c (add_accel_and_to_external): * gui-x.c (button_item_to_widget_value): * hpplay.c (player_error_internal): * hpplay.c (play_sound_file): * hpplay.c (play_sound_data): * intl.c (Fset_current_locale): * lisp.h: * menubar-gtk.c (gtk_xemacs_set_accel_keys): * menubar-msw.c (populate_menu_add_item): * menubar-msw.c (populate_or_checksum_helper): * menubar-x.c (menu_item_descriptor_to_widget_value_1): * nt.c (init_user_info): * nt.c (get_long_basename): * nt.c (nt_get_resource): * nt.c (init_mswindows_environment): * nt.c (get_cached_volume_information): * nt.c (mswindows_readdir): * nt.c (read_unc_volume): * nt.c (mswindows_stat): * nt.c (mswindows_getdcwd): * nt.c (mswindows_executable_type): * nt.c (Fmswindows_short_file_name): * ntplay.c (nt_play_sound_file): * objects-gtk.c: * objects-gtk.c (gtk_valid_color_name_p): * objects-gtk.c (gtk_initialize_font_instance): * objects-gtk.c (gtk_font_list): * objects-msw.c (font_enum_callback_2): * objects-msw.c (parse_font_spec): * objects-x.c (x_parse_nearest_color): * objects-x.c (x_valid_color_name_p): * objects-x.c (x_initialize_font_instance): * objects-x.c (x_font_instance_truename): * objects-x.c (x_font_list): * objects-xlike-inc.c (XFUN): * objects-xlike-inc.c (xft_find_charset_font): * process-nt.c (mswindows_report_winsock_error): * process-nt.c (nt_create_process): * process-nt.c (get_internet_address): * process-nt.c (nt_open_network_stream): * process-unix.c: * process-unix.c (allocate_pty): * process-unix.c (get_internet_address): * process-unix.c (unix_canonicalize_host_name): * process-unix.c (unix_open_network_stream): * realpath.c: * select-common.h (lisp_data_to_selection_data): * select-gtk.c (symbol_to_gtk_atom): * select-gtk.c (atom_to_symbol): * select-msw.c (symbol_to_ms_cf): * select-msw.c (mswindows_register_selection_data_type): * select-x.c (symbol_to_x_atom): * select-x.c (x_atom_to_symbol): * select-x.c (hack_motif_clipboard_selection): * select-x.c (Fx_store_cutbuffer_internal): * sound.c (Fplay_sound_file): * sound.c (Fplay_sound): * sound.h (sound_perror): * sysdep.c: * sysdep.c (qxe_allocating_getcwd): * sysdep.c (qxe_execve): * sysdep.c (copy_in_passwd): * sysdep.c (qxe_getpwnam): * sysdep.c (qxe_ctime): * sysdll.c (dll_open): * sysdll.c (dll_function): * sysdll.c (dll_variable): * sysdll.c (search_linked_libs): * sysdll.c (dll_error): * sysfile.h: * sysfile.h (PATHNAME_CONVERT_OUT_TSTR): * sysfile.h (PATHNAME_CONVERT_OUT_UTF_8): * sysfile.h (PATHNAME_CONVERT_OUT): * sysfile.h (LISP_PATHNAME_CONVERT_OUT): * syswindows.h (ITEXT_TO_TSTR): * syswindows.h (LOCAL_FILE_FORMAT_TO_TSTR): * syswindows.h (TSTR_TO_LOCAL_FILE_FORMAT): * syswindows.h (LOCAL_FILE_FORMAT_TO_INTERNAL_MSWIN): * syswindows.h (LISP_LOCAL_FILE_FORMAT_MAYBE_URL_TO_TSTR): * text.h: * text.h (eicpy_ext_len): * text.h (enum new_dfc_src_type): * text.h (EXTERNAL_TO_ITEXT): * text.h (GET_STRERROR): * tooltalk.c (check_status): * tooltalk.c (Fadd_tooltalk_message_arg): * tooltalk.c (Fadd_tooltalk_pattern_attribute): * tooltalk.c (Fadd_tooltalk_pattern_arg): * win32.c (tstr_to_local_file_format): * win32.c (mswindows_lisp_error_1): * win32.c (mswindows_report_process_error): * win32.c (Fmswindows_shell_execute): * win32.c (mswindows_read_link_1): Changes involving external/internal format conversion, mostly code cleanup and renaming. 1. Eliminate the previous macros like LISP_STRING_TO_EXTERNAL that stored its result in a parameter. The new version of LISP_STRING_TO_EXTERNAL returns its result through the return value, same as the previous NEW_LISP_STRING_TO_EXTERNAL. Use the new-style macros throughout the code. 2. Rename C_STRING_TO_EXTERNAL and friends to ITEXT_TO_EXTERNAL, in keeping with overall naming rationalization involving Itext and related types. Macros involved in previous two: EXTERNAL_TO_C_STRING -> EXTERNAL_TO_ITEXT EXTERNAL_TO_C_STRING_MALLOC -> EXTERNAL_TO_ITEXT_MALLOC SIZED_EXTERNAL_TO_C_STRING -> SIZED_EXTERNAL_TO_ITEXT SIZED_EXTERNAL_TO_C_STRING_MALLOC -> SIZED_EXTERNAL_TO_ITEXT_MALLOC C_STRING_TO_EXTERNAL -> ITEXT_TO_EXTERNAL C_STRING_TO_EXTERNAL_MALLOC -> ITEXT_TO_EXTERNAL_MALLOC LISP_STRING_TO_EXTERNAL LISP_STRING_TO_EXTERNAL_MALLOC LISP_STRING_TO_TSTR C_STRING_TO_TSTR -> ITEXT_TO_TSTR TSTR_TO_C_STRING -> TSTR_TO_ITEXT The following four still return their values through parameters, since they have more than one value to return: C_STRING_TO_SIZED_EXTERNAL -> ITEXT_TO_SIZED_EXTERNAL LISP_STRING_TO_SIZED_EXTERNAL C_STRING_TO_SIZED_EXTERNAL_MALLOC -> ITEXT_TO_SIZED_EXTERNAL_MALLOC LISP_STRING_TO_SIZED_EXTERNAL_MALLOC Sometimes additional casts had to be inserted, since the old macros played strange games and completely defeated the type system of the store params. 3. Rewrite many places where direct calls to TO_EXTERNAL_FORMAT occurred with calls to one of the convenience macros listed above, or to make_extstring(). 4. Eliminate SIZED_C_STRING macros (they were hardly used, anyway) and use a direct call to TO_EXTERNAL_FORMAT or TO_INTERNAL_FORMAT. 4. Use LISP_PATHNAME_CONVERT_OUT in many places instead of something like LISP_STRING_TO_EXTERNAL(..., Qfile_name). 5. Eliminate some temporary variables that are no longer necessary now that we return a value rather than storing it into a variable. 6. Some Mule-izing in database.c. 7. Error functions: -- A bit of code cleanup in maybe_signal_error_1. -- Eliminate report_file_type_error; it's just an alias for signal_error_2 with params in a different order. -- Fix some places in the hostname-handling code that directly inserted externally-retrieved error strings into the supposed ASCII "reason" param instead of doing the right thing and sticking text descriptive of what was going on in "reason" and putting the external message in a frob. 8. Use Ascbyte instead of CIbyte in process-unix.c and maybe one or two other places. 9. Some code cleanup in copy_in_passwd() in sysdep.c. 10. Fix a real bug due to accidental variable shadowing in tstr_to_local_file_format() in win32.c.
author Ben Wing <ben@xemacs.org>
date Fri, 05 Feb 2010 11:02:24 -0600
parents aa5ed11f473b
children ade4c7e2c6cb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* A general interface to the widgets of different toolkits.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1992, 1993, 1994 Lucid, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is part of the Lucid Widget Library.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 The Lucid Widget Library is free software; you can redistribute it and/or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 modify it under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 The Lucid Widget Library is distributed in the hope that it will be useful,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 GNU General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 #include <stdlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 #include <string.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 #include <sys/types.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 #ifdef HAVE_UNISTD_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 #include <unistd.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #include <X11/StringDefs.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #include "lwlib-internal.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include "lwlib-utils.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #ifdef NEED_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include "lwlib-Xlw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #ifdef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #include "lwlib-Xm.h"
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
39 #ifdef LWLIB_WIDGETS_MOTIF
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
40 #include <Xm/Xm.h>
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
41 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 #ifdef NEED_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 #include "lwlib-Xaw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 /* #### Does a check need to be put back in here to make sure we have
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 sufficient defines to function properly or are the checks in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 makefile sufficient? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 /* List of all widgets managed by the library. Note that each "widget"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 listed here may actually be a tree of widgets; for example, a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 single entry here might represent a single menubar or popup menu,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 each of which might be implemented with a tree of widgets.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 static widget_info *all_widget_info = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 /* boolean flag indicating that the menubar is active */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 int lw_menu_active = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 /* X11 menubar widget */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 Widget lw_menubar_widget = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 /* whether the last menu operation was a keyboard accelerator */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 int lw_menu_accelerate = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 /* Forward declarations */
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
69 static void instantiate_widget_instance (widget_instance *instance);
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
70 static void free_widget_value_args (widget_value* wv);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 /* utility functions for widget_instance and widget_info */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 static char *
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
75 safe_strdup (const char *s)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 char *result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 if (! s) return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 result = (char *) malloc (strlen (s) + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 if (! result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 strcpy (result, s);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 safe_free_str (char *s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 if (s) free (s);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 static widget_value *widget_value_free_list = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 widget_value *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 malloc_widget_value (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 widget_value *wv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 if (widget_value_free_list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 wv = widget_value_free_list;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 widget_value_free_list = wv->free_list;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 wv->free_list = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 wv = (widget_value *) malloc (sizeof (widget_value));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 if (wv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 {
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
110 memset (wv, '\0', sizeof (widget_value));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 return wv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 /* this is analogous to free(). It frees only what was allocated
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 by malloc_widget_value(), and no substructures.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 free_widget_value (widget_value *wv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 if (wv->free_list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 wv->free_list = widget_value_free_list;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 widget_value_free_list = wv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 free_widget_value_contents (widget_value *wv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 if (wv->name) free (wv->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 if (wv->value) free (wv->value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 if (wv->key) free (wv->key);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 /* #### - all of this 0xDEADBEEF stuff should be unnecessary
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 in production code... it should be conditionalized. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 wv->name = wv->value = wv->key = (char *) 0xDEADBEEF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 if (wv->toolkit_data && wv->free_toolkit_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 XtFree ((char *) wv->toolkit_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 wv->toolkit_data = (void *) 0xDEADBEEF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 #ifdef NEED_SCROLLBARS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 if (wv->scrollbar_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 free (wv->scrollbar_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 wv->scrollbar_data = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 if (wv->contents && (wv->contents != (widget_value*)1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 free_widget_value_tree (wv->contents);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 wv->contents = (widget_value *) 0xDEADBEEF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 }
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
155
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
156 free_widget_value_args (wv);
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
157
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 if (wv->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 free_widget_value_tree (wv->next);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 wv->next = (widget_value *) 0xDEADBEEF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 free_widget_value_tree (widget_value *wv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 if (!wv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 free_widget_value_contents (wv);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 free_widget_value (wv);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 #ifdef NEED_SCROLLBARS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 copy_scrollbar_values (widget_value *val, widget_value *copy)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 if (!copy->scrollbar_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 copy->scrollbar_data =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 (scrollbar_values *) malloc (sizeof (scrollbar_values));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 if (val->scrollbar_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 *copy->scrollbar_data = *val->scrollbar_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 else
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
187 memset (copy->scrollbar_data, '\0', sizeof (scrollbar_values));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 * Return true if old->scrollbar_data were not equivalent
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
192 * to new_->scrollbar_data.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 static Boolean
1201
c2569faae8ed [xemacs-hg @ 2003-01-12 10:45:53 by michaels]
michaels
parents: 872
diff changeset
195 merge_scrollbar_values (widget_value *old, widget_value *new_)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 Boolean changed = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198
1201
c2569faae8ed [xemacs-hg @ 2003-01-12 10:45:53 by michaels]
michaels
parents: 872
diff changeset
199 if (new_->scrollbar_data && !old->scrollbar_data)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 {
1201
c2569faae8ed [xemacs-hg @ 2003-01-12 10:45:53 by michaels]
michaels
parents: 872
diff changeset
201 copy_scrollbar_values (new_, old);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 changed = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 }
1201
c2569faae8ed [xemacs-hg @ 2003-01-12 10:45:53 by michaels]
michaels
parents: 872
diff changeset
204 else if (!new_->scrollbar_data && old->scrollbar_data)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 free (old->scrollbar_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 old->scrollbar_data = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 }
1201
c2569faae8ed [xemacs-hg @ 2003-01-12 10:45:53 by michaels]
michaels
parents: 872
diff changeset
209 else if (new_->scrollbar_data && old->scrollbar_data)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 scrollbar_values *old_sb = old->scrollbar_data;
1201
c2569faae8ed [xemacs-hg @ 2003-01-12 10:45:53 by michaels]
michaels
parents: 872
diff changeset
212 scrollbar_values *new_sb = new_->scrollbar_data;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 if ((old_sb->line_increment != new_sb->line_increment) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 (old_sb->page_increment != new_sb->page_increment) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 (old_sb->minimum != new_sb->minimum) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 (old_sb->maximum != new_sb->maximum) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 (old_sb->slider_size != new_sb->slider_size) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 (old_sb->slider_position != new_sb->slider_position) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 (old_sb->scrollbar_width != new_sb->scrollbar_width) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 (old_sb->scrollbar_height != new_sb->scrollbar_height) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 (old_sb->scrollbar_x != new_sb->scrollbar_x) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 (old_sb->scrollbar_y != new_sb->scrollbar_y))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 changed = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 *old_sb = *new_sb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 return changed;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 #endif /* NEED_SCROLLBARS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 639
diff changeset
234 #ifdef HAVE_X_WIDGETS
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
235 /*
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
236 * Return true if old->args was not equivalent
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
237 * to new_->args.
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
238 */
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
239 static Boolean
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
240 merge_widget_value_args (widget_value *old, widget_value *new_)
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
241 {
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
242 Boolean changed = False;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
243
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
244 if (new_->args && !old->args)
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
245 {
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
246 lw_copy_widget_value_args (new_, old);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
247 changed = True;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
248 }
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
249 /* Generally we don't want to lose values that are already in the
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
250 widget. */
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
251 else if (!new_->args && old->args)
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
252 {
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
253 lw_copy_widget_value_args (old, new_);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
254 changed = True;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
255 }
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
256 else if (new_->args && old->args && new_->args != old->args)
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
257 {
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
258 /* #### Do something more sensible here than just copying the
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
259 new values (like actually merging the values). */
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
260 lw_copy_widget_value_args (new_, old);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
261 changed = True;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
262 }
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
263 else if (new_->args && new_->args == old->args && new_->args->args_changed == True)
450
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
264 {
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
265 changed = True;
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
266 }
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
267
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
268 return changed;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
269 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 639
diff changeset
270 #endif /* HAVE_X_WIDGETS */
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
271
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 /* Make a complete copy of a widget_value tree. Store CHANGE into
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 the widget_value tree's `change' field. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
275 widget_value *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 copy_widget_value_tree (widget_value *val, change_type change)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 widget_value *copy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 if (!val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 if (val == (widget_value *) 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 return val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 copy = malloc_widget_value ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 if (copy)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 /* #### - don't seg fault *here* if out of memory. Menus will be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 truncated inexplicably. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 copy->type = val->type;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 copy->name = safe_strdup (val->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 copy->value = safe_strdup (val->value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 copy->key = safe_strdup (val->key);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 copy->accel = val->accel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 copy->enabled = val->enabled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 copy->selected = val->selected;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 copy->edited = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 copy->change = change;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 copy->contents = copy_widget_value_tree (val->contents, change);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 copy->call_data = val->call_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 copy->next = copy_widget_value_tree (val->next, change);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 copy->toolkit_data = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 copy->free_toolkit_data = False;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
304
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
305 lw_copy_widget_value_args (val, copy);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 #ifdef NEED_SCROLLBARS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 copy_scrollbar_values (val, copy);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 return copy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 /* This function is used to implement incremental menu construction. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 widget_value *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 replace_widget_value_tree (widget_value *node, widget_value *newtree)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 widget_value *copy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 if (!node || !newtree)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 copy = copy_widget_value_tree (newtree, STRUCTURAL_CHANGE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 free_widget_value_contents (node);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 *node = *copy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 free_widget_value (copy); /* free the node, but not its contents. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 return node;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 static widget_info *
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
332 allocate_widget_info (const char *type, const char *name,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 LWLIB_ID id, widget_value *val,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 lw_callback pre_activate_cb, lw_callback selection_cb,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 lw_callback post_activate_cb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 widget_info *info = (widget_info *) malloc (sizeof (widget_info));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 info->type = safe_strdup (type);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 info->name = safe_strdup (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 info->id = id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 info->val = copy_widget_value_tree (val, STRUCTURAL_CHANGE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 info->busy = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 info->pre_activate_cb = pre_activate_cb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 info->selection_cb = selection_cb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 info->post_activate_cb = post_activate_cb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 info->instances = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 info->next = all_widget_info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 all_widget_info = info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 return info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 free_widget_info (widget_info *info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 safe_free_str (info->type);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 safe_free_str (info->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 free_widget_value_tree (info->val);
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
360 memset (info, '\0', sizeof (widget_info));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 free (info);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1201
diff changeset
365 mark_widget_destroyed (Widget widget, XtPointer closure,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1201
diff changeset
366 XtPointer UNUSED (call_data))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 widget_instance *instance = (widget_instance*)closure;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 /* be very conservative */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 if (instance->widget == widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 instance->widget = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 static widget_instance *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 allocate_widget_instance (widget_info *info, Widget parent, Boolean pop_up_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 widget_instance *instance =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 (widget_instance *) malloc (sizeof (widget_instance));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 instance->parent = parent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 instance->pop_up_p = pop_up_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 instance->info = info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 instance->next = info->instances;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 info->instances = instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 instantiate_widget_instance (instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 XtAddCallback (instance->widget, XtNdestroyCallback,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 mark_widget_destroyed, (XtPointer)instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 return instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 free_widget_instance (widget_instance *instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 {
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
396 memset (instance, '\0', sizeof (widget_instance));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 free (instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 static widget_info *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 get_widget_info (LWLIB_ID id, Boolean remove_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 widget_info *info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 widget_info *prev;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 for (prev = NULL, info = all_widget_info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 prev = info, info = info->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 if (info->id == id)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 if (remove_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 if (prev)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 prev->next = info->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 all_widget_info = info->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 return info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 /* Internal function used by the library dependent implementation to get the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 widget_value for a given widget in an instance */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 widget_info *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 lw_get_widget_info (LWLIB_ID id)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 return get_widget_info (id, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 map_widget_values (widget_value *value, int (*mapfunc) (widget_value *value,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 void *closure),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 void *closure)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 int retval = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 if (value->contents)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 retval = map_widget_values (value->contents, mapfunc, closure);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 if (retval)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 return retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 if (value->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 retval = map_widget_values (value->next, mapfunc, closure);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 if (retval)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 return retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 return (mapfunc) (value, closure);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 lw_map_widget_values (LWLIB_ID id, int (*mapfunc) (widget_value *value,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 void *closure),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 void *closure)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 widget_info *info = get_widget_info (id, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 if (!info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 if (info->val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 return map_widget_values (info->val, mapfunc, closure);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 static widget_instance *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 get_widget_instance (Widget widget, Boolean remove_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 widget_info *info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 widget_instance *instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 widget_instance *prev;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 for (info = all_widget_info; info; info = info->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 for (prev = NULL, instance = info->instances;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 prev = instance, instance = instance->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 if (instance->widget == widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 if (remove_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 if (prev)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 prev->next = instance->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 info->instances = instance->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 return instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 return (widget_instance *) 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 static widget_instance*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 find_instance (LWLIB_ID id, Widget parent, Boolean pop_up_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 widget_info *info = get_widget_info (id, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 widget_instance *instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 if (info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 for (instance = info->instances; instance; instance = instance->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 if (instance->parent == parent && instance->pop_up_p == pop_up_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 return instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 /* utility function for widget_value */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 static Boolean
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
506 safe_strcmp (const char *s1, const char *s2)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 if (!!s1 ^ !!s2) return True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 return (s1 && s2) ? strcmp (s1, s2) : s1 ? False : !!s2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 # define EXPLAIN(name, oc, nc, desc, a1, a2) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 printf ("Change: \"%s\"\tmax(%s=%d,%s=%d)\t%s %d %d\n", \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 name, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 (oc == NO_CHANGE ? "none" : \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 (oc == INVISIBLE_CHANGE ? "invisible" : \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 (oc == VISIBLE_CHANGE ? "visible" : \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 (oc == STRUCTURAL_CHANGE ? "structural" : "???")))), \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 oc, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 (nc == NO_CHANGE ? "none" : \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 (nc == INVISIBLE_CHANGE ? "invisible" : \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 (nc == VISIBLE_CHANGE ? "visible" : \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 (nc == STRUCTURAL_CHANGE ? "structural" : "???")))), \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 nc, desc, a1, a2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 # define EXPLAIN(name, oc, nc, desc, a1, a2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 static widget_value *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 merge_widget_value (widget_value *val1, widget_value *val2, int level)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 change_type change;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 widget_value *merged_next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 widget_value *merged_contents;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 if (!val1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 if (val2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 return copy_widget_value_tree (val2, STRUCTURAL_CHANGE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 if (!val2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 free_widget_value_tree (val1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 change = NO_CHANGE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 if (val1->type != val2->type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 EXPLAIN (val1->name, change, STRUCTURAL_CHANGE, "type change",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 val1->type, val2->type);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 change = max (change, STRUCTURAL_CHANGE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 val1->type = val2->type;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 if (safe_strcmp (val1->name, val2->name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 EXPLAIN (val1->name, change, STRUCTURAL_CHANGE, "name change",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 val1->name, val2->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 change = max (change, STRUCTURAL_CHANGE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 safe_free_str (val1->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 val1->name = safe_strdup (val2->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 if (safe_strcmp (val1->value, val2->value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "value change",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 val1->value, val2->value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 change = max (change, VISIBLE_CHANGE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 safe_free_str (val1->value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 val1->value = safe_strdup (val2->value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 if (safe_strcmp (val1->key, val2->key))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "key change",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 val1->key, val2->key);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 change = max (change, VISIBLE_CHANGE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 safe_free_str (val1->key);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 val1->key = safe_strdup (val2->key);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 if (val1->accel != val2->accel)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "accelerator change",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 val1->accel, val2->accel);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 change = max (change, VISIBLE_CHANGE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 val1->accel = val2->accel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 if (val1->enabled != val2->enabled)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "enablement change",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 val1->enabled, val2->enabled);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 change = max (change, VISIBLE_CHANGE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 val1->enabled = val2->enabled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 if (val1->selected != val2->selected)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "selection change",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 val1->selected, val2->selected);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 change = max (change, VISIBLE_CHANGE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 val1->selected = val2->selected;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 if (val1->call_data != val2->call_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 EXPLAIN (val1->name, change, INVISIBLE_CHANGE, "call-data change",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 val1->call_data, val2->call_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 change = max (change, INVISIBLE_CHANGE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 val1->call_data = val2->call_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 639
diff changeset
612 #ifdef HAVE_X_WIDGETS
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
613 if (merge_widget_value_args (val1, val2))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
614 {
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
615 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "widget change", 0, 0);
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
616 change = max (change, VISIBLE_CHANGE);
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
617 }
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
618 #endif
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
619
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 #ifdef NEED_SCROLLBARS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 if (merge_scrollbar_values (val1, val2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "scrollbar change", 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 change = max (change, VISIBLE_CHANGE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 if (level > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 merged_contents =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 merge_widget_value (val1->contents, val2->contents, level - 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 if (val1->contents && !merged_contents)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 EXPLAIN (val1->name, change, INVISIBLE_CHANGE, "(contents gone)",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 change = max (change, INVISIBLE_CHANGE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 else if (merged_contents && merged_contents->change != NO_CHANGE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 EXPLAIN (val1->name, change, INVISIBLE_CHANGE, "(contents change)",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 change = max (change, INVISIBLE_CHANGE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 val1->contents = merged_contents;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 merged_next = merge_widget_value (val1->next, val2->next, level);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 if (val1->next && !merged_next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 EXPLAIN (val1->name, change, STRUCTURAL_CHANGE, "(following gone)",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 change = max (change, STRUCTURAL_CHANGE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 else if (merged_next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 if (merged_next->change)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 EXPLAIN (val1->name, change, merged_next->change, "(following change)",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 0, 0);
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1201
diff changeset
663 change = max (change, merged_next->change);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 val1->next = merged_next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 val1->change = change;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 if (change > NO_CHANGE && val1->toolkit_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 if (val1->free_toolkit_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 XtFree ((char *) val1->toolkit_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 val1->toolkit_data = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 return val1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 /* modifying the widgets */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 static Widget
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
684 name_to_widget (widget_instance *instance, const char *name)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 Widget widget = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 if (!instance->widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 if (!strcmp (XtName (instance->widget), name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 widget = instance->widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 int length = strlen (name) + 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 char *real_name = (char *) alloca (length);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 real_name [0] = '*';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 strcpy (real_name + 1, name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 widget = XtNameToWidget (instance->widget, real_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 return widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 set_one_value (widget_instance *instance, widget_value *val, Boolean deep_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 Widget widget = name_to_widget (instance, val->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 if (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 #ifdef NEED_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 if (lw_lucid_widget_p (instance->widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 xlw_update_one_widget (instance, widget, val, deep_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 #ifdef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 if (lw_motif_widget_p (instance->widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 xm_update_one_widget (instance, widget, val, deep_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 #ifdef NEED_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 if (lw_xaw_widget_p (instance->widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 xaw_update_one_widget (instance, widget, val, deep_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 update_one_widget_instance (widget_instance *instance, Boolean deep_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 widget_value *val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 if (!instance->widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 /* the widget was destroyed */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 for (val = instance->info->val; val; val = val->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 if (val->change != NO_CHANGE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 set_one_value (instance, val, deep_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 update_all_widget_values (widget_info *info, Boolean deep_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 widget_instance *instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 widget_value *val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 for (instance = info->instances; instance; instance = instance->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 update_one_widget_instance (instance, deep_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 for (val = info->val; val; val = val->next)
450
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
751 {
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
752 val->change = NO_CHANGE;
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
753 if (val->args)
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
754 val->args->args_changed = False;
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
755 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 lw_modify_all_widgets (LWLIB_ID id, widget_value *val, Boolean deep_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 widget_info *info = get_widget_info (id, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 widget_value *new_val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 widget_value *next_new_val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 widget_value *cur;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 widget_value *prev;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 widget_value *next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 int found;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 if (!info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 for (new_val = val; new_val; new_val = new_val->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 next_new_val = new_val->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 new_val->next = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 found = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 for (prev = NULL, cur = info->val; cur; prev = cur, cur = cur->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 if (!strcmp (cur->name, new_val->name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 found = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 next = cur->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 cur->next = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 cur = merge_widget_value (cur, new_val, deep_p ? 1000 : 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 if (prev)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 prev->next = cur ? cur : next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 info->val = cur ? cur : next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 if (cur)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 cur->next = next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 if (!found)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 /* Could not find it, add it */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 if (prev)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 prev->next = copy_widget_value_tree (new_val, STRUCTURAL_CHANGE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 info->val = copy_widget_value_tree (new_val, STRUCTURAL_CHANGE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 new_val->next = next_new_val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 update_all_widget_values (info, deep_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 /* creating the widgets */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 initialize_widget_instance (widget_instance *instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 widget_value *val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 for (val = instance->info->val; val; val = val->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 val->change = STRUCTURAL_CHANGE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 update_one_widget_instance (instance, True);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 for (val = instance->info->val; val; val = val->next)
450
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
820 {
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
821 val->change = NO_CHANGE;
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
822 if (val->args)
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
823 val->args->args_changed = False;
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
824 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826
1201
c2569faae8ed [xemacs-hg @ 2003-01-12 10:45:53 by michaels]
michaels
parents: 872
diff changeset
827 #if defined (NEED_LUCID) || defined (NEED_ATHENA) || defined (NEED_MOTIF)
c2569faae8ed [xemacs-hg @ 2003-01-12 10:45:53 by michaels]
michaels
parents: 872
diff changeset
828
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
829 /* strcasecmp() is not sufficiently portable or standard,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
830 and it's easier just to write our own. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
831 static int
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
832 ascii_strcasecmp (const char *s1, const char *s2)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
833 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
834 while (1)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
835 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
836 char c1 = *s1++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
837 char c2 = *s2++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
838 if (c1 >= 'A' && c1 <= 'Z') c1 += 'a' - 'A';
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
839 if (c2 >= 'A' && c2 <= 'Z') c2 += 'a' - 'A';
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
840 if (c1 != c2) return c1 - c2;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
841 if (c1 == '\0') return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
842 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
843 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 static widget_creation_function
450
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
846 find_in_table (const char *type, const widget_creation_entry table[])
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 {
450
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
848 const widget_creation_entry *cur;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 for (cur = table; cur->type; cur++)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
850 if (!ascii_strcasecmp (type, cur->type))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 return cur->function;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 771
diff changeset
855 #endif
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 771
diff changeset
856
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 static Boolean
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
858 dialog_spec_p (const char *name)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 /* return True if name matches [EILPQeilpq][1-9][Bb] or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 [EILPQeilpq][1-9][Bb][Rr][1-9] */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 if (!name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 return False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 switch (name [0])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 case 'E': case 'I': case 'L': case 'P': case 'Q':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 case 'e': case 'i': case 'l': case 'p': case 'q':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 if (name [1] >= '0' && name [1] <= '9')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 if (name [2] != 'B' && name [2] != 'b')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 return False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 if (!name [3])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 return True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 if ((name [3] == 'T' || name [3] == 't') && !name [4])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 return True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 if ((name [3] == 'R' || name [3] == 'r')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 && name [4] >= '0' && name [4] <= '9' && !name [5])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 return True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 return False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 return False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 return False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 instantiate_widget_instance (widget_instance *instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 widget_creation_function function = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 #ifdef NEED_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 if (!function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 function = find_in_table (instance->info->type, xlw_creation_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 #ifdef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 if (!function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 function = find_in_table (instance->info->type, xm_creation_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 #ifdef NEED_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 if (!function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 function = find_in_table (instance->info->type, xaw_creation_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 if (!function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 if (dialog_spec_p (instance->info->type))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 #ifdef LWLIB_DIALOGS_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 if (!function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 function = xm_create_dialog;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 #ifdef LWLIB_DIALOGS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 if (!function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 function = xaw_create_dialog;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 #ifdef LWLIB_DIALOGS_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 /* not yet (not ever?) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 if (!function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 fprintf (stderr, "No creation function for widget type %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 instance->info->type);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 instance->widget = (*function) (instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 if (!instance->widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 /* XtRealizeWidget (instance->widget);*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
942 lw_register_widget (const char *type, const char *name,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 LWLIB_ID id, widget_value *val,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 lw_callback pre_activate_cb, lw_callback selection_cb,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 lw_callback post_activate_cb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 if (!get_widget_info (id, False))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 allocate_widget_info (type, name, id, val, pre_activate_cb, selection_cb,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 post_activate_cb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 lw_get_widget (LWLIB_ID id, Widget parent, Boolean pop_up_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 widget_instance *instance = find_instance (id, parent, pop_up_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 return instance ? instance->widget : NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 lw_make_widget (LWLIB_ID id, Widget parent, Boolean pop_up_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 widget_instance *instance = find_instance (id, parent, pop_up_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 if (!instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 widget_info *info = get_widget_info (id, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 if (!info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 instance = allocate_widget_instance (info, parent, pop_up_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 initialize_widget_instance (instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 if (!instance->widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 return instance->widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 Widget
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
978 lw_create_widget (const char *type, const char *name,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 LWLIB_ID id, widget_value *val,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 Widget parent, Boolean pop_up_p, lw_callback pre_activate_cb,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 lw_callback selection_cb, lw_callback post_activate_cb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 lw_register_widget (type, name, id, val, pre_activate_cb, selection_cb,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 post_activate_cb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 return lw_make_widget (id, parent, pop_up_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 /* destroying the widgets */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 destroy_one_instance (widget_instance *instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 /* Remove the destroy callback on the widget; that callback will try to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 dereference the instance object (to set its widget slot to 0, since the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 widget is dead.) Since the instance is now dead, we don't have to worry
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 about the fact that its widget is dead too.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 This happens in the Phase2Destroy of the widget, so this callback would
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 not have been run until arbitrarily long after the instance was freed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 if (instance->widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 XtRemoveCallback (instance->widget, XtNdestroyCallback,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 mark_widget_destroyed, (XtPointer)instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 if (instance->widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 /* The else are pretty tricky here, including the empty statement
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 at the end because it would be very bad to destroy a widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 twice. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 #ifdef NEED_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 if (lw_lucid_widget_p (instance->widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 xlw_destroy_instance (instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 #ifdef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 if (lw_motif_widget_p (instance->widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 xm_destroy_instance (instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 #ifdef NEED_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 if (lw_xaw_widget_p (instance->widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 xaw_destroy_instance (instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 /* do not remove the empty statement */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 free_widget_instance (instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 lw_destroy_widget (Widget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 widget_instance *instance = get_widget_instance (w, True);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 if (instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 widget_info *info = instance->info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 /* instance has already been removed from the list; free it */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 destroy_one_instance (instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 /* if there are no instances left, free the info too */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 if (!info->instances)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 lw_destroy_all_widgets (info->id);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 lw_destroy_all_widgets (LWLIB_ID id)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 widget_info *info = get_widget_info (id, True);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 widget_instance *instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 widget_instance *next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 if (info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 for (instance = info->instances; instance; )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 next = instance->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 destroy_one_instance (instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 instance = next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 free_widget_info (info);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1070 lw_destroy_everything (void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 while (all_widget_info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 lw_destroy_all_widgets (all_widget_info->id);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1077 lw_destroy_all_pop_ups (void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 widget_info *info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 widget_info *next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 widget_instance *instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 for (info = all_widget_info; info; info = next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 next = info->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 instance = info->instances;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 if (instance && instance->pop_up_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 lw_destroy_all_widgets (info->id);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 lw_raise_all_pop_up_widgets (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 widget_info *info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 widget_instance *instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 Widget result = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 for (info = all_widget_info; info; info = info->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 for (instance = info->instances; instance; instance = instance->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 if (instance->pop_up_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 Widget widget = instance->widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 if (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 if (XtIsManaged (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 #ifdef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 /* What a complete load of crap!!!!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 When a dialogShell is on the screen, it is not managed!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 || (lw_motif_widget_p (instance->widget) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 XtIsManaged (first_child (widget)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 if (!result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 result = widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 XMapRaised (XtDisplay (widget), XtWindow (widget));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 lw_pop_all_widgets (LWLIB_ID id, Boolean up)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 widget_info *info = get_widget_info (id, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 widget_instance *instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 if (info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 for (instance = info->instances; instance; instance = instance->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 if (instance->pop_up_p && instance->widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 #ifdef NEED_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 if (lw_lucid_widget_p (instance->widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 XtRealizeWidget (instance->widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 xlw_pop_instance (instance, up);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 #ifdef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 if (lw_motif_widget_p (instance->widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 XtRealizeWidget (instance->widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 xm_pop_instance (instance, up);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 #ifdef NEED_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 if (lw_xaw_widget_p (instance->widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 XtRealizeWidget (XtParent (instance->widget));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 XtRealizeWidget (instance->widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 xaw_pop_instance (instance, up);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 lw_pop_up_all_widgets (LWLIB_ID id)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163 lw_pop_all_widgets (id, True);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 lw_pop_down_all_widgets (LWLIB_ID id)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 lw_pop_all_widgets (id, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 lw_popup_menu (Widget widget, XEvent *event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175 #ifdef LWLIB_MENUBARS_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 if (lw_lucid_widget_p (widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 xlw_popup_menu (widget, event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 #ifdef LWLIB_MENUBARS_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 if (lw_motif_widget_p (widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 xm_popup_menu (widget, event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 #ifdef LWLIB_MENUBARS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 if (lw_xaw_widget_p (widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 xaw_popup_menu (widget, event); /* not implemented */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 /* get the values back */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 static Boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 get_one_value (widget_instance *instance, widget_value *val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 Widget widget = name_to_widget (instance, val->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 if (widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197 #ifdef NEED_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198 if (lw_lucid_widget_p (instance->widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199 xlw_update_one_value (instance, widget, val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201 #ifdef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 if (lw_motif_widget_p (instance->widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 xm_update_one_value (instance, widget, val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 #ifdef NEED_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 if (lw_xaw_widget_p (instance->widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 xaw_update_one_value (instance, widget, val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 return True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212 return False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 Boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 lw_get_some_values (LWLIB_ID id, widget_value *val_out)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 widget_info *info = get_widget_info (id, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 widget_instance *instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 widget_value *val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 Boolean result = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223 if (!info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 return False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1226 instance = info->instances;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227 if (!instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 return False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230 for (val = val_out; val; val = val->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 if (get_one_value (instance, val))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 result = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 widget_value*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 lw_get_all_values (LWLIB_ID id)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 widget_info *info = get_widget_info (id, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 widget_value *val = info->val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242 if (lw_get_some_values (id, val))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243 return val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1248 /* internal function used by the library dependent implementation to get the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249 widget_value for a given widget in an instance */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250 widget_value*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251 lw_get_widget_value_for_widget (widget_instance *instance, Widget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253 char *name = XtName (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 widget_value *cur;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 for (cur = instance->info->val; cur; cur = cur->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256 if (!strcmp (cur->name, name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257 return cur;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262 /* update other instances value when one thing changed */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263 /* This function can be used as a an XtCallback for the widgets that get
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 modified to update other instances of the widgets. Closure should be the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1265 widget_instance. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267 lw_internal_update_other_instances (Widget widget, XtPointer closure,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1201
diff changeset
1268 XtPointer UNUSED (call_data))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 /* To forbid recursive calls */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271 static Boolean updating;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 widget_instance *instance = (widget_instance*)closure;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 char *name = XtName (widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 widget_info *info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 widget_instance *cur;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 widget_value *val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 /* never recurse as this could cause infinite recursions. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 if (updating)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 /* protect against the widget being destroyed */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 if (XtWidgetBeingDestroyedP (widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287 /* Return immediately if there are no other instances */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 info = instance->info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 if (!info->instances->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1290 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 updating = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294 for (val = info->val; val && strcmp (val->name, name); val = val->next);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 if (val && get_one_value (instance, val))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 for (cur = info->instances; cur; cur = cur->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298 if (cur != instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299 set_one_value (cur, val, True);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1300
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301 updating = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1305
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306 /* get the id */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1308 LWLIB_ID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309 lw_get_widget_id (Widget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1311 widget_instance *instance = get_widget_instance (w, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1312
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313 return instance ? instance->info->id : 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1314 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1315
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317 /* set the keyboard focus */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1319 lw_set_keyboard_focus (Widget parent, Widget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1320 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1321 #if defined(NEED_MOTIF) && !defined(LESSTIF_VERSION)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1322 /* This loses with Lesstif v0.75a */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1323 xm_set_keyboard_focus (parent, w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1324 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1325 XtSetKeyboardFocus (parent, w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1326 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1327 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1328
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1329
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1330 /* Show busy */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1331 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1201
diff changeset
1332 show_one_widget_busy (Widget w, Boolean UNUSED (flag))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1333 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1334 Pixel foreground = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1335 Pixel background = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1336 Widget widget_to_invert = XtNameToWidget (w, "*sheet");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1337 Arg al [2];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1338
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1339 if (!widget_to_invert)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1340 widget_to_invert = w;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1341
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342 XtSetArg (al [0], XtNforeground, &foreground);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1343 XtSetArg (al [1], XtNbackground, &background);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1344 XtGetValues (widget_to_invert, al, 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1345
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346 XtSetArg (al [0], XtNforeground, background);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1347 XtSetArg (al [1], XtNbackground, foreground);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 XtSetValues (widget_to_invert, al, 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352 lw_show_busy (Widget w, Boolean busy)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354 widget_instance *instance = get_widget_instance (w, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 widget_info *info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 widget_instance *next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358 if (instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360 info = instance->info;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 if (info->busy != busy)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1362 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 for (next = info->instances; next; next = next->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 if (next->widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365 show_one_widget_busy (next->widget, busy);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 info->busy = busy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371 void lw_add_value_args_to_args (widget_value* wv, ArgList addto, int* offset)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1372 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 int i;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1374 if (wv->args && wv->args->nargs)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 {
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1376 for (i = 0; i<wv->args->nargs; i++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 {
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1378 addto[i + *offset] = wv->args->args[i];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 }
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1380 *offset += wv->args->nargs;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1382 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
1384 XtArgVal lw_get_value_arg (widget_value* wv, const String name)
639
4b7d425dd3c2 [xemacs-hg @ 2001-07-28 05:08:58 by andyp]
andyp
parents: 450
diff changeset
1385 {
4b7d425dd3c2 [xemacs-hg @ 2001-07-28 05:08:58 by andyp]
andyp
parents: 450
diff changeset
1386 int i;
4b7d425dd3c2 [xemacs-hg @ 2001-07-28 05:08:58 by andyp]
andyp
parents: 450
diff changeset
1387 if (wv->args)
4b7d425dd3c2 [xemacs-hg @ 2001-07-28 05:08:58 by andyp]
andyp
parents: 450
diff changeset
1388 {
4b7d425dd3c2 [xemacs-hg @ 2001-07-28 05:08:58 by andyp]
andyp
parents: 450
diff changeset
1389 for (i = 0; i < wv->args->nargs; i++)
4b7d425dd3c2 [xemacs-hg @ 2001-07-28 05:08:58 by andyp]
andyp
parents: 450
diff changeset
1390 {
4b7d425dd3c2 [xemacs-hg @ 2001-07-28 05:08:58 by andyp]
andyp
parents: 450
diff changeset
1391 if (!strcmp (wv->args->args[i].name, name))
4b7d425dd3c2 [xemacs-hg @ 2001-07-28 05:08:58 by andyp]
andyp
parents: 450
diff changeset
1392 {
4b7d425dd3c2 [xemacs-hg @ 2001-07-28 05:08:58 by andyp]
andyp
parents: 450
diff changeset
1393 return wv->args->args[i].value;
4b7d425dd3c2 [xemacs-hg @ 2001-07-28 05:08:58 by andyp]
andyp
parents: 450
diff changeset
1394 }
4b7d425dd3c2 [xemacs-hg @ 2001-07-28 05:08:58 by andyp]
andyp
parents: 450
diff changeset
1395 }
4b7d425dd3c2 [xemacs-hg @ 2001-07-28 05:08:58 by andyp]
andyp
parents: 450
diff changeset
1396 }
4b7d425dd3c2 [xemacs-hg @ 2001-07-28 05:08:58 by andyp]
andyp
parents: 450
diff changeset
1397 return (XtArgVal)0;
4b7d425dd3c2 [xemacs-hg @ 2001-07-28 05:08:58 by andyp]
andyp
parents: 450
diff changeset
1398 }
4b7d425dd3c2 [xemacs-hg @ 2001-07-28 05:08:58 by andyp]
andyp
parents: 450
diff changeset
1399
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1400 void lw_add_widget_value_arg (widget_value* wv, String name, XtArgVal value)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1401 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1402 int i = 0;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1403 if (!wv->args)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1404 {
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1405 wv->args = (widget_args *) malloc (sizeof (widget_args));
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
1406 memset (wv->args, '\0', sizeof (widget_args));
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1407 wv->args->ref_count = 1;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1408 wv->args->nargs = 0;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1409 wv->args->args = (ArgList) malloc (sizeof (Arg) * 10);
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
1410 memset (wv->args->args, '\0', sizeof (Arg) * 10);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1411 }
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1412
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1413 if (wv->args->nargs > 10)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1414 return;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1415
450
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
1416 /* Register the change. */
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
1417 wv->args->args_changed = True;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1418 /* If the arg is already there then we must replace it. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1419 for (i = 0; i < wv->args->nargs; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1420 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1421 if (!strcmp (wv->args->args[i].name, name))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1422 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1423 XtSetArg (wv->args->args [i], name, value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1424 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1425 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1426 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1427 if (i >= wv->args->nargs)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1428 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1429 XtSetArg (wv->args->args [wv->args->nargs], name, value); wv->args->nargs++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1430 }
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1431 }
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1432
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1433 static void free_widget_value_args (widget_value* wv)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1434 {
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1435 if (wv->args)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1436 {
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1437 if (--wv->args->ref_count <= 0)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1438 {
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1439 #ifdef LWLIB_WIDGETS_MOTIF
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1440 int i;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1441 for (i = 0; i < wv->args->nargs; i++)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1442 {
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1443 if (!strcmp (wv->args->args[i].name, XmNfontList))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1444 XmFontListFree ((XmFontList)wv->args->args[i].value);
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1445 }
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1446 #endif
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1447 free (wv->args->args);
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1448 free (wv->args);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1449 wv->args = 0;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1450 }
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1451 }
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1452 }
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1453
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1454 void lw_copy_widget_value_args (widget_value* val, widget_value* copy)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1455 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1456 if (val == copy || val->args == copy->args)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1457 return;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1458
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1459 if (copy->args)
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1460 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1461 free_widget_value_args (copy);
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1462 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1463
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1464 if (val->args)
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1465 {
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1466 copy->args = val->args;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1467 copy->args->ref_count++;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1468 }
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1469 }
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1470
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1471 /* Remove %_ and convert %% to %. We can do this in-place because we
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1472 are always shortening, never lengthening, the string. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1473 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1474 lw_remove_accelerator_spec (char *val)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1475 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1476 char *foo = val, *bar = val;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1477
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1478 while (*bar)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1479 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1480 if (*bar == '%' && *(bar+1) == '_')
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1481 bar += 2;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1482 else if (*bar == '%' && *(bar+1) == '%')
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1483 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1484 *foo++ = *bar++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1485 bar++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1486 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1487 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1488 *foo++ = *bar++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1489 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1490 *foo = '\0';
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1491 }