在PolyML中,我试图绘制一个包含像素映射的按钮,但在调用shell小部件上的XtRealizeWidget之前,无法找到创建像素映射的方法。
在XCreateBitmapFromData之后使用XtRealizeWidget,在绘制包含图片的按钮时会出现很大的延迟,这实在是太愚蠢了。这是下面的代码。
有关项目如下:
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之前调用XtRealizeWidget。我没能把这件事办好。XGetWindowRoot的调用或任何类似的调用都不起作用。错误类似于:X错误BadDrawable in XGetGeometry
有人能告诉我如何创建一个窗口,其中有一个按钮,其中有一个像素地图,以这样的方式,一切都是同时绘制的吗?
剩余代码:
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) ;发布于 2015-08-24 14:40:45
试一试
Display *dpy = XtDisplay(shell);
XCreateBitmapFromData( dpy, DefaultRootWindow(dpy), ... );https://stackoverflow.com/questions/32179029
复制相似问题