lib/rabbit/renderer/base.rb in rabbit-2.1.3 vs lib/rabbit/renderer/base.rb in rabbit-2.1.4

- old
+ new

@@ -4,29 +4,21 @@ require "rabbit/rabbit" require "rabbit/trackball" require "rabbit/renderer/color" -module Pango - class Context - unless method_defined?(:families) - alias families list_families - end - end -end - module Rabbit module Renderer module Base extend Forwardable include ERB::Util include GetText include DirtyCount def_delegators(:@canvas, :reload_source) - + attr_reader :x_dpi, :y_dpi attr_accessor :paper_width, :paper_height, :slides_per_page attr_accessor :margin_left, :margin_right attr_accessor :margin_top, :margin_bottom attr_accessor :progress_foreground @@ -69,23 +61,23 @@ end def page_margin_left @page_margin_left || 0 end - + def page_margin_right @page_margin_right || 0 end - + def page_margin_top @page_margin_top || 0 end - + def page_margin_bottom @page_margin_bottom || 0 end - + def font_families if @font_families.nil? or @font_families.empty? @font_families = create_pango_context.families end @font_families @@ -146,11 +138,11 @@ end def create_pango_context Pango::Context.new end - + def printable? false end def display? @@ -161,11 +153,11 @@ true end def setup_event(area) end - + def to_attrs(hash) hash.collect do |key, value| if value "#{h key}='#{h value}'" else @@ -226,15 +218,15 @@ end def graffiti_mode? false end - + def have_graffiti? false end - + def can_undo_graffiti? false end def expand_hole @@ -267,11 +259,11 @@ private def off_screen_renderer? false end - + def do_print(&block) pre_print(@canvas.slide_size) canceled = false @canvas.slides.each_with_index do |slide, i| @canvas.move_to_if_can(i) @@ -294,11 +286,11 @@ canvas.parse(source) end canvas.toggle_index_mode if @canvas.index_mode? canvas end - + def make_canvas_with_printable_renderer renderer = Renderer.printable_renderer(@canvas.slides_per_page) make_canvas_with_renderer(renderer) do |canvas| canvas.filename = @canvas.filename setup_margin(canvas) @@ -306,11 +298,11 @@ setup_paper_size(canvas) setup_3d(canvas) canvas.slides_per_page = @canvas.slides_per_page end end - + def make_canvas_with_off_screen_renderer make_canvas_with_renderer(Pixmap) do |canvas| canvas.width = @canvas.width canvas.height = @canvas.height setup_3d(canvas) @@ -319,11 +311,11 @@ def setup_margin(canvas) canvas.margin_left = @canvas.margin_left canvas.margin_right = @canvas.margin_right canvas.margin_top = @canvas.margin_top - canvas.page_margin_bottom = @canvas.page_margin_bottom + canvas.margin_bottom = @canvas.margin_bottom end def setup_page_margin(canvas) canvas.page_margin_left = @canvas.page_margin_left canvas.page_margin_right = @canvas.page_margin_right @@ -345,11 +337,11 @@ canvas.use_gl = @canvas.use_gl? end def setup_flag_params(pole_height, default_flag_width_ratio, params) params = params.dup - + text = params["text"] text_attrs = params["text_attributes"] || {} if text markupped_text = "<span #{to_attrs(text_attrs)}>#{text}</span>" layout = make_layout(markupped_text) @@ -364,10 +356,10 @@ flag_height_default = [text_height, flag_width_default].max else params["layout"] = nil flag_width_default = flag_height_default = nil end - + params["pole_width"] = params["pole_width"] || 2 params["pole_color"] ||= "black" flag_height = params["flag_height"] || flag_height_default || pole_height / 2 flag_height = [flag_height, pole_height].min