3 /* Copyright Massachusetts Institute of Technology 1985 */
4 /* Copyright (C) 2001, 2002, 2003, 2004, 2005,
5 2006 Free Software Foundation, Inc. */
8 * XMenu: MIT Project Athena, X Window system menu package
10 * XMenuAddPane - Adds a pane to an XMenu object.
12 * Author: Tony Della Fera, DEC
21 XMenuAddPane(display
, menu
, label
, active
)
23 register XMenu
*menu
; /* Menu object to be modified. */
24 register char *label
; /* Selection label. */
25 int active
; /* Make selection active? */
27 register XMPane
*pane
; /* Newly created pane. */
28 register XMSelect
*select
; /* Initial selection for the new pane. */
30 int label_length
; /* Label length in characters. */
31 int label_width
; /* Label width in pixels. */
34 * Check for NULL pointers!
37 _XMErrorCode
= XME_ARG_BOUNDS
;
42 * Calloc the XMPane structure and the initial XMSelect.
44 pane
= (XMPane
*)calloc(1, sizeof(XMPane
));
46 _XMErrorCode
= XME_CALLOC
;
49 select
= (XMSelect
*)calloc(1, sizeof(XMSelect
));
51 _XMErrorCode
= XME_CALLOC
;
56 * Determine label size.
58 label_length
= strlen(label
);
59 label_width
= XTextWidth(menu
->p_fnt_info
,
64 * Set up the initial selection.
65 * Values not explicitly set are zeroed by calloc.
67 select
->next
= select
;
68 select
->prev
= select
;
69 select
->type
= SL_HEADER
;
71 select
->parent_p
= pane
;
74 * Fill the XMPane structure.
75 * X and Y position are set to 0 since a recompute will follow.
78 pane
->active
= active
;
81 pane
->label_width
= label_width
;
82 pane
->label_length
= label_length
;
83 pane
->s_list
= select
;
86 * Insert the pane at the end of the pane list.
88 emacs_insque(pane
, menu
->p_list
->prev
);
91 * Update the pane count.
96 * Schedule a recompute.
101 * Return the pane number just added.
103 _XMErrorCode
= XME_NO_ERROR
;
104 return((menu
->p_count
- 1));
107 /* arch-tag: 62a26021-f29d-48ba-96ef-3b6c4ebd6547
108 (do not change this comment) */