Search in sources :

Example 1 with ComponentProperties

use of org.develnext.jphp.swing.ComponentProperties in project jphp by jphp-compiler.

the class UIElement method __setAutosize.

@Signature(@Arg("value"))
protected Memory __setAutosize(Environment env, Memory... args) {
    ComponentProperties properties = SwingExtension.getProperties(getComponent());
    properties.setAutoSize(args[0].toBoolean());
    return Memory.NULL;
}
Also used : ComponentProperties(org.develnext.jphp.swing.ComponentProperties)

Example 2 with ComponentProperties

use of org.develnext.jphp.swing.ComponentProperties in project jphp by jphp-compiler.

the class UIElement method __setPadding.

@Signature(@Arg(value = "value", type = HintType.ARRAY))
protected Memory __setPadding(Environment env, Memory... args) {
    ComponentProperties properties = SwingExtension.getProperties(getComponent());
    if (properties == null)
        return Memory.NULL;
    int[] v = args[0].toValue(ArrayMemory.class).toIntArray();
    if (v.length == 1) {
        int size = v[0];
        properties.setPadding(size, size, size, size);
    } else if (v.length == 2) {
        int ver = v[0];
        int hor = v[1];
        properties.setPadding(ver, hor, ver, hor);
    } else if (v.length == 3) {
        int top = v[0];
        int hor = v[1];
        int bottom = v[2];
        properties.setPadding(top, hor, bottom, hor);
    } else if (v.length > 3) {
        int top = v[0];
        int right = v[1];
        int bottom = v[2];
        int left = v[3];
        properties.setPadding(top, right, bottom, left);
    }
    return Memory.NULL;
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) ComponentProperties(org.develnext.jphp.swing.ComponentProperties)

Example 3 with ComponentProperties

use of org.develnext.jphp.swing.ComponentProperties in project jphp by jphp-compiler.

the class UIElement method trigger.

@Signature({ @Arg("name") })
public Memory trigger(Environment env, Memory... args) throws Throwable {
    ComponentProperties properties = SwingExtension.getProperties(getComponent());
    if (args.length == 1) {
        properties.triggerEvent(args[0].toString().toLowerCase());
    } else {
        Memory[] passed = new Memory[args.length - 1];
        System.arraycopy(args, 1, passed, 0, args.length - 1);
        properties.triggerEvent(args[0].toString().toLowerCase(), passed);
    }
    return Memory.NULL;
}
Also used : ComponentProperties(org.develnext.jphp.swing.ComponentProperties) ArrayMemory(php.runtime.memory.ArrayMemory) LongMemory(php.runtime.memory.LongMemory) Memory(php.runtime.Memory) ObjectMemory(php.runtime.memory.ObjectMemory) StringMemory(php.runtime.memory.StringMemory)

Example 4 with ComponentProperties

use of org.develnext.jphp.swing.ComponentProperties in project jphp by jphp-compiler.

the class UIElement method __setAlign.

@Signature(@Arg("value"))
protected Memory __setAlign(Environment env, Memory... args) {
    ComponentProperties properties = SwingExtension.getProperties(getComponent());
    properties.setAlign(Align.valueOf(args[0].toString().toUpperCase()));
    return Memory.NULL;
}
Also used : ComponentProperties(org.develnext.jphp.swing.ComponentProperties)

Example 5 with ComponentProperties

use of org.develnext.jphp.swing.ComponentProperties in project jphp by jphp-compiler.

the class UIElement method __setAnchors.

@Signature(@Arg("value"))
protected Memory __setAnchors(Environment env, Memory... args) {
    ComponentProperties data = SwingExtension.getProperties(getComponent());
    data.anchors.clear();
    if (args[0].isArray()) {
        ForeachIterator iterator = args[0].getNewIterator(env, false, false);
        while (iterator.next()) {
            Anchor anchor = Anchor.valueOf(iterator.getValue().toString().toUpperCase());
            if (anchor == null)
                env.exception(env.trace(), "Invalid anchor value - " + iterator.getValue());
            data.anchors.add(anchor);
        }
    } else {
        Anchor anchor = Anchor.valueOf(args[0].toString().toUpperCase());
        if (anchor == null)
            env.exception(env.trace(), "Invalid anchor value - " + args[0]);
    }
    if (getComponent().getParent() != null) {
        LayoutManager layout = getComponent().getParent().getLayout();
        if (!(layout instanceof XYLayout))
            env.exception(env.trace(), "Layout must be an instance of XYLayout");
    }
    return Memory.NULL;
}
Also used : ForeachIterator(php.runtime.lang.ForeachIterator) Anchor(org.develnext.jphp.swing.misc.Anchor) ComponentProperties(org.develnext.jphp.swing.ComponentProperties) XYLayout(org.develnext.jphp.swing.XYLayout)

Aggregations

ComponentProperties (org.develnext.jphp.swing.ComponentProperties)14 ArrayMemory (php.runtime.memory.ArrayMemory)4 StringMemory (php.runtime.memory.StringMemory)3 Anchor (org.develnext.jphp.swing.misc.Anchor)2 ArrayList (java.util.ArrayList)1 XYLayout (org.develnext.jphp.swing.XYLayout)1 EventProvider (org.develnext.jphp.swing.event.EventProvider)1 Memory (php.runtime.Memory)1 Invoker (php.runtime.invoke.Invoker)1 ForeachIterator (php.runtime.lang.ForeachIterator)1 LongMemory (php.runtime.memory.LongMemory)1 ObjectMemory (php.runtime.memory.ObjectMemory)1