Search in sources :

Example 11 with ComponentProperties

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

the class UIElement method __setGroup.

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

Example 12 with ComponentProperties

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

the class UIScrollPanel method __setAutosize.

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

Example 13 with ComponentProperties

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

the class UIContainer method getComponents.

protected java.util.List<Component> getComponents(Container where, String group) {
    java.util.List<Component> result = new ArrayList<Component>();
    if (where instanceof JFrame)
        where = ((JFrame) where).getRootPane();
    int count = where instanceof JMenu ? ((JMenu) where).getItemCount() : where.getComponentCount();
    for (int i = 0; i < count; i++) {
        Component el = where instanceof JMenu ? ((JMenu) where).getItem(i) : where.getComponent(i);
        if (el == null)
            continue;
        ComponentProperties properties = SwingExtension.getProperties(el);
        if (properties != null && properties.hasGroup(group)) {
            result.add(el);
        }
        if (el instanceof Container) {
            result.addAll(getComponents((Container) el, group));
        }
    }
    return result;
}
Also used : ComponentProperties(org.develnext.jphp.swing.ComponentProperties) ArrayList(java.util.ArrayList)

Example 14 with ComponentProperties

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

the class UIElement method on.

@Signature({ @Arg("name"), @Arg("callback"), @Arg(value = "group", optional = @Optional("general")) })
public Memory on(Environment env, Memory... args) {
    Invoker invoker = Invoker.valueOf(env, null, args[1]);
    if (invoker == null) {
        env.exception(env.trace(), "Argument 2 must be callable");
        return Memory.NULL;
    }
    String name = args[0].toString().toLowerCase();
    EventProvider eventProvider = SwingExtension.isAllowedEventType(getComponent(), name);
    invoker.setTrace(env.trace());
    if (eventProvider == null) {
        if (allowedEvents == null || !allowedEvents.contains(name))
            throw new IllegalArgumentException("Unknown event type - " + args[0]);
    //env.exception(env.trace(), "Unknown event type - " + args[0]);
    }
    onBindEvent(env, name, invoker);
    ComponentProperties properties = SwingExtension.getProperties(getComponent(), true);
    properties.updateEvents(env);
    getEventContainer().addEvent(name, args[2].toString(), invoker);
    return Memory.NULL;
}
Also used : ComponentProperties(org.develnext.jphp.swing.ComponentProperties) Invoker(php.runtime.invoke.Invoker) EventProvider(org.develnext.jphp.swing.event.EventProvider)

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