This source file includes following definitions.
- XMenuAddSelection
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 #include "XMenuInt.h"
35 #include <string.h>
36
37 int
38 XMenuAddSelection(Display *display, register XMenu *menu, register int p_num, char *data, char *label, int active, char const *help)
39
40
41
42
43
44
45
46 {
47 register XMPane *pane;
48 register XMSelect *sel;
49
50
51 int label_length;
52 int label_width;
53
54
55
56
57 if (label == NULL) {
58 _XMErrorCode = XME_ARG_BOUNDS;
59 return(XM_FAILURE);
60 }
61
62
63
64 pane = _XMGetPanePtr(menu, p_num);
65 if (pane == NULL) return(XM_FAILURE);
66
67
68
69
70 sel = (XMSelect *)calloc(1, sizeof(XMSelect));
71 if (sel == NULL) {
72 _XMErrorCode = XME_CALLOC;
73 return(XM_FAILURE);
74 }
75
76
77
78 label_length = strlen(label);
79 label_width = XTextWidth(menu->s_fnt_info, label, label_length);
80
81
82
83
84 if (!strcmp (label, "--") || !strcmp (label, "---"))
85 {
86 sel->type = SEPARATOR;
87 sel->active = 0;
88 }
89 else
90 {
91 sel->type = SELECTION;
92 sel->active = active;
93 }
94
95 sel->serial = -1;
96 sel->label = label;
97 sel->label_width = label_width;
98 sel->label_length = label_length;
99 sel->data = data;
100 sel->parent_p = pane;
101 sel->help_string = help;
102
103
104
105
106 emacs_insque(sel, pane->s_list->prev);
107
108
109
110
111 pane->s_count++;
112
113
114
115
116 menu->recompute = 1;
117
118
119
120
121 _XMErrorCode = XME_NO_ERROR;
122 return((pane->s_count - 1));
123 }