3 /* Copyright Massachusetts Institute of Technology 1985 */
6 * XMenu: MIT Project Athena, X Window system menu package
8 * XMenuChangeSelection - Change a menu selection.
10 * Author: Tony Della Fera, DEC
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!
38 _XMErrorCode
= XME_ARG_BOUNDS
;
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
);
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.
68 s_ptr
->label_width
= label_width
;
69 s_ptr
->label_length
= label_length
;
72 * Schedule a recompute.
80 if (data_sw
) s_ptr
->data
= data
;
83 * Return successfully.
85 _XMErrorCode
= XME_NO_ERROR
;
89 /* arch-tag: 229732a6-46bf-4a3a-ad90-3d8ed65c0841
90 (do not change this comment) */