class Rabbit::Renderer::Print::Cairo
Public Class Methods
new(canvas)
click to toggle source
Calls superclass method
Rabbit::Renderer::Print::Base.new
# File lib/rabbit/renderer/print/cairo.rb, line 21 def initialize(canvas) super init_paper init_color end
Public Instance Methods
internal_clip_slide(x=0, y=0, w=width, h=height)
click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 57 def internal_clip_slide(x=0, y=0, w=width, h=height) x, y = from_screen(x, y) @context.rectangle(x, y, w, h) @context.clip end
internal_draw_background(x=0, y=0, w=width, h=height)
click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 63 def internal_draw_background(x=0, y=0, w=width, h=height) draw_rectangle(true, x, y, w, h, @background) end
internal_draw_slide(slide, simulation) { || ... }
click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 52 def internal_draw_slide(slide, simulation) yield @context.show_page if !simulation and @show_page end
post_apply_theme()
click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 43 def post_apply_theme end
post_move(old_index, index)
click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 46 def post_move(old_index, index) end
post_move_in_slide(old_index, index)
click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 49 def post_move_in_slide(old_index, index) end
post_parse()
click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 40 def post_parse end
post_print(canceled)
click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 32 def post_print(canceled) return if canceled @context.target.finish end
pre_parse()
click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 37 def pre_parse end
pre_print(slide_size)
click to toggle source
Calls superclass method
Rabbit::Renderer::Print::Base#pre_print
# File lib/rabbit/renderer/print/cairo.rb, line 27 def pre_print(slide_size) super init_context(create_context) end
priority()
click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 12 def priority if (::Cairo::VERSION <=> [1, 2, 0]) >= 0 100 else -100 end end
Private Instance Methods
create_context(output=nil)
click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 87 def create_context(output=nil) surface = find_surface(filename, output) surface.set_fallback_resolution(@x_dpi, @y_dpi) ::Cairo::Context.new(surface) end
create_pango_context()
click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 93 def create_pango_context context = create_context(StringIO.new).create_pango_layout.context set_font_resolution(context) context end
find_surface(filename, output=nil)
click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 99 def find_surface(filename, output=nil) args = [output || filename, @page_width, @page_height] case File.extname(filename) when /\.ps/i ::Cairo::PSSurface.new(*args) when /\.pdf/i ::Cairo::PDFSurface.new(*args) when /\.svg/i surface = ::Cairo::SVGSurface.new(*args) surface.restrict_to_version(::Cairo::SVG_VERSION_1_2) surface when /\.cs/i args[0] = ::Cairo::ScriptDevice.new(args[0]) ::Cairo::ScriptSurface.new(*args) else @canvas.logger.warn(_("can't find printer for %s") % filename) args[0] = "default.ps" ::Cairo::PSSurface.new(*args) end end
init_color()
click to toggle source
Calls superclass method
# File lib/rabbit/renderer/print/cairo.rb, line 75 def init_color super @foreground = make_color("black") @background = make_color(@background_color) end
init_dpi()
click to toggle source
Calls superclass method
# File lib/rabbit/renderer/print/cairo.rb, line 81 def init_dpi super @x_dpi = 300 @y_dpi = 300 end
init_paper()
click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 68 def init_paper default_width_mm = 360 default_height_mm = 270 @page_width = @paper_width || default_width_mm @page_height = @paper_height || default_height_mm end