root/oldXMenu/AddPane.c

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

DEFINITIONS

This source file includes following definitions.
  1. XMenuAddPane

     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  * XMenu:       MIT Project Athena, X Window system menu package
    25  *
    26  *      XMenuAddPane - Adds a pane to an XMenu object.
    27  *
    28  *      Author:         Tony Della Fera, DEC
    29  *                      August, 1985
    30  *
    31  */
    32 
    33 #include "XMenuInt.h"
    34 #include <string.h>
    35 
    36 int
    37 XMenuAddPane(Display *display, register XMenu *menu, register char const *label, int active)
    38 
    39                                 /* Menu object to be modified. */
    40                                 /* Selection label. */
    41                                 /* Make selection active? */
    42 {
    43     register XMPane *pane;      /* Newly created pane. */
    44     register XMSelect *sel;     /* Initial selection for the new pane. */
    45 
    46     int label_length;           /* Label length in characters. */
    47     int label_width;            /* Label width in pixels. */
    48 
    49     /*
    50      * Check for NULL pointers!
    51      */
    52     if (label == NULL) {
    53         _XMErrorCode = XME_ARG_BOUNDS;
    54         return(XM_FAILURE);
    55     }
    56 
    57     /*
    58      * Calloc the XMPane structure and the initial XMSelect.
    59      */
    60     pane = (XMPane *)calloc(1, sizeof(XMPane));
    61     if (pane == NULL) {
    62         _XMErrorCode = XME_CALLOC;
    63         return(XM_FAILURE);
    64     }
    65     sel = (XMSelect *)calloc(1, sizeof(XMSelect));
    66     if (sel == NULL) {
    67         _XMErrorCode = XME_CALLOC;
    68         return(XM_FAILURE);
    69     }
    70 
    71     /*
    72      * Determine label size.
    73      */
    74     label_length = strlen(label);
    75     label_width = XTextWidth(menu->p_fnt_info,
    76                              label,
    77                              label_length);
    78 
    79     /*
    80      * Set up the initial selection.
    81      * Values not explicitly set are zeroed by calloc.
    82      */
    83     sel->next = sel;
    84     sel->prev = sel;
    85     sel->type = SL_HEADER;
    86     sel->serial = -1;
    87     sel->parent_p = pane;
    88 
    89     /*
    90      * Fill the XMPane structure.
    91      * X and Y position are set to 0 since a recompute will follow.
    92      */
    93     pane->type = PANE;
    94     pane->active = active;
    95     pane->serial = -1;
    96     pane->label = label;
    97     pane->label_width = label_width;
    98     pane->label_length = label_length;
    99     pane->s_list = sel;
   100 
   101     /*
   102      * Insert the pane at the end of the pane list.
   103      */
   104     emacs_insque(pane, menu->p_list->prev);
   105 
   106     /*
   107      * Update the pane count.
   108      */
   109     menu->p_count++;
   110 
   111     /*
   112      * Schedule a recompute.
   113      */
   114     menu->recompute = 1;
   115 
   116     /*
   117      * Return the pane number just added.
   118      */
   119     _XMErrorCode = XME_NO_ERROR;
   120     return((menu->p_count - 1));
   121 }

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