* print.c (print_object): Fix last change.
[emacs.git] / oldXMenu / InsPane.c
blobd8470f3a5bf311e973edf675b293b2404a2f3201
1 /* Copyright Massachusetts Institute of Technology 1985 */
3 #include "copyright.h"
6 /*
7 * XMenu: MIT Project Athena, X Window system menu package
9 * XMenuInsertPane - Inserts a pane into an XMenu object in
10 * a particular position.
12 * Author: Tony Della Fera, DEC
13 * 20-Nov-85
17 #include "XMenuInt.h"
19 int
20 XMenuInsertPane(register XMenu *menu, register int p_num, char *label, int active)
21 /* Menu object to be modified. */
22 /* Pane number of new pane. */
23 /* Selection label. */
24 /* Make selection active? */
26 register XMPane *p_ptr; /* XMPane pointer. */
27 register XMPane *pane; /* Newly created pane. */
28 register XMSelect *sel; /* 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!
36 if (label == NULL) {
37 _XMErrorCode = XME_ARG_BOUNDS;
38 return(XM_FAILURE);
42 * Find the pane number one less than the one specified since that
43 * is the pane after which the insertion will occur.
45 p_ptr = _XMGetPanePtr(menu, (p_num - 1));
46 if (p_ptr == NULL) return(XM_FAILURE);
49 * Calloc the XMPane structure and the initial XMSelect.
51 pane = (XMPane *)calloc(1, sizeof(XMPane));
52 if (pane == NULL) {
53 _XMErrorCode = XME_CALLOC;
54 return(XM_FAILURE);
56 sel = (XMSelect *)calloc(1, sizeof(XMSelect));
57 if (sel == NULL) {
58 _XMErrorCode = XME_CALLOC;
59 return(XM_FAILURE);
63 * Determine label size.
65 label_length = strlen(label);
66 label_width = XTextWidth(menu->p_fnt_info, label, label_length);
69 * Set up the initial selection.
70 * Values not explicitly set are zeroed by calloc.
72 sel->next = sel;
73 sel->prev = sel;
74 sel->type = SL_HEADER;
75 sel->serial = -1;
76 sel->parent_p = pane;
79 * Fill the XMPane structure.
81 pane->type = PANE;
82 pane->active = active;
83 pane->serial = -1;
84 pane->label = label;
85 pane->label_width = label_width;
86 pane->label_length = label_length;
87 pane->s_list = sel;
90 * Insert the pane after the pane with the pane
91 * number one less than the desired number for the
92 * new pane.
94 emacs_insque(pane, p_ptr);
97 * Update the pane count.
99 menu->p_count++;
102 * Schedule a recompute.
104 menu->recompute = 1;
107 * Return the number of the pane just added.
109 _XMErrorCode = XME_NO_ERROR;
110 return(p_num);