Mercurial > emacs
changeset 27333:a5bceda5d689
(xm_arm_callback): New function.
(make_menu_in_widget): Set xm_arm_callback as XmNarmCallback and
XmNdisarmCallback for buttons (not supported for other widgets).
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Mon, 17 Jan 2000 09:09:08 +0000 |
parents | 5cfe77eaff45 |
children | b0f7b611a20e |
files | lwlib/lwlib-Xm.c |
diffstat | 1 files changed, 51 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/lwlib/lwlib-Xm.c Sun Jan 16 00:29:04 2000 +0000 +++ b/lwlib/lwlib-Xm.c Mon Jan 17 09:09:08 2000 +0000 @@ -129,6 +129,7 @@ void xm_set_main_areas P_ ((Widget, Widget, Widget)); static void xm_internal_update_other_instances P_ ((Widget, XtPointer, XtPointer)); +static void xm_arm_callback P_ ((Widget, XtPointer, XtPointer)); #if 0 void xm_update_one_widget P_ ((widget_instance *, Widget, widget_value *, @@ -138,8 +139,7 @@ #endif -static destroyed_instance* -all_destroyed_instances = NULL; +static destroyed_instance *all_destroyed_instances = NULL; static destroyed_instance* make_destroyed_instance (name, type, widget, parent, pop_up_p) @@ -247,6 +247,47 @@ } } + + +/* Callback XmNarmCallback and XmNdisarmCallback for buttons in a + menu. CLIENT_DATA contains a pointer to the widget_value + corresponding to widget W. CALL_DATA contains a + XmPushButtonCallbackStruct containing the reason why the callback + is called. */ + +static void +xm_arm_callback (w, client_data, call_data) + Widget w; + XtPointer client_data, call_data; +{ + XmPushButtonCallbackStruct *cbs = (XmPushButtonCallbackStruct *) call_data; + widget_value *wv = (widget_value *) client_data; + widget_instance *instance; + + /* Get the id of the menu bar or popup menu this widget is in. */ + while (1) + { + if (XmIsRowColumn (w)) + { + unsigned char type = 0xff; + + XtVaGetValues (w, XmNrowColumnType, &type, NULL); + if (type == XmMENU_BAR || type == XmMENU_POPUP) + break; + } + + w = XtParent (w); + } + + instance = lw_get_widget_instance (w); + if (instance && instance->info->highlight_cb) + { + call_data = cbs->reason == XmCR_DISARM ? NULL : wv; + instance->info->highlight_cb (w, instance->info->id, call_data); + } +} + + /* Update the label of widget WIDGET. WIDGET must be a Label widget or a subclass of Label. WIDGET_INSTANCE is unused. VAL contains @@ -519,10 +560,16 @@ ? XmN_OF_MANY : XmONE_OF_MANY)); ++ac; button = XmCreateToggleButton (widget, cur->name, al, ac); + XtAddCallback (button, XmNarmCallback, xm_arm_callback, cur); + XtAddCallback (button, XmNdisarmCallback, xm_arm_callback, cur); } else - button = XmCreatePushButton (widget, cur->name, al, ac); - + { + button = XmCreatePushButton (widget, cur->name, al, ac); + XtAddCallback (button, XmNarmCallback, xm_arm_callback, cur); + XtAddCallback (button, XmNdisarmCallback, xm_arm_callback, cur); + } + xm_update_label (instance, button, cur); /* Add a callback that is called when the button is