1: #include <X/mit-copyright.h>
   2: 
   3: /* $Header: XMenuAddPane.c,v 10.7 86/02/01 16:14:20 tony Rel $ */
   4: /* Copyright    Massachusetts Institute of Technology    1985	*/
   5: 
   6: /*
   7:  * XMenu:	MIT Project Athena, X Window system menu package
   8:  *
   9:  * 	XMenuAddPane - Adds a pane 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: XMenuAddPane(menu, label, active)
  20:     register XMenu *menu;   /* Menu object to be modified. */
  21:     register char *label;   /* Selection label. */
  22:     int active;         /* Make selection active? */
  23: {
  24:     register XMPane *pane;  /* Newly created pane. */
  25:     register XMSelect *select;  /* Initial selection for the new pane. */
  26: 
  27:     int label_length;       /* Label lenght in characters. */
  28:     int label_width;        /* Label width in pixels. */
  29: 
  30:     /*
  31:      * Check for NULL pointers!
  32:      */
  33:     if (label == NULL) {
  34:     _XMErrorCode = XME_ARG_BOUNDS;
  35:     return(XM_FAILURE);
  36:     }
  37: 
  38:     /*
  39:      * Calloc the XMPane structure and the initial XMSelect.
  40:      */
  41:     pane = (XMPane *)calloc(1, sizeof(XMPane));
  42:     if (pane == NULL) {
  43:     _XMErrorCode = XME_CALLOC;
  44:     return(XM_FAILURE);
  45:     }
  46:     select = (XMSelect *)calloc(1, sizeof(XMSelect));
  47:     if (select == NULL) {
  48:     _XMErrorCode = XME_CALLOC;
  49:     return(XM_FAILURE);
  50:     }
  51: 
  52:     /*
  53:      * Determine label size.
  54:      */
  55:     label_width = XQueryWidth(label, menu->p_fnt_info->id);
  56:     label_length = strlen(label);
  57: 
  58:     /*
  59:      * Set up the initial selection.
  60:      * Values not explicitly set are zeroed by calloc.
  61:      */
  62:     select->next = select;
  63:     select->prev = select;
  64:     select->type = SL_HEADER;
  65:     select->serial = -1;
  66:     select->parent_p = pane;
  67: 
  68:     /*
  69:      * Fill the XMPane structure.
  70:      * X and Y position are set to 0 since a recompute will follow.
  71:      */
  72:     pane->type = PANE;
  73:     pane->active = active;
  74:     pane->serial = -1;
  75:     pane->label = label;
  76:     pane->label_width = label_width;
  77:     pane->label_length = label_length;
  78:     pane->s_list = select;
  79: 
  80:     /*
  81:      * Insert the pane at the end of the pane list.
  82:      */
  83:     insque(pane, menu->p_list->prev);
  84: 
  85:     /*
  86:      * Update the pane count.
  87:      */
  88:     menu->p_count++;
  89: 
  90:     /*
  91:      * Schedule a recompute.
  92:      */
  93:     menu->recompute = 1;
  94: 
  95:     /*
  96:      * Return the pane number just added.
  97:      */
  98:     _XMErrorCode = XME_NO_ERROR;
  99:     return((menu->p_count - 1));
 100: }
Last modified: 1986-02-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 997
Valid CSS Valid XHTML 1.0 Strict