Class: Reflex::TextView

Inherits:
View
  • Object
show all
Defined in:
lib/reflex/text_view.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from View

#capturing?, #children, #delay, #find_child, has_model, #initialize, #interval, #on_contact, #on_contact_begin, #on_contact_end, #remove_self, #shapes, #style, #styles, #timeout

Methods included from HasTags

#clear_tags, #tag, #tag=, #tags, #untag

Methods included from HasFrame

#inset_by, #move_by, #move_to, #resize_by, #resize_to

Methods included from Hookable

#hook

Constructor Details

This class inherits a constructor from Reflex::View

Instance Attribute Details

#fontObject

Returns the value of attribute font.



13
14
15
# File 'lib/reflex/text_view.rb', line 13

def font
  @font
end

Instance Method Details

#content_boundsObject



18
19
20
21
22
23
# File 'lib/reflex/text_view.rb', line 18

def content_bounds()
  s = string
  return 0, 0 unless s && window
  font = @font || window.painter.font
  [font.width(s), font.height].map &:ceil
end

#on_draw(e) ⇒ Object



25
26
27
28
29
30
# File 'lib/reflex/text_view.rb', line 25

def on_draw(e)
  s = string
  e.painter.push font: @font do
    text s
  end
end