1

在 PolyML 中,我试图在其中绘制一个带有像素图的按钮,但在外壳小部件上调用 XtRealizeWidget 之前找不到创建像素图的方法。

在 XtRealizeWidget 之后使用 XCreateBitmapFromData,在绘制带有图片的按钮时会产生巨大的延迟,这真的很愚蠢。也就是下面的代码。

相关线路是:

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 ;

我认为我应该做的是让整个窗口(包括图片)同时显示,是在 XtRealizeWidget 之前调用 XtSetValues 。我无法完成这项工作。XGetWindowRoot 的调用或任何类似的调用都不起作用。错误类似于:XGetGeometry 中的 X 错误 BadDrawable

谁能告诉我如何创建一个窗口,其中包含一个带有像素图的按钮,以使所有内容都同时绘制?

剩余代码:

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) ;
4

1 回答 1

1

尝试

  Display *dpy = XtDisplay(shell);
  XCreateBitmapFromData( dpy, DefaultRootWindow(dpy), ... );
于 2015-08-24T14:40:45.450 回答