Sha256: 0e46b30037c6bf2a69703c7ded8911a647124709cf9b4ab70df9a28d419290ad

Contents?: true

Size: 1.44 KB

Versions: 8

Compression:

Stored size: 1.44 KB

Contents

require "rabbit/rabbit"

require "rabbit/renderer/base"

module Rabbit
  module Renderer
    module Print
      module Base
        include Renderer::Base

        attr_writer :filename
        attr_accessor :show_page

        def initialize(canvas)
          super
          @filename = nil
        end

        def page_width
          @page_width - page_margin_left - page_margin_right
        end

        def page_height
          @page_height - page_margin_top - page_margin_bottom
        end

        def width
          page_width
        end

        def height
          page_height
        end

        def paper_width=(value)
          super
          init_paper
        end

        def paper_height=(value)
          super
          init_paper
        end

        def pre_print(slide_size)
          @show_page = true
        end

        def printable?
          true
        end

        def filename
          @filename ||= default_filename
        end

        def draw_slide(slide, simulation)
          internal_draw_slide(slide, simulation) do
            if simulation
              yield
            else
              save_context do
                internal_clip_slide
                internal_draw_background
                yield
              end
            end
          end
        end

        private
        def default_filename
          "#{GLib.filename_from_utf8(@canvas.title.gsub(/\n/, ''))}.pdf"
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rabbit-2.2.1 lib/rabbit/renderer/print/base.rb
rabbit-2.2.0 lib/rabbit/renderer/print/base.rb
rabbit-2.1.9 lib/rabbit/renderer/print/base.rb
rabbit-2.1.8 lib/rabbit/renderer/print/base.rb
rabbit-2.1.7 lib/rabbit/renderer/print/base.rb
rabbit-2.1.6 lib/rabbit/renderer/print/base.rb
rabbit-2.1.5 lib/rabbit/renderer/print/base.rb
rabbit-2.1.4 lib/rabbit/renderer/print/base.rb