Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-603
[emacs.git] / oldXMenu / ChgSel.c
blob7dce694c41093d99d7dd736d7b0010d9b053fdb2
1 #include "copyright.h"
3 /* Copyright Massachusetts Institute of Technology 1985 */
5 /*
6 * XMenu: MIT Project Athena, X Window system menu package
8 * XMenuChangeSelection - Change a menu selection.
10 * Author: Tony Della Fera, DEC
11 * December 19, 1985
15 #include "XMenuInt.h"
17 int
18 XMenuChangeSelection(display, menu, p_num, s_num, data, data_sw, label, label_sw)
19 Display *display; /* previously opened display. */
20 register XMenu *menu; /* Menu object to be modified. */
21 register int p_num; /* Pane number to be modified. */
22 register int s_num; /* Selection number to modified. */
23 char *data; /* Data value. */
24 int data_sw; /* Change to new data value? */
25 char *label; /* Selection label. */
26 int label_sw; /* Change to new label? */
28 register XMPane *p_ptr; /* XMPane pointer. */
29 register XMSelect *s_ptr; /* XMSelect pointer. */
31 int label_length; /* Label length in characters. */
32 int label_width; /* Label width in pixels. */
35 * Check for NULL pointers!
37 if (label == NULL) {
38 _XMErrorCode = XME_ARG_BOUNDS;
39 return(XM_FAILURE);
43 * Find the right pane.
45 p_ptr = _XMGetPanePtr(menu, p_num);
46 if (p_ptr == NULL) return(XM_FAILURE);
49 * Find the right selection.
51 s_ptr = _XMGetSelectionPtr(p_ptr, s_num);
52 if (s_ptr == NULL) return(XM_FAILURE);
55 * Reset the label?
57 if (label_sw) {
59 * Determine label size.
61 label_length = strlen(label);
62 label_width = XTextWidth(menu->s_fnt_info, label, label_length);
65 * Change the selection data.
67 s_ptr->label = label;
68 s_ptr->label_width = label_width;
69 s_ptr->label_length = label_length;
72 * Schedule a recompute.
74 menu->recompute = 1;
78 * Reset the data?
80 if (data_sw) s_ptr->data = data;
83 * Return successfully.
85 _XMErrorCode = XME_NO_ERROR;
86 return(s_num);
89 /* arch-tag: 229732a6-46bf-4a3a-ad90-3d8ed65c0841
90 (do not change this comment) */