On 13/12/2014 17:04, David Topham wrote:
I did get the interactive version of the sample Motif code to work OK, but
failed to get it to build stand-alone (i.e. using polyc). Perhaps the
polyc script doesn't include the needed Motif libraries? But also, my
limited understanding of how to incorporate that GUI code into a main
function may be to blame.
I've experimented with building a stand-alone executable with Motif and
succeeded in getting it to work for me using polyc. (It required
building Poly/ML with --with-x). I took the example from
http://www.polyml.org/docs/Motif.html and wrapped it up in a function.
I did find a problem, though. It looks as though the function has to
suspend itself with something like Posix.Process.pause otherwise nothing
happens. I seem to recall that the Motif stuff is handled on a separate
thread to allow the REPL to continue to accept commands. With a
stand-alone application there isn't a REPL so without the "pause" it
terminates immediately.
David
open XWindows ;
open Motif ;
fun main() =
let
val shell =
XtAppInitialise "" "xed" "Editor" [] [XmNwidth 400, XmNheight 400] ;
val main = XmCreateMainWindow shell "main" [] ;
val bar = XmCreateMenuBar main "bar" [] ;
val fileMenu = XmCreateCascadeButton bar "file" [XmNlabelString "File"] ;
val editMenu = XmCreateCascadeButton bar "edit" [XmNlabelString "Edit"] ;
val viewMenu = XmCreateCascadeButton bar "view" [XmNlabelString "View"] ;
val helpMenu = XmCreateCascadeButton bar "help" [XmNlabelString "Help"] ;
val command = XmCreateText main "command" [XmNeditMode XmSINGLE_LINE_EDIT] ;
val hscroll = XmCreateScrollBar main "hscroll" [XmNorientation
XmHORIZONTAL] ;
val vscroll = XmCreateScrollBar main "vscroll" [XmNorientation XmVERTICAL] ;
val work = XmCreateDrawingArea main "work" [] ;
in
XtManageChildren [fileMenu, editMenu, viewMenu, helpMenu] ;
XtManageChildren [bar, command, hscroll, vscroll, work] ;
XmMainWindowSetAreas main bar command hscroll vscroll work ;
XtManageChild main ;
XtRealizeWidget shell;
Posix.Process.pause()
end;
_______________________________________________
polyml mailing list
[email protected]
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml