Mercurial > emacs
annotate oldXMenu/AddPane.c @ 75846:072d8d19c69e
etc/images/mh-logo copyright resolved.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Tue, 13 Feb 2007 17:07:55 +0000 |
parents | 3d45362f1d38 |
children | fec5e03aaf59 b8d9a391daf3 95d0cdf160ea |
rev | line source |
---|---|
25858 | 1 #include "copyright.h" |
2 | |
3 /* Copyright Massachusetts Institute of Technology 1985 */ | |
74548 | 4 /* Copyright (C) 2001, 2002, 2003, 2004, 2005, |
75348 | 5 2006, 2007 Free Software Foundation, Inc. */ |
25858 | 6 |
7 /* | |
8 * XMenu: MIT Project Athena, X Window system menu package | |
9 * | |
10 * XMenuAddPane - Adds a pane to an XMenu object. | |
11 * | |
12 * Author: Tony Della Fera, DEC | |
13 * August, 1985 | |
14 * | |
15 */ | |
16 | |
17 #include <config.h> | |
18 #include "XMenuInt.h" | |
19 | |
20 int | |
21 XMenuAddPane(display, menu, label, active) | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
25858
diff
changeset
|
22 Display *display; |
25858 | 23 register XMenu *menu; /* Menu object to be modified. */ |
24 register char *label; /* Selection label. */ | |
25 int active; /* Make selection active? */ | |
26 { | |
27 register XMPane *pane; /* Newly created pane. */ | |
28 register XMSelect *select; /* Initial selection for the new pane. */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
25858
diff
changeset
|
29 |
25858 | 30 int label_length; /* Label length in characters. */ |
31 int label_width; /* Label width in pixels. */ | |
32 | |
33 /* | |
34 * Check for NULL pointers! | |
35 */ | |
36 if (label == NULL) { | |
37 _XMErrorCode = XME_ARG_BOUNDS; | |
38 return(XM_FAILURE); | |
39 } | |
40 | |
41 /* | |
42 * Calloc the XMPane structure and the initial XMSelect. | |
43 */ | |
44 pane = (XMPane *)calloc(1, sizeof(XMPane)); | |
45 if (pane == NULL) { | |
46 _XMErrorCode = XME_CALLOC; | |
47 return(XM_FAILURE); | |
48 } | |
49 select = (XMSelect *)calloc(1, sizeof(XMSelect)); | |
50 if (select == NULL) { | |
51 _XMErrorCode = XME_CALLOC; | |
52 return(XM_FAILURE); | |
53 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
25858
diff
changeset
|
54 |
25858 | 55 /* |
56 * Determine label size. | |
57 */ | |
58 label_length = strlen(label); | |
59 label_width = XTextWidth(menu->p_fnt_info, | |
60 label, | |
61 label_length); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
25858
diff
changeset
|
62 |
25858 | 63 /* |
64 * Set up the initial selection. | |
65 * Values not explicitly set are zeroed by calloc. | |
66 */ | |
67 select->next = select; | |
68 select->prev = select; | |
69 select->type = SL_HEADER; | |
70 select->serial = -1; | |
71 select->parent_p = pane; | |
72 | |
73 /* | |
74 * Fill the XMPane structure. | |
75 * X and Y position are set to 0 since a recompute will follow. | |
76 */ | |
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; | |
84 | |
85 /* | |
86 * Insert the pane at the end of the pane list. | |
87 */ | |
88 emacs_insque(pane, menu->p_list->prev); | |
89 | |
90 /* | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
25858
diff
changeset
|
91 * Update the pane count. |
25858 | 92 */ |
93 menu->p_count++; | |
94 | |
95 /* | |
96 * Schedule a recompute. | |
97 */ | |
98 menu->recompute = 1; | |
99 | |
100 /* | |
101 * Return the pane number just added. | |
102 */ | |
103 _XMErrorCode = XME_NO_ERROR; | |
104 return((menu->p_count - 1)); | |
105 } | |
52401 | 106 |
107 /* arch-tag: 62a26021-f29d-48ba-96ef-3b6c4ebd6547 | |
108 (do not change this comment) */ |