|
|
|
@ -23,39 +23,35 @@ module Squib |
|
|
|
|
|
|
|
|
|
|
|
# :nodoc: |
|
|
|
# :nodoc: |
|
|
|
# @api private |
|
|
|
# @api private |
|
|
|
def ellipsize(layout, ellipsize) |
|
|
|
def set_ellipsize!(layout, ellipsize) |
|
|
|
unless ellipsize.nil? |
|
|
|
case ellipsize.to_s.downcase |
|
|
|
h = { :none => Pango::Layout::ELLIPSIZE_NONE, |
|
|
|
when 'none', 'false' |
|
|
|
:start => Pango::Layout::ELLIPSIZE_START, |
|
|
|
layout.ellipsize = Pango::Layout::ELLIPSIZE_NONE |
|
|
|
:middle => Pango::Layout::ELLIPSIZE_MIDDLE, |
|
|
|
when 'start' |
|
|
|
:end => Pango::Layout::ELLIPSIZE_END, |
|
|
|
layout.ellipsize = Pango::Layout::ELLIPSIZE_START |
|
|
|
true => Pango::Layout::ELLIPSIZE_END, |
|
|
|
when 'middle' |
|
|
|
false => Pango::Layout::ELLIPSIZE_NONE |
|
|
|
layout.ellipsize = Pango::Layout::ELLIPSIZE_MIDDLE |
|
|
|
} |
|
|
|
when 'end', 'true' |
|
|
|
layout.ellipsize = h[ellipsize] |
|
|
|
layout.ellipsize = Pango::Layout::ELLIPSIZE_END |
|
|
|
end |
|
|
|
end |
|
|
|
layout |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# :nodoc: |
|
|
|
# :nodoc: |
|
|
|
# @api private |
|
|
|
# @api private |
|
|
|
def wrap(layout, wrap) |
|
|
|
def set_wrap!(layout, wrap) |
|
|
|
layout.wrap = case wrap.to_s |
|
|
|
case wrap.to_s.downcase |
|
|
|
when 'word' |
|
|
|
when 'word' |
|
|
|
Pango::Layout::WRAP_WORD |
|
|
|
layout.wrap = Pango::Layout::WRAP_WORD |
|
|
|
when 'char' |
|
|
|
when 'char' |
|
|
|
Pango::Layout::WRAP_CHAR |
|
|
|
layout.wrap = Pango::Layout::WRAP_CHAR |
|
|
|
when 'word_char', true |
|
|
|
when 'word_char', 'true' |
|
|
|
Pango::Layout::WRAP_WORD_CHAR |
|
|
|
layout.wrap = Pango::Layout::WRAP_WORD_CHAR |
|
|
|
else |
|
|
|
end |
|
|
|
nil |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
layout |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# :nodoc: |
|
|
|
# :nodoc: |
|
|
|
# @api private |
|
|
|
# @api private |
|
|
|
def align(layout, align) |
|
|
|
def set_align!(layout, align) |
|
|
|
case align.to_s |
|
|
|
case align.to_s |
|
|
|
when 'left' |
|
|
|
when 'left' |
|
|
|
layout.alignment = Pango::ALIGN_LEFT |
|
|
|
layout.alignment = Pango::ALIGN_LEFT |
|
|
|
@ -64,7 +60,6 @@ module Squib |
|
|
|
when 'center' |
|
|
|
when 'center' |
|
|
|
layout.alignment = Pango::ALIGN_CENTER |
|
|
|
layout.alignment = Pango::ALIGN_CENTER |
|
|
|
end |
|
|
|
end |
|
|
|
layout |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# :nodoc: |
|
|
|
# :nodoc: |
|
|
|
@ -83,7 +78,7 @@ module Squib |
|
|
|
|
|
|
|
|
|
|
|
# :nodoc: |
|
|
|
# :nodoc: |
|
|
|
# @api private |
|
|
|
# @api private |
|
|
|
def setwh(layout, width, height) |
|
|
|
def set_wh!(layout, width, height) |
|
|
|
layout.width = width * Pango::SCALE unless width.nil? || width == :native |
|
|
|
layout.width = width * Pango::SCALE unless width.nil? || width == :native |
|
|
|
layout.height = height * Pango::SCALE unless height.nil? || height == :native |
|
|
|
layout.height = height * Pango::SCALE unless height.nil? || height == :native |
|
|
|
layout |
|
|
|
layout |
|
|
|
@ -107,10 +102,10 @@ module Squib |
|
|
|
layout.font_description = font_desc |
|
|
|
layout.font_description = font_desc |
|
|
|
layout.text = str.to_s |
|
|
|
layout.text = str.to_s |
|
|
|
layout.markup = str.to_s if markup |
|
|
|
layout.markup = str.to_s if markup |
|
|
|
layout = setwh(layout, width, height) |
|
|
|
set_wh!(layout, width, height) |
|
|
|
layout = wrap(layout, wrap) |
|
|
|
set_wrap!(layout, wrap) |
|
|
|
layout = ellipsize(layout, ellipsize) |
|
|
|
set_ellipsize!(layout, ellipsize) |
|
|
|
layout = align(layout, align) |
|
|
|
set_align!(layout, align) |
|
|
|
layout.justify = justify unless justify.nil? |
|
|
|
layout.justify = justify unless justify.nil? |
|
|
|
layout.spacing = spacing * Pango::SCALE unless spacing.nil? |
|
|
|
layout.spacing = spacing * Pango::SCALE unless spacing.nil? |
|
|
|
cc.update_pango_layout(layout) |
|
|
|
cc.update_pango_layout(layout) |
|
|
|
|