From: Philipp Hofmann Date: 2009-11-09T07:02:45+09:00 Subject: wxRuby + rcairo ... are driving me mad. How is it possible to use Wx::GraphicsContext#get_native_context with rcairo? Let me quote the wxRuby documentation from http://wxruby.rubyforge.org/doc/graphicscontext.html#GraphicsContext_getnativecontext "Returns the native context (CGContextRef for Core Graphics, Graphics pointer for GDIPlus and cairo_t pointer for cairo)." [1] Is there a way to cast the data the cairo_t pointer points to into a Cairo::Context? Everything I tried resulted in an 'called on terminated object' error. Well, at least the reasonable attempts. --- snip --------------------------------------------------------- #!/usr/bin/env ruby require 'rubygems' require 'wx' # require 'cairo' include Wx class MyCanvas < Window def initialize(parent) super(parent) timer = Timer.new(self, 1000) evt_paint do paint do |dc| puts "painting on #{dc}" gdc = GraphicsContext.create(dc) # whatever I do with the native context, I get # method '...' called on terminated object gdc.get_native_context end end evt_timer(1000, :refresh) timer.start(100) end end class MyFrame < Frame def initialize super(nil, -1, 'MyTitle', :style => DEFAULT_FRAME_STYLE) canvas = MyCanvas.new(self) end end class MyApp < App def on_init frame = MyFrame.new frame.show(true) end end myapp = MyApp.new myapp.main_loop --- snip --------------------------------------------------------- Any help is highly appreciated Best phil