1

In PolyML, I am trying to draw a button with a pixmap in it, but cannot find a way to create the pixmap before calling XtRealizeWidget on the shell widget.

Using XCreateBitmapFromData after XtRealizeWidget, gives a huge delay in drawing the button with the picture in it, which is really silly. That is the code below.

the relevant lines are:

val   shell = XtAppInitialise "" "appl" "clss" [] [XmNwidth 500, XmNheight 500 ] ;
val   mainw = XmCreateMainWindow shell "window" [] ;
val   instruct = XmCreateDrawnButton mainw "button" [XmNwidth 60, XmNheight 30 , XmNlabelType XmPIXMAP,  XmNmappedWhenManaged true ];
val x =XtManageChildren [ instruct ] ;
val x=XtManageChild mainw ;

XtRealizeWidget shell;
let
 val thePic = XCreateBitmapFromData (XGetWindowRoot (XtWindow instruct)) (MakeData thePiclist)  (Area{x=0,y=0,w=25,h=25}) 
in
 XtSetValues instruct [XmNlabelPixmap thePic] 
end ;

I think that what I should do, to make the whole window - including the picture - to be shown simultaneously, is call XtSetValues before XtRealizeWidget, . I have't been able to make this work. The call of XGetWindowRoot, or any comparable call, does not work. Errors are like : X Error BadDrawable in XGetGeometry

Can anybody tell me how to create a window having a button with a pixmap in it , in such a way that everything is drawn simultaneously ?

remaining code:

open XWindows ;
open Motif ;

val thePiclist= [
   0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00,
   0x7c, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00,
   0xfc, 0x1f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0xff, 0x01, 0x00,
   0xfc, 0xff, 0x07, 0x00, 0xfc, 0xff, 0x1f, 0x00, 0xfc, 0xff, 0x7f, 0x00,
   0xfc, 0xff, 0xff, 0x00, 0xfc, 0xff, 0x7f, 0x00, 0xfc, 0xff, 0x1f, 0x00,
   0xfc, 0xff, 0x07, 0x00, 0xfc, 0xff, 0x01, 0x00, 0xfc, 0x7f, 0x00, 0x00,
   0xfc, 0x1f, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00,
   0x7c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00];


fun MakeData []     = ""
 |   MakeData (H::T) = (str (chr H)) ^ (MakeData T) ;

1 Answers1

1

Try

  Display *dpy = XtDisplay(shell);
  XCreateBitmapFromData( dpy, DefaultRootWindow(dpy), ... );
FredK
  • 4,094
  • 1
  • 9
  • 11
  • Thank you. It was[br/] [code] val rw = RootWindow (XtDisplay shell) ; val P = XCreateBitmapFromData rw (MakeData thePiclist) ... ; val res=XtSetValues instruct [XmNlabelPixmap P] ;[/code][br/] which can be done before the realizeWidget shell. This works perfectly. [br/] The XtDisplay function does not seem to be in the PolyML-references. – thomasnnam123 Aug 24 '15 at 16:17