1 /* Copyright Massachusetts Institute of Technology 1985 */
6 * XMenu: MIT Project Athena, X Window system menu package
8 * XMenuAddPane - Adds a pane to an XMenu object.
10 * Author: Tony Della Fera, DEC
18 XMenuAddPane(Display
*display
, register XMenu
*menu
, register char const *label
, int active
)
20 /* Menu object to be modified. */
21 /* Selection label. */
22 /* Make selection active? */
24 register XMPane
*pane
; /* Newly created pane. */
25 register XMSelect
*sel
; /* Initial selection for the new pane. */
27 int label_length
; /* Label length in characters. */
28 int label_width
; /* Label width in pixels. */
31 * Check for NULL pointers!
34 _XMErrorCode
= XME_ARG_BOUNDS
;
39 * Calloc the XMPane structure and the initial XMSelect.
41 pane
= (XMPane
*)calloc(1, sizeof(XMPane
));
43 _XMErrorCode
= XME_CALLOC
;
46 sel
= (XMSelect
*)calloc(1, sizeof(XMSelect
));
48 _XMErrorCode
= XME_CALLOC
;
53 * Determine label size.
55 label_length
= strlen(label
);
56 label_width
= XTextWidth(menu
->p_fnt_info
,
61 * Set up the initial selection.
62 * Values not explicitly set are zeroed by calloc.
66 sel
->type
= SL_HEADER
;
71 * Fill the XMPane structure.
72 * X and Y position are set to 0 since a recompute will follow.
75 pane
->active
= active
;
78 pane
->label_width
= label_width
;
79 pane
->label_length
= label_length
;
83 * Insert the pane at the end of the pane list.
85 emacs_insque(pane
, menu
->p_list
->prev
);
88 * Update the pane count.
93 * Schedule a recompute.
98 * Return the pane number just added.
100 _XMErrorCode
= XME_NO_ERROR
;
101 return((menu
->p_count
- 1));