Task

Create a window and draw a pixel in it, subject to the following:

  the window is 320 x 240
  the color of the pixel must be red (255,0,0)
  the position of the pixel is x = 100, y = 100
open XWindows ;
open Motif ;
 
val imgWindow = fn () =>
 
 let
  val shell  =  XtAppInitialise      ""    "demo" "top" [] [ XmNwidth 320, XmNheight 240 ] ;
  val main   =  XmCreateMainWindow   shell    "main"       [ XmNmappedWhenManaged true ]   ;
  val canvas =  XmCreateDrawingArea  main   "drawarea"     [ XmNwidth 320, XmNheight 240 ] ;
  val usegc  =  DefaultGC (XtDisplay canvas) ;
  val put    =  fn (w,s,t) => ( XSetForeground usegc 0xff0000 ;
                                XDrawPoint (XtWindow canvas) usegc ( XPoint {x=100,y=100} ) ; t);
in
 
  (
   XtSetCallbacks   canvas [ (XmNexposeCallback , put) ] XmNarmCallback ;
   XtManageChild    canvas ;
   XtManageChild    main ; 
   XtRealizeWidget  shell 
  )
 
end;