/* * $Id: widget_arrowb.c,v 1.2 2000/08/16 22:04:31 scottm Exp $ * 6 August 1993, AB, RSI * * arrowb.c - This file contains C code to be called from VMS IDL via * CALL_EXTERNAL. It uses the IDL stub widget to add a Motif * ArrowButton to an IDL created widget hierarchy. The button issues * a WIDGET_STUB_EVENT every time the button is released. * * While this code is VMS-centric, the principles apply across platforms * and is included here as a guide to adding external widgets to IDL. * */ #include #include /* Keysyms for text widget events */ #include #include #include #include #include "idl_dir:[external]export.h" /*ARGSUSED*/ static void arrowb_CB(Widget w, caddr_t client_data, caddr_t call_data) { char *rec; XmArrowButtonCallbackStruct *abcs; IDL_WidgetStubLock(TRUE); if (rec = IDL_WidgetStubLookup((unsigned long) client_data)) { abcs = (XmArrowButtonCallbackStruct *) call_data; IDL_WidgetIssueStubEvent(rec, abcs->reason == XmCR_ARM); } IDL_WidgetStubLock(FALSE); } static void arrowb_size_func(int stub, int width, int height) { char *stub_rec; unsigned long t_id, b_id; IDL_WidgetStubLock(TRUE); if (stub_rec = IDL_WidgetStubLookup(stub)) { IDL_WidgetGetStubIds(stub_rec, &t_id, &b_id); printf("Setting WIDGET %d to width %d and height %d\n", stub, width,height); XtVaSetValues((Widget) b_id, XmNwidth, width, XmNheight, height, NULL); } IDL_WidgetStubLock(FALSE); } int widget_arrowb(IDL_LONG parent, IDL_LONG stub, int use_own_size_func) { Widget parent_w; Widget stub_w; char *parent_rec; char *stub_rec; unsigned long t_id, b_id; IDL_WidgetStubLock(TRUE); if ((parent_rec = IDL_WidgetStubLookup(parent)) && (stub_rec = IDL_WidgetStubLookup(stub))) { /* Bottom widget of parent is parent to arrow button */ IDL_WidgetGetStubIds(parent_rec, &t_id, &b_id); parent_w = (Widget) b_id; stub_w = XtVaCreateManagedWidget("arrowb", xmArrowButtonWidgetClass, parent_w, NULL); IDL_WidgetSetStubIds(stub_rec, (unsigned long) stub_w, (unsigned long) stub_w); XtAddCallback(stub_w, XmNarmCallback, (XtCallbackProc) arrowb_CB, (XtPointer) stub); XtAddCallback(stub_w, XmNdisarmCallback, (XtCallbackProc) arrowb_CB, (XtPointer) stub); if (use_own_size_func) IDL_WidgetStubSetSizeFunc(stub_rec,arrowb_size_func); } IDL_WidgetStubLock(FALSE); return stub; }