From 58d4857d60239a4aaa7aefbfd31785d2058972b7 Mon Sep 17 00:00:00 2001 From: lobingera Date: Sun, 6 Sep 2015 10:38:04 +0200 Subject: [PATCH] getting a CairoContext from pointer only, finalizer excluded --- src/Cairo.jl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Cairo.jl b/src/Cairo.jl index f88d85d..217e41c 100644 --- a/src/Cairo.jl +++ b/src/Cairo.jl @@ -110,6 +110,14 @@ type CairoSurface <: GraphicsDevice finalizer(self, destroy) self end + function CairoSurface(ptr::Ptr{Void}) + self = new(ptr) + #finalizer(self, destroy) + self + end + + + end width(surface::CairoSurface) = surface.width @@ -339,6 +347,18 @@ type CairoContext <: GraphicsContext finalizer(self, destroy) self end + function CairoContext(ptr::Ptr{Void}) + surface_p = ccall((:cairo_get_target,_jl_libcairo), + Ptr{Void}, (Ptr{Void},), ptr) + surface = CairoSurface(surface_p) + layout = ccall((:pango_cairo_create_layout,_jl_libpangocairo), + Ptr{Void}, (Ptr{Void},), ptr) + self = new(ptr,surface,layout) + #finalizer(self, destroy) + self + end + + end creategc(s::CairoSurface) = CairoContext(s)