lisp/emacs-lisp/timer.el (timer--time): Define setter with gv-define-setter.
[emacs.git] / oldXMenu / AddPane.c
blob2c8dda8cd11a28ca63075eb5100a7bdb7ce42a9a
1 /* Copyright Massachusetts Institute of Technology 1985 */
3 #include "copyright.h"
5 /*
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
11 * August, 1985
15 #include "XMenuInt.h"
17 int
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!
33 if (label == NULL) {
34 _XMErrorCode = XME_ARG_BOUNDS;
35 return(XM_FAILURE);
39 * Calloc the XMPane structure and the initial XMSelect.
41 pane = (XMPane *)calloc(1, sizeof(XMPane));
42 if (pane == NULL) {
43 _XMErrorCode = XME_CALLOC;
44 return(XM_FAILURE);
46 sel = (XMSelect *)calloc(1, sizeof(XMSelect));
47 if (sel == NULL) {
48 _XMErrorCode = XME_CALLOC;
49 return(XM_FAILURE);
53 * Determine label size.
55 label_length = strlen(label);
56 label_width = XTextWidth(menu->p_fnt_info,
57 label,
58 label_length);
61 * Set up the initial selection.
62 * Values not explicitly set are zeroed by calloc.
64 sel->next = sel;
65 sel->prev = sel;
66 sel->type = SL_HEADER;
67 sel->serial = -1;
68 sel->parent_p = pane;
71 * Fill the XMPane structure.
72 * X and Y position are set to 0 since a recompute will follow.
74 pane->type = PANE;
75 pane->active = active;
76 pane->serial = -1;
77 pane->label = label;
78 pane->label_width = label_width;
79 pane->label_length = label_length;
80 pane->s_list = sel;
83 * Insert the pane at the end of the pane list.
85 emacs_insque(pane, menu->p_list->prev);
88 * Update the pane count.
90 menu->p_count++;
93 * Schedule a recompute.
95 menu->recompute = 1;
98 * Return the pane number just added.
100 _XMErrorCode = XME_NO_ERROR;
101 return((menu->p_count - 1));