Annotation of researchv9/X11/src/X.V11R1/lib/oldXMenu/AddSel.c, revision 1.1

1.1     ! root        1: #include <X11/copyright.h>
        !             2: 
        !             3: /* $Header: AddSel.c,v 1.3 87/09/10 20:30:27 chris Exp $ */
        !             4: /* Copyright    Massachusetts Institute of Technology    1985  */
        !             5: 
        !             6: /*
        !             7:  * XMenu:      MIT Project Athena, X Window system menu package
        !             8:  *
        !             9:  *     XMenuAddSelection - Adds a selection to an XMenu object.
        !            10:  *
        !            11:  *     Author:         Tony Della Fera, DEC
        !            12:  *                     August, 1985
        !            13:  *
        !            14:  */
        !            15: 
        !            16: #include "XMenuInternal.h"
        !            17: 
        !            18: int
        !            19: XMenuAddSelection(display, menu, p_num, data, label, active)
        !            20:     Display *display;
        !            21:     register XMenu *menu;      /* Menu object to be modified. */
        !            22:     register int p_num;                /* Pane number to be modified. */
        !            23:     char *data;                        /* Data value. */
        !            24:     char *label;               /* Selection label. */
        !            25:     int active;                        /* Make selection active? */
        !            26: {
        !            27:     register XMPane *pane;     /* Pane containing the new selection. */
        !            28:     register XMSelect *select; /* Newly created selection. */
        !            29: 
        !            30: 
        !            31:     int label_length;          /* Label lenght in characters. */
        !            32:     int label_width;           /* Label width in pixels. */
        !            33:     
        !            34:     /*
        !            35:      * Check for NULL pointers!
        !            36:      */
        !            37:     if (label == NULL) {
        !            38:        _XMErrorCode = XME_ARG_BOUNDS;
        !            39:        return(XM_FAILURE);
        !            40:     }
        !            41:     /*
        !            42:      * Find the right pane.
        !            43:      */
        !            44:     pane = _XMGetPanePtr(menu, p_num);
        !            45:     if (pane == NULL) return(XM_FAILURE);
        !            46: 
        !            47:     /*
        !            48:      * Calloc the XMSelect structure.
        !            49:      */
        !            50:     select = (XMSelect *)calloc(1, sizeof(XMSelect));
        !            51:     if (select == NULL) {
        !            52:        _XMErrorCode = XME_CALLOC;
        !            53:        return(XM_FAILURE);
        !            54:     }
        !            55:     /*
        !            56:      * Determine label size.
        !            57:      */
        !            58:     label_length = strlen(label);
        !            59:     label_width = XTextWidth(menu->s_fnt_info, label, label_length);
        !            60:     
        !            61:     /*
        !            62:      * Fill the XMSelect structure.
        !            63:      */
        !            64:     select->type = SELECTION;
        !            65:     select->active = active;
        !            66:     select->serial = -1;
        !            67:     select->label = label;
        !            68:     select->label_width = label_width;
        !            69:     select->label_length = label_length;
        !            70:     select->data = data;
        !            71:     select->parent_p = pane;
        !            72:     
        !            73:     /*
        !            74:      * Insert the selection at the end of the selection list.
        !            75:      */
        !            76:     insque(select, pane->s_list->prev);
        !            77: 
        !            78:     /*
        !            79:      * Update the selection count.
        !            80:      */
        !            81:     pane->s_count++;
        !            82: 
        !            83:     /*
        !            84:      * Schedule a recompute.
        !            85:      */
        !            86:     menu->recompute = 1;
        !            87: 
        !            88:     /*
        !            89:      * Return the selection number just added.
        !            90:      */
        !            91:     _XMErrorCode = XME_NO_ERROR;
        !            92:     return((pane->s_count - 1));
        !            93: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.