허팔만 wrote:

> Where I can search the help regarding the CURL.REMOTE?
>
There is not any documentation in the product right now about
CURL.REMOTE, and the APIs might change a little bit in future
releases.
However, I have attached some sample code, just run the parent.curl
applet and you can tell it to change the colors of the child applets,
and see the child applets talking to the parent.

William Bardwell
[EMAIL PROTECTED]
{curl 4.0, 5.0 applet}
{curl-file-attributes character-encoding = "utf8"}

{include "ipc.scurl"}

|| For creating sub-applets.
{import * from CURL.ENGINE.BROWSER}

|| Allow graphical projecting of a child applet (as an "AppletGraphic"),
|| and also handle IPC from that child (as a "ParentInterface"), and, for
|| convenience, manage the "proxy" which can be used to communicate with
|| that child (as a "ChildInterface").
||
{define-class public final ChildGraphic
  {inherits ParentInterface, AppletGraphic}

  field public constant ident:String

  field public constant proxy:ChildProxy

  || See "ParentInterface".
  {method public {mention-string str:String}:String
    {popup-message "Got string from child <" & str & ">"}
    {return self.ident & ": " & str}
  }

  {constructor {default ident:String}

    set self.ident = ident

    || Prepare to project the child.
    {construct-super.AppletGraphic
        border-width = 1pt, border-color = "green"
    }

    || Create the child.
    let data:AppletData = {AppletData self, {url "child.curl"}} 

    || Get the connection to the child.
    let connection:RemoteConnection = data.inline-remote-connection

    || Allow communication to the child.
    set self.proxy = {ChildProxy connection, 0}

    || Handle incoming IPC from child.
    {ParentYxorp connection, 0, self}
  }
} 

{let child1:ChildGraphic = {ChildGraphic "child1"}}

{let child2:ChildGraphic = {ChildGraphic "child2"}}

{VBox
    background = "violet",
    width = 10cm,
    height = 6cm,
    margin = 5pt,
    spacing = 5pt,
    child1,
    child2
}

Set color for child1:
{TextField
    {on Action at tf:TextField do
        {remote-invoke-async
            {child1.proxy.set-color tf.value}
        }
    }
}

Set color for child2:
{TextField
    {on Action at tf:TextField do
        {remote-invoke-async
            {child2.proxy.set-color tf.value}
        }
    }
}
{curl 4.0, 5.0 applet}
{curl-file-attributes character-encoding = "utf8"}

{include "ipc.scurl"}


|| The graphical content of this applet, and also handle IPC from the
|| parent (as a "ChildInterface"), and, for convenience, track the "proxy"
|| which can be used to communicate with the parent (as a "ParentInterface").
||
{define-class Widget {inherits VBox, ChildInterface}

  field public constant proxy:ParentProxy

  || See "ChildInterface".
  {method public {set-color color:String}:void
    set self.border-color = color
  }

  {constructor {default}

    {construct-super.VBox
        background = "cyan",
        border-color = "red",
        border-width = 2pt,
        spacing = 5pt,
        {TextField
            font-style = "italic",
            font-size = 12pt,
            {on Action at tf:TextField do
                {remote-invoke-async
                    {self.proxy.mention-string tf.value}
                 receiving result:String do
                    {popup-message "Parent sent back <" & result & ">"}
                }
            }
        }
    }

    || Get the connection to the parent.
    let connection:RemoteConnection =
        {get-the-applet}.inline-remote-connection

    || Allow communication to the parent.
    set self.proxy = {ParentProxy connection, 0}

    || Handle incoming IPC from parent.
    {ChildYxorp connection, 0, self}
  }
}

{Widget}

|| This file is included by both "parent.curl" and "child.curl".
|| It could be made into a package if desired.

{import * from CURL.REMOTE}


|| Define IPC from a child to its parent.
||
{define-remote-class public abstract open ParentInterface
  {define-remote-proxy-class ParentProxy}
  {define-remote-yxorp-class ParentYxorp}

  {remote-method public abstract open {mention-string str:String}:String}
}


|| Define IPC from a parent to its child.
||
{define-remote-class public abstract open ChildInterface
  {define-remote-proxy-class ChildProxy}
  {define-remote-yxorp-class ChildYxorp}

  {remote-method public abstract open {set-color color:String}:void}
}

Reply via email to