annotate oldXMenu/Recomp.c @ 71018:97fa1dbc1aee

*** empty log message ***
author Kim F. Storm <storm@cua.dk>
date Sat, 27 May 2006 22:36:40 +0000
parents e8a3fb527b77
children ce127a46b1ca d04d8ccb3c41 c5406394f567
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
1 #include "copyright.h"
Dave Love <fx@gnu.org>
parents:
diff changeset
2
Dave Love <fx@gnu.org>
parents:
diff changeset
3 /* Copyright Massachusetts Institute of Technology 1985 */
68640
e8a3fb527b77 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 65000
diff changeset
4 /* Copyright (C) 2002, 2003, 2004, 2005,
e8a3fb527b77 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 65000
diff changeset
5 2006 Free Software Foundation, Inc. */
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
6
Dave Love <fx@gnu.org>
parents:
diff changeset
7 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
8 * XMenu: MIT Project Athena, X Window system menu package
Dave Love <fx@gnu.org>
parents:
diff changeset
9 *
Dave Love <fx@gnu.org>
parents:
diff changeset
10 * XMenuRecompute - Recompute XMenu object dependencies.
Dave Love <fx@gnu.org>
parents:
diff changeset
11 *
Dave Love <fx@gnu.org>
parents:
diff changeset
12 * Author: Tony Della Fera, DEC
Dave Love <fx@gnu.org>
parents:
diff changeset
13 * September, 1985
Dave Love <fx@gnu.org>
parents:
diff changeset
14 *
Dave Love <fx@gnu.org>
parents:
diff changeset
15 */
Dave Love <fx@gnu.org>
parents:
diff changeset
16
Dave Love <fx@gnu.org>
parents:
diff changeset
17 #include "XMenuInt.h"
Dave Love <fx@gnu.org>
parents:
diff changeset
18
Dave Love <fx@gnu.org>
parents:
diff changeset
19 int
Dave Love <fx@gnu.org>
parents:
diff changeset
20 XMenuRecompute(display, menu)
Dave Love <fx@gnu.org>
parents:
diff changeset
21 Display *display;
Dave Love <fx@gnu.org>
parents:
diff changeset
22 register XMenu *menu; /* Menu object to be recomputed. */
Dave Love <fx@gnu.org>
parents:
diff changeset
23 {
Dave Love <fx@gnu.org>
parents:
diff changeset
24 register XMPane *p_ptr; /* Pane pointer. */
Dave Love <fx@gnu.org>
parents:
diff changeset
25 register XMSelect *s_ptr; /* Selection pointer. */
Dave Love <fx@gnu.org>
parents:
diff changeset
26
Dave Love <fx@gnu.org>
parents:
diff changeset
27 register int p_num; /* Pane serial number. */
Dave Love <fx@gnu.org>
parents:
diff changeset
28 register int s_num; /* Selection serial number. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
29
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
30 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
31 * If there are no panes in the menu then return failure
Dave Love <fx@gnu.org>
parents:
diff changeset
32 * because the menu is not initialized.
Dave Love <fx@gnu.org>
parents:
diff changeset
33 */
Dave Love <fx@gnu.org>
parents:
diff changeset
34 if (menu->p_count == 0) {
Dave Love <fx@gnu.org>
parents:
diff changeset
35 _XMErrorCode = XME_NOT_INIT;
Dave Love <fx@gnu.org>
parents:
diff changeset
36 return(XM_FAILURE);
Dave Love <fx@gnu.org>
parents:
diff changeset
37 }
Dave Love <fx@gnu.org>
parents:
diff changeset
38
Dave Love <fx@gnu.org>
parents:
diff changeset
39 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
40 * Recompute menu wide global values: pane window size,
Dave Love <fx@gnu.org>
parents:
diff changeset
41 * selection size and maximum selection count.
Dave Love <fx@gnu.org>
parents:
diff changeset
42 */
Dave Love <fx@gnu.org>
parents:
diff changeset
43 _XMRecomputeGlobals(display, menu);
Dave Love <fx@gnu.org>
parents:
diff changeset
44
Dave Love <fx@gnu.org>
parents:
diff changeset
45 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
46 * For each pane in the menu...
Dave Love <fx@gnu.org>
parents:
diff changeset
47 */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
48
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
49 p_num = 0;
Dave Love <fx@gnu.org>
parents:
diff changeset
50 for (
Dave Love <fx@gnu.org>
parents:
diff changeset
51 p_ptr = menu->p_list->next;
Dave Love <fx@gnu.org>
parents:
diff changeset
52 p_ptr != menu->p_list;
Dave Love <fx@gnu.org>
parents:
diff changeset
53 p_ptr = p_ptr->next
Dave Love <fx@gnu.org>
parents:
diff changeset
54 ){
Dave Love <fx@gnu.org>
parents:
diff changeset
55 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
56 * Recompute pane dependencies.
Dave Love <fx@gnu.org>
parents:
diff changeset
57 */
Dave Love <fx@gnu.org>
parents:
diff changeset
58 if (_XMRecomputePane(display, menu, p_ptr, p_num) == _FAILURE) {
Dave Love <fx@gnu.org>
parents:
diff changeset
59 return(XM_FAILURE);
Dave Love <fx@gnu.org>
parents:
diff changeset
60 }
Dave Love <fx@gnu.org>
parents:
diff changeset
61 p_num++;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
62
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
63 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
64 * For each selection in the pane...
Dave Love <fx@gnu.org>
parents:
diff changeset
65 */
Dave Love <fx@gnu.org>
parents:
diff changeset
66 s_num = 0;
Dave Love <fx@gnu.org>
parents:
diff changeset
67 for (
Dave Love <fx@gnu.org>
parents:
diff changeset
68 s_ptr = p_ptr->s_list->next;
Dave Love <fx@gnu.org>
parents:
diff changeset
69 s_ptr != p_ptr->s_list;
Dave Love <fx@gnu.org>
parents:
diff changeset
70 s_ptr = s_ptr->next
Dave Love <fx@gnu.org>
parents:
diff changeset
71 ) {
Dave Love <fx@gnu.org>
parents:
diff changeset
72 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
73 * Recompute selection dependencies.
Dave Love <fx@gnu.org>
parents:
diff changeset
74 */
Dave Love <fx@gnu.org>
parents:
diff changeset
75 if (_XMRecomputeSelection(display, menu, s_ptr, s_num) == _FAILURE) {
Dave Love <fx@gnu.org>
parents:
diff changeset
76 return(XM_FAILURE);
Dave Love <fx@gnu.org>
parents:
diff changeset
77 }
Dave Love <fx@gnu.org>
parents:
diff changeset
78 s_num++;
Dave Love <fx@gnu.org>
parents:
diff changeset
79 }
Dave Love <fx@gnu.org>
parents:
diff changeset
80 }
Dave Love <fx@gnu.org>
parents:
diff changeset
81
Dave Love <fx@gnu.org>
parents:
diff changeset
82 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
83 * Recompute menu size.
Dave Love <fx@gnu.org>
parents:
diff changeset
84 */
Dave Love <fx@gnu.org>
parents:
diff changeset
85 if (menu->menu_style == CENTER) {
Dave Love <fx@gnu.org>
parents:
diff changeset
86 menu->width = menu->p_width + (menu->p_bdr_width << 1);
Dave Love <fx@gnu.org>
parents:
diff changeset
87 }
Dave Love <fx@gnu.org>
parents:
diff changeset
88 else {
Dave Love <fx@gnu.org>
parents:
diff changeset
89 menu->width = menu->p_width + (menu->p_bdr_width << 1) +
Dave Love <fx@gnu.org>
parents:
diff changeset
90 ((menu->p_count - 1) * menu->p_x_off);
Dave Love <fx@gnu.org>
parents:
diff changeset
91 }
Dave Love <fx@gnu.org>
parents:
diff changeset
92 menu->height = menu->p_height + (menu->p_bdr_width << 1) +
Dave Love <fx@gnu.org>
parents:
diff changeset
93 ((menu->p_count - 1) * menu->p_y_off);
Dave Love <fx@gnu.org>
parents:
diff changeset
94
Dave Love <fx@gnu.org>
parents:
diff changeset
95 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
96 * Reset the recompute flag.
Dave Love <fx@gnu.org>
parents:
diff changeset
97 */
Dave Love <fx@gnu.org>
parents:
diff changeset
98 menu->recompute = 0;
Dave Love <fx@gnu.org>
parents:
diff changeset
99
Dave Love <fx@gnu.org>
parents:
diff changeset
100 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
101 * Return successfully.
Dave Love <fx@gnu.org>
parents:
diff changeset
102 */
Dave Love <fx@gnu.org>
parents:
diff changeset
103 _XMErrorCode = XME_NO_ERROR;
Dave Love <fx@gnu.org>
parents:
diff changeset
104 return(XM_SUCCESS);
Dave Love <fx@gnu.org>
parents:
diff changeset
105 }
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
106
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
107 /* arch-tag: 1fe99b82-3873-4aab-b2b3-f277c93e00d9
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
108 (do not change this comment) */