class HeaderLayout

this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)

Attributes

height[RW]
layout[RW]
tlayout[RW]

Public Class Methods

new(cr,pop) click to toggle source
# File lib/ListHolder/EditableList/ListPrintOperation/HeaderLayout.rb, line 7
def initialize(cr,pop)
        @pop=pop
        @layout = cr.create_pango_layout
        text=pop.list.gtk_attribute("print_custom_header").nil? ? pop.list.title : eeval(pop.list.gtk_attribute("print_custom_header"),pop.list).to_s
        ecode(text)
        layout.set_text(text).set_width(@pop.pango_width)
        layout.set_font_description(Pango::FontDescription.new(@pop.header_font))
        layout.set_wrap(Pango::Layout::WRAP_WORD).set_ellipsize(Pango::Layout::ELLIPSIZE_NONE).set_single_paragraph_mode(false)
        layout.set_alignment(Pango::Layout::Alignment::CENTER)

        @tlayout = cr.create_pango_layout
        tlayout.set_text(Time.new.strftime("%m/%d/%Y")).set_width(@pop.pango_width).set_alignment(Pango::Layout::ALIGN_RIGHT)
        tlayout.set_font_description(Pango::FontDescription.new(@pop.date_font))
        tlayout.set_wrap(Pango::Layout::WRAP_WORD).set_ellipsize(Pango::Layout::ELLIPSIZE_NONE)

        @height=2*layout.size[1]/Pango::SCALE+cr.line_width*3
end

Public Instance Methods

draw(cr) click to toggle source
# File lib/ListHolder/EditableList/ListPrintOperation/HeaderLayout.rb, line 26
def draw(cr)
        cr.move_to(0,0) #position on begining of page
        cr.show_pango_layout(layout) if @pop.print_title
        cr.show_pango_layout(tlayout) if @pop.print_date
        if @pop.draw_header_line
                cr.set_line_width(@pop.header_line_width)
                cr.move_to(0,2*layout.size[1]/Pango::SCALE+cr.line_width) #move below header
                cr.line_to(@pop.width,2*layout.size[1]/Pango::SCALE+cr.line_width) #draw the line
        end
        cr.stroke
end