3 /* Copyright Massachusetts Institute of Technology 1985 */
4 /* Copyright (C) 2002, 2003, 2004, 2005,
5 2006 Free Software Foundation, Inc. */
8 * XMenu: MIT Project Athena, X Window system menu package
10 * XMenuInsertPane - Inserts a pane into an XMenu object in
11 * a particular position.
13 * Author: Tony Della Fera, DEC
22 XMenuInsertPane(menu
, p_num
, label
, active
)
23 register XMenu
*menu
; /* Menu object to be modified. */
24 register int p_num
; /* Pane number of new pane. */
25 char *label
; /* Selection label. */
26 int active
; /* Make selection active? */
28 register XMPane
*p_ptr
; /* XMPane pointer. */
29 register XMPane
*pane
; /* Newly created pane. */
30 register XMSelect
*select
; /* Initial selection for the new pane. */
32 int label_length
; /* Label length in characters. */
33 int label_width
; /* Label width in pixels. */
36 * Check for NULL pointers!
39 _XMErrorCode
= XME_ARG_BOUNDS
;
44 * Find the pane number one less than the one specified since that
45 * is the pane after which the insertion will occur.
47 p_ptr
= _XMGetPanePtr(menu
, (p_num
- 1));
48 if (p_ptr
== NULL
) return(XM_FAILURE
);
51 * Calloc the XMPane structure and the initial XMSelect.
53 pane
= (XMPane
*)calloc(1, sizeof(XMPane
));
55 _XMErrorCode
= XME_CALLOC
;
58 select
= (XMSelect
*)calloc(1, sizeof(XMSelect
));
60 _XMErrorCode
= XME_CALLOC
;
65 * Determine label size.
67 label_length
= strlen(label
);
68 label_width
= XTextWidth(menu
->p_fnt_info
, label
, label_length
);
71 * Set up the initial selection.
72 * Values not explicitly set are zeroed by calloc.
74 select
->next
= select
;
75 select
->prev
= select
;
76 select
->type
= SL_HEADER
;
78 select
->parent_p
= pane
;
81 * Fill the XMPane structure.
84 pane
->active
= active
;
87 pane
->label_width
= label_width
;
88 pane
->label_length
= label_length
;
89 pane
->s_list
= select
;
92 * Insert the pane after the pane with the pane
93 * number one less than the desired number for the
96 emacs_insque(pane
, p_ptr
);
99 * Update the pane count.
104 * Schedule a recompute.
109 * Return the number of the pane just added.
111 _XMErrorCode
= XME_NO_ERROR
;
115 /* arch-tag: ab94d53d-f05b-4273-82d3-f1b01eb9dc9e
116 (do not change this comment) */