root/oldXMenu/ChgPane.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. XMenuChangePane

     1 /* Copyright    Massachusetts Institute of Technology    1985   */
     2 
     3 /*
     4 
     5 Copyright 1985, 1986, 1987 by the Massachusetts Institute of Technology
     6 
     7 Permission to use, copy, modify, and distribute this
     8 software and its documentation for any purpose and without
     9 fee is hereby granted, provided that the above copyright
    10 notice appear in all copies and that both that copyright
    11 notice and this permission notice appear in supporting
    12 documentation, and that the name of M.I.T. not be used in
    13 advertising or publicity pertaining to distribution of the
    14 software without specific, written prior permission.
    15 M.I.T. makes no representations about the suitability of
    16 this software for any purpose.  It is provided "as is"
    17 without express or implied warranty.
    18 
    19 */
    20 
    21 
    22 
    23 
    24 /*
    25  * XMenu:       MIT Project Athena, X Window system menu package
    26  *
    27  *      XMenuChangePane - Change the label of a  menu pane.
    28  *
    29  *      Author:         Tony Della Fera, DEC
    30  *                      December 19, 1985
    31  *
    32  */
    33 
    34 #include "XMenuInt.h"
    35 #include <string.h>
    36 
    37 int
    38 XMenuChangePane(register XMenu *menu, register int p_num, char *label)
    39                                 /* Menu object to be modified. */
    40                                 /* Pane number to be modified. */
    41                                 /* Selection label. */
    42 {
    43     register XMPane *p_ptr;     /* XMPane pointer. */
    44 
    45     int label_length;           /* Label length in characters. */
    46     int label_width;            /* Label width in pixels. */
    47 
    48     /*
    49      * Check for NULL pointers!
    50      */
    51     if (label == NULL) {
    52         _XMErrorCode = XME_ARG_BOUNDS;
    53         return(XM_FAILURE);
    54     }
    55 
    56     /*
    57      * Find the right pane.
    58      */
    59     p_ptr = _XMGetPanePtr(menu, p_num);
    60     if (p_ptr == NULL) return(XM_FAILURE);
    61 
    62     /*
    63      * Determine label size.
    64      */
    65     label_length = strlen(label);
    66     label_width = XTextWidth(menu->p_fnt_info, label, label_length);
    67 
    68     /*
    69      * Change the pane data.
    70      */
    71     p_ptr->label = label;
    72     p_ptr->label_width = label_width;
    73     p_ptr->label_length = label_length;
    74 
    75     /*
    76      * Schedule a recompute.
    77      */
    78     menu->recompute = 1;
    79 
    80     /*
    81      * Return the pane number just changed.
    82      */
    83     _XMErrorCode = XME_NO_ERROR;
    84     return(p_num);
    85 }

/* [<][>][^][v][top][bottom][index][help] */