Commit e745ede7 authored by Dave Love's avatar Dave Love

#

parent 0c898dd9
This diff is collapsed.
#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));
}
#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));
}
This diff is collapsed.
#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);
}
#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);
}
This diff is collapsed.
#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);
}
#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);
}
#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);
}
#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);
}
#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;
}
#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') {