1: #include <X/mit-copyright.h>
2:
3: /* $Header: XMenuAddSel.c,v 10.8 86/02/01 16:14:26 tony Rel $ */
4: /* Copyright Massachusetts Institute of Technology 1985 */
5:
6: /*
7: * XMenu: MIT Project Athena, X Window system menu package
8: *
9: * XMenuAddSelection - Adds a selection to an XMenu object.
10: *
11: * Author: Tony Della Fera, DEC
12: * August, 1985
13: *
14: */
15:
16: #include "XMenuInternal.h"
17:
18:
19: XMenuAddSelection(menu, p_num, data, label, active)
20: register XMenu *menu; /* Menu object to be modified. */
21: register int p_num; /* Pane number to be modified. */
22: char *data; /* Data value. */
23: char *label; /* Selection label. */
24: int active; /* Make selection active? */
25: {
26: register XMPane *pane; /* Pane containing the new selection. */
27: register XMSelect *select; /* Newly created selection. */
28:
29: register int i; /* Loop index. */
30:
31: int label_length; /* Label lenght in characters. */
32: int label_width; /* Label width in pixels. */
33:
34: /*
35: * Check for NULL pointers!
36: */
37: if (label == NULL) {
38: _XMErrorCode = XME_ARG_BOUNDS;
39: return(XM_FAILURE);
40: }
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: /*
58: * Determine label size.
59: */
60: label_length = strlen(label);
61: label_width = XQueryWidth(label, menu->s_fnt_info->id);
62:
63: /*
64: * Fill the XMSelect structure.
65: */
66: select->type = SELECTION;
67: select->active = active;
68: select->serial = -1;
69: select->label = label;
70: select->label_width = label_width;
71: select->label_length = label_length;
72: select->data = data;
73: select->parent_p = pane;
74:
75: /*
76: * Insert the selection at the end of the selection list.
77: */
78: insque(select, pane->s_list->prev);
79:
80: /*
81: * Update the selection count.
82: */
83: pane->s_count++;
84:
85: /*
86: * Schedule a recompute.
87: */
88: menu->recompute = 1;
89:
90: /*
91: * Return the selection number just added.
92: */
93: _XMErrorCode = XME_NO_ERROR;
94: return((pane->s_count - 1));
95: }
Defined functions
defined in line
18; used 86 times
- in /usr/src/new/X/XMenu/XMenu.h line
227
- in /usr/src/new/X/XMenu/tests/acttest.c line
56-62(4),
68-72(3),
78-86(5),
92,
98-100(2)
- in /usr/src/new/X/XMenu/tests/deltest.c line
55-61(4),
67-71(3),
77-85(5),
91,
97-99(2)
- in /usr/src/new/X/XMenu/tests/instest.c line
55-61(4),
67-71(3),
77-85(5),
91,
97-99(2),
167,
175
- in /usr/src/new/X/XMenu/tests/posttest.c line
55-61(4),
67-71(3),
77-85(5),
91,
97-99(2)
- in /usr/src/new/X/XMenu/tests/rstest.c line
79-107(15)
- in /usr/src/new/X/xterm/button.c line
366-386(8)