]> code.delx.au - gnu-emacs/blob - oldXMenu/Recomp.c
Merge from emacs--devo--0
[gnu-emacs] / oldXMenu / Recomp.c
1 #include "copyright.h"
2
3 /* Copyright Massachusetts Institute of Technology 1985 */
4 /* Copyright (C) 2001, 2002, 2003, 2004, 2005,
5 2006 Free Software Foundation, Inc. */
6
7 /*
8 * XMenu: MIT Project Athena, X Window system menu package
9 *
10 * XMenuRecompute - Recompute XMenu object dependencies.
11 *
12 * Author: Tony Della Fera, DEC
13 * September, 1985
14 *
15 */
16
17 #include "XMenuInt.h"
18
19 int
20 XMenuRecompute(display, menu)
21 Display *display;
22 register XMenu *menu; /* Menu object to be recomputed. */
23 {
24 register XMPane *p_ptr; /* Pane pointer. */
25 register XMSelect *s_ptr; /* Selection pointer. */
26
27 register int p_num; /* Pane serial number. */
28 register int s_num; /* Selection serial number. */
29
30 /*
31 * If there are no panes in the menu then return failure
32 * because the menu is not initialized.
33 */
34 if (menu->p_count == 0) {
35 _XMErrorCode = XME_NOT_INIT;
36 return(XM_FAILURE);
37 }
38
39 /*
40 * Recompute menu wide global values: pane window size,
41 * selection size and maximum selection count.
42 */
43 _XMRecomputeGlobals(display, menu);
44
45 /*
46 * For each pane in the menu...
47 */
48
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
54 ){
55 /*
56 * Recompute pane dependencies.
57 */
58 if (_XMRecomputePane(display, menu, p_ptr, p_num) == _FAILURE) {
59 return(XM_FAILURE);
60 }
61 p_num++;
62
63 /*
64 * For each selection in the pane...
65 */
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 ) {
72 /*
73 * Recompute selection dependencies.
74 */
75 if (_XMRecomputeSelection(display, menu, s_ptr, s_num) == _FAILURE) {
76 return(XM_FAILURE);
77 }
78 s_num++;
79 }
80 }
81
82 /*
83 * Recompute menu size.
84 */
85 if (menu->menu_style == CENTER) {
86 menu->width = menu->p_width + (menu->p_bdr_width << 1);
87 }
88 else {
89 menu->width = menu->p_width + (menu->p_bdr_width << 1) +
90 ((menu->p_count - 1) * menu->p_x_off);
91 }
92 menu->height = menu->p_height + (menu->p_bdr_width << 1) +
93 ((menu->p_count - 1) * menu->p_y_off);
94
95 /*
96 * Reset the recompute flag.
97 */
98 menu->recompute = 0;
99
100 /*
101 * Return successfully.
102 */
103 _XMErrorCode = XME_NO_ERROR;
104 return(XM_SUCCESS);
105 }
106
107 /* arch-tag: 1fe99b82-3873-4aab-b2b3-f277c93e00d9
108 (do not change this comment) */