aboutsummaryrefslogtreecommitdiffstats
path: root/oldXMenu/AddSel.c
diff options
context:
space:
mode:
authorDave Love1999-10-03 19:36:13 +0000
committerDave Love1999-10-03 19:36:13 +0000
commite745ede7473e87b93d71858bc1c8447a1307de28 (patch)
tree59353dca94fcb3a9ce2fd9f79614a3119da7f863 /oldXMenu/AddSel.c
parent0c898dd963a3277b5ec8d59f0a350e3fb50e50c3 (diff)
downloademacs-e745ede7473e87b93d71858bc1c8447a1307de28.tar.gz
emacs-e745ede7473e87b93d71858bc1c8447a1307de28.zip
#
Diffstat (limited to 'oldXMenu/AddSel.c')
-rw-r--r--oldXMenu/AddSel.c103
1 files changed, 103 insertions, 0 deletions
diff --git a/oldXMenu/AddSel.c b/oldXMenu/AddSel.c
new file mode 100644
index 00000000000..cfb0b3dbcf0
--- /dev/null
+++ b/oldXMenu/AddSel.c
@@ -0,0 +1,103 @@
1#include "copyright.h"
2
3/* $Header: /u/src/emacs/19.0/oldXMenu/RCS/AddSel.c,v 1.1 1992/04/11 22:10:17 jimb Exp $ */
4/* Copyright Massachusetts Institute of Technology 1985 */
5
6/*
7 * XMenu: MIT Project Athena, X Window system menu package
8 *
9 * XMenuAddSelection - Adds a selection to an XMenu object.
10 *
11 * Author: Tony Della Fera, DEC
12 * August, 1985
13 *
14 */
15
16#include <config.h>
17#include "XMenuInt.h"
18
19int
20XMenuAddSelection(display, menu, p_num, data, label, active)
21 Display *display;
22 register XMenu *menu; /* Menu object to be modified. */
23 register int p_num; /* Pane number to be modified. */
24 char *data; /* Data value. */
25 char *label; /* Selection label. */
26 int active; /* Make selection active? */
27{
28 register XMPane *pane; /* Pane containing the new selection. */
29 register XMSelect *select; /* Newly created selection. */
30
31
32 int label_length; /* Label lenght in characters. */
33 int label_width; /* Label width in pixels. */
34
35 /*
36 * Check for NULL pointers!
37 */
38 if (label == NULL) {
39 _XMErrorCode = XME_ARG_BOUNDS;
40 return(XM_FAILURE);
41 }
42 /*
43 * Find the right pane.
44 */
45 pane = _XMGetPanePtr(menu, p_num);
46 if (pane == NULL) return(XM_FAILURE);
47
48 /*
49 * Calloc the XMSelect structure.
50 */
51 select = (XMSelect *)calloc(1, sizeof(XMSelect));
52 if (select == NULL) {
53 _XMErrorCode = XME_CALLOC;
54 return(XM_FAILURE);
55 }
56 /*
57 * Determine label size.
58 */
59 label_length = strlen(label);
60 label_width = XTextWidth(menu->s_fnt_info, label, label_length);
61
62 /*
63 * Fill the XMSelect structure.
64 */
65 if (!strcmp (label, "--") || !strcmp (label, "---"))
66 {
67 select->type = SEPARATOR;
68 select->active = 0;
69 }
70 else
71 {
72 select->type = SELECTION;
73 select->active = active;
74 }
75
76 select->serial = -1;
77 select->label = label;
78 select->label_width = label_width;
79 select->label_length = label_length;
80 select->data = data;
81 select->parent_p = pane;
82
83 /*
84 * Insert the selection at the end of the selection list.
85 */
86 emacs_insque(select, pane->s_list->prev);
87
88 /*
89 * Update the selection count.
90 */
91 pane->s_count++;
92
93 /*
94 * Schedule a recompute.
95 */
96 menu->recompute = 1;
97
98 /*
99 * Return the selection number just added.
100 */
101 _XMErrorCode = XME_NO_ERROR;
102 return((pane->s_count - 1));
103}