3 /* Copyright Massachusetts Institute of Technology 1985 */
6 * XMenu: MIT Project Athena, X Window system menu package
8 * XMenuAddSelection - Adds a selection to an XMenu object.
10 * Author: Tony Della Fera, DEC
19 XMenuAddSelection(display
, menu
, p_num
, data
, label
, active
, help
)
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? */
26 char *help
; /* Help string */
28 register XMPane
*pane
; /* Pane containing the new selection. */
29 register XMSelect
*select
; /* Newly created selection. */
32 int label_length
; /* Label lenght in characters. */
33 int label_width
; /* Label width in pixels. */
36 * Check for NULL pointers!
39 _XMErrorCode
= XME_ARG_BOUNDS
;
43 * Find the right pane.
45 pane
= _XMGetPanePtr(menu
, p_num
);
46 if (pane
== NULL
) return(XM_FAILURE
);
49 * Calloc the XMSelect structure.
51 select
= (XMSelect
*)calloc(1, sizeof(XMSelect
));
53 _XMErrorCode
= XME_CALLOC
;
57 * Determine label size.
59 label_length
= strlen(label
);
60 label_width
= XTextWidth(menu
->s_fnt_info
, label
, label_length
);
63 * Fill the XMSelect structure.
65 if (!strcmp (label
, "--") || !strcmp (label
, "---"))
67 select
->type
= SEPARATOR
;
72 select
->type
= SELECTION
;
73 select
->active
= active
;
77 select
->label
= label
;
78 select
->label_width
= label_width
;
79 select
->label_length
= label_length
;
81 select
->parent_p
= pane
;
82 select
->help_string
= help
;
85 * Insert the selection at the end of the selection list.
87 emacs_insque(select
, pane
->s_list
->prev
);
90 * Update the selection count.
95 * Schedule a recompute.
100 * Return the selection number just added.
102 _XMErrorCode
= XME_NO_ERROR
;
103 return((pane
->s_count
- 1));
106 /* arch-tag: 0161f024-c739-440d-9498-050280c6c355
107 (do not change this comment) */