# gSpin

Definition: | include xpGUI.e gdx id = gSpin([rtn value_changed=NULL,] string attributes="", dword_seq args={})
Description: | Creates a spin control. value_changed: (optional) a procedure to be invoked when the contents are changed, see VALUE_CHANGED below. For more information on the attributes and args parameters see gSetAttributes(). This is a paranormalised function. (see technicalia) Returns: the identifier of the created element.
pwa/p2js: | Supported.
Example: |
    -- demo\xpGUI\gSpin.exw
    include xpGUI.e

    procedure value_changed(gdx id)
        ?{"value_changed",id,gGetInt(id,"VALUE")}
    end procedure

    gdx spin = gSpin(value_changed,"MARGIN=13x13,VALUE=5"),
        dlg = gDialog(gHbox({spin}),`gSpin`,`SIZE=240x80`)
    gShow(dlg)
    gMainLoop()
Attributes: |
RANGE | the min/maximum values. Default: {0,100}.
STEP | the inc/decrement value, must be a positive integer (see technicalia). Default: 1.
VALUE | The current (integer) value of the control, initially blank.
WRAP | (creation only) should the position reach either limit, continue from the opposite limit. Default: false.
also | ACTIVE, CANFOCUS, FONT, EXPAND, MARGIN, MINSIZE, MAXSIZE, SIZE, TIP, VISIBLE.
Handlers: |
VALUE_CHANGED | Called after the value was interactively changed by the user. procedure value_changed(gdx id) id: identifier of the element that activated the event.
also | CLICK, KEY: All common handlers are supported.
Technicalia | As this is a paranormalised function, and with no expectation that you should memorise this lot, except maybe "raa", you can assume that all of the following are potentially perfectly valid, with the fairly obvious restrictions that any parameters must be in strict raa-order, and no args without attributes:
                            gSpin()
                            gSpin(rid)
                            gSpin(attributes)
                            gSpin(attributes, args)
                            gSpin(rid, attributes)
                            gSpin(rid, attributes, args)    -- (the full set)
Note that in practice rid is actually defined as object, and attributes as a sequence rather than a string, but verified to be of the documented types, after being repositioned via xpGUI.e/paranormalise_raa(). While JavaScript copes admirably with fractional steps, GTK purports to but did not work for me, and WinAPI quite clearly has no support for non-integers whatsoever. Hence STEP/RANGE/VALUE are limited to integers. Implementing a fake control for desktop/Phix should be perfectly feasible (gText+button/image+KEY?) but is left as an exercise for the reader. Whatever I end up having to do for gDatePick() on GTK, less the pop-up, will probably be somewhat similar, and the 100% fake scrollbars of demo\xpGUI\scroller.exw strike me as pretty solid evidence that sort of thing can be done.