*** empty log message ***
[emacs.git] / oldXMenu / Recomp.c
blobe955323c8254838b322fa6c7ca37885c749a73a6
1 #include "copyright.h"
3 /* Copyright Massachusetts Institute of Technology 1985 */
4 /* Copyright (C) 2002, 2003, 2004, 2005,
5 2006 Free Software Foundation, Inc. */
7 /*
8 * XMenu: MIT Project Athena, X Window system menu package
10 * XMenuRecompute - Recompute XMenu object dependencies.
12 * Author: Tony Della Fera, DEC
13 * September, 1985
17 #include "XMenuInt.h"
19 int
20 XMenuRecompute(display, menu)
21 Display *display;
22 register XMenu *menu; /* Menu object to be recomputed. */
24 register XMPane *p_ptr; /* Pane pointer. */
25 register XMSelect *s_ptr; /* Selection pointer. */
27 register int p_num; /* Pane serial number. */
28 register int s_num; /* Selection serial number. */
31 * If there are no panes in the menu then return failure
32 * because the menu is not initialized.
34 if (menu->p_count == 0) {
35 _XMErrorCode = XME_NOT_INIT;
36 return(XM_FAILURE);
40 * Recompute menu wide global values: pane window size,
41 * selection size and maximum selection count.
43 _XMRecomputeGlobals(display, menu);
46 * For each pane in the menu...
49 p_num = 0;
50 for (
51 p_ptr = menu->p_list->next;
52 p_ptr != menu->p_list;
53 p_ptr = p_ptr->next
56 * Recompute pane dependencies.
58 if (_XMRecomputePane(display, menu, p_ptr, p_num) == _FAILURE) {
59 return(XM_FAILURE);
61 p_num++;
64 * For each selection in the pane...
66 s_num = 0;
67 for (
68 s_ptr = p_ptr->s_list->next;
69 s_ptr != p_ptr->s_list;
70 s_ptr = s_ptr->next
71 ) {
73 * Recompute selection dependencies.
75 if (_XMRecomputeSelection(display, menu, s_ptr, s_num) == _FAILURE) {
76 return(XM_FAILURE);
78 s_num++;
83 * Recompute menu size.
85 if (menu->menu_style == CENTER) {
86 menu->width = menu->p_width + (menu->p_bdr_width << 1);
88 else {
89 menu->width = menu->p_width + (menu->p_bdr_width << 1) +
90 ((menu->p_count - 1) * menu->p_x_off);
92 menu->height = menu->p_height + (menu->p_bdr_width << 1) +
93 ((menu->p_count - 1) * menu->p_y_off);
96 * Reset the recompute flag.
98 menu->recompute = 0;
101 * Return successfully.
103 _XMErrorCode = XME_NO_ERROR;
104 return(XM_SUCCESS);
107 /* arch-tag: 1fe99b82-3873-4aab-b2b3-f277c93e00d9
108 (do not change this comment) */