class Metasm::Gui::XGui

Public Class Methods

test() click to toggle source
# File metasm/gui/x11.rb, line 579
def self.test
        d = xopendisplay(nil)
        s = xdefaultscreen(d)
        #cmap = xdefaultcolormap(d, s)
        w = xcreatesimplewindow(d, xdefaultrootwindow(d), 0, 0, 28, 28, 0, xblackpixel(d, s), xblackpixel(d, s))
        xstorename(d, w, "lol")
        gc = xcreategc(d, w, 0, 0)
        xsetforeground(d, gc, xwhitepixel(d, s))
        xselectinput(d, w, EXPOSUREMASK|KEYPRESSMASK|BUTTONPRESSMASK)
        xmapwindow(d, w)
        msg = alloc_c_struct('XEvent')
str = 'llllmmmml'
x = 12
y = 20
        loop {
                xnextevent(d, msg)
                case msg['type']
                when EXPOSE
                        #xsetforeground(d, gc, col)
                        #xdrawrectangle(d, w, gc, x, y+8, 30, 30)
                        xfillrectangle(d, w, gc, x, y+8, 30, 30)
                        xdrawline(d, w, gc, x, y+38, x+30, y+53)
                        xdrawstring(d, w, gc, x, y, str, str.length)
                when KEYPRESS
                        k = xlookupkeysym(msg, 0)
                        p k
                when BUTTONPRESS
                        break
                end
        }
        xdestroywindow(d, w)
        xclosedisplay(d)
end