Mercurial > hg > xemacs-beta
view src/gui.c @ 872:79c6ff3eef26
[xemacs-hg @ 2002-06-20 21:18:01 by ben]
font changes etc.; some 21.4 changes
mule/mule-msw-init-late.el: Specify charset->windows-registry conversion.
mule/mule-x-init.el: Delete extra mule font additions here. Put them in faces.c.
cl-macs.el: Document better.
font-lock.el: Move Lisp function regexp to lisp-mode.el.
lisp-mode.el: Various indentation fixes:
Handle flet functions better.
Handle argument lists in defuns and flets.
Handle quoted lists, e.g. property lists -- don't indent like
function calls. Distinguish between lambdas and other lists.
lisp-mode.el: Handle this form.
faces.el, font-menu.el, font.el, gtk-faces.el, msw-faces.el, msw-font-menu.el, x-faces.el, x-init.el: Major overhaul of face-handling code:
-- Fix lots of bogus code in msw-faces.el, msw-font-menu.el,
font-menu.el that was "truenaming" font specs -- i.e. in the
process of frobbing a particular field in a general user-specified
font spec with wildcarded fields, sticking in particular values
for all the remaining wildcarded fields. This bug was rampant
everywhere except in x-faces.el (the oldest and only correctly
written code). This also means that we need to work with font
names at all times and not font instances, because a font instance
is essentially a truenamed font.
-- Total rewrite of extremely junky code in msw-faces.el. Work
with names as well as font instances, and return names; stop
truenaming when canonicalizing and frobbing; fix handling of the
combined style field, i.e. weight/slant (also fixed in font.el).
-- Totally rewrite the frobbing functions in faces.el. This time,
we frob all the instantiators rather than just computing a single
instance value and working backwards. That way, e.g., `bold' will
work for all charsets that have bold available, rather than only
for whatever charset was part of the computed font instance
(another example of the truename virus). Also fix up code to look
at the fallbacks (all of them) when no global value present, so we
don't need to put something in the global value. Intelligently
handle a request to frob a buffer locale, rather than signalling
an error. When frobbing instantiators, try hard to figure out
what device type is associated with them, and frob each according
to its own proper device type. Correctly handle inheritance
vectors given as instantiators. Preserve existing tags when
putting back frobbed instantiators. Extract out general
specifier-frobbing code into specifier.el. Document everything
cleanly. Do lots of other things better, etc.
-- Don't duplicatively set a global specification for the default
font -- it's already in the fallback and we no longer need a
default global specification present. Delete various code in
x-faces.el and msw-faces.el that duplicated the lists of fonts in
faces.c.
-- init-global-faces was not being called at all under MS Windows!
Major bogosity. That caused device-specific values to get stuck
into all the fonts, making it very hard to change them -- setting
global specs caused nothing to happen.
-- Correct weight names in font.el.
-- Lots more font fixups in objects*.c.
Printer.el: Warning fix.
specifier.el: Add more args to map-specifier.
Add various "heuristic" specifier functions to aid in creation of
specifier-munging code such as in faces.el.
subr.el: New functions.
lwlib.c: Fix warning.
config.inc.samp: Clean up, add args to control fastcall (not yet supported! the
changes needed are in another ws of mine), profile support, vc6
support, union-type.
xemacs.dsp, xemacs.mak: Semi-major overhaul.
Fix bug where dump-id was always getting recomputed, forcing a
redump even when nothing changed.
Add support for fastcall. Support edit-and-continue (on by
default) with vc6. Use incremental linking when doing a debug
compilation. Add support for profiling.
Consolidate the various debug flags.
Partial support for "batch-compiling" -- compiling many files on a
single invocation of the compiler. Doesn't seem to help that much
for me, so it's not finished or enabled by default.
Remove HAVE_MSW_C_DIRED, we always do.
Correct some sloppy use of directories.
s/cygwin32.h: Allow pdump to work under Cygwin (mmap is broken, so need to undefine
HAVE_MMAP).
s/win32-common.h, s/windowsnt.h: Support for fastcall. Add WIN32_ANY for identifying all Win32
variants (Cygwin, native, MinGW). Both of these are properly used
in another ws.
alloc.c, balloon-x.c, buffer.c, bytecode.c, callint.c, cm.c, cmdloop.c, cmds.c, console-gtk.c, console-gtk.h, console-msw.c, console-msw.h, console-stream.c, console-stream.h, console-tty.c, console-tty.h, console-x.c, console-x.h, console.c, console.h, device-gtk.c, device-msw.c, device-tty.c, device-x.c, device.c, device.h, devslots.h, dialog-gtk.c, dialog-msw.c, dialog-x.c, dialog.c, dired-msw.c, editfns.c, emacs.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-tty.c, event-unixoid.c, events.c, extents.c, extents.h, faces.c, fileio.c, fns.c, frame-gtk.c, frame-msw.c, frame-tty.c, frame-x.c, frame.c, frame.h, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, glyphs.c, glyphs.h, gui-gtk.c, gui-msw.c, gui-x.c, gui.c, gutter.c, input-method-xlib.c, intl-encap-win32.c, intl-win32.c, keymap.c, lisp.h, macros.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, menubar.h, minibuf.c, mule-charset.c, nt.c, objects-gtk.c, objects-gtk.h, objects-msw.c, objects-msw.h, objects-tty.c, objects-tty.h, objects-x.c, objects-x.h, objects.c, objects.h, postgresql.c, print.c, process.h, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-tty.c, redisplay-x.c, redisplay.c, redisplay.h, scrollbar-gtk.c, scrollbar-msw.c, scrollbar-x.c, scrollbar.c, select-gtk.c, select-msw.c, select-x.c, select.c, signal.c, sound.c, specifier.c, symbols.c, syntax.c, sysdep.c, syssignal.h, syswindows.h, toolbar-common.c, toolbar-gtk.c, toolbar-msw.c, toolbar-x.c, toolbar.c, unicode.c, window.c, window.h: The following are the major changes made:
(1) Separation of various header files into an external and an
internal version, similar to the existing separation of process.h
and procimpl.h. Eventually this should be done for all Lisp
objects. The external version has the same name as currently; the
internal adds -impl. The external file has XFOO() macros for
objects, but the structure is opaque and defined only in the
internal file. It's now reasonable to move all prototypes in
lisp.h into the appropriate external file, and this should be
done. Currently, separation has been done on extents.h,
objects*.h, console.h, device.h, frame.h, and window.h.
For c/d/f/w, the most basic properties are available in the
external header file, with the macros resolving to functions. In
the internal header file, the macros are redefined to directly
access the structure. Also, the global MARK_FOO_CHANGED macros
have been made into functions so that they can be accessed without
needing to include lots of -impl headers -- they are used in
almost exclusively in non-time-critical functions, and take up
enough time that the function overhead will be negligible.
Similarly, the function overhead from making the basic properties
mentioned above into functions is negligible, and code that does
heavy accessing of c/d/f/w structures inevitably ends up needing
the internal header files, anyway.
(2) More face changes.
-- Major rewrite of objects-msw.c. Now handles wildcard specs
properly, rather than "truenaming" (or even worse, signalling an
error, which previously happened with some of the fallbacks if you
tried to use them in make-font-instance!).
-- Split charset matching of fonts into two stages -- one to find
a font specifically designed for a particular charset (by
examining its registry), the second to find a Unicode font that
can support the charset. This needs to proceed as two complete,
separate instantiations in order to work properly (otherwise many
of the fonts in the HELLO page look wrong). This should also make
it easy to support iso10646 (Unicode) fonts under X.
-- All default values for fonts are now completely specified in
the fallbacks. Stuff from mule-x-init.el has all been moved here,
merged with the existing specs, and totally rethought so you get
sensible results. (HELLO now looks much better!).
-- Generalize the "default X/GTK device" stuff into a
per-device-type "default device".
-- Add mswindows-{set-}charset-registry. In time,
charset<->code-page conversion functions will be removed.
-- Wrap protective code around calls to compute device specifier tags,
and do this computation before calling the face initialization code
because the latter may need these tags to be correctly updated.
(3) Other changes.
EmacsFrame.c, glyphs-msw.c, eval.c, gui-x.c, intl-encap-win32.c, search.c, signal.c, toolbar-msw.c, unicode.c: Warning fixes.
config.h.in: #undefs meant to be frobbed by configure *MUST* go inside of
#ifndef WIN32_NO_CONFIGURE, and everything else *MUST* go outside!
eval.c: Let detailed backtraces be detailed.
specifier.c: Don't override user's print-string-length/print-length settings.
glyphs.c: New function image-instance-instantiator.
config.h.in, sysdep.c: Changes for fastcall.
sysdep.c, nt.c: Fix up a previous botched patch that tried to add support for both
EEXIST and EACCES. IF THE BOTCHED PATCH WENT INTO 21.4, THIS FIXUP
NEEDS TO GO IN, TOO.
search.c: Fix *evil* crash due to incorrect synching of syntax-cache code
with 21.1. THIS SHOULD GO INTO 21.4.
author | ben |
---|---|
date | Thu, 20 Jun 2002 21:19:10 +0000 |
parents | 804517e16990 |
children | c925bacdda60 |
line wrap: on
line source
/* Generic GUI code. (menubars, scrollbars, toolbars, dialogs) Copyright (C) 1995 Board of Trustees, University of Illinois. Copyright (C) 1995, 1996, 2000, 2001, 2002 Ben Wing. Copyright (C) 1995 Sun Microsystems, Inc. Copyright (C) 1998 Free Software Foundation, Inc. This file is part of XEmacs. XEmacs is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. XEmacs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with XEmacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Synched up with: Not in FSF. */ /* This file Mule-ized by Ben Wing, 3-24-02. */ #include <config.h> #include "lisp.h" #include "buffer.h" #include "bytecode.h" #include "elhash.h" #include "gui.h" #include "menubar.h" Lisp_Object Qmenu_no_selection_hook; Lisp_Object Vmenu_no_selection_hook; static Lisp_Object parse_gui_item_tree_list (Lisp_Object list); Lisp_Object find_keyword_in_vector (Lisp_Object vector, Lisp_Object keyword); Lisp_Object Qgui_error; #ifdef HAVE_POPUPS /* count of menus/dboxes currently up */ int popup_up_p; DEFUN ("popup-up-p", Fpopup_up_p, 0, 0, 0, /* Return t if a popup menu or dialog box is up, nil otherwise. See `popup-menu' and `popup-dialog-box'. */ ()) { return popup_up_p ? Qt : Qnil; } #endif /* HAVE_POPUPS */ int separator_string_p (const Ibyte *s) { const Ibyte *p; Ibyte first; if (!s || s[0] == '\0') return 0; first = s[0]; if (first != '-' && first != '=') return 0; for (p = s; *p == first; p++) ; return (*p == '!' || *p == ':' || *p == '\0'); } /* Massage DATA to find the correct function and argument. Used by popup_selection_callback() and the msw code. */ void get_gui_callback (Lisp_Object data, Lisp_Object *fn, Lisp_Object *arg) { if (EQ (data, Qquit)) { *fn = Qeval; *arg = list3 (Qsignal, list2 (Qquote, Qquit), Qnil); Vquit_flag = Qt; } else if (SYMBOLP (data) || (COMPILED_FUNCTIONP (data) && XCOMPILED_FUNCTION (data)->flags.interactivep) || (CONSP (data) && (EQ (XCAR (data), Qlambda)) && !NILP (Fassq (Qinteractive, Fcdr (Fcdr (data)))))) { *fn = Qcall_interactively; *arg = data; } else if (CONSP (data)) { *fn = Qeval; *arg = data; } else { *fn = Qeval; *arg = list3 (Qsignal, list2 (Qquote, Qerror), list2 (Qquote, list2 (build_msg_string ("illegal callback"), data))); } } /* * Add a value VAL associated with keyword KEY into PGUI_ITEM * structure. If KEY is not a keyword, or is an unknown keyword, then * error is signaled. */ int gui_item_add_keyval_pair (Lisp_Object gui_item, Lisp_Object key, Lisp_Object val, Error_Behavior errb) { Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item); int retval = 0; if (!KEYWORDP (key)) sferror_2 ("Non-keyword in gui item", key, pgui_item->name); if (EQ (key, Q_descriptor)) { if (!EQ (pgui_item->name, val)) { retval = 1; pgui_item->name = val; } } #define FROB(slot) \ else if (EQ (key, Q_##slot)) \ { \ if (!EQ (pgui_item->slot, val)) \ { \ retval = 1; \ pgui_item->slot = val; \ } \ } FROB (suffix) FROB (active) FROB (included) FROB (config) FROB (filter) FROB (style) FROB (selected) FROB (keys) FROB (callback) FROB (callback_ex) FROB (value) #undef FROB else if (EQ (key, Q_key_sequence)) ; /* ignored for FSF compatibility */ else if (EQ (key, Q_label)) ; /* ignored for 21.0 implement in 21.2 */ else if (EQ (key, Q_accelerator)) { if (!EQ (pgui_item->accelerator, val)) { retval = 1; if (SYMBOLP (val) || CHARP (val)) pgui_item->accelerator = val; else if (ERRB_EQ (errb, ERROR_ME)) invalid_argument ("Bad keyboard accelerator", val); } } else if (ERRB_EQ (errb, ERROR_ME)) invalid_argument_2 ("Unknown keyword in gui item", key, pgui_item->name); return retval; } void gui_item_init (Lisp_Object gui_item) { Lisp_Gui_Item *lp = XGUI_ITEM (gui_item); lp->name = Qnil; lp->callback = Qnil; lp->callback_ex = Qnil; lp->suffix = Qnil; lp->active = Qt; lp->included = Qt; lp->config = Qnil; lp->filter = Qnil; lp->style = Qnil; lp->selected = Qnil; lp->keys = Qnil; lp->accelerator = Qnil; lp->value = Qnil; } Lisp_Object allocate_gui_item (void) { Lisp_Gui_Item *lp = alloc_lcrecord_type (Lisp_Gui_Item, &lrecord_gui_item); Lisp_Object val; zero_lcrecord (lp); val = wrap_gui_item (lp); gui_item_init (val); return val; } /* * ITEM is a lisp vector, describing a menu item or a button. The * function extracts the description of the item into the PGUI_ITEM * structure. */ static Lisp_Object make_gui_item_from_keywords_internal (Lisp_Object item, Error_Behavior errb) { int length, plist_p, start; Lisp_Object *contents; Lisp_Object gui_item = allocate_gui_item (); Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item); CHECK_VECTOR (item); length = XVECTOR_LENGTH (item); contents = XVECTOR_DATA (item); if (length < 1) sferror ("GUI item descriptors must be at least 1 elts long", item); /* length 1: [ "name" ] length 2: [ "name" callback ] length 3: [ "name" callback active-p ] or [ "name" keyword value ] length 4: [ "name" callback active-p suffix ] or [ "name" callback keyword value ] length 5+: [ "name" callback [ keyword value ]+ ] or [ "name" [ keyword value ]+ ] */ plist_p = (length > 2 && (KEYWORDP (contents [1]) || KEYWORDP (contents [2]))); pgui_item->name = contents [0]; if (length > 1 && !KEYWORDP (contents [1])) { pgui_item->callback = contents [1]; start = 2; } else start =1; if (!plist_p && length > 2) /* the old way */ { pgui_item->active = contents [2]; if (length == 4) pgui_item->suffix = contents [3]; } else /* the new way */ { int i; if ((length - start) & 1) sferror ( "GUI item descriptor has an odd number of keywords and values", item); for (i = start; i < length;) { Lisp_Object key = contents [i++]; Lisp_Object val = contents [i++]; gui_item_add_keyval_pair (gui_item, key, val, errb); } } return gui_item; } /* This will only work with descriptors in the new format. */ Lisp_Object widget_gui_parse_item_keywords (Lisp_Object item) { int i, length; Lisp_Object *contents; Lisp_Object gui_item = allocate_gui_item (); Lisp_Object desc = find_keyword_in_vector (item, Q_descriptor); CHECK_VECTOR (item); length = XVECTOR_LENGTH (item); contents = XVECTOR_DATA (item); if (!NILP (desc) && !STRINGP (desc) && !VECTORP (desc)) sferror ("Invalid GUI item descriptor", item); if (length & 1) { if (!SYMBOLP (contents [0])) sferror ("Invalid GUI item descriptor", item); contents++; /* Ignore the leading symbol. */ length--; } for (i = 0; i < length;) { Lisp_Object key = contents [i++]; Lisp_Object val = contents [i++]; gui_item_add_keyval_pair (gui_item, key, val, ERROR_ME_NOT); } return gui_item; } /* Update a gui item from a partial descriptor. */ int update_gui_item_keywords (Lisp_Object gui_item, Lisp_Object item) { int i, length, retval = 0; Lisp_Object *contents; CHECK_VECTOR (item); length = XVECTOR_LENGTH (item); contents = XVECTOR_DATA (item); if (length & 1) { if (!SYMBOLP (contents [0])) sferror ("Invalid GUI item descriptor", item); contents++; /* Ignore the leading symbol. */ length--; } for (i = 0; i < length;) { Lisp_Object key = contents [i++]; Lisp_Object val = contents [i++]; if (gui_item_add_keyval_pair (gui_item, key, val, ERROR_ME_DEBUG_WARN)) retval = 1; } return retval; } Lisp_Object gui_parse_item_keywords (Lisp_Object item) { return make_gui_item_from_keywords_internal (item, ERROR_ME); } Lisp_Object gui_parse_item_keywords_no_errors (Lisp_Object item) { return make_gui_item_from_keywords_internal (item, ERROR_ME_DEBUG_WARN); } /* convert a gui item into plist properties */ void gui_add_item_keywords_to_plist (Lisp_Object plist, Lisp_Object gui_item) { Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item); if (!NILP (pgui_item->callback)) Fplist_put (plist, Q_callback, pgui_item->callback); if (!NILP (pgui_item->callback_ex)) Fplist_put (plist, Q_callback_ex, pgui_item->callback_ex); if (!NILP (pgui_item->suffix)) Fplist_put (plist, Q_suffix, pgui_item->suffix); if (!NILP (pgui_item->active)) Fplist_put (plist, Q_active, pgui_item->active); if (!NILP (pgui_item->included)) Fplist_put (plist, Q_included, pgui_item->included); if (!NILP (pgui_item->config)) Fplist_put (plist, Q_config, pgui_item->config); if (!NILP (pgui_item->filter)) Fplist_put (plist, Q_filter, pgui_item->filter); if (!NILP (pgui_item->style)) Fplist_put (plist, Q_style, pgui_item->style); if (!NILP (pgui_item->selected)) Fplist_put (plist, Q_selected, pgui_item->selected); if (!NILP (pgui_item->keys)) Fplist_put (plist, Q_keys, pgui_item->keys); if (!NILP (pgui_item->accelerator)) Fplist_put (plist, Q_accelerator, pgui_item->accelerator); if (!NILP (pgui_item->value)) Fplist_put (plist, Q_value, pgui_item->value); } /* * Decide whether a GUI item is active by evaluating its :active form * if any */ int gui_item_active_p (Lisp_Object gui_item) { /* This function can call lisp */ /* Shortcut to avoid evaluating Qt each time */ return (EQ (XGUI_ITEM (gui_item)->active, Qt) || !NILP (Feval (XGUI_ITEM (gui_item)->active))); } /* set menu accelerator key to first underlined character in menu name */ Lisp_Object gui_item_accelerator (Lisp_Object gui_item) { Lisp_Gui_Item *pgui = XGUI_ITEM (gui_item); if (!NILP (pgui->accelerator)) return pgui->accelerator; else return gui_name_accelerator (pgui->name); } Lisp_Object gui_name_accelerator (Lisp_Object nm) { Ibyte *name = XSTRING_DATA (nm); while (*name) { if (*name == '%') { ++name; if (!(*name)) return Qnil; if (*name == '_' && *(name + 1)) { Ichar accelerator = itext_ichar (name + 1); return make_char (DOWNCASE (0, accelerator)); } } INC_IBYTEPTR (name); } return make_char (DOWNCASE (0, itext_ichar (XSTRING_DATA (nm)))); } /* * Decide whether a GUI item is selected by evaluating its :selected form * if any */ int gui_item_selected_p (Lisp_Object gui_item) { /* This function can call lisp */ /* Shortcut to avoid evaluating Qt each time */ return (EQ (XGUI_ITEM (gui_item)->selected, Qt) || !NILP (Feval (XGUI_ITEM (gui_item)->selected))); } Lisp_Object gui_item_list_find_selected (Lisp_Object gui_item_list) { /* This function can GC. */ Lisp_Object rest; LIST_LOOP (rest, gui_item_list) { if (gui_item_selected_p (XCAR (rest))) return XCAR (rest); } return XCAR (gui_item_list); } /* * Decide whether a GUI item is included by evaluating its :included * form if given, and testing its :config form against supplied CONFLIST * configuration variable */ int gui_item_included_p (Lisp_Object gui_item, Lisp_Object conflist) { /* This function can call lisp */ Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item); /* Evaluate :included first. Shortcut to avoid evaluating Qt each time */ if (!EQ (pgui_item->included, Qt) && NILP (Feval (pgui_item->included))) return 0; /* Do :config if conflist is given */ if (!NILP (conflist) && !NILP (pgui_item->config) && NILP (Fmemq (pgui_item->config, conflist))) return 0; return 1; } /* * Format "left flush" display portion of an item. */ Lisp_Object gui_item_display_flush_left (Lisp_Object gui_item) { /* This function can call lisp */ Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item); Lisp_Object retval; CHECK_STRING (pgui_item->name); retval = pgui_item->name; if (!NILP (pgui_item->suffix)) { Lisp_Object suffix = pgui_item->suffix; /* Shortcut to avoid evaluating suffix each time */ if (!STRINGP (suffix)) { suffix = Feval (suffix); CHECK_STRING (suffix); } retval = concat3 (pgui_item->name, build_string (" "), suffix); } return retval; } /* * Format "right flush" display portion of an item into BUF. */ Lisp_Object gui_item_display_flush_right (Lisp_Object gui_item) { Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item); #ifdef HAVE_MENUBARS /* Have keys? */ if (!menubar_show_keybindings) return Qnil; #endif /* Try :keys first */ if (!NILP (pgui_item->keys)) { CHECK_STRING (pgui_item->keys); return pgui_item->keys; } /* See if we can derive keys out of callback symbol */ if (SYMBOLP (pgui_item->callback)) { DECLARE_EISTRING_MALLOC (buf); Lisp_Object str; where_is_to_char (pgui_item->callback, buf); str = eimake_string (buf); eifree (buf); return str; } /* No keys - no right flush display */ return Qnil; } static Lisp_Object mark_gui_item (Lisp_Object obj) { Lisp_Gui_Item *p = XGUI_ITEM (obj); mark_object (p->name); mark_object (p->callback); mark_object (p->callback_ex); mark_object (p->config); mark_object (p->suffix); mark_object (p->active); mark_object (p->included); mark_object (p->config); mark_object (p->filter); mark_object (p->style); mark_object (p->selected); mark_object (p->keys); mark_object (p->accelerator); mark_object (p->value); return Qnil; } static Hashcode gui_item_hash (Lisp_Object obj, int depth) { Lisp_Gui_Item *p = XGUI_ITEM (obj); return HASH2 (HASH6 (internal_hash (p->name, depth + 1), internal_hash (p->callback, depth + 1), internal_hash (p->callback_ex, depth + 1), internal_hash (p->suffix, depth + 1), internal_hash (p->active, depth + 1), internal_hash (p->included, depth + 1)), HASH6 (internal_hash (p->config, depth + 1), internal_hash (p->filter, depth + 1), internal_hash (p->style, depth + 1), internal_hash (p->selected, depth + 1), internal_hash (p->keys, depth + 1), internal_hash (p->value, depth + 1))); } int gui_item_id_hash (Lisp_Object hashtable, Lisp_Object gitem, int slot) { int hashid = gui_item_hash (gitem, 0); int id = GUI_ITEM_ID_BITS (hashid, slot); while (!UNBOUNDP (Fgethash (make_int (id), hashtable, Qunbound))) { id = GUI_ITEM_ID_BITS (id + 1, slot); } return id; } int gui_item_equal_sans_selected (Lisp_Object obj1, Lisp_Object obj2, int depth) { Lisp_Gui_Item *p1 = XGUI_ITEM (obj1); Lisp_Gui_Item *p2 = XGUI_ITEM (obj2); if (!(internal_equal (p1->name, p2->name, depth + 1) && internal_equal (p1->callback, p2->callback, depth + 1) && internal_equal (p1->callback_ex, p2->callback_ex, depth + 1) && EQ (p1->suffix, p2->suffix) && EQ (p1->active, p2->active) && EQ (p1->included, p2->included) && EQ (p1->config, p2->config) && EQ (p1->filter, p2->filter) && EQ (p1->style, p2->style) && EQ (p1->accelerator, p2->accelerator) && EQ (p1->keys, p2->keys) && EQ (p1->value, p2->value))) return 0; return 1; } static int gui_item_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) { Lisp_Gui_Item *p1 = XGUI_ITEM (obj1); Lisp_Gui_Item *p2 = XGUI_ITEM (obj2); if (!(gui_item_equal_sans_selected (obj1, obj2, depth) && EQ (p1->selected, p2->selected))) return 0; return 1; } static void print_gui_item (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) { Lisp_Gui_Item *g = XGUI_ITEM (obj); if (print_readably) printing_unreadable_object ("#<gui-item 0x%x>", g->header.uid); write_fmt_string (printcharfun, "#<gui-item 0x%x>", g->header.uid); } Lisp_Object copy_gui_item (Lisp_Object gui_item) { Lisp_Object ret = allocate_gui_item (); Lisp_Gui_Item *lp, *g = XGUI_ITEM (gui_item); lp = XGUI_ITEM (ret); lp->name = g->name; lp->callback = g->callback; lp->callback_ex = g->callback_ex; lp->suffix = g->suffix; lp->active = g->active; lp->included = g->included; lp->config = g->config; lp->filter = g->filter; lp->style = g->style; lp->selected = g->selected; lp->keys = g->keys; lp->accelerator = g->accelerator; lp->value = g->value; return ret; } Lisp_Object copy_gui_item_tree (Lisp_Object arg) { if (CONSP (arg)) { Lisp_Object rest = arg = Fcopy_sequence (arg); while (CONSP (rest)) { XCAR (rest) = copy_gui_item_tree (XCAR (rest)); rest = XCDR (rest); } return arg; } else if (GUI_ITEMP (arg)) return copy_gui_item (arg); else return arg; } /* parse a glyph descriptor into a tree of gui items. The gui_item slot of an image instance can be a single item or an arbitrarily nested hierarchy of item lists. */ static Lisp_Object parse_gui_item_tree_item (Lisp_Object entry) { Lisp_Object ret = entry; struct gcpro gcpro1; GCPRO1 (ret); if (VECTORP (entry)) { ret = gui_parse_item_keywords_no_errors (entry); } else if (STRINGP (entry)) { CHECK_STRING (entry); } else sferror ("item must be a vector or a string", entry); RETURN_UNGCPRO (ret); } Lisp_Object parse_gui_item_tree_children (Lisp_Object list) { Lisp_Object rest, ret = Qnil, sub = Qnil; struct gcpro gcpro1, gcpro2; GCPRO2 (ret, sub); CHECK_CONS (list); /* recursively add items to the tree view */ LIST_LOOP (rest, list) { if (CONSP (XCAR (rest))) sub = parse_gui_item_tree_list (XCAR (rest)); else sub = parse_gui_item_tree_item (XCAR (rest)); ret = Fcons (sub, ret); } /* make the order the same as the items we have parsed */ RETURN_UNGCPRO (Fnreverse (ret)); } static Lisp_Object parse_gui_item_tree_list (Lisp_Object list) { Lisp_Object ret; struct gcpro gcpro1; CHECK_CONS (list); /* first one can never be a list */ ret = parse_gui_item_tree_item (XCAR (list)); GCPRO1 (ret); ret = Fcons (ret, parse_gui_item_tree_children (XCDR (list))); RETURN_UNGCPRO (ret); } static void finalize_gui_item (void *header, int for_disksave) { } DEFINE_LRECORD_IMPLEMENTATION ("gui-item", gui_item, mark_gui_item, print_gui_item, finalize_gui_item, gui_item_equal, gui_item_hash, 0, Lisp_Gui_Item); DOESNT_RETURN gui_error (const Char_ASCII *reason, Lisp_Object frob) { signal_error (Qgui_error, reason, frob); } DOESNT_RETURN gui_error_2 (const Char_ASCII *reason, Lisp_Object frob0, Lisp_Object frob1) { signal_error_2 (Qgui_error, reason, frob0, frob1); } void syms_of_gui (void) { INIT_LRECORD_IMPLEMENTATION (gui_item); DEFSYMBOL (Qmenu_no_selection_hook); DEFERROR_STANDARD (Qgui_error, Qio_error); #ifdef HAVE_POPUPS DEFSUBR (Fpopup_up_p); #endif } void vars_of_gui (void) { DEFVAR_LISP ("menu-no-selection-hook", &Vmenu_no_selection_hook /* Function or functions to call when a menu or dialog box is dismissed without a selection having been made. */ ); Vmenu_no_selection_hook = Qnil; }