Fix spurious open-paren-in-column-0 in a comment.
[emacs.git] / oldXMenu / AddPane.c
blob35d85a863b7f47e23577c4d0a9accc6f4b605266
1 #include "copyright.h"
3 /* Copyright Massachusetts Institute of Technology 1985 */
4 /* Copyright (C) 2001, 2002, 2003, 2004, 2005,
5 2006 Free Software Foundation, Inc. */
7 /*
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
13 * August, 1985
17 #include <config.h>
18 #include "XMenuInt.h"
20 int
21 XMenuAddPane(display, menu, label, active)
22 Display *display;
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!
36 if (label == NULL) {
37 _XMErrorCode = XME_ARG_BOUNDS;
38 return(XM_FAILURE);
42 * Calloc the XMPane structure and the initial XMSelect.
44 pane = (XMPane *)calloc(1, sizeof(XMPane));
45 if (pane == NULL) {
46 _XMErrorCode = XME_CALLOC;
47 return(XM_FAILURE);
49 select = (XMSelect *)calloc(1, sizeof(XMSelect));
50 if (select == NULL) {
51 _XMErrorCode = XME_CALLOC;
52 return(XM_FAILURE);
56 * Determine label size.
58 label_length = strlen(label);
59 label_width = XTextWidth(menu->p_fnt_info,
60 label,
61 label_length);
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;
70 select->serial = -1;
71 select->parent_p = pane;
74 * Fill the XMPane structure.
75 * X and Y position are set to 0 since a recompute will follow.
77 pane->type = PANE;
78 pane->active = active;
79 pane->serial = -1;
80 pane->label = label;
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.
93 menu->p_count++;
96 * Schedule a recompute.
98 menu->recompute = 1;
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) */