Mercurial > emacs
annotate oldXMenu/AddSel.c @ 56405:10b68aa88abe
Doc fix. Change name of some funs.
author | Vinicius Jose Latorre <viniciusjl@ig.com.br> |
---|---|
date | Tue, 13 Jul 2004 01:32:18 +0000 |
parents | e8824c4f5f7e |
children | 3861ff8f4bf1 8e5779acd195 |
rev | line source |
---|---|
25858 | 1 #include "copyright.h" |
2 | |
3 /* Copyright Massachusetts Institute of Technology 1985 */ | |
4 | |
5 /* | |
6 * XMenu: MIT Project Athena, X Window system menu package | |
7 * | |
8 * XMenuAddSelection - Adds a selection to an XMenu object. | |
9 * | |
10 * Author: Tony Della Fera, DEC | |
11 * August, 1985 | |
12 * | |
13 */ | |
14 | |
15 #include <config.h> | |
16 #include "XMenuInt.h" | |
17 | |
18 int | |
27455
d93b1a9c3c96
(XMenuAddSelection): Add parameter HELP.
Gerd Moellmann <gerd@gnu.org>
parents:
25858
diff
changeset
|
19 XMenuAddSelection(display, menu, p_num, data, label, active, help) |
25858 | 20 Display *display; |
21 register XMenu *menu; /* Menu object to be modified. */ | |
22 register int p_num; /* Pane number to be modified. */ | |
23 char *data; /* Data value. */ | |
24 char *label; /* Selection label. */ | |
25 int active; /* Make selection active? */ | |
27455
d93b1a9c3c96
(XMenuAddSelection): Add parameter HELP.
Gerd Moellmann <gerd@gnu.org>
parents:
25858
diff
changeset
|
26 char *help; /* Help string */ |
25858 | 27 { |
28 register XMPane *pane; /* Pane containing the new selection. */ | |
29 register XMSelect *select; /* Newly created selection. */ | |
30 | |
31 | |
32 int label_length; /* Label lenght in characters. */ | |
33 int label_width; /* Label width in pixels. */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
27455
diff
changeset
|
34 |
25858 | 35 /* |
36 * Check for NULL pointers! | |
37 */ | |
38 if (label == NULL) { | |
39 _XMErrorCode = XME_ARG_BOUNDS; | |
40 return(XM_FAILURE); | |
41 } | |
42 /* | |
43 * Find the right pane. | |
44 */ | |
45 pane = _XMGetPanePtr(menu, p_num); | |
46 if (pane == NULL) return(XM_FAILURE); | |
47 | |
48 /* | |
49 * Calloc the XMSelect structure. | |
50 */ | |
51 select = (XMSelect *)calloc(1, sizeof(XMSelect)); | |
52 if (select == NULL) { | |
53 _XMErrorCode = XME_CALLOC; | |
54 return(XM_FAILURE); | |
55 } | |
56 /* | |
57 * Determine label size. | |
58 */ | |
59 label_length = strlen(label); | |
60 label_width = XTextWidth(menu->s_fnt_info, label, label_length); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
27455
diff
changeset
|
61 |
25858 | 62 /* |
63 * Fill the XMSelect structure. | |
64 */ | |
65 if (!strcmp (label, "--") || !strcmp (label, "---")) | |
66 { | |
67 select->type = SEPARATOR; | |
68 select->active = 0; | |
69 } | |
70 else | |
71 { | |
72 select->type = SELECTION; | |
73 select->active = active; | |
74 } | |
75 | |
76 select->serial = -1; | |
77 select->label = label; | |
78 select->label_width = label_width; | |
79 select->label_length = label_length; | |
80 select->data = data; | |
81 select->parent_p = pane; | |
27455
d93b1a9c3c96
(XMenuAddSelection): Add parameter HELP.
Gerd Moellmann <gerd@gnu.org>
parents:
25858
diff
changeset
|
82 select->help_string = help; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
27455
diff
changeset
|
83 |
25858 | 84 /* |
85 * Insert the selection at the end of the selection list. | |
86 */ | |
87 emacs_insque(select, pane->s_list->prev); | |
88 | |
89 /* | |
90 * Update the selection count. | |
91 */ | |
92 pane->s_count++; | |
93 | |
94 /* | |
95 * Schedule a recompute. | |
96 */ | |
97 menu->recompute = 1; | |
98 | |
99 /* | |
100 * Return the selection number just added. | |
101 */ | |
102 _XMErrorCode = XME_NO_ERROR; | |
103 return((pane->s_count - 1)); | |
104 } | |
52401 | 105 |
106 /* arch-tag: 0161f024-c739-440d-9498-050280c6c355 | |
107 (do not change this comment) */ |