3 /* Copyright Massachusetts Institute of Technology 1985 */
4 /* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. */
7 * XMenu: MIT Project Athena, X Window system menu package
9 * XMenuAddPane - Adds a pane to an XMenu object.
11 * Author: Tony Della Fera, DEC
20 XMenuAddPane(display
, menu
, label
, active
)
22 register XMenu
*menu
; /* Menu object to be modified. */
23 register char *label
; /* Selection label. */
24 int active
; /* Make selection active? */
26 register XMPane
*pane
; /* Newly created pane. */
27 register XMSelect
*select
; /* Initial selection for the new pane. */
29 int label_length
; /* Label length in characters. */
30 int label_width
; /* Label width in pixels. */
33 * Check for NULL pointers!
36 _XMErrorCode
= XME_ARG_BOUNDS
;
41 * Calloc the XMPane structure and the initial XMSelect.
43 pane
= (XMPane
*)calloc(1, sizeof(XMPane
));
45 _XMErrorCode
= XME_CALLOC
;
48 select
= (XMSelect
*)calloc(1, sizeof(XMSelect
));
50 _XMErrorCode
= XME_CALLOC
;
55 * Determine label size.
57 label_length
= strlen(label
);
58 label_width
= XTextWidth(menu
->p_fnt_info
,
63 * Set up the initial selection.
64 * Values not explicitly set are zeroed by calloc.
66 select
->next
= select
;
67 select
->prev
= select
;
68 select
->type
= SL_HEADER
;
70 select
->parent_p
= pane
;
73 * Fill the XMPane structure.
74 * X and Y position are set to 0 since a recompute will follow.
77 pane
->active
= active
;
80 pane
->label_width
= label_width
;
81 pane
->label_length
= label_length
;
82 pane
->s_list
= select
;
85 * Insert the pane at the end of the pane list.
87 emacs_insque(pane
, menu
->p_list
->prev
);
90 * Update the pane count.
95 * Schedule a recompute.
100 * Return the pane number just added.
102 _XMErrorCode
= XME_NO_ERROR
;
103 return((menu
->p_count
- 1));
106 /* arch-tag: 62a26021-f29d-48ba-96ef-3b6c4ebd6547
107 (do not change this comment) */