1 /* Copyright Massachusetts Institute of Technology 1985 */
7 * XMenu: MIT Project Athena, X Window system menu package
9 * XMenuChangeSelection - Change a menu selection.
11 * Author: Tony Della Fera, DEC
19 XMenuChangeSelection(Display
*display
, register XMenu
*menu
, register int p_num
, register int s_num
, char *data
, int data_sw
, char *label
, int label_sw
)
20 /* previously opened display. */
21 /* Menu object to be modified. */
22 /* Pane number to be modified. */
23 /* Selection number to modified. */
25 /* Change to new data value? */
26 /* Selection label. */
27 /* Change to new label? */
29 register XMPane
*p_ptr
; /* XMPane pointer. */
30 register XMSelect
*s_ptr
; /* XMSelect pointer. */
32 int label_length
; /* Label length in characters. */
33 int label_width
; /* Label width in pixels. */
36 * Check for NULL pointers!
39 _XMErrorCode
= XME_ARG_BOUNDS
;
44 * Find the right pane.
46 p_ptr
= _XMGetPanePtr(menu
, p_num
);
47 if (p_ptr
== NULL
) return(XM_FAILURE
);
50 * Find the right selection.
52 s_ptr
= _XMGetSelectionPtr(p_ptr
, s_num
);
53 if (s_ptr
== NULL
) return(XM_FAILURE
);
60 * Determine label size.
62 label_length
= strlen(label
);
63 label_width
= XTextWidth(menu
->s_fnt_info
, label
, label_length
);
66 * Change the selection data.
69 s_ptr
->label_width
= label_width
;
70 s_ptr
->label_length
= label_length
;
73 * Schedule a recompute.
81 if (data_sw
) s_ptr
->data
= data
;
84 * Return successfully.
86 _XMErrorCode
= XME_NO_ERROR
;