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
20 XMenuChangeSelection(display
, menu
, p_num
, s_num
, data
, data_sw
, label
, label_sw
)
21 Display
*display
; /* previously opened display. */
22 register XMenu
*menu
; /* Menu object to be modified. */
23 register int p_num
; /* Pane number to be modified. */
24 register int s_num
; /* Selection number to modified. */
25 char *data
; /* Data value. */
26 int data_sw
; /* Change to new data value? */
27 char *label
; /* Selection label. */
28 int label_sw
; /* Change to new label? */
30 register XMPane
*p_ptr
; /* XMPane pointer. */
31 register XMSelect
*s_ptr
; /* XMSelect pointer. */
33 int label_length
; /* Label length in characters. */
34 int label_width
; /* Label width in pixels. */
37 * Check for NULL pointers!
40 _XMErrorCode
= XME_ARG_BOUNDS
;
45 * Find the right pane.
47 p_ptr
= _XMGetPanePtr(menu
, p_num
);
48 if (p_ptr
== NULL
) return(XM_FAILURE
);
51 * Find the right selection.
53 s_ptr
= _XMGetSelectionPtr(p_ptr
, s_num
);
54 if (s_ptr
== NULL
) return(XM_FAILURE
);
61 * Determine label size.
63 label_length
= strlen(label
);
64 label_width
= XTextWidth(menu
->s_fnt_info
, label
, label_length
);
67 * Change the selection data.
70 s_ptr
->label_width
= label_width
;
71 s_ptr
->label_length
= label_length
;
74 * Schedule a recompute.
82 if (data_sw
) s_ptr
->data
= data
;
85 * Return successfully.
87 _XMErrorCode
= XME_NO_ERROR
;
91 /* arch-tag: 229732a6-46bf-4a3a-ad90-3d8ed65c0841
92 (do not change this comment) */