Mercurial > emacs
annotate oldXMenu/InsPane.c @ 59221:4de707f3cc8e
(auto-revert-tail-handler): Put in undo boundaries.
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Thu, 30 Dec 2004 23:27:23 +0000 |
parents | e8824c4f5f7e |
children | 3861ff8f4bf1 8e5779acd195 |
rev | line source |
---|---|
25858 | 1 #include "copyright.h" |
2 | |
3 /* Copyright Massachusetts Institute of Technology 1985 */ | |
4 | |
5 /* | |
6 * XMenu: MIT Project Athena, X Window system menu package | |
7 * | |
8 * XMenuInsertPane - Inserts a pane into an XMenu object in | |
9 * a particular position. | |
10 * | |
11 * Author: Tony Della Fera, DEC | |
12 * 20-Nov-85 | |
13 * | |
14 */ | |
15 | |
16 #include <config.h> | |
17 #include "XMenuInt.h" | |
18 | |
19 int | |
20 XMenuInsertPane(menu, p_num, label, active) | |
21 register XMenu *menu; /* Menu object to be modified. */ | |
22 register int p_num; /* Pane number of new pane. */ | |
23 char *label; /* Selection label. */ | |
24 int active; /* Make selection active? */ | |
25 { | |
26 register XMPane *p_ptr; /* XMPane pointer. */ | |
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 * Find the pane number one less than the one specified since that | |
43 * is the pane after which the insertion will occur. | |
44 */ | |
45 p_ptr = _XMGetPanePtr(menu, (p_num - 1)); | |
46 if (p_ptr == NULL) return(XM_FAILURE); | |
47 | |
48 /* | |
49 * Calloc the XMPane structure and the initial XMSelect. | |
50 */ | |
51 pane = (XMPane *)calloc(1, sizeof(XMPane)); | |
52 if (pane == NULL) { | |
53 _XMErrorCode = XME_CALLOC; | |
54 return(XM_FAILURE); | |
55 } | |
56 select = (XMSelect *)calloc(1, sizeof(XMSelect)); | |
57 if (select == NULL) { | |
58 _XMErrorCode = XME_CALLOC; | |
59 return(XM_FAILURE); | |
60 } | |
61 | |
62 /* | |
63 * Determine label size. | |
64 */ | |
65 label_length = strlen(label); | |
66 label_width = XTextWidth(menu->p_fnt_info, label, label_length); | |
67 | |
68 /* | |
69 * Set up the initial selection. | |
70 * Values not explicitly set are zeroed by calloc. | |
71 */ | |
72 select->next = select; | |
73 select->prev = select; | |
74 select->type = SL_HEADER; | |
75 select->serial = -1; | |
76 select->parent_p = pane; | |
77 | |
78 /* | |
79 * Fill the XMPane structure. | |
80 */ | |
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 = select; | |
88 | |
89 /* | |
90 * Insert the pane after the pane with the pane | |
91 * number one less than the desired number for the | |
92 * new pane. | |
93 */ | |
94 emacs_insque(pane, p_ptr); | |
95 | |
96 /* | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
25858
diff
changeset
|
97 * Update the pane count. |
25858 | 98 */ |
99 menu->p_count++; | |
100 | |
101 /* | |
102 * Schedule a recompute. | |
103 */ | |
104 menu->recompute = 1; | |
105 | |
106 /* | |
107 * Return the number of the pane just added. | |
108 */ | |
109 _XMErrorCode = XME_NO_ERROR; | |
110 return(p_num); | |
111 } | |
52401 | 112 |
113 /* arch-tag: ab94d53d-f05b-4273-82d3-f1b01eb9dc9e | |
114 (do not change this comment) */ |