root/oldXMenu/Recomp.c

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

DEFINITIONS

This source file includes following definitions.
  1. XMenuRecompute

     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  *      XMenuRecompute - Recompute XMenu object dependencies.
    28  *
    29  *      Author:         Tony Della Fera, DEC
    30  *                      September, 1985
    31  *
    32  */
    33 
    34 #include "XMenuInt.h"
    35 
    36 int
    37 XMenuRecompute(Display *display, register XMenu *menu)
    38                      
    39                                 /* Menu object to be recomputed. */
    40 {
    41     register XMPane *p_ptr;     /* Pane pointer. */
    42     register XMSelect *s_ptr;   /* Selection pointer. */
    43 
    44     register int p_num;         /* Pane serial number. */
    45     register int s_num;         /* Selection serial number. */
    46 
    47     /*
    48      * If there are no panes in the menu then return failure
    49      * because the menu is not initialized.
    50      */
    51     if (menu->p_count == 0) {
    52         _XMErrorCode = XME_NOT_INIT;
    53         return(XM_FAILURE);
    54     }
    55 
    56     /*
    57      * Recompute menu wide global values: pane window size,
    58      * selection size and maximum selection count.
    59      */
    60     _XMRecomputeGlobals(display, menu);
    61 
    62     /*
    63      * For each pane in the menu...
    64      */
    65 
    66     p_num = 0;
    67     for (
    68         p_ptr = menu->p_list->next;
    69         p_ptr != menu->p_list;
    70         p_ptr = p_ptr->next
    71     ){
    72         /*
    73          * Recompute pane dependencies.
    74          */
    75         if (_XMRecomputePane(display, menu, p_ptr, p_num) == _FAILURE) {
    76             return(XM_FAILURE);
    77         }
    78         p_num++;
    79 
    80         /*
    81          * For each selection in the pane...
    82          */
    83         s_num = 0;
    84         for (
    85             s_ptr = p_ptr->s_list->next;
    86             s_ptr != p_ptr->s_list;
    87             s_ptr = s_ptr->next
    88         ) {
    89             /*
    90              * Recompute selection dependencies.
    91              */
    92             if (_XMRecomputeSelection(display, menu, s_ptr, s_num) == _FAILURE) {
    93                 return(XM_FAILURE);
    94             }
    95             s_num++;
    96         }
    97     }
    98 
    99     /*
   100      * Recompute menu size.
   101      */
   102     if (menu->menu_style == CENTER) {
   103         menu->width = menu->p_width + (menu->p_bdr_width << 1);
   104     }
   105     else {
   106         menu->width = menu->p_width + (menu->p_bdr_width << 1) +
   107             ((menu->p_count - 1) * menu->p_x_off);
   108     }
   109     menu->height = menu->p_height + (menu->p_bdr_width << 1) +
   110         ((menu->p_count - 1) * menu->p_y_off);
   111 
   112     /*
   113      * Reset the recompute flag.
   114      */
   115     menu->recompute = 0;
   116 
   117     /*
   118      * Return successfully.
   119      */
   120     _XMErrorCode = XME_NO_ERROR;
   121     return(XM_SUCCESS);
   122 }
   123 

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