Question about LuaCairo and wxLua

W Wlourf <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
Hello,


Is it possible to use LuaCairo with wxLua. I've seen CairoPad but I can't get it works on my computer (Debian Squeeze). 


What sould I change to this code to display the cairo context on the screen :



package.cpath = package.cpath..";./?.dll;./?.so;../lib/?.so;../lib/vc_dll/?.dll;../lib/bcc_dll/?.dll;../lib/mingw_dll/?.dll;"

require("wx")
local Cairo = require("lcairo")

mainWin = wx.wxFrame(wx.NULL, -1,"Hello Shao",wx.wxPoint(100,100),wx.wxSize(500,500))
 
function OnPaint(event)
        local dc = wx.wxPaintDC(mainWin) 
        local cs = Cairo.image_surface_create(Cairo.FORMAT_ARGB32, 250,250)
        print ("cs",cs)
        --doesn't work
        --local cr = Cairo.CreateContext(wx.get_drawable(dc)) --HACK!   
        local cr = Cairo.Context(cs)
        print ("cr", cr)
        
        cr:push_group_with_content(Cairo.CONTENT_COLOR)
        cr:set_source_rgb (0, 0, 1)
        cr:paint ()
        cr:set_source_rgba(0,1,0,1)
        cr:rectangle(0, 0, 100, 100)
        cr:fill()
        cr:pop_group_to_source()
        Cairo.surface_write_to_png(cs,"/tmp/test.png") -->ok if not push/pop group
        dc:DrawRectangle(100,100,100,100) -->ok
        dc:delete()

end
 
mainWin:Connect(wx.wxEVT_PAINT, OnPaint)
 
mainWin:Show(true)
wx.wxGetApp():MainLoop()


Thanks in advance


PS : Hakki, if you read me, why your Hack wx.get_drawable(dc) doesn't work ?

--
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.