#
authorDave Love <fx@gnu.org>
Sun, 3 Oct 1999 19:36:13 +0000 (19:36 +0000)
committerDave Love <fx@gnu.org>
Sun, 3 Oct 1999 19:36:13 +0000 (19:36 +0000)
39 files changed:
oldXMenu/Activate.c [new file with mode: 0644]
oldXMenu/AddPane.c [new file with mode: 0644]
oldXMenu/AddSel.c [new file with mode: 0644]
oldXMenu/ChangeLog [new file with mode: 0644]
oldXMenu/ChgPane.c [new file with mode: 0644]
oldXMenu/ChgSel.c [new file with mode: 0644]
oldXMenu/Create.c [new file with mode: 0644]
oldXMenu/DelPane.c [new file with mode: 0644]
oldXMenu/DelSel.c [new file with mode: 0644]
oldXMenu/Destroy.c [new file with mode: 0644]
oldXMenu/Error.c [new file with mode: 0644]
oldXMenu/EvHand.c [new file with mode: 0644]
oldXMenu/FindPane.c [new file with mode: 0644]
oldXMenu/FindSel.c [new file with mode: 0644]
oldXMenu/Imakefile [new file with mode: 0644]
oldXMenu/InsPane.c [new file with mode: 0644]
oldXMenu/InsSel.c [new file with mode: 0644]
oldXMenu/Internal.c [new file with mode: 0644]
oldXMenu/Locate.c [new file with mode: 0644]
oldXMenu/Makefile.in [new file with mode: 0644]
oldXMenu/Post.c [new file with mode: 0644]
oldXMenu/README [new file with mode: 0644]
oldXMenu/Recomp.c [new file with mode: 0644]
oldXMenu/SetAEQ.c [new file with mode: 0644]
oldXMenu/SetFrz.c [new file with mode: 0644]
oldXMenu/SetPane.c [new file with mode: 0644]
oldXMenu/SetSel.c [new file with mode: 0644]
oldXMenu/X10.h [new file with mode: 0644]
oldXMenu/XCrAssoc.c [new file with mode: 0644]
oldXMenu/XDelAssoc.c [new file with mode: 0644]
oldXMenu/XDestAssoc.c [new file with mode: 0644]
oldXMenu/XLookAssoc.c [new file with mode: 0644]
oldXMenu/XMakeAssoc.c [new file with mode: 0644]
oldXMenu/XMenu.h [new file with mode: 0644]
oldXMenu/XMenuInt.h [new file with mode: 0644]
oldXMenu/compile.com [new file with mode: 0644]
oldXMenu/copyright.h [new file with mode: 0644]
oldXMenu/descrip.mms [new file with mode: 0644]
oldXMenu/insque.c [new file with mode: 0644]

diff --git a/oldXMenu/Activate.c b/oldXMenu/Activate.c
new file mode 100644 (file)
index 0000000..fb1ef2b
--- /dev/null
@@ -0,0 +1,546 @@
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/Activate.c,v 1.1 1992/04/11 22:10:17 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "copyright.h"
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuActivate - Maps a given menu to the display and activates
+ *                     the menu for user selection.  The user is allowed to
+ *                     specify which pane and selection will be current,
+ *                     the X and Y location of the menu (relative to the
+ *                     parent window) and the mouse button event mask that
+ *                     will be used to identify a selection request.
+ *
+ *                     A menu selection is shown to be current by placing
+ *                     a highlight box around the selection as the mouse
+ *                     cursor enters its active region.  Inactive selections
+ *                     will not be highlighted.  As the mouse cursor moved
+ *                     from one menu pane to another menu pane the pane being
+ *                     entered is raised and made current and the pane being
+ *                     left is lowered.
+ *
+ *                     Anytime XMenuActivate returns, the p_num and
+ *                     s_num are left at their last known values (i.e.,
+ *                     the last known current pane and selection indices).
+ *                     The following are the defined return states:
+ *
+ *                     1)      If at any time an error occurs the data
+ *                             pointer is left untouched and XM_FAILURE
+ *                             is returned.  
+ *
+ *                     2)      When a selection request is received (i.e.,
+ *                             when the specified mouse event occurs) the
+ *                             data pointer will be set to the data
+ *                             associated with the particular selection
+ *                             current at the time of the selection request
+ *                             and XM_SUCCESS is returned.
+ *
+ *                     3)      If no selection was current at the time a
+ *                             selection request is made the data pointer
+ *                             will be left untouched and XM_NO_SELECT will
+ *                             be returned.
+ *
+ *                     4)      If the selection that was current at the time 
+ *                             a selection request is made is not an active
+ *                             selection the data pointer will be left
+ *                             untouched and XM_IA_SELECT will be returned.
+ *
+ *                     Since X processes events in an asynchronous manner
+ *                     it is likely that XMenuActivate will encounter
+ *                     a "foreign event" while it is executing.  Foreign
+ *                     events are handled in one of three ways:
+ *
+ *                     1)      The event is discarded.  This is the default
+ *                             mode and requires no action on the part of the
+ *                             application.
+ *
+ *                     2)      The application has identified an asynchronous
+ *                             event handler that will be called and the
+ *                             foreign event handed off to it.  Note:
+ *                             AEQ mode disables this mode temporarily.
+ *
+ *                     3)      The application has enabled asynchronous event
+ *                             queuing mode.  In this mode all foreign events
+ *                             will be queued up untill XMenuActivate
+ *                             terminates; at which time they will be
+ *                             returned to the X event queue.  As long as
+ *                             AEQ mode is enabled any asynchronous event
+ *                             handler as temporarily disabled.
+ *
+ *                     Any events encountered while taking down the menu
+ *                     (i.e., exposure events from occluded windows) will
+ *                     automatically be returned to the X event queue after
+ *                     XMenuActivate has cleaned the queue of any of its own
+ *                     events that are no longer needed.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     March 12, 1986
+ *
+ */
+
+#include <config.h>
+#include "XMenuInt.h"
+
+int
+XMenuActivate(display, menu, p_num, s_num, x_pos, y_pos, event_mask, data)
+    register Display *display;         /* Display to put menu on. */
+    register XMenu *menu;              /* Menu to activate. */
+    int *p_num;                                /* Pane number selected. */
+    int *s_num;                                /* Selection number selected. */
+    int x_pos;                         /* X coordinate of menu position. */
+    int y_pos;                         /* Y coordinate of menu position. */
+    unsigned int event_mask;           /* Mouse button event mask. */
+    char **data;                       /* Pointer to return data value. */
+{
+    int status;                                /* X routine call status. */
+    int orig_x;                                /* Upper left menu origin X coord. */
+    int orig_y;                                /* Upper left menu origin Y coord. */
+    int ret_val;                       /* Return value. */
+
+    register XMPane *p_ptr;            /* Current XMPane. */
+    register XMPane *event_xmp;                /* Event XMPane pointer. */
+    register XMPane *cur_p;            /* Current pane. */
+    register XMSelect *cur_s;          /* Current selection. */
+    XMWindow *event_xmw;               /* Event XMWindow pointer. */
+    XEvent event;                      /* X input event. */
+    XEvent peek_event;                 /* X input peek ahead event. */
+
+    Bool selection = False;            /* Selection has been made. */
+    Bool forward = True;               /* Moving forward in the pane list. */
+
+    Window root, child;
+    int root_x, root_y, win_x, win_y;
+    unsigned int mask;
+
+    /*
+     * Define and allocate a foreign event queue to hold events
+     * that don't belong to XMenu.  These events are later restored
+     * to the X event queue.
+     */
+    typedef struct _xmeventque {
+       XEvent event;
+       struct _xmeventque *next;
+    } XMEventQue;
+
+    XMEventQue *feq = NULL;                    /* Foreign event queue. */
+    XMEventQue *feq_tmp;               /* Foreign event queue temporary. */
+    
+    /*
+     * If there are no panes in the menu then return failure
+     * because the menu is not initialized.
+     */
+    if (menu->p_count == 0) {
+       _XMErrorCode = XME_NOT_INIT;
+       return(XM_FAILURE);
+    }
+
+    /*
+     * Find the desired current pane.
+     */
+    cur_p = _XMGetPanePtr(menu, *p_num);
+    if (cur_p == NULL) {
+       return(XM_FAILURE);
+    }
+    cur_p->activated = cur_p->active;
+
+    /*
+     * Find the desired current selection.
+     * If the current selection index is out of range a null current selection
+     * will be assumed and the cursor will be placed in the current pane
+     * header.
+     */
+    cur_s = _XMGetSelectionPtr(cur_p, *s_num);
+
+    /*
+     * Compute origin of menu so that cursor is in
+     * Correct pane and selection.
+     */
+    _XMTransToOrigin(display, 
+                    menu, 
+                    cur_p, cur_s, 
+                    x_pos, y_pos, 
+                    &orig_x, &orig_y);
+    menu->x_pos = orig_x;      /* Store X and Y coords of menu. */
+    menu->y_pos = orig_y;
+    
+    if (XMenuRecompute(display, menu) == XM_FAILURE) {
+       return(XM_FAILURE);
+    }
+
+    /*
+     * Flush the window creation queue.
+     * This batches all window creates since lazy evaluation
+     * is more efficient than individual evaluation.
+     * This routine also does an XFlush().
+     */
+    if (_XMWinQueFlush(display, menu, cur_p, cur_s) == _FAILURE) {
+       return(XM_FAILURE);
+    }
+
+    /*
+     * Make sure windows are in correct order (in case we were passed
+     * an already created menu in incorrect order.)
+     */
+    for(p_ptr = menu->p_list->next; p_ptr != cur_p; p_ptr = p_ptr->next)
+       XRaiseWindow(display, p_ptr->window);
+    for(p_ptr = menu->p_list->prev; p_ptr != cur_p->prev; p_ptr = p_ptr->prev)
+       XRaiseWindow(display, p_ptr->window);
+
+    /*
+     * Make sure all selection windows are mapped.
+     */
+    for (
+       p_ptr = menu->p_list->next;
+       p_ptr != menu->p_list;
+       p_ptr = p_ptr->next
+    ){
+       XMapSubwindows(display, p_ptr->window);
+    }
+
+    /*
+     * Synchronize the X buffers and the event queue.
+     * From here on, all events in the queue that don't belong to
+     * XMenu are sent back to the application via an application
+     * provided event handler or discarded if the application has
+     * not provided an event handler.
+     */
+    XSync(display, 0);
+    
+    /*
+     * Grab the mouse for menu input.
+     */
+    
+    status = XGrabPointer(
+                         display,
+                         menu->parent,
+                         True,
+                         event_mask,
+                         GrabModeAsync,
+                         GrabModeAsync,
+                         None,
+                         menu->mouse_cursor,
+                         CurrentTime
+                         );
+    if (status == _X_FAILURE) {
+       _XMErrorCode = XME_GRAB_MOUSE;
+       return(XM_FAILURE);
+    }
+
+    /*
+     * Map the menu panes.
+     */
+    XMapWindow(display, cur_p->window);
+    for (p_ptr = menu->p_list->next;
+        p_ptr != cur_p; 
+        p_ptr = p_ptr->next)
+      XMapWindow(display, p_ptr->window);
+    for (p_ptr = cur_p->next;
+        p_ptr != menu->p_list;
+        p_ptr = p_ptr->next)
+      XMapWindow(display, p_ptr->window);
+
+    XRaiseWindow(display, cur_p->window);      /* Make sure current */
+                                               /* pane is on top. */
+    
+    cur_s = NULL;                      /* Clear current selection. */
+
+    /*
+     * Begin event processing loop.
+     */
+    while (1) {
+       XNextEvent(display, &event);    /* Get next event. */
+       switch (event.type) {           /* Dispatch on the event type. */
+    case Expose:
+           event_xmp = (XMPane *)XLookUpAssoc(display,
+                                              menu->assoc_tab, 
+                                              event.xexpose.window);
+           if (event_xmp == NULL) {
+               /*
+                * If AEQ mode is enabled then queue the event.
+                */
+               if (menu->aeq) {
+                   feq_tmp = (XMEventQue *)malloc(sizeof(XMEventQue));
+                   if (feq_tmp == NULL) {
+                       _XMErrorCode = XME_CALLOC;
+                       return(XM_FAILURE);
+                   }
+                   feq_tmp->event = event;
+                   feq_tmp->next = feq;
+                   feq = feq_tmp;
+               }
+               else if (_XMEventHandler) (*_XMEventHandler)(&event);
+               break;
+           }
+           if (event_xmp->activated) {
+               XSetWindowBackground(display,
+                                    event_xmp->window, 
+                                    menu->bkgnd_color);
+           }
+           else {
+               XSetWindowBackgroundPixmap(display,
+                                          event_xmp->window,
+                                          menu->inact_pixmap);
+           }
+           _XMRefreshPane(display, menu, event_xmp);
+           break;
+    case EnterNotify:
+           /* 
+            * First wait a small period of time, and see
+            * if another EnterNotify event follows hard on the
+            * heels of this one. i.e., the user is simply
+            * "passing through". If so, ignore this one.
+            */
+       
+           event_xmw = (XMWindow *)XLookUpAssoc(display,
+                                                menu->assoc_tab,
+                                                event.xcrossing.window);
+           if (event_xmw == NULL) break;
+           if (event_xmw->type == SELECTION) {
+               /*
+                * We have entered a selection.
+                */
+               /* if (XPending(display) == 0) usleep(150000); */
+               if (XPending(display) != 0) {
+                   XPeekEvent(display, &peek_event);
+                   if(peek_event.type == LeaveNotify) {
+                       break;
+                   }
+               }                         
+               cur_s = (XMSelect *)event_xmw;
+               /*
+                * If the pane we are in is active and the
+                * selection entered is active then activate
+                * the selection.
+                */
+               if (cur_p->active && cur_s->active > 0) {
+                   cur_s->activated = 1;
+                   _XMRefreshSelection(display, menu, cur_s);
+               }
+           }
+           else {
+               /*
+                * We have entered a pane.
+                */
+               /* if (XPending(display) == 0) usleep(150000); */
+               if (XPending(display) != 0) {
+                   XPeekEvent(display, &peek_event);
+                   if (peek_event.type == EnterNotify) break;
+               }
+               XQueryPointer(display,
+                             menu->parent,
+                             &root, &child,
+                             &root_x, &root_y,
+                             &win_x, &win_y,
+                             &mask);
+               event_xmp = (XMPane *)XLookUpAssoc(display,
+                                                  menu->assoc_tab,
+                                                  child);
+               if (event_xmp == NULL) break;
+               if (event_xmp == cur_p) break;
+               if (event_xmp->serial > cur_p->serial) forward = True;
+               else forward = False;
+               p_ptr = cur_p;
+               while (p_ptr != event_xmp) {
+                   if (forward) p_ptr = p_ptr->next;
+                   else p_ptr = p_ptr->prev;
+                   XRaiseWindow(display, p_ptr->window);
+               }
+               if (cur_p->activated) {
+                   cur_p->activated = False;
+                   XSetWindowBackgroundPixmap(display,
+                                              cur_p->window,
+                                              menu->inact_pixmap);
+                   _XMRefreshPane(display, menu, cur_p);
+               }
+               if (event_xmp->active) event_xmp->activated = True;
+#if 1
+               /*
+                * i suspect the we don't get an EXPOSE event when backing
+                * store is enabled; the menu windows content is probably
+                * not drawn in when it should be in that case.
+                * in that case, this is probably an ugly fix!
+                * i hope someone more familiar with this code would
+                * take it from here.  -- caveh@eng.sun.com.
+                */
+               XSetWindowBackground(display,
+                                    event_xmp->window, 
+                                    menu->bkgnd_color);
+               _XMRefreshPane(display, menu, event_xmp);
+#endif
+               cur_p = event_xmp;
+           }
+           break;
+    case LeaveNotify:
+           event_xmw = (XMWindow *)XLookUpAssoc(
+                                                display,
+                                                menu->assoc_tab,
+                                                event.xcrossing.window
+                                                );
+           if (event_xmw == NULL) break;
+           if(cur_s == NULL) break;
+           
+           /*
+            * If the current selection was activated then
+            * deactivate it.
+            */
+           if (cur_s->activated) {
+               cur_s->activated = False;
+               _XMRefreshSelection(display, menu, cur_s);
+           }
+           cur_s = NULL;
+           break;
+       
+    case ButtonPress:
+    case ButtonRelease:
+               *p_num = cur_p->serial;
+               /*
+                * Check to see if there is a current selection.
+                */
+               if (cur_s != NULL) {
+                   /*
+                    * Set the selection number to the current selection.
+                    */
+                   *s_num = cur_s->serial;
+                   /*
+                    * If the current selection was activated then
+                    * we have a valid selection otherwise we have
+                    * an inactive selection.
+                    */
+                   if (cur_s->activated) {
+                       *data = cur_s->data;
+                       ret_val = XM_SUCCESS;
+                   }
+                   else {
+                       ret_val = XM_IA_SELECT;
+                   }
+               }
+               else {
+                   /*
+                    * No selection was current.
+                    */
+                   ret_val = XM_NO_SELECT;
+               }
+               selection = True;
+               break;
+           default:
+               /*
+                * If AEQ mode is enabled then queue the event.
+                */
+               if (menu->aeq) {
+                   feq_tmp = (XMEventQue *)malloc(sizeof(XMEventQue));
+                   if (feq_tmp == NULL) {
+                       _XMErrorCode = XME_CALLOC;
+                       return(XM_FAILURE);
+                   }
+                   feq_tmp->event = event;
+                   feq_tmp->next = feq;
+                   feq = feq_tmp;
+               }
+               else if (_XMEventHandler) (*_XMEventHandler)(&event);
+       }
+       /*
+        * If a selection has been made, break out of the event loop.
+        */
+       if (selection == True) break;
+    }
+
+    /*
+     * Unmap the menu.
+     */
+    for ( p_ptr = menu->p_list->next;
+        p_ptr != menu->p_list;
+        p_ptr = p_ptr->next) 
+      {
+         XUnmapWindow(display, p_ptr->window);
+      }
+
+    /*
+     * Ungrab the mouse.
+     */
+    XUngrabPointer(display, CurrentTime);
+
+    /* 
+     * Restore bits under where the menu was if we managed
+     * to save them and free the pixmap.
+     */
+
+    /*
+     * If there is a current selection deactivate it.
+     */
+    if (cur_s != NULL) cur_s->activated = 0;
+
+    /*
+     * Deactivate the current pane.
+     */
+    cur_p->activated = 0;
+    XSetWindowBackgroundPixmap(display, cur_p->window, menu->inact_pixmap);
+
+    /*
+     * Synchronize the X buffers and the X event queue.
+     */
+    XSync(display, 0);
+    
+    /*
+     * Dispatch any events remaining on the queue.
+     */
+    while (QLength(display)) {
+       /*
+        * Fetch the next event.
+        */
+       XNextEvent(display, &event);
+
+       /*
+        * Discard any events left on the queue that belong to XMenu.
+        * All others are held and then returned to the event queue.
+        */
+       switch (event.type) {
+           case Expose:
+           case EnterNotify:
+           case LeaveNotify:
+           case ButtonPress:
+           case ButtonRelease:
+               /*
+                * Does this event belong to one of XMenu's windows?
+                * If so, discard it and process the next event.
+                * If not fall through and treat it as a foreign event.
+                */
+               event_xmp = (XMPane *)XLookUpAssoc(
+                                                  display,
+                                                  menu->assoc_tab,
+                                                  event.xbutton.window
+                                                  );
+               if (event_xmp != NULL) continue;
+           default:
+               /*
+                * This is a foreign event.
+                * Queue it for later return to the X event queue.
+                */
+               feq_tmp = (XMEventQue *)malloc(sizeof(XMEventQue));
+               if (feq_tmp == NULL) {
+                   _XMErrorCode = XME_CALLOC;
+                   return(XM_FAILURE);
+               }
+               feq_tmp->event = event;
+               feq_tmp->next = feq;
+               feq = feq_tmp;
+           }
+    }
+    /*
+     * Return any foreign events that were queued to the X event queue.
+     */
+    while (feq != NULL) {
+       feq_tmp = feq;
+       XPutBackEvent(display, &feq_tmp->event);
+       feq = feq_tmp->next;
+       free((char *)feq_tmp);
+    }
+    
+    /*
+     * Return successfully.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return(ret_val);
+
+}
diff --git a/oldXMenu/AddPane.c b/oldXMenu/AddPane.c
new file mode 100644 (file)
index 0000000..739cdfe
--- /dev/null
@@ -0,0 +1,104 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/AddPane.c,v 1.1 1992/04/11 22:10:17 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuAddPane - Adds a pane to an XMenu object.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     August, 1985
+ *
+ */
+
+#include <config.h>
+#include "XMenuInt.h"
+
+int
+XMenuAddPane(display, menu, label, active)
+    Display *display;           
+    register XMenu *menu;      /* Menu object to be modified. */
+    register char *label;      /* Selection label. */
+    int active;                        /* Make selection active? */
+{
+    register XMPane *pane;     /* Newly created pane. */
+    register XMSelect *select; /* Initial selection for the new pane. */
+        
+    int label_length;          /* Label length in characters. */
+    int label_width;           /* Label width in pixels. */
+
+    /*
+     * Check for NULL pointers!
+     */
+    if (label == NULL) {
+       _XMErrorCode = XME_ARG_BOUNDS;
+       return(XM_FAILURE);
+    }
+
+    /*
+     * Calloc the XMPane structure and the initial XMSelect.
+     */
+    pane = (XMPane *)calloc(1, sizeof(XMPane));
+    if (pane == NULL) {
+       _XMErrorCode = XME_CALLOC;
+       return(XM_FAILURE);
+    }
+    select = (XMSelect *)calloc(1, sizeof(XMSelect));
+    if (select == NULL) {
+       _XMErrorCode = XME_CALLOC;
+       return(XM_FAILURE);
+    }
+    
+    /*
+     * Determine label size.
+     */
+    label_length = strlen(label);
+    label_width = XTextWidth(menu->p_fnt_info,
+                            label,
+                            label_length);
+    
+    /*
+     * Set up the initial selection.
+     * Values not explicitly set are zeroed by calloc.
+     */
+    select->next = select;
+    select->prev = select;
+    select->type = SL_HEADER;
+    select->serial = -1;
+    select->parent_p = pane;
+
+    /*
+     * Fill the XMPane structure.
+     * X and Y position are set to 0 since a recompute will follow.
+     */
+    pane->type = PANE;
+    pane->active = active;
+    pane->serial = -1;
+    pane->label = label;
+    pane->label_width = label_width;
+    pane->label_length = label_length;
+    pane->s_list = select;
+
+    /*
+     * Insert the pane at the end of the pane list.
+     */
+    emacs_insque(pane, menu->p_list->prev);
+
+    /*
+     * Update the pane count. 
+     */
+    menu->p_count++;
+
+    /*
+     * Schedule a recompute.
+     */
+    menu->recompute = 1;
+
+    /*
+     * Return the pane number just added.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return((menu->p_count - 1));
+}
diff --git a/oldXMenu/AddSel.c b/oldXMenu/AddSel.c
new file mode 100644 (file)
index 0000000..cfb0b3d
--- /dev/null
@@ -0,0 +1,103 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/AddSel.c,v 1.1 1992/04/11 22:10:17 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuAddSelection - Adds a selection to an XMenu object.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     August, 1985
+ *
+ */
+
+#include <config.h>
+#include "XMenuInt.h"
+
+int
+XMenuAddSelection(display, menu, p_num, data, label, active)
+    Display *display;
+    register XMenu *menu;      /* Menu object to be modified. */
+    register int p_num;                /* Pane number to be modified. */
+    char *data;                        /* Data value. */
+    char *label;               /* Selection label. */
+    int active;                        /* Make selection active? */
+{
+    register XMPane *pane;     /* Pane containing the new selection. */
+    register XMSelect *select; /* Newly created selection. */
+
+
+    int label_length;          /* Label lenght in characters. */
+    int label_width;           /* Label width in pixels. */
+    
+    /*
+     * Check for NULL pointers!
+     */
+    if (label == NULL) {
+       _XMErrorCode = XME_ARG_BOUNDS;
+       return(XM_FAILURE);
+    }
+    /*
+     * Find the right pane.
+     */
+    pane = _XMGetPanePtr(menu, p_num);
+    if (pane == NULL) return(XM_FAILURE);
+
+    /*
+     * Calloc the XMSelect structure.
+     */
+    select = (XMSelect *)calloc(1, sizeof(XMSelect));
+    if (select == NULL) {
+       _XMErrorCode = XME_CALLOC;
+       return(XM_FAILURE);
+    }
+    /*
+     * Determine label size.
+     */
+    label_length = strlen(label);
+    label_width = XTextWidth(menu->s_fnt_info, label, label_length);
+    
+    /*
+     * Fill the XMSelect structure.
+     */
+    if (!strcmp (label, "--") || !strcmp (label, "---"))
+      {
+       select->type = SEPARATOR;
+       select->active = 0;
+      }
+    else
+      {
+       select->type = SELECTION;
+       select->active = active;
+      }
+
+    select->serial = -1;
+    select->label = label;
+    select->label_width = label_width;
+    select->label_length = label_length;
+    select->data = data;
+    select->parent_p = pane;
+    
+    /*
+     * Insert the selection at the end of the selection list.
+     */
+    emacs_insque(select, pane->s_list->prev);
+
+    /*
+     * Update the selection count.
+     */
+    pane->s_count++;
+
+    /*
+     * Schedule a recompute.
+     */
+    menu->recompute = 1;
+
+    /*
+     * Return the selection number just added.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return((pane->s_count - 1));
+}
diff --git a/oldXMenu/ChangeLog b/oldXMenu/ChangeLog
new file mode 100644 (file)
index 0000000..9bb8d9c
--- /dev/null
@@ -0,0 +1,397 @@
+1999-07-12  Richard Stallman  <rms@gnu.org>
+
+       * Version 20.4 released.
+
+1998-08-19  Richard Stallman  <rms@psilocin.ai.mit.edu>
+
+       * Version 20.3 released.
+
+1997-09-19  Richard Stallman  <rms@psilocin.gnu.ai.mit.edu>
+
+       * Version 20.2 released.
+
+1997-09-15  Richard Stallman  <rms@psilocin.gnu.ai.mit.edu>
+
+       * Version 20.1 released.
+
+1996-08-11  Richard Stallman  <rms@psilocin.gnu.ai.mit.edu>
+
+       * Version 19.33 released.
+
+1996-07-31  Richard Stallman  <rms@psilocin.gnu.ai.mit.edu>
+
+       * Version 19.32 released.
+
+1996-06-12  Richard Stallman  <rms@psilocin.gnu.ai.mit.edu>
+
+       * Internal.c (_XMRefreshSelection): Check for type SEPARATOR.
+       * InsSel.c (XMenuInsertSelection): Use SEPARATOR if nec.
+       * AddSel.c (XMenuAddSelection): Use SEPARATOR if nec.
+
+       * XMenu.h: New alternative SEPARATOR.
+
+1996-05-25  Karl Heuer  <kwzh@gnu.ai.mit.edu>
+
+       * Version 19.31 released.
+
+1995-11-24  Richard Stallman  <rms@mole.gnu.ai.mit.edu>
+
+       * Version 19.30 released.
+
+1995-11-13  Richard Stallman  <rms@mole.gnu.ai.mit.edu>
+
+       * Makefile.in (ALL_CFLAGS): Add some -I options.
+
+       * Activate.c, AddPane.c, AddSel.c, Create.c, InsPane.c, InsSel.c:
+       * Internal.c, XCrAssoc.c, XMakeAssoc.c: Include config.h.
+
+1995-06-19  Richard Stallman  <rms@mole.gnu.ai.mit.edu>
+
+       * Version 19.29 released.
+
+1995-02-07  Richard Stallman  <rms@pogo.gnu.ai.mit.edu>
+
+       * Makefile.in (maintainer-clean): Renamed from realclean.
+
+1994-10-25  Richard Stallman  <rms@mole.gnu.ai.mit.edu>
+
+       * Makefile.in (ALL_CFLAGS): Reorder the switches more rationally.
+
+1994-10-24  Jim Wilson  (wilson@chestnut.cygnus.com)
+
+       * Makefile.in (ALL_CFLAGS): Add C_SWITCH_X_MACHINE.
+
+1994-09-11  Richard Stallman  <rms@mole.gnu.ai.mit.edu>
+
+       * Version 19.27 released.
+
+1994-09-07  Richard Stallman  <rms@mole.gnu.ai.mit.edu>
+
+       * Version 19.26 released.
+
+1994-07-23  Richard Stallman  <rms@mole.gnu.ai.mit.edu>
+
+       * Error.c (XMenuError): Make `message' static.
+
+1994-06-28  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Create.c (XAllocDisplayColor): New function.
+       Use it throughout in place of XAllocNamedColor.
+
+1994-05-30  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Version 19.25 released.
+
+1994-05-23  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Version 19.24 released.
+
+1994-05-17  Karl Heuer  (kwzh@hal.gnu.ai.mit.edu)
+
+       * Create.c (XMenuCreate): Declare `data' as char*.
+
+1994-05-16  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Version 19.23 released.
+
+1994-04-12  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Create.c (XMenuCreate): Declare `data' as unsigned char*.
+
+1994-01-03  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * XMakeAssoc.c (XMakeAssoc): Use xmalloc.
+       (_XIOErrorFunction): Decl deleted.
+
+1993-11-27  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Version 19.22 released.
+
+1993-11-26  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Activate.c (XMenuActivate):
+       Call XSetWindowBackground and _XMRefreshPane.
+
+1993-11-16  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Version 19.21 released.
+
+1993-11-13  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Makefile.in (libXMenu11.a): Tell make not to worry if ranlib fails.
+       Tell user too, in case make doesn't pay attention.
+
+1993-11-11  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Version 19.20 released.
+
+1993-10-25  Brian Fox  (bfox@albert.gnu.ai.mit.edu)
+
+       * Makefile.in (ALL_CFLAGS): Add C_SWITCH_X_SYSTEM.
+
+1993-09-27  Brian Fox  (bfox@valhalla)
+
+       * Makefile.in (CPP, LN_S, C_SWITCH_X_SITE, CC, CFLAGS): Allow
+       `configure' to supply the values for these variables.
+
+1993-09-26  Brian Fox  (bfox@ai.mit.edu)
+
+       * Makefile.in (VPATH, srcdir): Now that `configure' creates the
+       Makefiles, do not append the current directory to the value of
+       `srcdir' or `VPATH'.
+
+1993-08-14  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Version 19.19 released.
+
+1993-08-08  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Version 19.18 released.
+
+1993-07-30  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Internal.c (_XMWinQueInit): Use explicit loop, not bzero.
+
+1993-07-27  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Makefile (ALL_CFLAGS): Use all 6 C_SWITCH_... vars.
+
+       Among them, put the ..._SITE vars last.
+
+1993-07-18  Jim Blandy  (jimb@wookumz.gnu.ai.mit.edu)
+
+       * Version 19.17 released.
+
+1993-07-07  Jim Blandy  (jimb@geech.gnu.ai.mit.edu)
+
+       * Makefile.in: Write out the dependencies for the object files;
+       otherwise, VPATH won't work.
+
+       * Makefile.in: Re-arrange, to put `all' target at the top.
+
+1993-07-06  Jim Blandy  (jimb@geech.gnu.ai.mit.edu)
+
+       * Version 19.16 released.
+
+1993-06-19  Jim Blandy  (jimb@wookumz.gnu.ai.mit.edu)
+
+       * version 19.15 released.
+
+1993-06-18  Jim Blandy  (jimb@geech.gnu.ai.mit.edu)
+
+       * Makefile.in (ALL_CFLAGS): Always #define EMACS_BITMAP_FILES.
+       This should make it work under any circumstances.
+
+       * Makefile.in (mostlyclean): Use rm -f.
+
+1993-06-17  Jim Blandy  (jimb@wookumz.gnu.ai.mit.edu)
+
+       * Version 19.14 released.
+
+1993-06-17  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Makefile.in (ALL_CFLAGS): Include C_SWITCH_MACHINE, and CPPFLAGS.
+       Put CFLAGS last.
+
+1993-06-16  Jim Blandy  (jimb@wookumz.gnu.ai.mit.edu)
+
+        Bring mumbleclean targets into conformance with GNU coding standards.
+       * Makefile.in (mostlyclean, realclean): New targets.
+
+1993-06-08  Jim Blandy  (jimb@wookumz.gnu.ai.mit.edu)
+
+       * Version 19.13 released.
+
+1993-05-30  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Version 19.10 released.
+
+1993-05-29  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Create.c: Handle EMACS_BITMAP_FILES.
+       Use new names of renamed bitmap files.
+
+1993-05-28  Jim Blandy  (jimb@geech.gnu.ai.mit.edu)
+
+       * AddPane.c, AddSel.c, DelPane.c, DelSel.c, InsPane.c, InsSel.c,
+       XDelAssoc.c, XMakeAssoc.c, XMenu.h, insque.c: Changed all uses of
+       insque and remque to emacs_insque and emacs_remque, so we can
+       safely include insque.c in the library on all systems.
+
+1993-05-27  Jim Blandy  (jimb@geech.gnu.ai.mit.edu)
+
+       * Makefile.in (.c.o): Use $< instead of ${srcdir}/$*.c; the latter
+       only works with GNU Make.
+
+1993-05-27  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Create.c (XMenuCreate): Use classes PaneFont and SelectionFont.
+
+1993-05-27  Jim Blandy  (jimb@geech.gnu.ai.mit.edu)
+
+       * Version 19.9 released.
+
+1993-05-27  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Create.c (XMenuCreate): Use x_get_resource_string, not XGetDefault.
+
+1993-05-24  Jim Blandy  (jimb@wookumz.gnu.ai.mit.edu)
+
+       * Version 19.8 released.
+
+1993-05-23  Jim Blandy  (jimb@geech.gnu.ai.mit.edu)
+
+       * Makefile.in (C_SWITCH_X_SITE): New variable, so that the
+       configuration process can correctly implement the --x-includes
+       option.
+
+1993-05-22  Jim Blandy  (jimb@geech.gnu.ai.mit.edu)
+
+       * Create.c (XMenuCreate): Initialize the menu's pixmaps to None,
+       not NULL.
+
+1993-05-22  Jim Blandy  (jimb@geech.gnu.ai.mit.edu)
+
+        * Version 19.7 released.
+
+1993-05-15  Jim Blandy  (jimb@geech.gnu.ai.mit.edu)
+
+       * Makefile.in: Renamed from Makefile, so that the top-level
+       makefile can edit it.
+
+1993-04-13  Jim Blandy  (jimb@totoro.cs.oberlin.edu)
+
+       * XLookAssoc.c, XMakeAssoc: VMS needs <X11/Xresource.h>, not
+       <X11/Xos.h>.
+
+       * XCrAssoc.c: #include <errno.h>, not "errno.h".
+       (XCreateAssocTable): Doc fix.
+
+1993-03-24  Jim Blandy  (jimb@geech.gnu.ai.mit.edu)
+
+       * Makefile (.c.o): Include C_SWITCH_SITE and C_SWITCH_SYSTEM in
+       the options to the C compiler.
+
+       * compile.com, descrip.mms: New files for VMS from Richard
+       Levitte.
+       * XCrAssoc.c, XLookAssoc.c, XDestAssoc.c, XDelAssoc.c: Use <angle
+       brackets> around the names of the X Windows #include files; VMS
+       needs this.
+       * XLookAssoc.c, XMakeAssoc.c: #include <X11/Xos.h>.  VMS needs
+       this.
+       * Create.c: On VMS, we have to look for the bitmap files in
+       `./src/bitmaps', not <X11/bitmaps>.
+
+1993-03-14  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Makefile (.c.o): Don't rm the .o files.
+
+1993-03-13  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Activate.c (XMenuActivate): If `active' field is negative,
+       don't allow selecting a string.
+
+1993-03-09  Jim Blandy  (jimb@totoro.cs.oberlin.edu)
+
+       * Create.c (XMenuCreate): New variable `root', holding the
+       display's default root window, so we don't have to write out
+       "RootWindow (display, DefaultScreen (display))" a jillion times.
+
+       * Create.c (XMenuCreate): Don't assume that all the
+       <X11/bitmaps/foo> patterns are 16x16.  Instead of building a
+       bitmap and then converting it to a pixmap of the appropriate
+       depth if necessary, build a pixmap of the appropriate depth
+       directly, using XCreatePixmapFromBitmapData.
+
+       * Imakefile: Include XCrAssoc.c, XDelAssoc.c, XDestAssoc.c,
+       XLookAssoc.c, and XMakeAssoc.c in SRCS.  Similarly for OBJS.
+
+       * XMenuInt.h: #include <stdio.h> before <X11/Xlib.h>, to avoid
+       warnings about redefining NULL.
+
+       * XMakeAssoc.c, XLookAssoc.c, XDestAssoc.c, XDelAssoc.c,
+       XCrAssoc.c: #include X11/Xlib.h instead of X11/Xlibint.h.
+
+       * XMakeAssoc.c, XLookAssoc.c, XCrAssoc.c: If NULL isn't defined by
+       any of the `.h' files, define it.
+
+       * XMakeAssoc.c, XCrAssoc.c: #include <errno.h>.
+       Add an extern declaration for errno.
+
+       * XMakeAssoc.c: Add an extern declaration for _XIOErrorFunction.
+       (XMakeAssoc): Use malloc instead of Xmalloc to allocate new
+       parts of the assoc table.
+       * XCrAssoc.c (XCreateAssocTable): Same.
+
+       * XDestAssoc.c (XDestroyAssocTable): Use free instead of Xfree.
+       * XDelAssoc.c (XDeleteAssoc): Same.
+
+1992-10-18  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * XMakeAssoc.c (XMakeAssoc): Use malloc, not Xmalloc.
+       * XCrAssoc.c (XCreateAssocTable): Use malloc and calloc directly.
+       * XDelAssoc.c (XDeleteAssoc): Use free, not Xfree.
+       * XDestAssoc.c (XDestroyAssocTable): Likewise.
+
+1992-10-17  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * XDelAssoc.c, XLookAssoc.c, XCrAssoc.c, XDestAssoc.c, XMakeAssoc.c:
+       Use Xlib.h, not Xlibint.h.
+       * XLookAssoc.c, XMakeAssoc.c, XCrAssoc.c (NULL): Defined.
+       * XMakeAssoc.c, XCrAssoc.c: Include errno.h.  Declare errno.
+       * XMakeAssoc.c (_XIOErrorFunction): Declared.
+
+1992-09-19  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * XDelAssoc.c, XLookAssoc.c, XCrAssoc.c, XDestAssoc.c, XMakeAssoc.c:
+       Specify dir X11/ when including Xlibint.h.
+
+1992-09-17  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * XDelAssoc.c, XLookAssoc.c, XCrAssoc.c, XDestAssoc.c, XMakeAssoc.c:
+       New files.
+
+       * Makefile (SRCS, OBJS): Compile those files.
+
+1992-01-31  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Makefile (clean): Delete object files and library.
+       (distclean): New target.
+
+1992-01-29  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Makefile (libXMenu11.a): Put `-' on ranlib line.
+
+1992-01-27  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Makefile (EXTRA): New variable.
+       (libXMenu11.a): Use that.
+
+       * insque.c: New file.
+
+1992-01-26  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
+
+       * Makefile (CC): Assignment commented out.
+
+1991-11-16  Noah Friedman  (friedman at nutrimat)
+
+        * copyright.h: New file (copied from X11R4 distribution)
+        * All files: Replaced occurrences of #include <X11/copyright.h>
+          with #include "copyright.h"
+
+1991-10-25  Richard Stallman  (rms at mole.gnu.ai.mit.edu)
+
+       * XMenu.h (enum _xmmode): Remove spurious comma.
+
+       * X10.h: New file.
+       * XMenu.h, XMenuInt.h: Include X10.h from this dir.
+
+1990-11-13  Richard Stallman  (rms at mole.ai.mit.edu)
+
+       * XMenu.h (struct _xmenu): Use unsigned long for colors.
+
+1990-11-12  Richard Stallman  (rms at mole.ai.mit.edu)
+
+       * Internal.c: Declare argument `display' in some functions.
+
+
diff --git a/oldXMenu/ChgPane.c b/oldXMenu/ChgPane.c
new file mode 100644 (file)
index 0000000..e039507
--- /dev/null
@@ -0,0 +1,66 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/ChgPane.c,v 1.1 1992/04/11 22:10:17 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuChangePane - Change the label of a  menu pane.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     December 19, 1985
+ *
+ */
+
+#include "XMenuInt.h"
+
+int
+XMenuChangePane(menu, p_num, label)
+    register XMenu *menu;      /* Menu object to be modified. */
+    register int p_num;                /* Pane number to be modified. */
+    char *label;               /* Selection label. */
+{
+    register XMPane *p_ptr;    /* XMPane pointer. */
+
+    int label_length;          /* Label length in characters. */
+    int label_width;           /* Label width in pixels. */
+
+    /*
+     * Check for NULL pointers!
+     */
+    if (label == NULL) {
+       _XMErrorCode = XME_ARG_BOUNDS;
+       return(XM_FAILURE);
+    }
+
+    /*
+     * Find the right pane.
+     */
+    p_ptr = _XMGetPanePtr(menu, p_num);
+    if (p_ptr == NULL) return(XM_FAILURE);
+
+    /*
+     * Determine label size.
+     */
+    label_length = strlen(label);
+    label_width = XTextWidth(menu->p_fnt_info, label, label_length);
+
+    /*
+     * Change the pane data.
+     */
+    p_ptr->label = label;
+    p_ptr->label_width = label_width;
+    p_ptr->label_length = label_length;
+
+    /*
+     * Schedule a recompute.
+     */
+    menu->recompute = 1;
+
+    /*
+     * Return the pane number just changed.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return(p_num);
+}
diff --git a/oldXMenu/ChgSel.c b/oldXMenu/ChgSel.c
new file mode 100644 (file)
index 0000000..591fbb7
--- /dev/null
@@ -0,0 +1,88 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/ChgSel.c,v 1.1 1992/04/11 22:10:17 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuChangeSelection - Change a menu selection.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     December 19, 1985
+ *
+ */
+
+#include "XMenuInt.h"
+
+int
+XMenuChangeSelection(display, menu, p_num, s_num, data, data_sw, label, label_sw)
+    Display *display;          /* previously opened display. */
+    register XMenu *menu;      /* Menu object to be modified. */
+    register int p_num;                /* Pane number to be modified. */
+    register int s_num;                /* Selection number to modified. */
+    char *data;                        /* Data value. */
+    int data_sw;               /* Change to new data value? */
+    char *label;               /* Selection label. */
+    int label_sw;              /* Change to new label? */
+{
+    register XMPane *p_ptr;    /* XMPane pointer. */
+    register XMSelect *s_ptr;  /* XMSelect pointer. */
+    
+    int label_length;          /* Label length in characters. */
+    int label_width;           /* Label width in pixels. */
+
+    /*
+     * Check for NULL pointers!
+     */
+    if (label == NULL) {
+       _XMErrorCode = XME_ARG_BOUNDS;
+       return(XM_FAILURE);
+    }
+
+    /*
+     * Find the right pane.
+     */
+    p_ptr = _XMGetPanePtr(menu, p_num);
+    if (p_ptr == NULL) return(XM_FAILURE);
+
+    /*
+     * Find the right selection.
+     */
+    s_ptr = _XMGetSelectionPtr(p_ptr, s_num);
+    if (s_ptr == NULL) return(XM_FAILURE);
+
+    /*
+     * Reset the label?
+     */
+    if (label_sw) {
+       /*
+        * Determine label size.
+        */
+       label_length = strlen(label);
+       label_width = XTextWidth(menu->s_fnt_info, label, label_length);
+
+       /*
+        * Change the selection data.
+        */
+       s_ptr->label = label;
+       s_ptr->label_width = label_width;
+       s_ptr->label_length = label_length;
+
+       /*
+        * Schedule a recompute.
+        */
+       menu->recompute = 1;
+    }
+
+    /*
+     * Reset the data?
+     */
+    if (data_sw) s_ptr->data = data;
+
+    /*
+     * Return successfully.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return(s_num);
+}
diff --git a/oldXMenu/Create.c b/oldXMenu/Create.c
new file mode 100644 (file)
index 0000000..ffbee59
--- /dev/null
@@ -0,0 +1,761 @@
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/Create.c,v 1.4 1993/03/09 18:18:01 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "copyright.h"
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuCreate -   Creates an X window system menu object.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     January 23, 1986
+ *
+ */
+
+#include <config.h>
+#include "XMenuInt.h"
+
+
+#ifdef EMACS_BITMAP_FILES
+#include "../src/bitmaps/dimple1.xbm"
+#include "../src/bitmaps/dimple3.xbm"
+#include "../src/bitmaps/gray1.xbm"
+#include "../src/bitmaps/gray3.xbm"
+#include "../src/bitmaps/crosswv.xbm"
+
+#include "../src/bitmaps/leftptr.xbm"
+#include "../src/bitmaps/leftpmsk.xbm"
+#include "../src/bitmaps/rtptr.xbm"
+#include "../src/bitmaps/rtpmsk.xbm"
+#include "../src/bitmaps/cntrptr.xbm"
+#include "../src/bitmaps/cntrpmsk.xbm"
+#include "../src/bitmaps/stipple.xbm"
+
+#else
+#ifndef VMS
+
+#include <X11/bitmaps/dimple1>
+#include <X11/bitmaps/dimple3>
+#include <X11/bitmaps/gray1>
+#include <X11/bitmaps/gray3>
+#include <X11/bitmaps/cross_weave>
+
+#include <X11/bitmaps/left_ptr>
+#include <X11/bitmaps/left_ptrmsk>
+#include <X11/bitmaps/right_ptr>
+#include <X11/bitmaps/right_ptrmsk>
+#include <X11/bitmaps/cntr_ptr>
+#include <X11/bitmaps/cntr_ptrmsk>
+#include <X11/bitmaps/stipple>
+
+#else
+
+#include "[-.src.bitmaps]dimple1.xbm"
+#include "[-.src.bitmaps]dimple3.xbm"
+#include "[-.src.bitmaps]gray1.xbm"
+#include "[-.src.bitmaps]gray3.xbm"
+#include "[-.src.bitmaps]crosswv.xbm"
+
+#include "[-.src.bitmaps]leftptr.xbm"
+#include "[-.src.bitmaps]leftpmsk.xbm"
+#include "[-.src.bitmaps]rtptr.xbm"
+#include "[-.src.bitmaps]rtpmsk.xbm"
+#include "[-.src.bitmaps]cntrptr.xbm"
+#include "[-.src.bitmaps]cntrpmsk.xbm"
+#include "[-.src.bitmaps]stipple.xbm"
+
+#endif /* VMS */
+#endif /* not EMACS_BITMAP_FILES */
+
+#define DEF_FREEZE             0
+#define DEF_REVERSE            0
+#define DEF_MENU_STYLE         LEFT
+#define DEF_MENU_MODE          BOX
+#define DEF_INACT_PNUM         3
+#define MAX_INACT_PNUM         4
+
+#define DEF_P_STYLE            CENTER
+
+#define DEF_P_EVENTS           (EnterWindowMask | ExposureMask)
+#define DEF_P_FNT_NAME         "fixed"
+#define DEF_P_SPREAD           0.5
+#define DEF_P_BDR_WIDTH                2
+
+#define DEF_S_STYLE            LEFT
+#define DEF_S_EVENTS           (EnterWindowMask | LeaveWindowMask)
+#define DEF_S_FNT_NAME         "fixed"
+#define DEF_S_SPREAD           0.10
+#define DEF_S_BDR_WIDTH                1
+
+#define XASSOC_TABLE_SIZE      64
+
+#define TILE_BUF_SIZE          5
+
+int atoi();
+double atof();
+char *x_get_resource_string ();
+
+
+
+static Status 
+XAllocDisplayColor(display, map, colorName, color, junk)
+    Display *display;
+    Colormap map;
+    char *colorName;
+    XColor *color;
+    XColor *junk;
+{
+  return (colorName!=0 &&
+         XParseColor(display, map, colorName, color) &&
+         XAllocColor(display, map, color));
+}
+
+
+XMenu *
+XMenuCreate(display, parent, def_env)
+    Display *display;           /* ID of previously opened display */
+    Window parent;             /* Window ID of the menu's parent window. */
+    register char *def_env;    /* X Defaults program environment name. */
+{
+  register int i;              /* Loop counter. */
+  register int j;              /* Loop counter. */
+  register char *def_val;      /* X Default value temp variable. */
+
+  register XMenu *menu;                /* Pointer to the new menu. */
+  XMStyle menu_style;          /* Menu display style. */
+  XMMode menu_mode;            /* Menu display mode. */
+  XMPane *pane;                        /* Pane list header. */
+  XAssocTable *assoc_tab;      /* XAssocTable pointer. */
+
+  int freeze;                  /* Freeze server mode. */
+  int reverse;                 /* Reverse video mode. */
+
+  XMStyle p_style;             /* Pane display style. */
+  char *p_fnt_name;            /* Flag font name. */
+  XFontStruct *p_fnt_info;     /* Flag font structure */
+  int p_fnt_pad;               /* Flag font padding in pixels. */
+  double p_spread;             /* Pane spread in flag height fractions. */
+  int p_fnt_height;            /* Pane character height. */
+  int p_bdr_width;             /* Pane border width. */
+  int flag_height;             /* Flag window height. */
+  int p_height;                        /* Pane window height. */
+  int p_x_off;                 /* Pane X offset. */
+  int p_y_off;                 /* Pane Y offset. */
+  GC pane_GC;                  /* Pane graphics context. */
+
+  XMStyle s_style;             /* Selection display style. */
+  char *s_fnt_name;            /* Selection font name. */
+  XFontStruct *s_fnt_info;     /* Selection font structure. */
+  int s_fnt_pad;               /* Selection font padding in pixels. */
+  int s_fnt_height;            /* Selection font character height */
+  double s_spread;             /* Select spread in line height fractions. */
+  int s_bdr_width;             /* Highlight border width. */
+  int s_height;                        /* Selection window height. */
+  int s_x_off;                 /* Selection window X offset. */
+  int s_y_off;                 /* Selection window Y offset. */
+  GC normal_select_GC;         /* GC used for normal video selection. */
+  GC inverse_select_GC;                /* GC used for inverse video selection. */
+  GC inact_GC;                 /* GC for inactive pane header and */
+  /* selections. */
+  GC inact_GC_noexpose;
+
+  XColor color_def;            /* Temp color definition holder. */
+  XColor screen_def;           /* Temp screen color definition holder */
+  XColor p_bdr_color;          /* Color of border. */
+  XColor s_bdr_color;          /* Color of highlight. */
+  XColor p_frg_color;          /* Color of pane foreground color. */
+  XColor s_frg_color;          /* Color of selection foreground. */
+  XColor bkgnd_color;          /* Color of background.. */
+  XColor mouse_color;          /* Color of mouse cursor. */
+  Cursor mouse_cursor;         /* Mouse cursor. */
+  Pixmap inact_bitmap;         /* Menu inactive pixmap. */
+
+  int inact_pnum;              /* Inactive background pattern number. */
+
+  Pixel p_bdr_pixel;           /* Pane border pixel. */
+  Pixel s_bdr_pixel;           /* Selection border pixel. */
+  Pixel p_frg_pixel;           /* Pane foreground pixel. */
+  Pixel s_frg_pixel;           /* Selection foreground pixel. */
+  Pixel bkgnd_pixel;           /* Menu background pixel. */
+
+  int *width, *height;
+  Pixmap *bitmap;
+  int *x_hot, *y_hot;
+  int status;                  /* Return code from XReadBitmapFile. */
+
+  Pixmap cursor;               /* Cursor pixmap holder. */
+  Pixmap cursor_mask;          /* Cursor mask pixmap holder. */
+  Pixmap stipple_pixmap;       /* Stipple mask for half-tone text. */
+  unsigned long valuemask;
+  XGCValues *values;
+    
+  Window root = RootWindow (display, DefaultScreen (display));
+
+  /*
+   * Calloc the XMenu structure and the initial pane.
+   */
+  menu = (XMenu *)calloc(1, sizeof(XMenu));
+  if (menu == NULL) {
+    _XMErrorCode = XME_CALLOC;
+    return(NULL);
+  }
+  pane = (XMPane *)calloc(1, sizeof(XMPane));
+  if (pane == NULL) {
+    _XMErrorCode = XME_CALLOC;
+    return(NULL);
+  }
+    
+  /* 
+   * Create the XAssocTable
+   */
+  assoc_tab = (XAssocTable *)XCreateAssocTable(XASSOC_TABLE_SIZE);
+  if(assoc_tab == NULL) {
+    _XMErrorCode= XME_CREATE_ASSOC;
+    return(NULL);
+  }
+
+  /*
+   * Set up the default environment name.
+   */
+  if (def_env == NULL || *def_env == '\0') def_env = "XMenu";
+
+  /*
+   * Set up internal fail-safe defaults.
+   */
+  freeze = DEF_FREEZE;
+  reverse = DEF_REVERSE;
+  menu_style = DEF_MENU_STYLE;
+  menu_mode = DEF_MENU_MODE;
+  inact_pnum = DEF_INACT_PNUM;
+
+  p_style = DEF_P_STYLE;
+  p_spread = DEF_P_SPREAD;
+  p_fnt_name = DEF_P_FNT_NAME;
+  p_bdr_width = DEF_P_BDR_WIDTH;
+
+  s_style = DEF_S_STYLE;
+  s_spread = DEF_S_SPREAD;
+  s_fnt_name = DEF_S_FNT_NAME;
+  s_bdr_width = DEF_S_BDR_WIDTH;
+
+  /*
+   * Get default values from X.
+   */
+  def_val = x_get_resource_string ("menuFreeze", "MenuFreeze");
+  if (def_val != NULL) {
+    if (strcmp(def_val, "on") == 0) freeze = 1;
+    else if (strcmp(def_val, "off") == 0) freeze = 0;
+  }
+
+  def_val = x_get_resource_string ("menuReverseVideo", "MenuReverseVideo");
+  if (def_val != NULL) {
+    if (strcmp(def_val, "on") == 0) reverse = 1;
+    else if (strcmp(def_val, "off") == 0) reverse = 0;
+  }
+
+  def_val = x_get_resource_string ("menuStyle", "MenuStyle");
+  if (def_val != NULL) {
+    if (strcmp(def_val, "right_hand") == 0) menu_style = RIGHT;
+    else if (strcmp(def_val, "left_hand") == 0) menu_style = LEFT;
+    else if (strcmp(def_val, "center") == 0) menu_style = CENTER;
+  }
+
+  def_val = x_get_resource_string ("menuMode", "MenuMode");
+  if (def_val != NULL) {
+    if (strcmp(def_val, "box") == 0) menu_mode = BOX;
+    else if (strcmp(def_val, "invert") == 0) menu_mode = INVERT;
+  }
+    
+  def_val = x_get_resource_string ("menuMouse", "MenuMouse");
+  if (
+      def_val != NULL &&
+      DisplayCells(display, DefaultScreen(display)) > 2 &&
+      XAllocDisplayColor(display, 
+                        DefaultColormap(display, DefaultScreen(display)), 
+                        def_val, 
+                        &mouse_color, &color_def)
+      );
+  else if (reverse &&
+          XAllocDisplayColor(display,
+                             DefaultColormap(display, DefaultScreen(display)),
+                             "white",
+                             &mouse_color, &color_def)
+          );
+    
+  else if (XAllocDisplayColor(display,
+                             DefaultColormap(display, DefaultScreen(display)),
+                             "black", 
+                             &mouse_color, &color_def)
+          );
+    
+  else ;
+
+  def_val = x_get_resource_string ("menuBackground", "MenuBackground");
+  if (
+      def_val != NULL &&
+      DisplayCells(display, DefaultScreen(display)) > 2 &&
+      XAllocDisplayColor(display,
+                        DefaultColormap(display, DefaultScreen(display)),
+                        def_val,
+                        &bkgnd_color, &color_def)
+      );
+  else if (reverse &&
+          XAllocDisplayColor(display,
+                             DefaultColormap(display, DefaultScreen(display)),
+                             "black",
+                             &bkgnd_color, &color_def)
+          );
+  else if (XAllocDisplayColor(display,
+                             DefaultColormap(display, DefaultScreen(display)),
+                             "white",
+                             &bkgnd_color, &color_def)
+          );
+  else;
+
+  def_val = x_get_resource_string ("menuInactivePattern", "MenuInactivePattern");
+  if (def_val != NULL) {
+    if (strcmp(def_val, "dimple1") == 0) inact_pnum = 0;
+    else if (strcmp(def_val, "dimple3") == 0) inact_pnum = 1;
+    else if (strcmp(def_val, "gray1") == 0) inact_pnum = 2;
+    else if (strcmp(def_val, "gray3") == 0) inact_pnum = 3;
+    else if (strcmp(def_val, "cross_weave") == 0) inact_pnum = 4;
+  }
+
+  def_val = x_get_resource_string ("paneStyle", "PaneStyle");
+  if (def_val != NULL) {
+    if (strcmp(def_val, "flush_left") == 0) p_style = LEFT;
+    else if (strcmp(def_val, "flush_right") == 0) p_style = RIGHT;
+    else if (strcmp(def_val, "center") == 0) p_style = CENTER;
+  }
+
+  def_val = x_get_resource_string ("paneFont", "PaneFont");
+  if (def_val != NULL) p_fnt_name = def_val;
+
+  def_val = x_get_resource_string ("paneForeground", "PaneForeground");
+  if (
+      def_val != NULL &&
+      DisplayCells(display, DefaultScreen(display)) > 2 
+      )
+    XAllocDisplayColor(display, DefaultColormap(display,
+                                               DefaultScreen(display)),
+                      def_val,
+                      &p_frg_color, &color_def);
+         
+  else if (reverse) XAllocDisplayColor(display,
+                                      DefaultColormap(display, 
+                                                      DefaultScreen(display)),
+                                      "white",
+                                      &p_frg_color, &color_def);
+  else XAllocDisplayColor(display,
+                         DefaultColormap(display, DefaultScreen(display)),
+                         "black",
+                         &p_frg_color, &color_def);
+
+  def_val = x_get_resource_string ("paneBorder", "PaneBorder");
+  if (
+      def_val != NULL &&
+      DisplayCells(display, DefaultScreen(display)) > 2 &&
+      XAllocDisplayColor(display,
+                        DefaultColormap(display, DefaultScreen(display)),
+                        def_val,
+                        &p_bdr_color, &color_def)
+      );
+  else if (reverse &&
+          XAllocDisplayColor(display, 
+                             DefaultColormap(display, DefaultScreen(display)),
+                             "white",
+                             &p_bdr_color, &color_def)
+          );
+  else XAllocDisplayColor(display, 
+                         DefaultColormap(display, DefaultScreen(display)),
+                         "black",
+                         &p_bdr_color, &color_def);
+    
+  def_val = x_get_resource_string ("paneBorderWidth", "PaneBorderWidth");
+  if (def_val != NULL) p_bdr_width = atoi(def_val);
+    
+  def_val = x_get_resource_string ("paneSpread", "PaneSpread");
+  if (def_val != NULL) p_spread = atof(def_val);
+
+  def_val = x_get_resource_string ("selectionStyle", "SelectionStyle");
+  if (def_val != NULL) {
+    if (strcmp(def_val, "flush_left") == 0) s_style = LEFT;
+    else if (strcmp(def_val, "flush_right") == 0) s_style = RIGHT;
+    else if (strcmp(def_val, "center") == 0) s_style = CENTER;
+  }
+
+  def_val = x_get_resource_string ("selectionFont", "SelectionFont");
+  if (def_val != NULL) s_fnt_name = def_val;
+
+  def_val = x_get_resource_string ("selectionForeground", "SelectionForeground");
+  if (
+      def_val != NULL &&
+      DisplayCells(display, DefaultScreen(display)) > 2 &&
+      XAllocDisplayColor(display,
+                        DefaultColormap(display, DefaultScreen(display)),
+                        def_val,
+                        &s_frg_color, &color_def)
+      ); 
+  else if (reverse &&
+          XAllocDisplayColor(display,
+                             DefaultColormap(display, DefaultScreen(display)),
+                             "white",
+                             &s_frg_color, &color_def)
+          ) ;
+  else if (XAllocDisplayColor(display,
+                             DefaultColormap(display, DefaultScreen(display)),
+                             "black",
+                             &s_frg_color, &color_def)
+          ) ;
+  else ;
+    
+
+  def_val = x_get_resource_string ("selectionBorder", "SelectionBorder");
+  if (
+      def_val != NULL &&
+      DisplayCells(display, DefaultScreen(display)) > 2 &&
+      XAllocDisplayColor(display,
+                        DefaultColormap(display, DefaultScreen(display)),
+                        def_val,
+                        &s_bdr_color, &color_def)
+      ) ;
+  else if (reverse &&
+          XAllocDisplayColor(display, 
+                             DefaultColormap(display, DefaultScreen(display)),
+                             "white",
+                             &s_bdr_color, &color_def)
+          ) ;
+  else if (XAllocDisplayColor(display,
+                             DefaultColormap(display, DefaultScreen(display)),
+                             "black",
+                             &s_bdr_color, &color_def)
+          ) ;
+  else ;
+
+  def_val = x_get_resource_string ("selectionBorderWidth", "SelectionBorderWidth");
+  if (def_val != NULL) s_bdr_width = atoi(def_val);
+    
+  def_val = x_get_resource_string ("selectionSpread", "SelectionSpread");
+  if (def_val != NULL) s_spread = atof(def_val);
+
+  /*
+   * Create and store the inactive pattern pixmap.
+   */
+  {
+    char *data = NULL;
+    int width, height;
+
+    switch (inact_pnum) 
+      {
+      case 0:
+       data = (char *)dimple1_bits;
+       width = dimple1_width;
+       height = dimple1_height;
+       break;
+
+      case 1:
+       data = (char *)dimple3_bits;
+       width = dimple3_width;
+       height = dimple3_height;
+       break;
+
+      case 2:
+       data = (char *)gray1_bits;
+       width = gray1_width;
+       height = gray1_height;
+       break;
+
+      case 3:
+       data = (char *)gray3_bits;
+       width = gray3_width;
+       height = gray3_height;
+       break;
+
+      case 4:
+       data = (char *)cross_weave_bits;
+       width = cross_weave_width;
+       height = cross_weave_height;
+       break;
+      }
+
+    if (! data)
+      {
+       _XMErrorCode = XME_STORE_BITMAP;
+       return(NULL);
+      }
+
+    inact_bitmap =
+      XCreatePixmapFromBitmapData
+       (display, root, data, width, height,
+        p_frg_color.pixel, bkgnd_color.pixel,
+        DisplayPlanes (display, DefaultScreen (display)));
+  }
+
+  /*
+   * Load the mouse cursor.
+   */
+         
+  switch (menu_style) {
+  case LEFT:
+    cursor = XCreateBitmapFromData(display,
+                                  root,
+                                  left_ptr_bits,
+                                  left_ptr_width,
+                                  left_ptr_height);
+    cursor_mask = XCreateBitmapFromData(display,
+                                       root,
+                                       left_ptrmsk_bits,
+                                       left_ptrmsk_width,
+                                       left_ptrmsk_height);
+    mouse_cursor = XCreatePixmapCursor(
+                                      display,
+                                      cursor, cursor_mask, 
+                                      &mouse_color, &bkgnd_color,
+                                      left_ptr_x_hot,
+                                      left_ptr_y_hot
+                                      );
+    XFreePixmap(display, cursor);
+    XFreePixmap(display, cursor_mask);     
+    break;
+  case RIGHT:
+    cursor = XCreateBitmapFromData(display,
+                                  root,
+                                  right_ptr_bits,
+                                  right_ptr_width,
+                                  right_ptr_height);
+    cursor_mask = XCreateBitmapFromData(display,
+                                       root,
+                                       right_ptrmsk_bits,
+                                       right_ptrmsk_width,
+                                       right_ptrmsk_height);
+    mouse_cursor = XCreatePixmapCursor(
+                                      display,
+                                      cursor, cursor_mask,
+                                      &mouse_color, &bkgnd_color,
+                                      right_ptr_x_hot,
+                                      right_ptr_y_hot
+                                      );
+    XFreePixmap(display, cursor);
+    XFreePixmap(display, cursor_mask);     
+    break;
+  case CENTER:
+    cursor = XCreateBitmapFromData(display,
+                                  root,
+                                  cntr_ptr_bits,
+                                  cntr_ptr_width,
+                                  cntr_ptr_height);
+    cursor_mask = XCreateBitmapFromData(display,
+                                       root,
+                                       cntr_ptrmsk_bits,
+                                       cntr_ptrmsk_width,
+                                       cntr_ptrmsk_height);
+    mouse_cursor = XCreatePixmapCursor(
+                                      display,
+                                      cursor, cursor_mask,
+                                      &mouse_color, &bkgnd_color,
+                                      cntr_ptr_x_hot,
+                                      cntr_ptr_y_hot
+                                      );
+    XFreePixmap(display, cursor);
+    XFreePixmap(display, cursor_mask);     
+    break;
+  default:
+    /* Error! Invalid style parameter. */
+    _XMErrorCode = XME_STYLE_PARAM;
+    return(NULL);
+  }
+  if (mouse_cursor == _X_FAILURE) {
+    _XMErrorCode = XME_CREATE_CURSOR;
+    return(NULL);
+  }
+
+  /*
+   * Open the pane and selection fonts.
+   */
+    
+  p_fnt_info = XLoadQueryFont(display, p_fnt_name);
+  if (p_fnt_info == NULL) {
+    _XMErrorCode = XME_OPEN_FONT;
+    return(NULL);
+       
+  }
+
+  s_fnt_info = XLoadQueryFont(display, s_fnt_name);
+  if (s_fnt_info == NULL) {
+    _XMErrorCode = XME_OPEN_FONT;
+    return(NULL);
+  }
+  /*
+   * Calculate the fixed padding value in pixels for each font.
+   */
+  p_fnt_height = p_fnt_info->max_bounds.ascent + p_fnt_info->max_bounds.descent;
+  s_fnt_height = s_fnt_info->max_bounds.ascent + s_fnt_info->max_bounds.descent;
+  p_fnt_pad = s_spread * p_fnt_height;
+  s_fnt_pad = s_spread * s_fnt_height;
+
+  /*
+   * Calculate fixed height and offset requirements.
+   */
+  flag_height = p_fnt_height + (p_fnt_pad << 1);
+
+  p_height = 0;
+  p_y_off = flag_height + p_bdr_width;
+  p_x_off = p_y_off * p_spread;
+
+  s_height = s_fnt_height + (s_fnt_pad << 1) + (s_bdr_width << 1);
+  s_y_off = s_height;
+  s_x_off = p_x_off;
+
+  /*
+   * Set up the pane list header.
+   */
+  pane->next = pane;
+  pane->prev = pane;
+  pane->type = PL_HEADER;
+  pane->serial = -1;
+
+  /*
+   * Initialize the internal pane and selection creation queues.
+   */
+  _XMWinQueInit();
+    
+  /*
+   * Create pane, active, and inactive GC's.
+   */
+  values = (XGCValues *)malloc(sizeof(XGCValues));
+  valuemask = (GCForeground | GCBackground | GCFont | GCLineWidth);
+
+  /*
+   * First, pane.
+   */
+
+  values->foreground = p_frg_color.pixel;
+  values->background = bkgnd_color.pixel;
+  values->font = p_fnt_info->fid;
+  values->line_width = p_bdr_width;
+    
+  pane_GC = XCreateGC(
+                     display, 
+                     root,
+                     valuemask,
+                     values);
+  /*
+   * Then normal video selection.
+   */
+
+  values->foreground = s_frg_color.pixel;
+  values->background = bkgnd_color.pixel;
+  values->font = s_fnt_info->fid;
+  values->line_width = s_bdr_width;
+  normal_select_GC = XCreateGC(display, 
+                              root,
+                              valuemask,
+                              values);
+  /*
+   * Inverse video selection.
+   */
+
+  values->foreground = bkgnd_color.pixel;              
+  values->background = s_frg_color.pixel;
+  values->font = s_fnt_info->fid;
+  values->line_width = s_bdr_width;
+  inverse_select_GC = XCreateGC(display, 
+                               root,
+                               valuemask,
+                               values);
+  stipple_pixmap = XCreateBitmapFromData(display,
+                                        root,
+                                        stipple_bits,          
+                                        stipple_width,         
+                                        stipple_height);       
+    
+  /*
+   * Finally, inactive pane header and selections
+   */
+  valuemask |= (GCFillStyle | GCStipple);
+  values->foreground = s_frg_color.pixel;
+  values->background = bkgnd_color.pixel;
+  values->font = s_fnt_info->fid;
+  values->line_width = s_bdr_width;
+  values->fill_style = FillStippled;
+  values->stipple = stipple_pixmap;
+       
+  inact_GC = XCreateGC(display, 
+                      root,
+                      valuemask,
+                      values);
+
+  valuemask |= (GCGraphicsExposures);
+  values->graphics_exposures = False;
+  inact_GC_noexpose = XCreateGC (display, 
+                                root,
+                                valuemask, values);
+
+
+  /*
+   * Construct the XMenu object.
+   */
+  /* -------------------- Menu data -------------------- */
+  menu->menu_style = menu_style;
+  menu->menu_mode = menu_mode;
+  menu->freeze = freeze;
+  menu->aeq = 0;
+  menu->recompute = 1;
+  menu->parent = parent;
+  menu->height = 0;
+  menu->width = 0;
+  menu->mouse_cursor = mouse_cursor;
+  menu->assoc_tab = assoc_tab;
+  menu->p_list = pane;
+  /* -------------------- Pane window data -------------------- */
+  menu->p_style = p_style;
+  menu->p_events = DEF_P_EVENTS;
+  menu->p_fnt_info = p_fnt_info;
+  menu->p_fnt_pad = p_fnt_pad;
+  menu->p_spread = p_spread;
+  menu->p_bdr_width = p_bdr_width;
+  menu->flag_height = flag_height;
+  menu->p_width = 0;
+  menu->p_height = p_height;
+  menu->p_x_off = p_x_off;
+  menu->p_y_off = p_y_off;
+  menu->p_count = 0;
+  menu->pane_GC = pane_GC;
+  menu->x_pos = 0;
+  menu->y_pos = 0;
+  /* -------------------- Selection window data -------------------- */
+  menu->s_style = s_style;
+  menu->s_events = DEF_S_EVENTS;
+  menu->s_fnt_info = s_fnt_info;
+  menu->s_fnt_pad = s_fnt_pad;
+  menu->s_spread = s_spread;
+  menu->s_bdr_width = s_bdr_width; /* unnecessary */
+  menu->s_width = 0;
+  menu->s_height = s_height;
+  menu->s_x_off = s_x_off;
+  menu->s_y_off = s_y_off;
+  menu->s_count = 0;
+  menu->normal_select_GC = normal_select_GC;
+  menu->inverse_select_GC = inverse_select_GC;
+  menu->inact_GC = inact_GC;
+  /* -------------------- Color data -------------------- */
+  menu->p_bdr_color = p_bdr_color.pixel;
+  menu->s_bdr_color = s_bdr_color.pixel;
+  menu->p_frg_color = p_frg_color.pixel;
+  menu->s_frg_color = s_frg_color.pixel;
+  menu->bkgnd_color = bkgnd_color.pixel;
+  /* -------------------- Pixmap data -------------------- */
+  menu->p_bdr_pixmap = None;
+  menu->s_bdr_pixmap = None;
+  menu->p_frg_pixmap = None;
+  menu->s_frg_pixmap = None;
+  menu->bkgnd_pixmap = None;
+  menu->inact_pixmap = inact_bitmap;
+
+  /*
+   * Return the completed XMenu.
+   */
+  _XMErrorCode = XME_NO_ERROR;
+  return(menu);
+}
diff --git a/oldXMenu/DelPane.c b/oldXMenu/DelPane.c
new file mode 100644 (file)
index 0000000..cf03549
--- /dev/null
@@ -0,0 +1,88 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/DelPane.c,v 1.1 1992/04/11 22:10:18 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuDeletePane - Deletes a pane from an XMenu object.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     20-Nov-85
+ *
+ */
+
+#include "XMenuInt.h"
+
+int
+XMenuDeletePane(display, menu, p_num)
+    register Display *display; /* Previously opened display */
+    register XMenu *menu;      /* Menu object to be modified. */
+    register int p_num;                /* Pane number to be deleted. */
+{
+    register XMPane *p_ptr;    /* Pointer to pane being deleted. */
+    register XMSelect *s_ptr;  /* Pointer to selections being deleted. */
+    register XMSelect *s_next;  /* Pointer to next selection to be deleted. */
+        
+    /*
+     * Find the right pane.
+     */
+    p_ptr = _XMGetPanePtr(menu, p_num);
+    if (p_ptr == NULL) return(XM_FAILURE);
+
+    /*
+     * Remove the pane from the association table.
+     */
+    XDeleteAssoc(display, menu->assoc_tab, p_ptr->window);
+
+    /*
+     * Remove the pane from the pane list and update
+     * the pane count.
+     */
+    emacs_remque(p_ptr);
+    menu->p_count--;
+
+    /*
+     * Remove all the selections in the pane from the
+     * association table and free their XMSelect structures.
+     */
+    for (
+       s_ptr = p_ptr->s_list->next; 
+       s_ptr != p_ptr->s_list;
+       s_ptr = s_next
+    ) {
+       XDeleteAssoc(display, menu->assoc_tab, s_ptr->window);
+       s_next = s_ptr->next;
+       free(s_ptr);
+    }
+    free(p_ptr->s_list);
+
+    if (p_ptr->window) {
+       /*
+        * Destroy the selection transparencies.
+        */
+       XDestroySubwindows(display, p_ptr->window);
+    
+       /*
+        * Destroy the pane window.
+        */
+       XDestroyWindow(display, p_ptr->window);
+    }
+    
+    /*
+     * Free the pane's XMPane structure.
+     */
+    free(p_ptr);
+
+    /*
+     * Schedule a recompute.
+     */
+    menu->recompute = 1;
+
+    /*
+     * Return the pane number just deleted.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return(p_num);
+}
diff --git a/oldXMenu/DelSel.c b/oldXMenu/DelSel.c
new file mode 100644 (file)
index 0000000..9f52086
--- /dev/null
@@ -0,0 +1,72 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/DelSel.c,v 1.1 1992/04/11 22:10:18 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuDeleteSelection - Deletes a selection from an XMenu object.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     20-Nov-85
+ *
+ */
+
+#include "XMenuInt.h"
+
+int
+XMenuDeleteSelection(display, menu, p_num, s_num)
+    register Display *display; /* Previously opened display. */
+    register XMenu *menu;      /* Menu object to be modified. */
+    register int p_num;                /* Pane number to be deleted. */
+    register int s_num;                /* Selection number to be deleted. */
+{
+    register XMPane *p_ptr;    /* Pointer to pane being deleted. */
+    register XMSelect *s_ptr;  /* Pointer to selections being deleted. */
+        
+    /*
+     * Find the right pane.
+     */
+    p_ptr = _XMGetPanePtr(menu, p_num);
+    if (p_ptr == NULL) return(XM_FAILURE);
+
+    /*
+     * Find the right selection.
+     */
+    s_ptr = _XMGetSelectionPtr(p_ptr, s_num);
+    if (s_ptr == NULL) return(XM_FAILURE);
+
+    /*
+     * Remove the selection from the association table.
+     */
+    XDeleteAssoc(display, menu->assoc_tab, s_ptr->window);
+
+    /*
+     * Remove the selection from the parent pane's selection
+     * list and update the selection count.
+     */
+    emacs_remque(s_ptr);
+    p_ptr->s_count--;
+
+    /*
+     * Destroy the selection transparency.
+     */
+    if (s_ptr->window) XDestroyWindow(display, s_ptr->window);
+    
+    /*
+     * Free the selection's XMSelect structure.
+     */
+    free(s_ptr);
+
+    /*
+     * Schedule a recompute.
+     */
+    menu->recompute = 1;
+
+    /*
+     * Return the selection number just deleted.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return(s_num);
+}
diff --git a/oldXMenu/Destroy.c b/oldXMenu/Destroy.c
new file mode 100644 (file)
index 0000000..b7f34fc
--- /dev/null
@@ -0,0 +1,116 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/Destroy.c,v 1.1 1992/04/11 22:10:18 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuDestroy - Free all resources associated with and XMenu.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     August, 1985
+ *
+ */
+
+#include "XMenuInt.h"
+
+XMenuDestroy(display, menu)
+    Display *display;
+    register XMenu *menu;      /* Menu object to destroy. */
+{
+    register XMPane *p_ptr;    /* Pointer to the current pane. */
+    register XMPane *p_next;   /* Pointer to the next pane. */
+    register XMSelect *s_ptr;  /* Pointer to the current selection. */
+    register XMSelect *s_next;  /* Pointer to the next selection. */
+
+    /*
+     * Destroy the selection and pane X windows and free
+     * their corresponding XMWindows.
+     */
+    for (
+       p_ptr = menu->p_list->next;
+       p_ptr != menu->p_list;
+       p_ptr = p_next
+    ) {
+       for (
+           s_ptr = p_ptr->s_list->next;
+           s_ptr != p_ptr->s_list;
+           s_ptr = s_next
+       ) {
+           s_next = s_ptr->next;
+           free(s_ptr);
+       }
+       if (p_ptr->window) {
+           XDestroySubwindows(display, p_ptr->window);
+           XDestroyWindow(display, p_ptr->window);
+       }
+       p_next = p_ptr->next;
+       free(p_ptr);
+    }
+
+    /*
+     * Destroy the association table.
+     */
+    XDestroyAssocTable(menu->assoc_tab);
+
+    /*
+     * Free the mouse cursor.
+     */
+    XFreeCursor(display, menu->mouse_cursor);
+
+    /*
+     * Free the fonts.
+     */
+    XFreeFont(display, menu->p_fnt_info);
+    XFreeFont(display, menu->s_fnt_info);
+
+    /*
+     * Free the pixmaps.
+     */
+/*    XFreePixmap(display, menu->p_bdr_pixmap);
+    XFreePixmap(display, menu->s_bdr_pixmap);
+    XFreePixmap(display, menu->p_frg_pixmap);
+    XFreePixmap(display, menu->s_frg_pixmap);
+    XFreePixmap(display, menu->bkgnd_pixmap); */
+    XFreePixmap(display, menu->inact_pixmap);
+
+    /*
+     * Free the color cells.
+     */
+    if ((menu->p_bdr_color != BlackPixel(display, DefaultScreen(display))) && (menu->p_bdr_color != WhitePixel(display, DefaultScreen(display))))
+       XFreeColors(
+                   display, 
+                   DefaultColormap(display, DefaultScreen(display)),
+                   &menu->p_bdr_color, 
+                   1, 0);
+    if ((menu->s_bdr_color != BlackPixel(display, DefaultScreen(display))) && (menu->s_bdr_color != WhitePixel(display, DefaultScreen(display))))
+       XFreeColors(
+                   display, 
+                   DefaultColormap(display, DefaultScreen(display)), 
+                   &menu->s_bdr_color, 
+                   1, 0);
+    if ((menu->p_frg_color != BlackPixel(display, DefaultScreen(display))) && (menu->p_frg_color != WhitePixel(display, DefaultScreen(display))))
+       XFreeColors(
+                   display, 
+                   DefaultColormap(display, DefaultScreen(display)),
+                   &menu->p_frg_color, 
+                   1, 0);
+    if ((menu->s_frg_color != BlackPixel(display, DefaultScreen(display))) && (menu->s_frg_color != WhitePixel(display, DefaultScreen(display))))
+       XFreeColors(
+                   display, 
+                   DefaultColormap(display, DefaultScreen(display)),
+                   &menu->s_frg_color, 
+                   1, 0);
+    if ((menu->bkgnd_color != BlackPixel(display, DefaultScreen(display))) && (menu->bkgnd_color != WhitePixel(display, DefaultScreen(display))))
+       XFreeColors(
+                   display, 
+                   DefaultColormap(display, DefaultScreen(display)),
+                   &menu->bkgnd_color, 
+                   1, 0);
+
+    /*
+     * Free the XMenu.
+     */
+    free(menu);
+}
diff --git a/oldXMenu/Error.c b/oldXMenu/Error.c
new file mode 100644 (file)
index 0000000..80f2272
--- /dev/null
@@ -0,0 +1,30 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/Error.c,v 1.1 1992/04/11 22:10:18 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuError -    Returns a string description of the current
+ *                     XMenu error status flag.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     August, 1985
+ *
+ */
+
+#include "XMenuInt.h"
+
+char *
+XMenuError()
+{
+    static char message[128];          /* Error message buffer. */
+
+    if ((_XMErrorCode < XME_CODE_COUNT) && (_XMErrorCode >= 0)) {
+       return(_XMErrorList[_XMErrorCode]);
+    }
+    sprintf(message, "Unknown _XMErrorCode: %d", _XMErrorCode);
+    return(message);
+}
+
diff --git a/oldXMenu/EvHand.c b/oldXMenu/EvHand.c
new file mode 100644 (file)
index 0000000..375ea44
--- /dev/null
@@ -0,0 +1,26 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/EvHand.c,v 1.1 1992/04/11 22:10:19 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuEventHandler - Set the XMenu asynchronous event handler.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     December 19, 1985
+ *
+ */
+
+#include "XMenuInt.h"
+
+XMenuEventHandler(handler)
+    int (*handler)();
+{
+    /*
+     * Set the global event handler variable.
+     */
+    _XMEventHandler = handler;
+}
+
diff --git a/oldXMenu/FindPane.c b/oldXMenu/FindPane.c
new file mode 100644 (file)
index 0000000..a4bed43
--- /dev/null
@@ -0,0 +1,64 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/FindPane.c,v 1.1 1992/04/11 22:10:19 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuFindPane - Find the first menu pane who's label matches a 
+ *                     particular string.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     January 22, 1986
+ *
+ */
+
+#include "XMenuInt.h"
+
+int
+XMenuFindPane(menu, label) 
+    register XMenu *menu;
+    register char *label;
+{
+    register XMPane *p_ptr;
+    register int i = 0;
+
+    /*
+     * Check for NULL pointers!
+     */
+    if (label == NULL) {
+       _XMErrorCode = XME_ARG_BOUNDS;
+       return(XM_FAILURE);
+    }
+
+    /*
+     * Find the pane who's label matches the given label.
+     */
+    for (
+       p_ptr = menu->p_list->next;
+       p_ptr != menu->p_list;
+       p_ptr = p_ptr->next
+    ){
+       if (p_ptr->label_length == 0) {
+           if (*label == '\0') {
+               _XMErrorCode = XME_NO_ERROR;
+               return (i);
+           }
+       }
+       else {
+           if (strncmp (label, p_ptr->label, p_ptr->label_length) == 0) {
+               _XMErrorCode = XME_NO_ERROR;
+               return (i);
+           }
+       }
+       i++;
+    }
+
+    /*
+     * If we get here then we have not found
+     * a match.
+     */
+    _XMErrorCode = XME_P_NOT_FOUND;
+    return (XM_FAILURE);
+}
diff --git a/oldXMenu/FindSel.c b/oldXMenu/FindSel.c
new file mode 100644 (file)
index 0000000..97853fa
--- /dev/null
@@ -0,0 +1,72 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/FindSel.c,v 1.1 1992/04/11 22:10:19 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuFindSelection - Find the first selection in a pane who's
+ *                          label matches a particular string.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     January 22, 1986
+ *
+ */
+
+#include "XMenuInt.h"
+
+int
+XMenuFindSelection(menu, p_num, label)
+    register XMenu *menu;
+    int p_num;
+    register char *label;
+{
+    register XMPane *p_ptr;
+    register XMSelect *s_ptr;
+    register int i = 0;
+
+    /*
+     * Check for NULL pointers!
+     */
+    if (label == NULL) {
+       _XMErrorCode = XME_ARG_BOUNDS;
+       return(XM_FAILURE);
+    }
+
+    /*
+     * Find the right pane.
+     */
+    p_ptr = _XMGetPanePtr(menu, p_num);
+    if (p_ptr == NULL) return(XM_FAILURE);
+
+    /*
+     * Find the right selection.
+     */
+    for (
+       s_ptr = p_ptr->s_list->next;
+       s_ptr != p_ptr->s_list;
+       s_ptr = s_ptr->next
+    ){
+       if (s_ptr->label_length == 0) {
+           if (*label == '\0') {
+               _XMErrorCode = XME_NO_ERROR;
+               return (i);
+           }
+       }
+       else {
+           if (strncmp (label, s_ptr->label, s_ptr->label_length) == 0) {
+               _XMErrorCode = XME_NO_ERROR;
+               return (i);
+           }
+       }
+       i++;
+    }
+
+    /*
+     * If we get here then we have not found
+     * a match.
+     */
+    _XMErrorCode = XME_S_NOT_FOUND;
+    return (XM_FAILURE);
+}
diff --git a/oldXMenu/Imakefile b/oldXMenu/Imakefile
new file mode 100644 (file)
index 0000000..8f69bdb
--- /dev/null
@@ -0,0 +1,97 @@
+        HEADERS = XMenu.h
+       LINTLIBS = ../lib/X/llib-lX.ln
+   INSTALLFLAGS = $(INSTINCFLAGS)
+         RANLIB = ranlib -t
+
+SRCS =  Activate.c \
+       AddPane.c \
+       AddSel.c \
+       ChgPane.c \
+       ChgSel.c \
+       Create.c \
+       DelPane.c \
+       DelSel.c \
+       Destroy.c \
+       Error.c \
+       EvHand.c \
+       FindPane.c \
+       FindSel.c \
+       InsPane.c \
+       InsSel.c \
+       Internal.c \
+       Locate.c \
+       Post.c \
+       Recomp.c \
+       SetAEQ.c \
+       SetFrz.c \
+       SetPane.c \
+       SetSel.c \
+       XCrAssoc.c \
+       XDelAssoc.c \
+       XDestAssoc.c \
+       XLookAssoc.c \
+       XMakeAssoc.c
+
+OBJS =  Activate.o \
+       AddPane.o \
+       AddSel.o \
+       ChgPane.o \
+       ChgSel.o \
+       Create.o \
+       DelPane.o \
+       DelSel.o \
+       Destroy.o \
+       Error.o \
+       EvHand.o \
+       FindPane.o \
+       FindSel.o \
+       InsPane.o \
+       InsSel.o \
+       Internal.o \
+       Locate.o \
+       Post.o \
+       Recomp.o \
+       SetAEQ.o \
+       SetFrz.o \
+       SetPane.o \
+       SetSel.o \
+       XCrAssoc.o \
+       XDelAssoc.o \
+       XDestAssoc.o \
+       XLookAssoc.o \
+       XMakeAssoc.o
+
+#if DebugOldLibXMenu && ProfileOldLibXMenu
+DebuggedAndProfiledLibraryObjectRule()
+#else
+# if DebugOldLibXMenu
+DebuggedLibraryObjectRule()
+# else
+#  if ProfileOldLibXMenu
+ProfiledLibraryObjectRule()
+#  else
+NormalLibraryObjectRule()
+#  endif
+# endif
+#endif
+
+NormalLibraryTarget(XMenu11,$(OBJS))
+LintLibraryTarget(XMenu11,$(SRCS))
+InstallLibrary(XMenu11,$(USRLIBDIR))
+#if InstallLintLibs
+InstallLintLibrary(XMenu11,$(LINTLIBDIR))
+#endif
+InstallMultiple($(HEADERS),$(INCDIR))
+
+#if ProfileOldLibXMenu
+ProfiledLibraryTarget(XMenu11,$(OBJS))
+InstallLibrary(XMenu11_p,$(USRLIBDIR))
+#endif
+
+#if DebugOldLibXMenu
+DebuggedLibraryTarget(XMenu11,$(OBJS))
+#endif
+
+DependTarget()
+
+NormalLintTarget($(SRCS))
diff --git a/oldXMenu/InsPane.c b/oldXMenu/InsPane.c
new file mode 100644 (file)
index 0000000..7a0d6e3
--- /dev/null
@@ -0,0 +1,112 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/InsPane.c,v 1.1 1992/04/11 22:10:19 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuInsertPane - Inserts a pane into an XMenu object in
+ *                       a particular position.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     20-Nov-85
+ *
+ */
+
+#include <config.h>
+#include "XMenuInt.h"
+
+int
+XMenuInsertPane(menu, p_num, label, active)
+    register XMenu *menu;      /* Menu object to be modified. */
+    register int p_num;                /* Pane number of new pane. */
+    char *label;               /* Selection label. */
+    int active;                        /* Make selection active? */
+{
+    register XMPane *p_ptr;    /* XMPane pointer. */
+    register XMPane *pane;     /* Newly created pane. */
+    register XMSelect *select; /* Initial selection for the new pane. */
+        
+    int label_length;          /* Label length in characters. */
+    int label_width;           /* Label width in pixels. */
+
+    /*
+     * Check for NULL pointers!
+     */
+    if (label == NULL) {
+       _XMErrorCode = XME_ARG_BOUNDS;
+       return(XM_FAILURE);
+    }
+
+    /*
+     * Find the pane number one less than the one specified since that
+     * is the pane after which the insertion will occur.
+     */
+    p_ptr = _XMGetPanePtr(menu, (p_num - 1));
+    if (p_ptr == NULL) return(XM_FAILURE);
+
+    /*
+     * Calloc the XMPane structure and the initial XMSelect.
+     */
+    pane = (XMPane *)calloc(1, sizeof(XMPane));
+    if (pane == NULL) {
+       _XMErrorCode = XME_CALLOC;
+       return(XM_FAILURE);
+    }
+    select = (XMSelect *)calloc(1, sizeof(XMSelect));
+    if (select == NULL) {
+       _XMErrorCode = XME_CALLOC;
+       return(XM_FAILURE);
+    }
+
+    /*
+     * Determine label size.
+     */
+    label_length = strlen(label);
+    label_width = XTextWidth(menu->p_fnt_info, label, label_length);
+
+    /*
+     * Set up the initial selection.
+     * Values not explicitly set are zeroed by calloc.
+     */
+    select->next = select;
+    select->prev = select;
+    select->type = SL_HEADER;
+    select->serial = -1;
+    select->parent_p = pane;
+
+    /*
+     * Fill the XMPane structure.
+     */
+    pane->type = PANE;
+    pane->active = active;
+    pane->serial = -1;
+    pane->label = label;
+    pane->label_width = label_width;
+    pane->label_length = label_length;
+    pane->s_list = select;
+
+    /*
+     * Insert the pane after the pane with the pane
+     * number one less than the desired number for the
+     * new pane.
+     */
+    emacs_insque(pane, p_ptr);
+
+    /*
+     * Update the pane count. 
+     */
+    menu->p_count++;
+
+    /*
+     * Schedule a recompute.
+     */
+    menu->recompute = 1;
+
+    /*
+     * Return the number of the pane just added.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return(p_num);
+}
diff --git a/oldXMenu/InsSel.c b/oldXMenu/InsSel.c
new file mode 100644 (file)
index 0000000..200f575
--- /dev/null
@@ -0,0 +1,116 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/InsSel.c,v 1.1 1992/04/11 22:10:19 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuInsertSelection - Inserts a selection into an XMenu object
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     20-Nov-85
+ *
+ */
+
+#include <config.h>
+#include "XMenuInt.h"
+
+int
+XMenuInsertSelection(menu, p_num, s_num, data, label, active)
+    register XMenu *menu;      /* Menu object to be modified. */
+    register int p_num;                /* Pane number to be modified. */
+    register int s_num;                /* Selection number of new selection. */
+    char *data;                        /* Data value. */
+    char *label;               /* Selection label. */
+    int active;                        /* Make selection active? */
+{
+    register XMPane *p_ptr;    /* XMPane pointer. */
+    register XMSelect *s_ptr;  /* XMSelect pointer. */
+
+    XMSelect *select;          /* Newly created selection. */
+
+    int label_length;          /* Label length in characters. */
+    int label_width;           /* Label width in pixels. */
+    
+    /*
+     * Check for NULL pointers!
+     */
+    if (label == NULL) {
+       _XMErrorCode = XME_ARG_BOUNDS;
+       return(XM_FAILURE);
+    }
+
+    /*
+     * Find the right pane.
+     */
+    p_ptr = _XMGetPanePtr(menu, p_num);
+    if (p_ptr == NULL) return(XM_FAILURE);
+
+    /*
+     * Find the selection number one less than the one specified since that
+     * is the selection after which the insertion will occur.
+     */
+    s_ptr = _XMGetSelectionPtr(p_ptr, (s_num - 1));
+    if (s_ptr == NULL) return(XM_FAILURE);
+
+    /*
+     * Calloc the XMSelect structure.
+     */
+    select = (XMSelect *)calloc(1, sizeof(XMSelect));
+    if (select == NULL) {
+       _XMErrorCode = XME_CALLOC;
+       return(XM_FAILURE);
+    }
+
+    /*
+     * Determine label size.
+     */
+    label_length = strlen(label);
+    label_width = XTextWidth(menu->s_fnt_info, label, label_length);
+
+
+    /*
+     * Fill the XMSelect structure.
+     */
+    if (!strcmp (label, "--") || !strcmp (label, "---"))
+      {
+       select->type = SEPARATOR;
+       select->active = 0;
+      }
+    else
+      {
+       select->type = SELECTION;
+       select->active = active;
+      }
+
+    select->active = active;
+    select->serial = -1;
+    select->label = label;
+    select->label_width = label_width;
+    select->label_length = label_length;
+    select->data = data;
+    select->parent_p = p_ptr;
+
+    /*
+     * Insert the selection after the selection with the selection
+     * number one less than the desired number for the new selection.
+     */
+    emacs_insque(select, s_ptr);
+
+    /*
+     * Update the selection count.
+     */
+    p_ptr->s_count++;
+
+    /*
+     * Schedule a recompute.
+     */
+    menu->recompute = 1;
+
+    /*
+     * Return the selection number just inserted.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return(s_num);
+}
diff --git a/oldXMenu/Internal.c b/oldXMenu/Internal.c
new file mode 100644 (file)
index 0000000..39a6a3b
--- /dev/null
@@ -0,0 +1,1006 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/Internal.c,v 1.1 1992/04/11 22:10:20 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuInternal.c - XMenu internal (not user visible) routines.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     November, 1985
+ *
+ */
+
+#include <config.h>
+#include "XMenuInt.h"
+
+/*
+ * Toggle color macro.
+ */
+#define toggle_color(x) \
+       ((x) == menu->bkgnd_color ? menu->s_frg_color : menu->bkgnd_color)
+
+/*
+ * Internal Window creation queue sizes.
+ */
+#define S_QUE_SIZE     300
+#define P_QUE_SIZE     20
+#define BUFFER_SIZE    (S_QUE_SIZE >= P_QUE_SIZE ? S_QUE_SIZE : P_QUE_SIZE)
+
+
+/*
+ * XMWinQue - Internal window creation queue datatype.
+ */
+typedef struct _xmwinquedef {
+    int sq_size;
+    XMSelect *sq[S_QUE_SIZE];
+    XMSelect **sq_ptr;
+    int pq_size;
+    XMPane *pq[P_QUE_SIZE];
+    XMPane **pq_ptr;
+} XMWinQue;
+
+/*
+ * _XMWinQue - Internal static window creation queue.
+ */
+static Bool _XMWinQueIsInit = False;
+static XMWinQue _XMWinQue;
+
+/*
+ * _XMErrorCode - Global XMenu error code.
+ */
+int _XMErrorCode = XME_NO_ERROR; 
+/*
+ * _XMErrorList - Global XMenu error code description strings.
+ */
+char *
+_XMErrorList[XME_CODE_COUNT] = {
+    "No error",                                /* XME_NO_ERROR */
+    "Menu not initialized",            /* XME_NOT_INIT */
+    "Argument out of bounds",          /* XME_ARG_BOUNDS */
+    "Pane not found",                  /* XME_P_NOT_FOUND */
+    "Selection not found",             /* XME_S_NOT_FOUND */
+    "Invalid menu style parameter",    /* XME_STYLE_PARAM */
+    "Unable to grab mouse",            /* XME_GRAB_MOUSE */
+    "Unable to interpret locator",     /* XME_INTERP_LOC */
+    "Unable to calloc memory",         /* XME_CALLOC */
+    "Unable to create XAssocTable",    /* XME_CREATE_ASSOC */
+    "Unable to store bitmap",          /* XME_STORE_BITMAP */
+    "Unable to make tile pixmaps",     /* XME_MAKE_TILES */
+    "Unable to make pixmap",           /* XME_MAKE_PIXMAP */
+    "Unable to create cursor",         /* XME_CREATE_CURSOR */
+    "Unable to open font",             /* XME_OPEN_FONT */
+    "Unable to create windows",                /* XME_CREATE_WINDOW */
+    "Unable to create transparencies", /* XME_CREATE_TRANSP */
+};
+
+/*
+ * _XMEventHandler - Internal event handler variable.
+ */
+int (*_XMEventHandler)() = NULL;
+
+
+
+/*
+ * _XMWinQueInit - Internal routine to initialize the window
+ *                queue.
+ */
+_XMWinQueInit()
+{
+    /*
+     * If the queue is not initialized initialize it.
+     */
+    if (!_XMWinQueIsInit) {
+       /*
+        * Blank the queue structure.
+        */
+       register int i;
+
+       for (i = 0; i < S_QUE_SIZE; i++)
+         _XMWinQue.sq[i] = 0;
+
+       for (i = 0; i < P_QUE_SIZE; i++)
+         _XMWinQue.pq[i] = 0;
+
+       _XMWinQue.sq_size = _XMWinQue.pq_size = 0;
+
+       /*
+        * Initialize the next free location pointers.
+        */
+       _XMWinQue.sq_ptr = _XMWinQue.sq;
+       _XMWinQue.pq_ptr = _XMWinQue.pq;
+    }
+}
+
+
+
+/*
+ * _XMWinQueAddPane - Internal routine to add a pane to the pane
+ *                   window queue.
+ */
+int
+_XMWinQueAddPane(display, menu, p_ptr)
+    register Display *display;
+    register XMenu *menu;      /* Menu being manipulated. */
+    register XMPane *p_ptr;    /* XMPane being queued. */
+{
+    /*
+     * If the queue is currently full then flush it.
+     */
+    if (_XMWinQue.pq_size == P_QUE_SIZE) {
+       if (_XMWinQueFlush(display, menu, 0, 0) == _FAILURE) return(_FAILURE);
+    }
+
+    /*
+     * Insert the new XMPane pointer and increment the queue pointer
+     * and the queue size.
+     */
+    *_XMWinQue.pq_ptr = p_ptr;
+    _XMWinQue.pq_ptr++;
+    _XMWinQue.pq_size++;
+
+    /*
+     * All went well, return successfully.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return(_SUCCESS);
+}
+
+
+
+/*
+ * _XMWinQueAddSelection - Internal routine to add a selection to
+ *                        the selection window queue.
+ */
+int
+_XMWinQueAddSelection(display, menu, s_ptr)
+    register Display *display;
+    register XMenu *menu;      /* Menu being manipulated. */
+    register XMSelect *s_ptr;  /* XMSelection being queued. */
+{
+    /*
+     * If this entry will overflow the queue then flush it.
+     */
+    if (_XMWinQue.sq_size == S_QUE_SIZE) {
+       if (_XMWinQueFlush(display, menu, 0, 0) == _FAILURE) return(_FAILURE);
+    }
+
+    /*
+     * Insert the new XMSelect pointer and increment the queue pointer
+     * and the queue size.
+     */
+    *_XMWinQue.sq_ptr = s_ptr;
+    _XMWinQue.sq_ptr++;
+    _XMWinQue.sq_size++;
+
+    /*
+     * All went well, return successfully.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return(_SUCCESS);
+}
+
+
+
+/*
+ * _XMWinQueFlush - Internal routine to flush the pane and
+ *                 selection window queues.
+ */
+int
+_XMWinQueFlush(display, menu, pane, select)
+    register Display *display;
+    register XMenu *menu;              /* Menu being manipulated. */
+    register XMPane *pane;             /* Current pane. */
+{
+    register int pq_index;             /* Pane queue index. */
+    register int sq_index;             /* Selection queue index. */
+    register XMPane *p_ptr;            /* XMPane pointer. */
+    register XMSelect *s_ptr;          /* XMSelect pointer. */
+    unsigned long valuemask;           /* Which attributes to set. */
+    XSetWindowAttributes *attributes;  /* Attributes to be set. */
+
+    /*
+     * If the pane window queue is not empty...
+     */
+    
+    if (_XMWinQue.pq_size > 0) {
+       /*
+        * set up attributes for pane window to be created.
+        */
+       valuemask = (CWBackPixmap | CWBorderPixel | CWOverrideRedirect);
+       attributes = (XSetWindowAttributes *)malloc(sizeof(XSetWindowAttributes));
+       attributes->border_pixel = menu->p_bdr_color;
+       attributes->background_pixmap = menu->inact_pixmap;
+       attributes->override_redirect = True;
+       
+       /*
+        * Create all the pending panes in order, so that the
+        * current pane will be on top, with the others
+        * stacked appropriately under it.
+        */
+       for (pq_index = _XMWinQue.pq_size - 1;
+            pq_index >= 0;
+            pq_index--) 
+         {
+             p_ptr = _XMWinQue.pq[pq_index];  /* Retrieve next pane. */
+             if (p_ptr == pane) break;
+             p_ptr->window = XCreateWindow(display,
+                                           menu->parent,
+                                           p_ptr->window_x,
+                                           p_ptr->window_y,
+                                           p_ptr->window_w,
+                                           p_ptr->window_h,
+                                           menu->p_bdr_width,
+                                           CopyFromParent,
+                                           InputOutput,
+                                           CopyFromParent,
+                                           valuemask,
+                                           attributes);
+             XMakeAssoc(display, menu->assoc_tab, p_ptr->window, p_ptr);
+             XSelectInput(display, p_ptr->window, menu->p_events);
+         }
+       for (pq_index = 0;
+            pq_index < _XMWinQue.pq_size;
+            pq_index++) 
+         {
+             p_ptr = _XMWinQue.pq[pq_index];   /* Retrieve next pane. */
+             p_ptr->window = XCreateWindow(display,
+                                           menu->parent,
+                                           p_ptr->window_x,
+                                           p_ptr->window_y,
+                                           p_ptr->window_w,
+                                           p_ptr->window_h,
+                                           menu->p_bdr_width,
+                                           CopyFromParent,
+                                           InputOutput,
+                                           CopyFromParent,
+                                           valuemask,
+                                           attributes);
+             XMakeAssoc(display, menu->assoc_tab, p_ptr->window, p_ptr);
+             XSelectInput(display, p_ptr->window, menu->p_events);
+             if (p_ptr == pane) break;
+       }
+
+       /*
+        * Reset the pane queue pointer and size.
+        */
+       _XMWinQue.pq_size = 0;
+       _XMWinQue.pq_ptr = _XMWinQue.pq;
+    }
+
+    /*
+     * If the selection window queue is not empty...
+     */
+    
+    if (_XMWinQue.sq_size > 0) {
+
+       for (sq_index = 0; sq_index < _XMWinQue.sq_size; sq_index++) {
+           /*
+            * Retrieve the XMSelect pointer.
+            */
+           s_ptr = _XMWinQue.sq[sq_index];
+           s_ptr->window = XCreateWindow(display,
+                                  s_ptr->parent_p->window,
+                                  s_ptr->window_x,
+                                  s_ptr->window_y,
+                                  s_ptr->window_w,
+                                  s_ptr->window_h,
+                                  0,                /* border width*/
+                                  CopyFromParent,
+                                  InputOnly,
+                                  CopyFromParent,
+                                  0,
+                                  attributes);
+           
+           /*
+            * Insert the new window id and its
+            * associated XMSelect structure into the 
+            * association table.
+            */
+           XMakeAssoc(display, menu->assoc_tab, s_ptr->window, s_ptr);
+           XSelectInput(display, s_ptr->window, menu->s_events);
+       }
+
+       /*
+        * Reset the selection queue pointer and size.
+        */
+       _XMWinQue.sq_size = 0;
+       _XMWinQue.sq_ptr = _XMWinQue.sq;
+    }
+
+    /*
+     * Flush X's internal queues.
+     */
+    XFlush(display);
+
+    /*
+     * All went well, return successfully.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return(_SUCCESS);
+}
+
+
+
+/*
+ * _XMGetPanePtr -     Given a menu pointer and a pane index number, return
+ *                     a pane pointer that points to the indexed pane.
+ */
+XMPane *
+_XMGetPanePtr(menu, p_num)
+    register XMenu *menu;      /* Menu to find the pane in. */
+    register int p_num;                /* Index number of pane to find. */
+{
+    register XMPane *p_ptr;    /* Pane pointer to be returned. */
+    register int i;            /* Loop counter. */
+
+    /*
+     * Is the pane number out of range?
+     */
+    if ((p_num < 0) || (p_num > (menu->p_count - 1))) {
+       _XMErrorCode = XME_P_NOT_FOUND;
+       return(NULL);
+    }
+
+    /*
+     * Find the right pane.
+     */
+    p_ptr = menu->p_list->next;
+    for (i = 0; i < p_num; i++) p_ptr = p_ptr->next;
+
+    /*
+     * Return successfully.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return(p_ptr);
+}
+
+
+
+/*
+ * _XMGetSelectionPtr -        Given pane pointer and a selection index number,
+ *                     return a selection pointer that points to the
+ *                     indexed selection.
+ */
+XMSelect *
+_XMGetSelectionPtr(p_ptr, s_num)
+    register XMPane *p_ptr;    /* Pane to find the selection in. */
+    register int s_num;                /* Index number of the selection to find. */
+{
+    register XMSelect *s_ptr;  /* Selection pointer to be returned. */
+    register int i;            /* Loop counter. */
+    
+    /*
+     * Is the selection number out of range?
+     */
+    if ((s_num < 0) || (s_num > (p_ptr->s_count - 1))) {
+       _XMErrorCode = XME_S_NOT_FOUND;
+       return(NULL);
+    }
+
+    /*
+     * Find the right selection.
+     */
+    s_ptr = p_ptr->s_list->next;
+    for (i = 0; i < s_num; i++) s_ptr = s_ptr->next;
+
+    /*
+     * Return successfully.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return(s_ptr);
+}
+
+
+
+/*
+ * _XMRecomputeGlobals - Internal subroutine to recompute menu wide
+ *                      global values.
+ */
+_XMRecomputeGlobals(display, menu)
+    register Display *display; /*X11 display variable. */      
+    register XMenu *menu;      /* Menu object to compute from. */
+{
+    register XMPane *p_ptr;    /* Pane pointer. */
+    register XMSelect *s_ptr;  /* Selection pointer. */
+
+    register int max_p_label = 0;      /* Maximum pane label width. */
+    register int max_s_label = 0;      /* Maximum selection label width. */
+    register int s_count = 0;          /* Maximum selection count. */
+
+    int p_s_pad;               /* Pane <-> selection padding. */
+    int p_s_diff;              /* Pane <-> selection separation. */
+
+    int p_height;              /* Pane window height. */
+    int p_width;               /* Pane window width. */
+    int s_width;               /* Selection window width. */
+
+    int screen;                        /* DefaultScreen holder. */
+    
+    /*
+     * For each pane...
+     */
+    for (
+       p_ptr = menu->p_list->next;
+       p_ptr != menu->p_list;
+       p_ptr = p_ptr->next
+    ){
+       
+       /*
+        * Recompute maximum pane label width.
+        */
+       max_p_label = max(max_p_label, p_ptr->label_width);
+
+       /*
+        * Recompute maximum selection count. 
+        */
+       s_count = max(s_count, p_ptr->s_count);
+
+       /*
+        * For each selection in the current pane...
+        */
+       for (
+           s_ptr = p_ptr->s_list->next;
+           s_ptr != p_ptr->s_list;
+           s_ptr = s_ptr->next
+       ){
+
+           /*
+            * Recompute maximum selection label width.
+            */
+           max_s_label = max(max_s_label, s_ptr->label_width);
+       }
+    }
+
+    /*
+     * Recompute pane height.
+     */
+    p_height = (menu->flag_height << 1) + (menu->s_y_off * s_count);
+
+    /*
+     * Recompute horizontal padding between the pane window and the
+     * selection windows.
+     */
+    p_s_pad = menu->p_x_off << 1;
+
+    /*
+     * Recompute pane and selection window widths.
+     * This is done by first computing the window sizes from the maximum
+     * label widths.  If the spacing between the selection window and the
+     * containing pane window is less than the pane selection padding value
+     * (twice the pane X offset) then change the size of the pane to be
+     * the size of the selection window plus the padding.  If, however the
+     * spacing between the selection window and the containing pane window
+     * is more than the pane selection padding value increase the size of
+     * the selection to its maximum possible value (the pane width minus
+     * the pane selection padding value).
+     */
+    p_width = max_p_label + p_s_pad;
+    s_width = max_s_label + (menu->s_fnt_pad << 1) + (menu->s_bdr_width << 1);
+    p_s_diff = p_width - s_width;
+    if (p_s_diff < p_s_pad) {
+       p_width = s_width + p_s_pad;
+    }
+    else if (p_s_diff > p_s_pad) {
+       s_width = p_width - p_s_pad;
+    }
+
+    /*
+     * Reset menu wide global values.
+     */
+    menu->s_count = s_count;
+    menu->p_height = p_height;
+    menu->p_width = p_width;
+    menu->s_width = s_width;
+
+    /* 
+     * Ensure that the origin of the menu is placed so that
+     * None of the panes ore selections are off the screen.
+     */
+    screen = DefaultScreen(display);
+    if (menu->x_pos + menu->width > DisplayWidth(display, screen))
+           menu->x_pos = DisplayWidth(display, screen) - menu->width;
+    else if (menu->x_pos < 0) menu->x_pos = 0;
+    if(menu->y_pos + menu->height > DisplayHeight(display, screen))
+           menu->y_pos = DisplayHeight(display, screen) - menu->height;
+    else if (menu->y_pos < 0) menu->y_pos = 0;
+}
+
+
+/*
+ * _XMRecomputePane - Internal subroutine to recompute pane
+ *                   window dependencies.
+ */
+int
+_XMRecomputePane(display, menu, p_ptr, p_num)
+    register Display *display; /* Standard X display variable. */
+    register XMenu *menu;      /* Menu object being recomputed. */
+    register XMPane *p_ptr;    /* Pane pointer. */
+    register int p_num;                /* Pane sequence number. */
+{
+    register int window_x;     /* Recomputed window X coordinate. */
+    register int window_y;     /* Recomputed window Y coordinate. */
+    
+    unsigned long change_mask; /* Value mask to reconfigure window. */
+    XWindowChanges *changes;   /* Values to use in configure window. */
+    
+    register Bool config_p = False;    /* Reconfigure pane window? */
+
+    /*
+     * Update the pane serial number.
+     */
+    p_ptr->serial = p_num;
+
+    /*
+     * Recompute window X and Y coordinates.
+     */
+    switch (menu->menu_style) {
+       case LEFT:
+           window_x = menu->p_x_off * ((menu->p_count - 1) - p_num);
+           window_y = menu->p_y_off * ((menu->p_count - 1) - p_num);
+           break;
+       case RIGHT:
+           window_x = menu->p_x_off * p_num;
+           window_y = menu->p_y_off * ((menu->p_count - 1) - p_num);
+           break;
+       case CENTER:
+           window_x = 0;
+           window_y = menu->p_y_off * ((menu->p_count - 1) - p_num);
+           break;
+       default:
+           /* Error! Invalid style parameter. */
+           _XMErrorCode = XME_STYLE_PARAM;
+           return(_FAILURE);
+    }
+    window_x += menu->x_pos;
+    window_y += menu->y_pos;
+
+    /*
+     * If the newly compute pane coordinates differ from the 
+     * current coordinates, reset the current coordinates and
+     * reconfigure the pane.
+     */
+    if (
+       (window_x != p_ptr->window_x) ||
+       (window_y != p_ptr->window_y)
+    ){
+       /*
+        * Reset the coordinates and schedule
+        * the pane for reconfiguration.
+        */
+       p_ptr->window_x = window_x;
+       p_ptr->window_y = window_y;
+       config_p = True;
+    }
+
+    /*
+     * If the local pane width and height differs from the
+     * menu pane width and height, reset the local values.
+     */
+    if (
+       (p_ptr->window_w != menu->p_width) ||
+       (p_ptr->window_h != menu->p_height)
+    ){
+       /*
+        * Reset window width and height and schedule
+        * the pane for reconfiguration.
+        */
+       p_ptr->window_w = menu->p_width;
+       p_ptr->window_h = menu->p_height;
+       config_p = True;
+    }
+
+    /*
+     * If we need to reconfigure the pane window do it now.
+     */
+    if (config_p == True) {
+       /*
+        * If the pane window has already been created then
+        * reconfigure the existing window, otherwise queue
+        * it for creation with the new configuration.
+        */
+       if (p_ptr->window) {
+           change_mask = (CWX | CWY | CWWidth | CWHeight);
+           changes = (XWindowChanges *)malloc(sizeof(XWindowChanges));
+           changes->x = p_ptr->window_x;
+           changes->y = p_ptr->window_y;
+           changes->width = p_ptr->window_w;
+           changes->height = p_ptr->window_h;
+           
+           XConfigureWindow(
+                            display,
+                            p_ptr->window,
+                            change_mask,
+                            changes
+                            );
+           free(changes);
+           
+       }
+       else {
+           if (_XMWinQueAddPane(display, menu, p_ptr) == _FAILURE) {
+               return(_FAILURE);
+           }
+       }
+    }
+    /*
+     * Recompute label X position.
+     */
+    switch (menu->p_style) {
+       case LEFT:
+           p_ptr->label_x = menu->p_x_off + menu->p_fnt_pad;
+           break;
+       case RIGHT:
+           p_ptr->label_x = menu->p_width -
+               (p_ptr->label_width + menu->p_x_off + menu->p_fnt_pad);
+           break;
+       case CENTER:
+           p_ptr->label_x = (menu->p_width - p_ptr->label_width) >> 1;
+           break;
+       default:
+           /* Error! Invalid style parameter. */
+           _XMErrorCode = XME_STYLE_PARAM;
+           return(_FAILURE);
+    }
+    /*
+     * Recompute label Y positions.
+     */
+    p_ptr->label_uy = menu->p_fnt_pad + menu->p_fnt_info->max_bounds.ascent;
+    p_ptr->label_ly = (menu->p_height - menu->p_fnt_pad - menu->p_fnt_info->max_bounds.descent);
+
+    /*
+     * All went well, return successfully.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return(_SUCCESS);
+}
+
+
+
+/*
+ * _XMRecomputeSelection - Internal subroutine to recompute
+ *                        selection window dependencies.
+ */
+int
+_XMRecomputeSelection(display, menu, s_ptr, s_num)
+    register Display *display;
+    register XMenu *menu;      /* Menu object being recomputed. */
+    register XMSelect *s_ptr;  /* Selection pointer. */
+    register int s_num;                /* Selection sequence number. */
+{
+    register Bool config_s = False;    /* Reconfigure selection window? */
+    XWindowChanges *changes;           /* Values to change in configure. */
+    unsigned long change_mask;         /* Value mask for XConfigureWindow. */
+    
+    /*
+     * If the selection serial numbers are out of order, begin
+     * resequencing selections.  Recompute selection window coordinates
+     * and serial number.
+     *
+     * When selections are created they are given a serial number of
+     * -1, this causes this routine to give a new selection
+     * its initial coordinates and serial number.
+     */
+    if (s_ptr->serial != s_num) {
+       /*
+        * Fix the sequence number.
+        */
+       s_ptr->serial = s_num;
+       /*
+        * Recompute window X and Y coordinates.
+        */
+       s_ptr->window_x = menu->s_x_off;
+       s_ptr->window_y = menu->flag_height + (menu->s_y_off * s_num);
+       /*
+        * We must reconfigure the window.
+        */
+       config_s = True;
+    }
+
+    /*
+     * If the local selection width and height differs from the
+     * menu selection width and height, reset the local values.
+     */
+    if (
+       (s_ptr->window_w != menu->s_width) ||
+       (s_ptr->window_h != menu->s_height)
+    ){
+       /*
+        * We must reconfigure the window.
+        */
+       config_s = True;
+       /*
+        * Reset window width and height.
+        */
+       s_ptr->window_w = menu->s_width;
+       s_ptr->window_h = menu->s_height;
+    }
+
+    /*
+     * If we need to reconfigure the selection window do it now.
+     */
+    if (config_s == True) {
+       /*
+        * If the selection window has already been created then
+        * reconfigure the existing window, otherwise queue it
+        * for creation with the new configuration.
+        */
+       if (s_ptr->window) {
+           changes = (XWindowChanges *)malloc(sizeof(XWindowChanges));
+           change_mask = (CWX | CWY | CWWidth | CWHeight);
+           changes = (XWindowChanges *)malloc(sizeof(XWindowChanges));
+           changes->x = s_ptr->window_x;
+           changes->y = s_ptr->window_y;
+           changes->width = s_ptr->window_w;
+           changes->height = s_ptr->window_h;
+           
+           XConfigureWindow(
+                            display,
+                            s_ptr->window,
+                            change_mask,
+                            changes
+                            );
+           free(changes);
+           
+       }
+       else {
+           if (_XMWinQueAddSelection(display, menu, s_ptr) == _FAILURE) {
+               return(_FAILURE);
+           }
+       }
+    }
+
+    /*
+     * Recompute label X position.
+     */
+    switch (menu->s_style) {
+       case LEFT:
+           s_ptr->label_x = menu->s_bdr_width + menu->s_fnt_pad + s_ptr->window_x;
+           break;
+       case RIGHT:
+           s_ptr->label_x = s_ptr->window_x + menu->s_width -
+               (s_ptr->label_width + menu->s_bdr_width + menu->s_fnt_pad);
+           break;
+       case CENTER:
+           s_ptr->label_x = s_ptr->window_x + ((menu->s_width - s_ptr->label_width) >> 1);
+           break;
+       default:
+           /* Error! Invalid style parameter. */
+           _XMErrorCode = XME_STYLE_PARAM;
+           return(_FAILURE);
+    }
+    /*
+     * Recompute label Y position.
+     */
+    s_ptr->label_y = s_ptr->window_y + menu->s_fnt_info->max_bounds.ascent + menu->s_fnt_pad + menu->s_bdr_width;
+    
+    /*
+     * All went well, return successfully.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return(_SUCCESS);
+}
+
+
+
+/*
+ * _XMTransToOrigin - Internal subroutine to translate the point at
+ *                   the center of the current pane and selection to the 
+ *                   the menu origin.
+ *
+ *     WARNING! ****** Be certain that all menu dependencies have been
+ *                     recomputed before calling this routine or
+ *                     unpredictable results will follow.
+ */
+_XMTransToOrigin(display, menu, p_ptr, s_ptr, x_pos, y_pos, orig_x, orig_y)
+    Display *display;          /* Not used. Included for consistency. */
+    register XMenu *menu;      /* Menu being computed against. */
+    register XMPane *p_ptr;    /* Current pane pointer. */
+    register XMSelect *s_ptr;  /* Current selection pointer. */
+    int x_pos;                 /* X coordinate of point to translate. */
+    int y_pos;                 /* Y coordinate of point to translate. */
+    int *orig_x;               /* Return value X coord. of the menu origin. */
+    int *orig_y;               /* Return value Y coord. of the menu origin. */
+{
+    register int l_orig_x;     /* Local X coordinate of the menu origin. */
+    register int l_orig_y;     /* Local Y coordinate of the menu origin. */
+    
+    /*
+     * Translate the menu origin such that the cursor hot point will be in the
+     * center of the desired current selection and pane.
+     * If the current selection pointer is NULL then assume that the hot point
+     * will be in the center of the current pane flag.
+     */
+
+    if (s_ptr == NULL) {
+       /*
+        * Translate from the center of the pane flag to the upper left
+        * of the current pane window.
+        */
+       l_orig_x = x_pos - (menu->p_width >> 1) - menu->p_bdr_width;
+       l_orig_y = y_pos - (menu->flag_height >> 1) - menu->p_bdr_width;
+    }
+    else {
+       /*
+        * First translate from the center of the current selection
+        * to the upper left of the current selection window.
+        */
+       l_orig_x = x_pos - (menu->s_width >> 1);
+       l_orig_y = y_pos - (menu->s_height >> 1);
+
+       /*
+        * Then translate to the upper left of the current pane window.
+        */
+       l_orig_x -= (s_ptr->window_x + menu->p_bdr_width);
+       l_orig_y -= (s_ptr->window_y + menu->p_bdr_width);
+    }
+
+    /*
+     * Finally translate to the upper left of the menu.
+     */
+    l_orig_x -= (p_ptr->window_x - menu->x_pos);
+    l_orig_y -= (p_ptr->window_y - menu->y_pos);
+
+    /*
+     * Set the return values.
+     */
+    *orig_x = l_orig_x;
+    *orig_y = l_orig_y;
+}
+
+/*
+ * _XMRefreshPane - Internal subroutine to completely refresh
+ *                 the contents of a pane.
+ */
+_XMRefreshPane(display, menu, pane)
+    register Display *display;
+    register XMenu *menu;
+    register XMPane *pane;
+{
+    register XMSelect *s_list = pane->s_list;
+    register XMSelect *s_ptr;
+
+    /*
+     * First clear the pane. 
+     */
+    XClearWindow(display, pane->window);
+    if (!pane->activated) {
+       XFillRectangle(display,
+                      pane->window,
+                      menu->inverse_select_GC,
+                      pane->label_x - menu->p_fnt_pad,
+                      pane->label_uy - menu->p_fnt_info->max_bounds.ascent - menu->p_fnt_pad,
+                      pane->label_width + (menu->p_fnt_pad << 1),
+                      menu->flag_height);
+
+       XFillRectangle(display,
+                      pane->window,
+                      menu->inverse_select_GC,
+                      pane->label_x - menu->p_fnt_pad,
+                      pane->label_ly - menu->p_fnt_info->max_bounds.ascent - menu->p_fnt_pad,
+                      pane->label_width + (menu->p_fnt_pad << 1),
+                      menu->flag_height);
+    }
+    if (!pane->active) {
+       XDrawString(display,
+                   pane->window,
+                   menu->inact_GC,
+                   pane->label_x, pane->label_uy,
+                   pane->label, pane->label_length);
+       XDrawString(display,
+                   pane->window,
+                   menu->inact_GC,
+                   pane->label_x, pane->label_ly,
+                   pane->label, pane->label_length);
+    }
+    else {
+       XDrawString(display,
+                        pane->window,
+                        menu->pane_GC,
+                        pane->label_x, pane->label_uy,
+                        pane->label, pane->label_length);
+       XDrawString(display,
+                        pane->window,
+                        menu->pane_GC,
+                        pane->label_x, pane->label_ly,
+                        pane->label, pane->label_length);
+
+       /*
+        * Finally refresh each selection if the pane is activated.
+        */
+       if (pane->activated) {
+           for (s_ptr = s_list->next; s_ptr != s_list; s_ptr = s_ptr->next)
+               _XMRefreshSelection(display, menu, s_ptr);
+       }
+    }
+}
+    
+    
+
+
+/*
+ * _XMRefreshSelection - Internal subroutine that refreshes 
+ *                      a single selection window.
+ */
+_XMRefreshSelection(display, menu, select)
+    register Display *display;
+    register XMenu *menu;
+    register XMSelect *select;
+{
+    register int width = select->window_w;
+    register int height = select->window_h;
+    register int bdr_width = menu->s_bdr_width;
+    
+    if (select->type == SEPARATOR) {
+        XDrawLine(display,
+                  select->parent_p->window,
+                  menu->normal_select_GC,
+                  select->window_x,
+                  select->window_y + height / 2,
+                  select->window_x + width,
+                  select->window_y + height / 2);
+    }
+    else if (select->activated) {
+       if (menu->menu_mode == INVERT) {
+           XFillRectangle(display, 
+                          select->parent_p->window,
+                          menu->normal_select_GC,
+                          select->window_x, select->window_y,
+                          width, height); 
+           XDrawString(display,
+                       select->parent_p->window,
+                       menu->inverse_select_GC,
+                       select->label_x,
+                       select->label_y,
+                       select->label, select->label_length);
+       }
+        else {
+            /*
+            * Using BOX mode.
+             * Since most drawing routines with arbitrary width lines
+            * are slow compared to raster-ops lets use a raster-op to
+            * draw the boxes.
+             */
+           
+           XDrawRectangle(display,
+                          select->parent_p->window,
+                          menu->normal_select_GC,
+                          select->window_x + (bdr_width >> 1),
+                          select->window_y + (bdr_width >> 1 ),
+                          width - bdr_width,
+                          height - bdr_width);
+           XDrawString(display,
+                       select->parent_p->window,
+                       menu->normal_select_GC,
+                       select->label_x,
+                       select->label_y,
+                       select->label, select->label_length);
+        }
+    }
+    else {
+       XClearArea(display, 
+                  select->parent_p->window,
+                  select->window_x, select->window_y,
+                  width, height,
+                  False);
+       if (select->active) {
+           XDrawString(display,
+                       select->parent_p->window,
+                       menu->normal_select_GC,
+                       select->label_x,
+                       select->label_y,
+                       select->label, select->label_length);
+       }
+       else {
+           XDrawString(display,
+                       select->parent_p->window,
+                       menu->inact_GC,
+                       select->label_x,
+                       select->label_y,
+                       select->label, select->label_length);
+       }
+    }
+}
+
diff --git a/oldXMenu/Locate.c b/oldXMenu/Locate.c
new file mode 100644 (file)
index 0000000..1e02807
--- /dev/null
@@ -0,0 +1,78 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/Locate.c,v 1.1 1992/04/11 22:10:20 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuLocate - Return data necessary to position and locate
+ *                   a menu on the screen.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     January 11, 1985
+ *
+ */
+
+#include "XMenuInt.h"
+
+int
+XMenuLocate(display, menu, p_num, s_num, x_pos, y_pos, ul_x, ul_y, width, height)
+    register Display *display; /* Previously opened display. */
+    register XMenu *menu;      /* Menu object being located. */
+    int p_num;                 /* Active pane number. */
+    int s_num;                 /* Active selection number. */
+    int x_pos;                 /* X coordinate of mouse active position. */
+    int y_pos;                 /* Y coordinate of mouse active position. */
+    int *ul_x;                 /* Returned upper left menu X coordinate. */
+    int *ul_y;                 /* Returned upper left menu Y coordinate. */
+    int *width;                        /* Returned menu width. */
+    int *height;               /* Returned menu height. */
+{
+    register XMPane *p_ptr;    /* XMPane pointer. */
+    register XMSelect *s_ptr;  /* XMSelect pointer. */
+    
+    /*
+     * Are the position arguments positive?
+     */
+    if ((x_pos <= 0) || (y_pos <= 0)) {
+       _XMErrorCode = XME_ARG_BOUNDS;
+       return(XM_FAILURE);
+    }
+
+    /*
+     * Find the right pane.
+     */
+    p_ptr = _XMGetPanePtr(menu, p_num);
+    if (p_ptr == NULL) return(XM_FAILURE);
+
+    /*
+     * Find the right selection.
+     */
+      s_ptr = _XMGetSelectionPtr(p_ptr, s_num);
+
+    /*
+     * Check to see that the menu's dependencies have been
+     * recomputed and are up to date.  If not, do it now.
+     */
+    if (menu->recompute) XMenuRecompute(display, menu);
+
+    /*
+     * Compute the new menu origin such that the active point lies
+     * in the center of the desired active pane and selection.
+     * This sets the values of ul_x and ul_y.
+     */
+    _XMTransToOrigin(display, menu, p_ptr, s_ptr, x_pos, y_pos, ul_x, ul_y);
+
+    /*
+     * Set remaining return argument values.
+     */
+    *width = menu->width;
+    *height = menu->height;
+
+    /*
+     * Return successfully.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return(XM_SUCCESS);
+}
diff --git a/oldXMenu/Makefile.in b/oldXMenu/Makefile.in
new file mode 100644 (file)
index 0000000..e20a583
--- /dev/null
@@ -0,0 +1,109 @@
+srcdir=@srcdir@
+VPATH=@srcdir@
+C_SWITCH_X_SITE=@C_SWITCH_X_SITE@
+
+EXTRA=insque.o
+CC=@CC@
+CFLAGS=@CFLAGS@
+CPP=@CPP@
+LN_S=@LN_S@
+             AS = as
+             LD = ld
+           TAGS = etags
+             RM = rm -f
+             MV = mv
+         RANLIB = ranlib
+# Solaris 2.1 ar doesn't accept the 'l' option.
+             AR = ar cq
+             LS = ls
+       LINTOPTS = -axz
+    LINTLIBFLAG = -C
+           MAKE = make
+    STD_DEFINES =
+    CDEBUGFLAGS = -O
+         RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \
+                       tags TAGS make.log
+
+OBJS =  Activate.o \
+       AddPane.o \
+       AddSel.o \
+       ChgPane.o \
+       ChgSel.o \
+       Create.o \
+       DelPane.o \
+       DelSel.o \
+       Destroy.o \
+       Error.o \
+       EvHand.o \
+       FindPane.o \
+       FindSel.o \
+       InsPane.o \
+       InsSel.o \
+       Internal.o \
+       Locate.o \
+       Post.o \
+       Recomp.o \
+       SetAEQ.o \
+       SetFrz.o \
+       SetPane.o \
+       SetSel.o \
+      XDelAssoc.o XLookAssoc.o XCrAssoc.o XDestAssoc.o XMakeAssoc.o
+
+all:: libXMenu11.a
+
+ALL_CFLAGS=$(C_SWITCH_SITE) $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) \
+  $(C_SWITCH_X_SITE) $(C_SWITCH_X_SYSTEM) $(C_SWITCH_X_MACHINE) \
+  $(CPPFLAGS) $(CFLAGS) -DEMACS_BITMAP_FILES \
+  -I../src -I${srcdir} -I${srcdir}/../src
+
+.c.o:
+       $(CC) -c ${ALL_CFLAGS} $<
+
+libXMenu11.a: $(OBJS) $(EXTRA)
+       $(RM) $@
+       $(AR) $@ $(OBJS) $(EXTRA)
+       @echo Do not be alarmed if the following ranlib command
+       @echo fails due to the absence of a ranlib program on your system.
+       -$(RANLIB) $@ || true
+#If running ranlib fails, probably there is none.
+#That's ok.  So don't stop the build.
+
+Activate.o: Activate.c XMenuInt.h XMenu.h X10.h
+AddPane.o: AddPane.c XMenuInt.h XMenu.h X10.h
+AddSel.o: AddSel.c XMenuInt.h XMenu.h X10.h
+ChgPane.o: ChgPane.c XMenuInt.h XMenu.h X10.h
+ChgSel.o: ChgSel.c XMenuInt.h XMenu.h X10.h
+Create.o: Create.c XMenuInt.h XMenu.h X10.h
+DelPane.o: DelPane.c XMenuInt.h XMenu.h X10.h
+DelSel.o: DelSel.c XMenuInt.h XMenu.h X10.h
+Destroy.o: Destroy.c XMenuInt.h XMenu.h X10.h
+Error.o: Error.c XMenuInt.h XMenu.h X10.h
+EvHand.o: EvHand.c XMenuInt.h XMenu.h X10.h
+FindPane.o: FindPane.c XMenuInt.h XMenu.h X10.h
+FindSel.o: FindSel.c XMenuInt.h XMenu.h X10.h
+InsPane.o: InsPane.c XMenuInt.h XMenu.h X10.h
+InsSel.o: InsSel.c XMenuInt.h XMenu.h X10.h
+Internal.o: Internal.c XMenuInt.h XMenu.h X10.h
+Locate.o: Locate.c XMenuInt.h XMenu.h X10.h
+Post.o: Post.c XMenuInt.h XMenu.h X10.h
+Recomp.o: Recomp.c XMenuInt.h XMenu.h X10.h
+SetAEQ.o: SetAEQ.c XMenuInt.h XMenu.h X10.h
+SetFrz.o: SetFrz.c XMenuInt.h XMenu.h X10.h
+SetPane.o: SetPane.c XMenuInt.h XMenu.h X10.h
+SetSel.o: SetSel.c XMenuInt.h XMenu.h X10.h
+XDelAssoc.o: XDelAssoc.c X10.h
+XLookAssoc.o: XLookAssoc.c X10.h
+XCrAssoc.o: XCrAssoc.c X10.h
+XDestAssoc.o: XDestAssoc.c X10.h
+XMakeAssoc.o: XMakeAssoc.c X10.h
+insque.o: insque.c
+
+FRC.mostlyclean:
+mostlyclean: FRC.mostlyclean
+       rm -f libXMenu11.a ${OBJS} ${EXTRA}
+clean: mostlyclean
+distclean: clean
+maintainer-clean: distclean
+
+tags::
+       $(TAGS) -t *.[ch]
diff --git a/oldXMenu/Post.c b/oldXMenu/Post.c
new file mode 100644 (file)
index 0000000..8b0a080
--- /dev/null
@@ -0,0 +1,85 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/Post.c,v 1.1 1992/04/11 22:10:20 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuPost -     Maps a given menu to the display and activates
+ *                     the menu for user selection.  The user is allowed to
+ *                     specify the mouse button event mask that will be used
+ *                     to identify a selection request.  When a selection 
+ *                     request is received (i.e., when the specified mouse
+ *                     event occurs) the data  returned will be either the
+ *                     data associated with the particular selection active
+ *                     at the time of the selection request or NULL if no
+ *                     selection was active.  A menu selection is shown to
+ *                     be active by placing a highlight box around the
+ *                     selection as the mouse cursor enters its active
+ *                     region.  Inactive selections will not be highlighted.
+ *                     As the mouse cursor moved from one menu pane
+ *                     to another menu pane the pane being entered is raised
+ *                     and activated and the pane being left is deactivated.
+ *                     If an error occurs NULL will be returned with the
+ *                     p_num set to POST_ERROR, s_num set to
+ *                     NO_SELECTION and _XMErrorCode set to an
+ *                     appropriate value.
+ *                     Every time the routine returns successfully the
+ *                     p_num and s_num indices will be set to indicate
+ *                     the currently active pane and/or selection.  If the
+ *                     mouse was not in a selection window at the time
+ *                     s_num will be set to NO_SELECTION.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     August, 1984
+ *
+ */
+
+#include "XMenuInt.h"
+
+char *
+XMenuPost(display, menu, p_num, s_num, x_pos, y_pos, event_mask)
+    register Display *display; /* Previously opened display. */
+    register XMenu *menu;      /* Menu to post. */
+    register int *p_num;       /* Pane number selected. */
+    register int *s_num;       /* Selection number selected. */
+    register int x_pos;                /* X coordinate of menu position. */
+    register int y_pos;                /* Y coordinate of menu position. */
+    int event_mask;            /* Mouse button event mask. */
+{
+    register int stat;         /* Routine call return status. */
+    char *data;                        /* Return data. */
+
+    /*
+     * Set up initial pane and selection assumptions.
+     */
+
+    /*
+     * Make the procedure call.
+     */
+    stat = XMenuActivate(
+                        display, 
+                        menu,
+                        p_num, s_num, 
+                        x_pos, y_pos, 
+                        event_mask, 
+                        &data);
+
+    /*
+     * Check the return value and return accordingly.
+     */
+    switch (stat) {
+       case XM_FAILURE:
+           *p_num = POST_ERROR;
+           *s_num = NO_SELECTION;
+           return(NULL);
+       case XM_NO_SELECT:
+       case XM_IA_SELECT:
+           *s_num = NO_SELECTION;
+           return(NULL);
+       case XM_SUCCESS:
+       default:
+           return(data);
+    }
+}
diff --git a/oldXMenu/README b/oldXMenu/README
new file mode 100644 (file)
index 0000000..79b4250
--- /dev/null
@@ -0,0 +1,6 @@
+This directory contains the source code for the X11R2 XMenu library.
+
+As of Release 2 of the X Window System, Version 11 from MIT, the XMenu
+library no longer supported.  It is not used in any software supplied 
+by MIT and its use is not encouraged.
+
diff --git a/oldXMenu/Recomp.c b/oldXMenu/Recomp.c
new file mode 100644 (file)
index 0000000..c433cd5
--- /dev/null
@@ -0,0 +1,104 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/Recomp.c,v 1.1 1992/04/11 22:10:20 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuRecompute - Recompute XMenu object dependencies.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     September, 1985
+ *
+ */
+
+#include "XMenuInt.h"
+
+int
+XMenuRecompute(display, menu)
+    Display *display;
+    register XMenu *menu;      /* Menu object to be recomputed. */
+{
+    register XMPane *p_ptr;    /* Pane pointer. */
+    register XMSelect *s_ptr;  /* Selection pointer. */
+
+    register int p_num;                /* Pane serial number. */
+    register int s_num;                /* Selection serial number. */
+    
+    /*
+     * If there are no panes in the menu then return failure
+     * because the menu is not initialized.
+     */
+    if (menu->p_count == 0) {
+       _XMErrorCode = XME_NOT_INIT;
+       return(XM_FAILURE);
+    }
+
+    /*
+     * Recompute menu wide global values: pane window size,
+     * selection size and maximum selection count.
+     */
+    _XMRecomputeGlobals(display, menu);
+
+    /*
+     * For each pane in the menu...
+     */
+        
+    p_num = 0;
+    for (
+       p_ptr = menu->p_list->next;
+       p_ptr != menu->p_list;
+       p_ptr = p_ptr->next
+    ){
+       /*
+        * Recompute pane dependencies.
+        */
+       if (_XMRecomputePane(display, menu, p_ptr, p_num) == _FAILURE) {
+           return(XM_FAILURE);
+       }
+        p_num++;
+       
+       /*
+        * For each selection in the pane...
+        */
+       s_num = 0;
+       for (
+           s_ptr = p_ptr->s_list->next;
+           s_ptr != p_ptr->s_list;
+           s_ptr = s_ptr->next
+       ) {
+           /*
+            * Recompute selection dependencies.
+            */
+           if (_XMRecomputeSelection(display, menu, s_ptr, s_num) == _FAILURE) {
+               return(XM_FAILURE);
+           }
+           s_num++;
+       }
+    }
+
+    /*
+     * Recompute menu size.
+     */
+    if (menu->menu_style == CENTER) {
+       menu->width = menu->p_width + (menu->p_bdr_width << 1);
+    }
+    else {
+       menu->width = menu->p_width + (menu->p_bdr_width << 1) +
+           ((menu->p_count - 1) * menu->p_x_off);
+    }
+    menu->height = menu->p_height + (menu->p_bdr_width << 1) +
+       ((menu->p_count - 1) * menu->p_y_off);
+
+    /*
+     * Reset the recompute flag.
+     */
+    menu->recompute = 0;
+
+    /*
+     * Return successfully.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return(XM_SUCCESS);
+}
diff --git a/oldXMenu/SetAEQ.c b/oldXMenu/SetAEQ.c
new file mode 100644 (file)
index 0000000..7da7c11
--- /dev/null
@@ -0,0 +1,29 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/SetAEQ.c,v 1.1 1992/04/11 22:10:20 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuSetAEQ - Set Asynchronous event queuing mode.
+ *                   When enabled asynchronous events will be queue while
+ *                   a menu is being displayed and restored to the X
+ *                   event queue when the menu is taken down.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     March 12, 1986
+ *
+ */
+
+#include "XMenuInt.h"
+
+XMenuSetAEQ(menu, aeq)
+    register XMenu *menu;      /* Menu object to be modified. */
+    register int aeq;          /* AEQ mode? */
+{
+    /*
+     * Set the AEQ mode switch.
+     */
+    menu->aeq = aeq;
+}
diff --git a/oldXMenu/SetFrz.c b/oldXMenu/SetFrz.c
new file mode 100644 (file)
index 0000000..0b5cb27
--- /dev/null
@@ -0,0 +1,28 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/SetFrz.c,v 1.1 1992/04/11 22:10:21 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuSetFreeze - Forcibly set the menu freeze mode switch
+ *                      overriding the Xdefaults setting.
+ *                      This is necessary in some situations.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     January 29, 1986
+ *
+ */
+
+#include "XMenuInt.h"
+
+XMenuSetFreeze(menu, freeze)
+    register XMenu *menu;      /* Menu object to be modified. */
+    register int freeze;       /* Freeze mode? */
+{
+    /*
+     * Set the freeze mode switch.
+     */
+    menu->freeze = freeze;
+}
diff --git a/oldXMenu/SetPane.c b/oldXMenu/SetPane.c
new file mode 100644 (file)
index 0000000..cdd9e37
--- /dev/null
@@ -0,0 +1,43 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/SetPane.c,v 1.1 1992/04/11 22:10:21 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuSetPane - Set a menu pane to be active or inactive.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     August, 1985
+ *
+ */
+
+#include "XMenuInt.h"
+
+int
+XMenuSetPane(menu, p_num, active)
+    register XMenu *menu;      /* Menu object to be modified. */
+    register int p_num;                /* Pane number to be modified. */
+    register int active;       /* Make selection active? */
+{
+    register XMPane *p_ptr;    /* XMPane pointer. */
+
+    /*
+     * Find the right pane.
+     */
+    p_ptr = _XMGetPanePtr(menu, p_num);
+    if (p_ptr == NULL) return(XM_FAILURE);
+
+    /*
+     * Set its active switch.
+     */
+    p_ptr->active = active;
+    if (p_ptr->active == False) p_ptr->activated = False;
+
+    /*
+     * Return the pane number just set.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return(p_num);
+}
diff --git a/oldXMenu/SetSel.c b/oldXMenu/SetSel.c
new file mode 100644 (file)
index 0000000..0db2c8e
--- /dev/null
@@ -0,0 +1,50 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/SetSel.c,v 1.1 1992/04/11 22:10:21 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuSetSelection - Set a menu selection to be active or inactive.
+ *
+ *     Author:         Tony Della Fera, DEC
+ *                     August, 1985
+ *
+ */
+
+#include "XMenuInt.h"
+
+int
+XMenuSetSelection(menu, p_num, s_num, active)
+    register XMenu *menu;      /* Menu object to be modified. */
+    register int p_num;                /* Pane number to be modified. */
+    register int s_num;                /* Selection number to modified. */
+    int active;                        /* Make selection active? */
+{
+    register XMPane *p_ptr;    /* XMPane pointer. */
+    register XMSelect *s_ptr;  /* XMSelect pointer. */
+    
+    /*
+     * Find the right pane.
+     */
+    p_ptr = _XMGetPanePtr(menu, p_num);
+    if (p_ptr == NULL) return(XM_FAILURE);
+
+    /*
+     * Find the right selection.
+     */
+    s_ptr = _XMGetSelectionPtr(p_ptr, s_num);
+    if (s_ptr == NULL) return(XM_FAILURE);
+
+    /*
+     * Set its active switch.
+     */
+    s_ptr->active = active;
+
+    /*
+     * Return the selection number just set.
+     */
+    _XMErrorCode = XME_NO_ERROR;
+    return(s_num);
+}
diff --git a/oldXMenu/X10.h b/oldXMenu/X10.h
new file mode 100644 (file)
index 0000000..4a983fe
--- /dev/null
@@ -0,0 +1,78 @@
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/X10.h,v 1.1 1992/04/11 22:10:21 jimb Exp $ */
+/* 
+ * Copyright 1985, 1986, 1987 by the Massachusetts Institute of Technology
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided 
+ * that the above copyright notice appear in all copies and that both that 
+ * copyright notice and this permission notice appear in supporting 
+ * documentation, and that the name of M.I.T. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific, 
+ * written prior permission. M.I.T. makes no representations about the 
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * The X Window System is a Trademark of MIT.
+ *
+ */
+
+
+/*
+ *     X10.h - Header definition and support file for the C subroutine
+ *     interface library for V10 support routines.
+ */
+#ifndef _X10_H_
+#define _X10_H_
+
+/* Used in XDraw and XDrawFilled */
+
+typedef struct {
+       short x, y;
+       unsigned short flags;
+} Vertex;
+
+/* The meanings of the flag bits.  If the bit is 1 the predicate is true */
+
+#define VertexRelative         0x0001          /* else absolute */
+#define VertexDontDraw         0x0002          /* else draw */
+#define VertexCurved           0x0004          /* else straight */
+#define VertexStartClosed      0x0008          /* else not */
+#define VertexEndClosed                0x0010          /* else not */
+/*#define VertexDrawLastPoint  0x0020  */      /* else don't */        
+
+/*
+The VertexDrawLastPoint option has not been implemented in XDraw and 
+XDrawFilled so it shouldn't be defined. 
+*/
+
+/*
+ * XAssoc - Associations used in the XAssocTable data structure.  The 
+ * associations are used as circular queue entries in the association table
+ * which is contains an array of circular queues (buckets).
+ */
+typedef struct _XAssoc {
+       struct _XAssoc *next;   /* Next object in this bucket. */
+       struct _XAssoc *prev;   /* Previous obejct in this bucket. */
+       Display *display;       /* Display which owns the id. */
+       XID x_id;               /* X Window System id. */
+       char *data;             /* Pointer to untyped memory. */
+} XAssoc;
+
+/* 
+ * XAssocTable - X Window System id to data structure pointer association
+ * table.  An XAssocTable is a hash table whose buckets are circular
+ * queues of XAssoc's.  The XAssocTable is constructed from an array of
+ * XAssoc's which are the circular queue headers (bucket headers).  
+ * An XAssocTable consists an XAssoc pointer that points to the first
+ * bucket in the bucket array and an integer that indicates the number
+ * of buckets in the array.
+ */
+typedef struct {
+    XAssoc *buckets;           /* Pointer to first bucket in bucket array.*/
+    int size;                  /* Table size (number of buckets). */
+} XAssocTable;
+
+XAssocTable *XCreateAssocTable();
+char *XLookUpAssoc();
+
+#endif /* _X10_H_ */
diff --git a/oldXMenu/XCrAssoc.c b/oldXMenu/XCrAssoc.c
new file mode 100644 (file)
index 0000000..864ed9d
--- /dev/null
@@ -0,0 +1,68 @@
+/* $XConsortium: XCrAssoc.c,v 10.17 91/01/06 12:04:57 rws Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation, and that the name of M.I.T. not be used in advertising or
+publicity pertaining to distribution of the software without specific,
+written prior permission.  M.I.T. makes no representations about the
+suitability of this software for any purpose.  It is provided "as is"
+without express or implied warranty.
+*/
+
+#include <config.h>
+#include <X11/Xlib.h>
+#include <errno.h>
+#include "X10.h"
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+extern int errno;
+
+/*
+ * XCreateAssocTable - Create an XAssocTable.  The size argument should be
+ * a power of two for efficiency reasons.  Some size suggestions: use 32
+ * buckets per 100 objects;  a reasonable maximum number of object per
+ * buckets is 8.  If there is an error creating the XAssocTable, a NULL
+ * pointer is returned.
+ */
+XAssocTable *XCreateAssocTable(size)
+       register int size;              /* Desired size of the table. */
+{
+       register XAssocTable *table;    /* XAssocTable to be initialized. */
+       register XAssoc *buckets;       /* Pointer to the first bucket in */
+                                       /* the bucket array. */
+       
+       /* Malloc the XAssocTable. */
+       if ((table = (XAssocTable *)malloc(sizeof(XAssocTable))) == NULL) {
+               /* malloc call failed! */
+               errno = ENOMEM;
+               return(NULL);
+       }
+       
+       /* calloc the buckets (actually just their headers). */
+       buckets = (XAssoc *)calloc((unsigned)size, (unsigned)sizeof(XAssoc));
+       if (buckets == NULL) {
+               /* calloc call failed! */
+               errno = ENOMEM;
+               return(NULL);
+       }
+
+       /* Insert table data into the XAssocTable structure. */
+       table->buckets = buckets;
+       table->size = size;
+
+       while (--size >= 0) {
+               /* Initialize each bucket. */
+               buckets->prev = buckets;
+               buckets->next = buckets;
+               buckets++;
+       }
+
+       return(table);
+}
diff --git a/oldXMenu/XDelAssoc.c b/oldXMenu/XDelAssoc.c
new file mode 100644 (file)
index 0000000..df3bee6
--- /dev/null
@@ -0,0 +1,71 @@
+/* $XConsortium: XDelAssoc.c,v 10.19 91/01/06 12:06:39 rws Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation, and that the name of M.I.T. not be used in advertising or
+publicity pertaining to distribution of the software without specific,
+written prior permission.  M.I.T. makes no representations about the
+suitability of this software for any purpose.  It is provided "as is"
+without express or implied warranty.
+*/
+
+#include <X11/Xlib.h>
+#include "X10.h"
+void emacs_remque();
+struct qelem {
+       struct    qelem *q_forw;
+       struct    qelem *q_back;
+       char q_data[1];
+};
+
+/*
+ * XDeleteAssoc - Delete an association in an XAssocTable keyed on
+ * an XId.  An association may be removed only once.  Redundant
+ * deletes are meaningless (but cause no problems).
+ */
+XDeleteAssoc(dpy, table, x_id)
+        register Display *dpy;
+       register XAssocTable *table;
+       register XID x_id;
+{
+       int hash;
+       register XAssoc *bucket;
+       register XAssoc *Entry;
+
+       /* Hash the XId to get the bucket number. */
+       hash = x_id & (table->size - 1);
+       /* Look up the bucket to get the entries in that bucket. */
+       bucket = &table->buckets[hash];
+       /* Get the first entry in the bucket. */
+       Entry = bucket->next;
+
+       /* Scan through the entries in the bucket for the right XId. */
+       for (; Entry != bucket; Entry = Entry->next) {
+               if (Entry->x_id == x_id) {
+                       /* We have the right XId. */
+                       if (Entry->display == dpy) {
+                               /* We have the right display. */
+                               /* We have the right entry! */
+                               /* Remove it from the queue and */
+                               /* free the entry. */
+                               emacs_remque((struct qelem *)Entry);
+                               free((char *)Entry);
+                               return;
+                       }
+                       /* Oops, identical XId's on different displays! */
+                       continue;
+               }
+               if (Entry->x_id > x_id) {
+                       /* We have gone past where it should be. */
+                       /* It is apparently not in the table. */
+                       return;
+               }
+       }
+       /* It is apparently not in the table. */
+       return;
+}
+
diff --git a/oldXMenu/XDestAssoc.c b/oldXMenu/XDestAssoc.c
new file mode 100644 (file)
index 0000000..452dd22
--- /dev/null
@@ -0,0 +1,49 @@
+/* $XConsortium: XDestAssoc.c,v 10.17 91/02/08 13:11:50 rws Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation, and that the name of M.I.T. not be used in advertising or
+publicity pertaining to distribution of the software without specific,
+written prior permission.  M.I.T. makes no representations about the
+suitability of this software for any purpose.  It is provided "as is"
+without express or implied warranty.
+*/
+
+#include <X11/Xlib.h>
+#include "X10.h"
+
+/*
+ * XDestroyAssocTable - Destroy (free the memory associated with)
+ * an XAssocTable.  
+ */
+XDestroyAssocTable(table)
+       register XAssocTable *table;
+{
+       register int i;
+       register XAssoc *bucket;
+       register XAssoc *Entry, *entry_next;
+
+       /* Free the buckets. */
+       for (i = 0; i < table->size; i++) {
+               bucket = &table->buckets[i];
+               for (
+                       Entry = bucket->next;
+                       Entry != bucket;
+                       Entry = entry_next
+               ) {
+                       entry_next = Entry->next;
+                       free((char *)Entry);
+               }
+       }
+
+       /* Free the bucket array. */
+       free((char *)table->buckets);
+
+       /* Free the table. */
+       free((char *)table);
+}
+
diff --git a/oldXMenu/XLookAssoc.c b/oldXMenu/XLookAssoc.c
new file mode 100644 (file)
index 0000000..f80952a
--- /dev/null
@@ -0,0 +1,68 @@
+/* $XConsortium: XLookAssoc.c,v 10.16 91/01/06 12:09:24 rws Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation, and that the name of M.I.T. not be used in advertising or
+publicity pertaining to distribution of the software without specific,
+written prior permission.  M.I.T. makes no representations about the
+suitability of this software for any purpose.  It is provided "as is"
+without express or implied warranty.
+*/
+
+#include <X11/Xlib.h>
+#include <X11/Xresource.h>
+#include "X10.h"
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+/* 
+ * XLookUpAssoc - Retrieve the data stored in an XAssocTable by its XId.
+ * If an appropriately matching XId can be found in the table the routine will
+ * return apointer to the data associated with it. If the XId can not be found
+ * in the table the routine will return a NULL pointer.  All XId's are relative
+ * to the currently active Display.
+ */
+caddr_t XLookUpAssoc(dpy, table, x_id)
+        register Display *dpy;
+       register XAssocTable *table;    /* XAssocTable to search in. */
+       register XID x_id;                      /* XId to search for. */
+{
+       int hash;
+       register XAssoc *bucket;
+       register XAssoc *Entry;
+
+       /* Hash the XId to get the bucket number. */
+       hash = x_id & (table->size - 1);
+       /* Look up the bucket to get the entries in that bucket. */
+       bucket = &table->buckets[hash];
+       /* Get the first entry in the bucket. */
+       Entry = bucket->next;
+
+       /* Scan through the entries in the bucket for the right XId. */
+       for (; Entry != bucket; Entry = Entry->next) {
+               if (Entry->x_id == x_id) {
+                       /* We have the right XId. */
+                       if (Entry->display == dpy) {
+                               /* We have the right display. */
+                               /* We have the right entry! */
+                               return(Entry->data);
+                       }
+                       /* Oops, identical XId's on different displays! */
+                       continue;
+               }
+               if (Entry->x_id > x_id) {
+                       /* We have gone past where it should be. */
+                       /* It is apparently not in the table. */
+                       return(NULL);
+               }
+       }
+       /* It is apparently not in the table. */
+       return(NULL);
+}
+
diff --git a/oldXMenu/XMakeAssoc.c b/oldXMenu/XMakeAssoc.c
new file mode 100644 (file)
index 0000000..d468270
--- /dev/null
@@ -0,0 +1,102 @@
+/* $XConsortium: XMakeAssoc.c,v 10.18 91/01/06 12:09:28 rws Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation, and that the name of M.I.T. not be used in advertising or
+publicity pertaining to distribution of the software without specific,
+written prior permission.  M.I.T. makes no representations about the
+suitability of this software for any purpose.  It is provided "as is"
+without express or implied warranty.
+*/
+
+#include <config.h>
+#include <X11/Xlib.h>
+#include <X11/Xresource.h>
+#include "X10.h"
+#include <errno.h>
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+extern int errno;
+
+void emacs_insque();
+struct qelem {
+       struct    qelem *q_forw;
+       struct    qelem *q_back;
+       char q_data[1];
+};
+/*
+ * XMakeAssoc - Insert data into an XAssocTable keyed on an XId.
+ * Data is inserted into the table only once.  Redundant inserts are
+ * meaningless (but cause no problems).  The queue in each association
+ * bucket is sorted (lowest XId to highest XId).
+ */
+XMakeAssoc(dpy, table, x_id, data)
+       register Display *dpy;
+       register XAssocTable *table;
+       register XID x_id;
+       register caddr_t data;
+{
+       int hash;
+       register XAssoc *bucket;
+       register XAssoc *Entry;
+       register XAssoc *new_entry;
+       
+       /* Hash the XId to get the bucket number. */
+       hash = x_id & (table->size - 1);
+       /* Look up the bucket to get the entries in that bucket. */
+       bucket = &table->buckets[hash];
+       /* Get the first entry in the bucket. */
+       Entry = bucket->next;
+
+       /* If (Entry != bucket), the bucket is empty so make */
+       /* the new entry the first entry in the bucket. */
+       /* if (Entry == bucket), the we have to search the */
+       /* bucket. */
+       if (Entry != bucket) {
+               /* The bucket isn't empty, begin searching. */
+               /* If we leave the for loop then we have either passed */
+               /* where the entry should be or hit the end of the bucket. */
+               /* In either case we should then insert the new entry */
+               /* before the current value of "Entry". */
+               for (; Entry != bucket; Entry = Entry->next) {
+                       if (Entry->x_id == x_id) {
+                               /* Entry has the same XId... */
+                               if (Entry->display == dpy) {
+                                       /* Entry has the same Display... */
+                                       /* Therefore there is already an */
+                                       /* entry with this XId and Display, */
+                                       /* reset its data value and return. */
+                                       Entry->data = data;
+                                       return;
+                               }
+                               /* We found an association with the right */
+                               /* id but the wrong display! */
+                               continue;
+                       }
+                       /* If the current entry's XId is greater than the */
+                       /* XId of the entry to be inserted then we have */
+                       /* passed the location where the new XId should */
+                       /* be inserted. */
+                       if (Entry->x_id > x_id) break;
+               }
+        }
+
+       /* If we are here then the new entry should be inserted just */
+       /* before the current value of "Entry". */
+       /* Create a new XAssoc and load it with new provided data. */
+       new_entry = (XAssoc *) xmalloc(sizeof(XAssoc));
+       new_entry->display = dpy;
+       new_entry->x_id = x_id;
+       new_entry->data = data;
+
+       /* Insert the new entry. */
+       emacs_insque((struct qelem *)new_entry, (struct qelem *)Entry->prev);
+}
+
diff --git a/oldXMenu/XMenu.h b/oldXMenu/XMenu.h
new file mode 100644 (file)
index 0000000..8b90c99
--- /dev/null
@@ -0,0 +1,262 @@
+#include "copyright.h"
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/XMenu.h,v 1.1 1992/04/11 22:10:21 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenu.h -       Include file for the MIT Project Athena
+ *                     XMenu X window system menu package.
+ *                     
+ *     Author:         Tony Della Fera, DEC
+ *                     August, 1984
+ */
+
+#ifndef _XMenu_h_
+#define _XMenu_h_
+
+#include <X11/Xutil.h>
+#include "X10.h"
+
+#define FAILURE                        -1
+#define SUCCESS                        1
+#define POST_ERROR             -1
+#define NO_SELECTION           -1
+
+#define XM_FAILURE             -1
+#define XM_SUCCESS             1
+#define XM_NO_SELECT           2
+#define XM_IA_SELECT           3
+
+#define XME_CODE_COUNT         17
+
+#define XME_NO_ERROR           0
+#define XME_NOT_INIT           1
+#define XME_ARG_BOUNDS         2
+#define XME_P_NOT_FOUND                3
+#define XME_S_NOT_FOUND                4
+#define XME_STYLE_PARAM                5
+#define XME_GRAB_MOUSE         6
+#define XME_INTERP_LOC         7
+#define XME_CALLOC             8
+#define XME_CREATE_ASSOC       9
+#define XME_STORE_BITMAP       10
+#define XME_MAKE_TILES         11
+#define XME_MAKE_PIXMAP                12
+#define XME_CREATE_CURSOR      13
+#define XME_OPEN_FONT          14
+#define XME_CREATE_WINDOW      15
+#define XME_CREATE_TRANSP      16
+
+/*
+ * XMenu error code and error list definitions.
+ */
+extern int _XMErrorCode;
+extern char *_XMErrorList[];
+
+/*
+ * Define the XMWindow datatypes.
+ *
+ * An XMWindow is either an XMPane or an XMSelect.
+ *
+ * XMWindow is wrapper used to identify the constant window
+ * information that makes up XMPane and XMSelect objects.
+ *
+ * An XMPane is a menu pane made up of one or more XMSelect and a label.
+ *
+ * An XMSelect is a menu selection object with a label and a data pointer.
+ */
+typedef enum _xmwintype {PANE, SELECTION, PL_HEADER, SL_HEADER, SEPARATOR} XMWType;
+
+typedef struct _xmwindow {
+    struct _xmwindow *next;    /* Next obj pointer (for emacs_insque). */
+    struct _xmwindow *prev;    /* Prev obj pointer (for emacs_insque). */
+    XMWType type;              /* Type of window. */
+    Window window;             /* X Window Id. */
+    int window_x;              /* Window upper left X coordinate. */
+    int window_y;              /* Window upper left y coordinate. */
+    int window_w;              /* Window width. */
+    int window_h;              /* Window height. */
+    int active;                        /* Window active? */
+    int activated;             /* Window activated? */
+    int pad_l1;                        /* ---- */
+    char *pad_l2;              /* ---- */
+    int pad_l3;                        /* ---- */
+    int pad_l4;                        /* ---- */
+    int pad_l5;                        /* ---- */
+    int pad_l6;                        /* ---- */
+    int pad_l7;                        /* ---- */
+    int pad_l8;                        /* ---- */
+    struct _xmwindow *pad_l9;  /* ---- */
+    char *pad_l10;             /* ---- */
+    struct _xmwindow *pad_l11; /* ---- */
+} XMWindow;
+
+typedef struct _xmpane {
+    struct _xmpane *next;      /* Next obj pointer (for emacs_insque). */
+    struct _xmpane *prev;      /* Prev obj pointer (for emacs_insque). */
+    XMWType type;              /* Type of window. */
+    Window window;             /* X Window Id. */
+    int window_x;              /* Window upper left X coordinate. */
+    int window_y;              /* Window upper left y coordinate. */
+    int window_w;              /* Window width. */
+    int window_h;              /* Window height. */
+    int active;                        /* Window active? */
+    int activated;             /* Window activated? */
+    int serial;                        /* -- Pane serial number. */
+    char *label;               /* -- Pane label. */
+    int label_width;           /* -- Pane label width in pixels. */
+    int label_length;          /* -- Pane label length in chars. */
+    int label_x;               /* -- Pane label X offset. */
+    int label_uy;              /* -- Pane label upper Y offset. */
+    int label_ly;              /* -- Pane label lower Y offset. */
+    int s_count;               /* -- Selections in this pane. */
+    struct _xmselect *s_list;  /* -- Selection  window list. */
+    char *pad_l10;             /* ---- */
+    struct _xmwindow *pad_l11; /* ---- */
+} XMPane;
+
+typedef struct _xmselect {
+    struct _xmselect *next;    /* Next obj pointer (for emacs_insque). */
+    struct _xmselect *prev;    /* Prev obj pointer (for emacs_insque). */
+    XMWType type;              /* Type of window. */
+    Window window;             /* X Window Id. */
+    Window parent;             /* X Window id of parent window. */
+    int window_x;              /* Window upper left X coordinate. */
+    int window_y;              /* Window upper left y coordinate. */
+    int window_w;              /* Window width. */
+    int window_h;              /* Window height. */
+    int active;                        /* Window active? */
+    int activated;             /* Window activated? */
+    int serial;                        /* -- Selection serial number. */
+    char *label;               /* -- Selection label. */
+    int label_width;           /* -- Selection label width in pixels. */
+    int label_length;          /* -- Selection label length in chars. */
+    int label_x;               /* -- Selection label X offset. */
+    int label_y;               /* -- Selection label Y offset. */
+    int pad_l7;                        /* ---- */
+    int pad_l8;                        /* ---- */
+    struct _xmwindow *pad_l9;  /* ---- */
+    char *data;                        /* -- Selection data pointer. */
+    struct _xmpane *parent_p;  /* -- Selection parent pane structure. */
+} XMSelect;
+
+
+/*
+ * Define the XMStyle datatype.
+ *
+ * Menu presentation style information.
+ *
+ */
+typedef enum _xmstyle {
+    LEFT,                      /* Left oriented obejct. */
+    RIGHT,                     /* Right oriented obejct. */
+    CENTER                     /* Center oriented object. */
+} XMStyle;
+
+
+/*
+ * Define the XMMode datatype.
+ *
+ * Menu presentation mode information.
+ *
+ */
+typedef enum _xmmode {
+    BOX,                       /* BOXed graphic rendition. */
+    INVERT                     /* INVERTed graphic rendition. */
+} XMMode;
+
+
+/* 
+ * Define the XMenu datatype. 
+ *
+ * All dimensions are in pixels unless otherwise noted.
+ */
+typedef struct _xmenu {
+    /* -------------------- Menu data -------------------- */
+    XMStyle menu_style;                /* Menu display style. */
+    XMMode menu_mode;          /* Menu display mode. */
+    int freeze;                        /* Freeze server mode? */
+    int aeq;                   /* Asynchronous Event Queuing mode? */
+    int recompute;             /* Recompute menu dependencies? */
+    Window parent;             /* Menu's parent window. */
+    int width;                 /* Overall menu width. */
+    int height;                        /* Overall menu height. */
+    int x_pos;                 /* Oveall menu origin. */
+    int y_pos;                 /* Overall menu origin. */
+    Cursor mouse_cursor;       /* Mouse cursor raster. */
+    XAssocTable *assoc_tab;    /* XMWindow association table. */
+    XMPane *p_list;            /* List of XMPanes. */
+    /* -------------------- Pane window data -------------------- */
+    XMStyle p_style;           /* Pane display style. */
+    int p_events;              /* Pane window X events. */
+    XFontStruct *p_fnt_info;   /* Flag font info structure. */
+    GC pane_GC;                        /* Pane graphics context. */
+    int p_fnt_pad;             /* Fixed flag font padding in pixels. */
+    double p_spread;           /* Pane spread in flag height fractions. */
+    int p_bdr_width;           /* Pane border width. */
+    int flag_height;           /* Flag height. */
+    int p_width;               /* Menu pane width. */
+    int p_height;              /* Menu pane height. */
+    int p_x_off;               /* Pane window X offset. */
+    int p_y_off;               /* Pane window Y offset. */
+    int p_count;               /* Number of panes per menu. */
+    /* -------------------- Selection window data -------------------- */
+    XMStyle s_style;           /* Selection display style. */
+    int s_events;              /* Selection window X events. */
+    XFontStruct *s_fnt_info;   /* Body font info structure. */
+    int s_fnt_pad;             /* Fixed body font padding in pixels. */
+    double s_spread;           /* Select spread in line height fractions. */
+    int s_bdr_width;           /* Select border width. */
+    int s_width;               /* Selection window width. */
+    int s_height;              /* Selection window height. */
+    int s_x_off;               /* Selection window X offset. */
+    int s_y_off;               /* Selection window Y offset. */
+    int s_count;               /* Maximum number of selections per pane. */
+    GC normal_select_GC;       /* GC used for inactive selections. */
+    GC inverse_select_GC;      /* GC used for active (current) selection. */  
+    GC inact_GC;               /* GC used for inactive selections and */
+                               /* panes headers. */
+    /* -------------------- Color data -------------------- */
+    unsigned long p_bdr_color; /* Color of pane border pixmap. */
+    unsigned long s_bdr_color; /* Color of selection border pixmap. */
+    unsigned long p_frg_color; /* Color of pane foreground pixmap. */
+    unsigned long s_frg_color; /* Color of selection pixmap. */
+    unsigned long bkgnd_color; /* Color of menu background pixmap. */
+    /* -------------------- Pixmap data -------------------- */
+    Pixmap p_bdr_pixmap;       /* Pane border pixmap. */
+    Pixmap s_bdr_pixmap;       /* Selection border pixmap. */
+    Pixmap p_frg_pixmap;       /* Pane foreground pixmap. */
+    Pixmap s_frg_pixmap;       /* Selection foreground pixmap. */
+    Pixmap bkgnd_pixmap;       /* Menu background pixmap. */
+    Pixmap inact_pixmap;       /* Menu inactive pixmap. */
+} XMenu;
+
+/*
+ * XMenu library routine declarations.
+ */
+XMenu *XMenuCreate();
+int XMenuAddPane();
+int XMenuAddSelection();
+int XMenuInsertPane();
+int XMenuInsertSelection();
+int XMenuFindPane();
+int XMenuFindSelection();
+int XMenuChangePane();
+int XMenuChangeSelection();
+int XMenuSetPane();
+int XMenuSetSelection();
+int XMenuRecompute();
+int XMenuEventHandler();       /* No value actually returned. */
+int XMenuLocate();
+int XMenuSetFreeze();          /* No value actually returned. */
+int XMenuActivate();
+char *XMenuPost();
+int XMenuDeletePane();
+int XMenuDeleteSelection();
+int XMenuDestroy();            /* No value actually returned. */
+char *XMenuError();
+
+#endif
+/* Don't add after this point. */
diff --git a/oldXMenu/XMenuInt.h b/oldXMenu/XMenuInt.h
new file mode 100644 (file)
index 0000000..7f3f013
--- /dev/null
@@ -0,0 +1,63 @@
+
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/XMenuInt.h,v 1.3 1992/10/10 16:05:10 jimb Exp $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ * XMenu:      MIT Project Athena, X Window system menu package
+ *
+ *     XMenuInternal.h - Internal menu system include file for the
+ *                     MIT Project Athena XMenu X window system
+ *                     menu package.
+ *                     
+ *     Author:         Tony Della Fera, DEC
+ *                     October, 1985
+ */
+
+#ifndef _XMenuInternal_h_
+#define _XMenuInternal_h_
+
+/* Avoid warnings about redefining NULL by including <stdio.h> first;
+   the other file which wants to define it (<stddef.h> on Ultrix
+   systems) can deal if NULL is already defined, but <stdio.h> can't.  */
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include "X10.h"
+#include "XMenu.h"
+
+#define min(x, y)      ((x) <= (y) ? (x) : (y))
+#define max(x, y)      ((x) >= (y) ? (x) : (y))
+#define abs(a)         ((a) < 0 ? -(a) : (a))
+
+#define _X_FAILURE     -1
+
+#define _SUCCESS       1
+#define _FAILURE       -1
+
+/*
+ * XMenu internal event handler variable.
+ */
+extern int (*_XMEventHandler)();
+
+#ifndef Pixel
+#define Pixel unsigned long
+#endif
+
+/*
+ * Internal routine declarations.
+ */
+int _XMWinQueInit();           /* No value actually returned. */
+int _XMWinQueAddPane();
+int _XMWinQueAddSelection();
+int _XMWinQueFlush();
+XMPane *_XMGetPanePtr();
+XMSelect *_XMGetSelectionPtr();
+int _XMRecomputeGlobals();     /* No value actually returned. */
+int _XMRecomputePane();
+int _XMRecomputeSelection();
+int _XMTransToOrigin();                /* No value actually returned. */
+int _XMRefreshPane();          /* No value actually returned. */
+int _XMRefreshSelections();    /* No value actually returned. */
+int _XMHighlightSelection();   /* No value actually returned. */
+
+#endif
+/* Don't add stuff after this #endif */
diff --git a/oldXMenu/compile.com b/oldXMenu/compile.com
new file mode 100644 (file)
index 0000000..0ed2a6b
--- /dev/null
@@ -0,0 +1,66 @@
+$! This file was autogenerated with the command:
+$!
+$!     mms/noaction/output = compile.com
+$ if f$search("ACTIVATE.OBJ") then delete ACTIVATE.OBJ.*
+$ cc /obj=ACTIVATE.OBJ /NOLIST/OBJECT=ACTIVATE.OBJ ACTIVATE.c
+$ if f$search("ADDPANE.OBJ") then delete ADDPANE.OBJ.*
+$ cc /obj=ADDPANE.OBJ /NOLIST/OBJECT=ADDPANE.OBJ ADDPANE.c
+$ if f$search("ADDSEL.OBJ") then delete ADDSEL.OBJ.*
+$ cc /obj=ADDSEL.OBJ /NOLIST/OBJECT=ADDSEL.OBJ ADDSEL.c
+$ if f$search("CHGPANE.OBJ") then delete CHGPANE.OBJ.*
+$ cc /obj=CHGPANE.OBJ /NOLIST/OBJECT=CHGPANE.OBJ CHGPANE.c
+$ if f$search("CHGSEL.OBJ") then delete CHGSEL.OBJ.*
+$ cc /obj=CHGSEL.OBJ /NOLIST/OBJECT=CHGSEL.OBJ CHGSEL.c
+$ if f$search("CREATE.OBJ") then delete CREATE.OBJ.*
+$ cc /obj=CREATE.OBJ /NOLIST/OBJECT=CREATE.OBJ CREATE.c
+$ if f$search("DELPANE.OBJ") then delete DELPANE.OBJ.*
+$ cc /obj=DELPANE.OBJ /NOLIST/OBJECT=DELPANE.OBJ DELPANE.c
+$ if f$search("DELSEL.OBJ") then delete DELSEL.OBJ.*
+$ cc /obj=DELSEL.OBJ /NOLIST/OBJECT=DELSEL.OBJ DELSEL.c
+$ if f$search("DESTROY.OBJ") then delete DESTROY.OBJ.*
+$ cc /obj=DESTROY.OBJ /NOLIST/OBJECT=DESTROY.OBJ DESTROY.c
+$ if f$search("ERROR.OBJ") then delete ERROR.OBJ.*
+$ cc /obj=ERROR.OBJ /NOLIST/OBJECT=ERROR.OBJ ERROR.c
+$ if f$search("EVHAND.OBJ") then delete EVHAND.OBJ.*
+$ cc /obj=EVHAND.OBJ /NOLIST/OBJECT=EVHAND.OBJ EVHAND.c
+$ if f$search("FINDPANE.OBJ") then delete FINDPANE.OBJ.*
+$ cc /obj=FINDPANE.OBJ /NOLIST/OBJECT=FINDPANE.OBJ FINDPANE.c
+$ if f$search("FINDSEL.OBJ") then delete FINDSEL.OBJ.*
+$ cc /obj=FINDSEL.OBJ /NOLIST/OBJECT=FINDSEL.OBJ FINDSEL.c
+$ if f$search("INSPANE.OBJ") then delete INSPANE.OBJ.*
+$ cc /obj=INSPANE.OBJ /NOLIST/OBJECT=INSPANE.OBJ INSPANE.c
+$ if f$search("INSSEL.OBJ") then delete INSSEL.OBJ.*
+$ cc /obj=INSSEL.OBJ /NOLIST/OBJECT=INSSEL.OBJ INSSEL.c
+$ if f$search("INTERNAL.OBJ") then delete INTERNAL.OBJ.*
+$ cc /obj=INTERNAL.OBJ /NOLIST/OBJECT=INTERNAL.OBJ INTERNAL.c
+$ if f$search("LOCATE.OBJ") then delete LOCATE.OBJ.*
+$ cc /obj=LOCATE.OBJ /NOLIST/OBJECT=LOCATE.OBJ LOCATE.c
+$ if f$search("POST.OBJ") then delete POST.OBJ.*
+$ cc /obj=POST.OBJ /NOLIST/OBJECT=POST.OBJ POST.c
+$ if f$search("RECOMP.OBJ") then delete RECOMP.OBJ.*
+$ cc /obj=RECOMP.OBJ /NOLIST/OBJECT=RECOMP.OBJ RECOMP.c
+$ if f$search("SETAEQ.OBJ") then delete SETAEQ.OBJ.*
+$ cc /obj=SETAEQ.OBJ /NOLIST/OBJECT=SETAEQ.OBJ SETAEQ.c
+$ if f$search("SETFRZ.OBJ") then delete SETFRZ.OBJ.*
+$ cc /obj=SETFRZ.OBJ /NOLIST/OBJECT=SETFRZ.OBJ SETFRZ.c
+$ if f$search("SETPANE.OBJ") then delete SETPANE.OBJ.*
+$ cc /obj=SETPANE.OBJ /NOLIST/OBJECT=SETPANE.OBJ SETPANE.c
+$ if f$search("SETSEL.OBJ") then delete SETSEL.OBJ.*
+$ cc /obj=SETSEL.OBJ /NOLIST/OBJECT=SETSEL.OBJ SETSEL.c
+$ if f$search("XDELASSOC.OBJ") then delete XDELASSOC.OBJ.*
+$ cc /obj=XDELASSOC.OBJ /NOLIST/OBJECT=XDELASSOC.OBJ XDELASSOC.c
+$ if f$search("XLOOKASSOC.OBJ") then delete XLOOKASSOC.OBJ.*
+$ cc /obj=XLOOKASSOC.OBJ /NOLIST/OBJECT=XLOOKASSOC.OBJ XLOOKASSOC.c
+$ if f$search("XCRASSOC.OBJ") then delete XCRASSOC.OBJ.*
+$ cc /obj=XCRASSOC.OBJ /NOLIST/OBJECT=XCRASSOC.OBJ XCRASSOC.c
+$ if f$search("XDESTASSOC.OBJ") then delete XDESTASSOC.OBJ.*
+$ cc /obj=XDESTASSOC.OBJ /NOLIST/OBJECT=XDESTASSOC.OBJ XDESTASSOC.c
+$ if f$search("XMAKEASSOC.OBJ") then delete XMAKEASSOC.OBJ.*
+$ cc /obj=XMAKEASSOC.OBJ /NOLIST/OBJECT=XMAKEASSOC.OBJ XMAKEASSOC.c
+$ if f$search("INSQUE.OBJ") then delete INSQUE.OBJ.*
+$ cc /obj=INSQUE.OBJ /NOLIST/OBJECT=INSQUE.OBJ INSQUE.c
+$ if f$search("LIBXMENU11.OLB") then delete LIBXMENU11.OLB.*
+$ library/insert/create LIBXMENU11.OLB Activate.obj,   AddPane.obj,    AddSel.obj,     ChgPane.obj,    ChgSel.obj,     Create.obj,     DelPane.obj,    DelSel.obj,     Destroy.obj,    Error.obj,      EvHand.obj,     FindPane.obj,   FindSel.obj,    InsPane.obj,    InsSel.obj,     Internal.-
+obj,   Locate.obj,     Post.obj,       Recomp.obj,     SetAEQ.obj,     SetFrz.obj,     SetPane.obj,    SetSel.obj,         XDelAssoc.obj, XLookAssoc.obj, XCrAssoc.obj, XDestAssoc.obj,         XMakeAssoc.obj
+$ if ("insque.obj" .nes. "") then library/insert LIBXMENU11.OLB insque.obj
+$ !
diff --git a/oldXMenu/copyright.h b/oldXMenu/copyright.h
new file mode 100644 (file)
index 0000000..1cd0883
--- /dev/null
@@ -0,0 +1,19 @@
+/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/copyright.h,v 1.1 1992/04/11 22:10:22 jimb Exp $ */
+/*
+
+Copyright 1985, 1986, 1987 by the Massachusetts Institute of Technology
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of M.I.T. not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+M.I.T. makes no representations about the suitability of
+this software for any purpose.  It is provided "as is"
+without express or implied warranty.
+
+*/
+
diff --git a/oldXMenu/descrip.mms b/oldXMenu/descrip.mms
new file mode 100644 (file)
index 0000000..6ecd694
--- /dev/null
@@ -0,0 +1,88 @@
+!# Uncomment following line if linking temacs complains about missing insque.
+EXTRA=insque.obj
+
+AS = as
+CC = cc
+LD = link
+TAGS = etags
+RM = delete
+MV = rename
+AR = library/insert
+MAKE = mms
+STD_DEFINES =
+CDEBUGFLAGS = /debug/noopt
+RM_CMD = $(RM) *.BAK.*, *.obj.*
+
+SRCS =  Activate.c, -
+       AddPane.c, -
+       AddSel.c, -
+       ChgPane.c, -
+       ChgSel.c, -
+       Create.c, -
+       DelPane.c, -
+       DelSel.c, -
+       Destroy.c, -
+       Error.c, -
+       EvHand.c, -
+       FindPane.c, -
+       FindSel.c, -
+       InsPane.c, -
+       InsSel.c, -
+       Internal.c, -
+       Locate.c, -
+       Post.c, -
+       Recomp.c, -
+       SetAEQ.c, -
+       SetFrz.c, -
+       SetPane.c, -
+       SetSel.c, -
+        XDelAssoc.c, XLookAssoc.c, XCrAssoc.c, XDestAssoc.c, XMakeAssoc.c
+
+OBJS =  Activate.obj, -
+       AddPane.obj, -
+       AddSel.obj, -
+       ChgPane.obj, -
+       ChgSel.obj, -
+       Create.obj, -
+       DelPane.obj, -
+       DelSel.obj, -
+       Destroy.obj, -
+       Error.obj, -
+       EvHand.obj, -
+       FindPane.obj, -
+       FindSel.obj, -
+       InsPane.obj, -
+       InsSel.obj, -
+       Internal.obj, -
+       Locate.obj, -
+       Post.obj, -
+       Recomp.obj, -
+       SetAEQ.obj, -
+       SetFrz.obj, -
+       SetPane.obj, -
+       SetSel.obj, -
+        XDelAssoc.obj, XLookAssoc.obj, XCrAssoc.obj, XDestAssoc.obj, -
+        XMakeAssoc.obj
+
+.c.obj :
+       if f$search("$@") then $(RM) $@.*
+       $(CC) /obj=$@ $(CFLAGS) $*.c
+
+all :: libXMenu11.olb
+       !
+
+libXMenu11.olb : $(OBJS) $(EXTRA)
+       if f$search("$@") then $(RM) $@.*
+       $(AR)/create $@ $(OBJS)
+       if ("$(EXTRA)" .nes. "") then $(AR) $@ $(EXTRA)
+#If running ranlib fails, probably there is none.
+#That's ok.  So don't stop the build.
+
+distclean : clean
+       !
+
+clean ::
+       $(RM_CMD) \#* libXMenu11.a *.obj,
+tags ::
+       $(TAGS) -t *.[ch]
+
diff --git a/oldXMenu/insque.c b/oldXMenu/insque.c
new file mode 100644 (file)
index 0000000..4d26443
--- /dev/null
@@ -0,0 +1,38 @@
+/* This file implements the emacs_insque and emacs_remque functions,
+   copies of the insque and remque functions of BSD.  They and all
+   their callers have been renamed to emacs_mumble to allow us to
+   include this file in the menu library on all systems.  */
+
+
+struct qelem {
+  struct    qelem *q_forw;
+  struct    qelem *q_back;
+  char q_data[1];
+};
+
+/* Insert ELEM into a doubly-linked list, after PREV.  */
+
+void
+emacs_insque (elem, prev) 
+     struct qelem *elem, *prev;
+{
+  struct qelem *next = prev->q_forw;
+  prev->q_forw = elem;
+  if (next)
+    next->q_back = elem;
+  elem->q_forw = next;
+  elem->q_back = prev;
+}
+
+/* Unlink ELEM from the doubly-linked list that it is in.  */
+
+emacs_remque (elem)
+     struct qelem *elem;
+{
+  struct qelem *next = elem->q_forw;
+  struct qelem *prev = elem->q_back;
+  if (next)
+    next->q_back = prev;
+  if (prev)
+    prev->q_forw = next;
+}