# gSlider

Definition: | include xpGUI.e gdx id = gSlider([nullable_string orientation=NULL, ] [rtn value_changed=NULL, ] string attributes="", dword_seq args={})
Description: | Creates a slider control, which selects a value within a limited interval. Also known as a scale or trackbar in some native systems, and pGUI called it an IupValuator or IupVal. orientation: optional orientation of slider. Can be NULL (defaults to HORIZONTAL), see ORIENTATION below. value_changed: a procedure identifier, 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\gSlider.exw
    include xpGUI.e
    constant title = "Slider"

    procedure value_changed(gdx id)
        gdx dlg = gGetDialog(id)
        atom v = gGetAttribute(id,"VALUE")
        gSetAttribute(dlg,"TITLE","%s:%g",{title,v})
    end procedure

    gdx slider = gSlider(value_changed,"SIZE=220x30"),
        vbox = gVbox({slider},"MARGIN=9x9"),
        window = gDialog(vbox,title,`SIZE=240x80`)
    gShow(window)
    gMainLoop()
Attributes: |
? INVERTED | Invert the minimum and maximum positions on screen. When INVERTED=YES maximum is at top and left (minimum is bottom and right), when INVERTED=NO maximum is at bottom and right (minimum is top and left). The initial value depends on ORIENTATION passed as parameter on creation, if ORIENTATION=VERTICAL default is YES, if ORIENTATION=HORIZONTAL default is NO. (since 3.0)
? MAX+ | The maximum value, default 100.
? MIN+ | The minimum value, default 0.
? SIZE | (non inheritable) The initial size is 100 pixels along the major axis, and the handler normal size on the minor axis. If there are ticks then they are added to the natural size on the minor axis. The handler can be smaller than the normal size. Set to NULL to allow the automatic layout use smaller values.
? ORIENTATION+ | (non inheritable) Informs whether the valuator is "VERTICAL" or "HORIZONTAL". Vertical valuators are bottom to up, and horizontal valuators are left to right variations of min to max (but can be inverted using INVERTED). Default: "HORIZONTAL".
VALUE | A number between MIN and MAX, indicating the current position, default 0.
also | ACTIVE, CANFOCUS, EXPAND, FONT, MINSIZE, MAXSIZE, TIP, SIZE, 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 | KEY: All common handlers are supported.
Technicalia | As this is a paranormalised function, and with no expectation that you should attempt to memorise this lot, except maybe "ovaa", you can assume that all of the following are potentially perfectly valid, with the fairly obvious restrictions that any parameters must be in strict ovaa-order, and no args without attributes:
                            gSlider()
                            gSlider(value_changed)
                            gSlider(value_changed, attributes)
                            gSlider(value_changed, attributes, args)
                            gSlider(attributes, args)
                            gSlider(attributes)                      -- (see 2nd note)
                            gSlider(orientation)
                            gSlider(orientation, value_changed)
                            gSlider(orientation, attributes)
                            gSlider(orientation, attributes, args)
                            gSlider(orientation, value_changed, attributes)
                            gSlider(orientation, value_changed, attributes, args)  -- (the full set)
Note that in practice orientation and value_changed are actually defined as object, and attributes as a sequence rather than a string, but they are all manually and thoroughly verified to be of the documented types, after being repositioned via xpGUI.e/paranormalise_traa() [which is shared with gButton, etc]. Note that gSlider(attributes) is distinguished from gSlider(orientation) by the presence of an '=' character, see here, though since you’d never actually want an '=' in the ORIENTATION that probably doesn’t really apply.