1
在PolyML中,我試圖繪製一個帶有位圖的按鈕,但是在調用外殼小部件上的XtRealizeWidget之前無法找到創建像素圖的方法。PolyML/Motif:我如何同時繪製一個包含XmLabelPixmap按鈕的窗口?
在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或任何類似的調用都不起作用。錯誤是這樣的: X錯誤BadDrawable在XGetGeometry
任何人都可以告訴我如何創建一個窗口,其中有一個pixmap的按鈕,以這樣的方式,一切都是同時繪製?
剩餘代碼:
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) ;
謝謝。 這是[012 /] [code] val rw = RootWindow(XtDisplay shell); val P = XCreateBitmapFromData rw(MakeData thePiclist)...; val res = XtSetValues指示[XmNlabelPixmap P]; [/ code] 這可以在之前的realizeWidget shell中完成。這工作完美。 [br /] XtDisplay函數似乎不在PolyML引用中。 – thomasnnam123