#include "../xt/xt.h"
#include <Xm/Xm.h>
#include <Xm/Scale.h>

static Object Get_Scale_CB (p) XmScaleCallbackStruct *p; {
    Object ret, s;
    extern SYMDESCR Reason_Syms[];
    GC_Node2;

    ret = s = Make_Integer (p->value);
    GC_Link2 (ret, s);
    ret = Cons (ret, Null);
#ifdef SCALE_WIDGET_WORKS   /* It doesn't. */
    s = Get_Any_CB ((XmAnyCallbackStruct *)p);
#else
    s = Intern ("event-goes-here-when-Xm-is-fixed");
    s = Cons (s, Null);
    s = Cons (Bits_To_Symbols ((unsigned long)p->reason, 0, Reason_Syms), s);
#endif
    ret = Cons (Cdr (s), ret);
    ret = Cons (Car (s), ret);
    GC_Unlink;
    return ret;
}

static Object S_Scale_DragCallback (x) XtArgVal x; {
   return Get_Scale_CB ((XmScaleCallbackStruct *)x);
}

static Object S_Scale_ValueChangedCallback (x) XtArgVal x; {
   return Get_Scale_CB ((XmScaleCallbackStruct *)x);
}

init_scale () {
    XtResourceList r = 0;
    Define_Class ("scale", xmScaleWidgetClass, r, 0);
    Define_Callback ("scale", "valueChangedCallback", 1);
    Define_Callback ("scale", "dragCallback", 1);
    Define_Converter_To_Scheme ("scale-valueChangedCallback", S_Scale_ValueChangedCallback);
    Define_Converter_To_Scheme ("scale-dragCallback", S_Scale_DragCallback);
}
