wxRuby + rcairo ... are driving me mad.

  • Thread starter Philipp Hofmann
  • Start date
P

Philipp Hofmann

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
 
A

Alex Fenton

Philipp said:
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.

I suggest you post this on the wxRuby list.

I don't know of anyone who's tried to do this. If it doesn't work at the
moment, it should be pretty easy to get a Integer corresponding to a C
pointer out of the wrapper. But we'd need to know a bit more about what
the Cairo wrapping expects.

a
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top