class TextLayout
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
layout[R]
Public Class Methods
new(cr,txt,font,width,x,y,alignment='left')
click to toggle source
# File lib/Print/PrintItem/TextLayout.rb, line 6 def initialize(cr,txt,font,width,x,y,alignment='left') @cr=cr @font=font @layout=cr.create_pango_layout @txt=txt @layout.set_text(txt) @x=x @y=y @width=width @alignment=alignment @layout.set_font_description(Pango::FontDescription.new(@font)).set_width(@width*Pango::SCALE) @layout.set_wrap(Pango::Layout::WRAP_WORD_CHAR).set_ellipsize(Pango::Layout::ELLIPSIZE_NONE)#.set_single_paragraph_mode(true) set_alignment end
Public Instance Methods
draw(cr)
click to toggle source
# File lib/Print/PrintItem/TextLayout.rb, line 41 def draw(cr) cr.move_to(@x,@y) cr.show_pango_layout(@layout) cr.stroke end
height()
click to toggle source
# File lib/Print/PrintItem/TextLayout.rb, line 36 def height w,h=@layout.size h/Pango::SCALE end
set_alignment(alignment=@alignment)
click to toggle source
# File lib/Print/PrintItem/TextLayout.rb, line 28 def set_alignment(alignment=@alignment) @alignment=alignment case @alignment when 'left' then @layout.set_alignment(Pango::Layout::ALIGN_LEFT) when 'right' then @layout.set_alignment(Pango::Layout::ALIGN_RIGHT) when 'center' then @layout.set_alignment(Pango::Layout::ALIGN_CENTER) end end
set_x(newx=x)
click to toggle source
# File lib/Print/PrintItem/TextLayout.rb, line 22 def set_x(newx=x) @x=newx end
set_y(newy=y)
click to toggle source
# File lib/Print/PrintItem/TextLayout.rb, line 25 def set_y(newy=y) @y=newy end