Class: HeaderLayout

Inherits:
Object
  • Object
show all
Defined in:
lib/ListHolder/EditableList/ListPrintOperation/HeaderLayout.rb

Overview

this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint([email protected])

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cr, pop) ⇒ HeaderLayout

Returns a new instance of HeaderLayout.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ListHolder/EditableList/ListPrintOperation/HeaderLayout.rb', line 6

def initialize(cr,pop)
	@pop=pop
	@layout = cr.create_pango_layout
	layout.set_text(pop.list.title).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(true)
	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

Instance Attribute Details

#heightObject

Returns the value of attribute height.



21
22
23
# File 'lib/ListHolder/EditableList/ListPrintOperation/HeaderLayout.rb', line 21

def height
  @height
end

#layoutObject

Returns the value of attribute layout.



21
22
23
# File 'lib/ListHolder/EditableList/ListPrintOperation/HeaderLayout.rb', line 21

def layout
  @layout
end

#tlayoutObject

Returns the value of attribute tlayout.



21
22
23
# File 'lib/ListHolder/EditableList/ListPrintOperation/HeaderLayout.rb', line 21

def tlayout
  @tlayout
end

Instance Method Details

#draw(cr) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ListHolder/EditableList/ListPrintOperation/HeaderLayout.rb', line 23

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