1: #include <X/mit-copyright.h>
   2: 
   3: /* $Header: XMenuRecomp.c,v 10.7 86/02/01 16:15:31 tony Rel $ */
   4: /* Copyright    Massachusetts Institute of Technology    1985	*/
   5: 
   6: /*
   7:  * XMenu:	MIT Project Athena, X Window system menu package
   8:  *
   9:  * 	XMenuRecompute - Recompute XMenu object dependencies.
  10:  *
  11:  *	Author:		Tony Della Fera, DEC
  12:  *			September, 1985
  13:  *
  14:  */
  15: 
  16: #include "XMenuInternal.h"
  17: 
  18: int
  19: XMenuRecompute(menu)
  20:     register XMenu *menu;   /* Menu object to be recomputed. */
  21: {
  22:     register XMPane *p_ptr; /* Pane pointer. */
  23:     register XMSelect *s_ptr;   /* Selection pointer. */
  24: 
  25:     register int p_num;     /* Pane serial number. */
  26:     register int s_num;     /* Selection serial number. */
  27: 
  28:     /*
  29:      * If no recompute is necessary, return.
  30:      */
  31:     if (!menu->recompute) {
  32:     _XMErrorCode = XME_NO_ERROR;
  33:     return(XM_SUCCESS);
  34:     }
  35: 
  36:     /*
  37:      * If there are no panes in the menu then return failure
  38:      * beacuse the menu is not initialized.
  39:      */
  40:     if (menu->p_count == 0) {
  41:     _XMErrorCode = XME_NOT_INIT;
  42:     return(XM_FAILURE);
  43:     }
  44: 
  45:     /*
  46:      * Recompute menu wide global values: pane window size,
  47:      * selection size and maximum selection count.
  48:      */
  49:     _XMRecomputeGlobals(menu);
  50: 
  51:     /*
  52:      * For each pane in the menu...
  53:      */
  54:     p_num = 0;
  55:     for (
  56:     p_ptr = menu->p_list->next;
  57:     p_ptr != menu->p_list;
  58:     p_ptr = p_ptr->next
  59:     ){
  60:     /*
  61: 	 * Recompute pane dependencies.
  62: 	 */
  63:     if (_XMRecomputePane(menu, p_ptr, p_num) == _FAILURE) {
  64:         return(XM_FAILURE);
  65:     }
  66:         p_num++;
  67:     /*
  68: 	 * For each selection in the pane...
  69: 	 */
  70:     s_num = 0;
  71:     for (
  72:         s_ptr = p_ptr->s_list->next;
  73:         s_ptr != p_ptr->s_list;
  74:         s_ptr = s_ptr->next
  75:     ) {
  76:         /*
  77: 	     * Recompute selection dependencies.
  78: 	     */
  79:         if (_XMRecomputeSelection(menu, s_ptr, s_num) == _FAILURE) {
  80:         return(XM_FAILURE);
  81:         }
  82:         s_num++;
  83:     }
  84:     }
  85: 
  86:     /*
  87:      * Flush the window creation queue.
  88:      * This batches all window creates since lazy evaluation
  89:      * is more efficient than individual evaluation.
  90:      * This routine also does an XFlush().
  91:      */
  92:     if (_XMWinQueFlush(menu) == _FAILURE) return(XM_FAILURE);
  93: 
  94:     /*
  95:      * Make sure all selection windows are mapped.
  96:      */
  97:     for (
  98:     p_ptr = menu->p_list->next;
  99:     p_ptr != menu->p_list;
 100:     p_ptr = p_ptr->next
 101:     ){
 102:     XMapSubwindows(p_ptr->window);
 103:     }
 104: 
 105:     /*
 106:      * Recompute menu size.
 107:      */
 108:     if (menu->menu_style == CENTER) {
 109:     menu->width = menu->p_width + (menu->p_bdr_width << 1);
 110:     }
 111:     else {
 112:     menu->width = menu->p_width + (menu->p_bdr_width << 1) +
 113:         ((menu->p_count - 1) * menu->p_x_off);
 114:     }
 115:     menu->height = menu->p_height + (menu->p_bdr_width << 1) +
 116:     ((menu->p_count - 1) * menu->p_y_off);
 117: 
 118:     /*
 119:      * Reset the recompute flag.
 120:      */
 121:     menu->recompute = 0;
 122: 
 123:     /*
 124:      * Return successfully.
 125:      */
 126:     _XMErrorCode = XME_NO_ERROR;
 127:     return(XM_SUCCESS);
 128: }
Last modified: 1986-02-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 982
Valid CSS Valid XHTML 1.0 Strict