view oldXMenu/ChgSel.c @ 103344:d04aeff22966

2009-06-08 Adrian Robert <Adrian.B.Robert@gmail.com> * nsterm.m (ns_use_system_highlight_color): Drop, unused. 2009-06-08 Adrian Robert <Adrian.B.Robert@gmail.com> Changes to support :script/:lang/:otf in NS font driver. * nsfont.m (nsfont_escape_name, nsfont_unescape_name) (nsfont_get_family, nsfont_char_width): Rename to ns_ prefix to indicate not part of font driver interface, and change callers. (ns_get_family): Remove pointless null check. (nsfont_spec_to_traits, nsfont_fmember_to_entity): Replace with ns_spec_to_descriptor, ns_descriptor_to_entity. (nsfont_trait_distance, nsfont_make_fontset_for_font): Remove. (ns_attribute_value, ns_attribute_fvalue, ns_has_attribute) (ns_spec_to_descriptor, ns_descriptor_to_entity) (ns_charset_covers, ns_lang_to_script, ns_otf_to_script) (ns_get_req_script, ns_accumulate_script_ranges) (ns_script_to_charset, ns_get_covering_families, ns_findfonts): New functions. (nsfont_list, nsfont_match): Use ns_findfonts. (nsfont_open): Use font descriptor instead of traits. (nsfont_draw): Handle "automatic" (lookup-table) compositions. (dump_glyphstring): Rename to ns_dump_glyphstring. * nsfns.m (Fns_popup_font_panel): Use shared font manager. * fontset.c (fontset_from_font): Remove NS-specific code. 2009-06-08 Peter Jones <pjones@pmade.com> (tiny change) * nsterm.m (ns_draw_window_cursor): Respect cursor_type for nonactive windows. 2009-06-08 Felix Mueller <felix@enqueue.eu> (tiny change) * nsterm.m (ns_init_paths): Append path separator to INFOPATH variable.
author Adrian Robert <Adrian.B.Robert@gmail.com>
date Mon, 08 Jun 2009 04:34:54 +0000
parents d4f6522bb9d2
children e9f94688a064 5cc91198ffb2
line wrap: on
line source

/* Copyright    Massachusetts Institute of Technology    1985	*/

#include "copyright.h"


/*
 * XMenu:	MIT Project Athena, X Window system menu package
 *
 *	XMenuChangeSelection - Change a menu selection.
 *
 *	Author:		Tony Della Fera, DEC
 *			December 19, 1985
 *
 */

#include <config.h>
#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);
}

/* arch-tag: 229732a6-46bf-4a3a-ad90-3d8ed65c0841
   (do not change this comment) */