Class: Reflex::TextView
Instance Attribute Summary collapse
-
#font ⇒ Object
Returns the value of attribute font.
Instance Method Summary collapse
- #content_size ⇒ Object
-
#initialize(*args, &block) ⇒ TextView
constructor
A new instance of TextView.
- #on_data_update(e) ⇒ Object
- #on_draw(e) ⇒ Object
Methods inherited from View
#capture, #capture=, #capturing?, #children, #gravity=, has_model, #style, #styles
Methods included from HasTags
#clear_tags, #tag, #tag=, #tags, #untag
Methods included from HasFrame
#frame, #frame=, #inset_by, #move_by, #move_to, #resize_by, #resize_to
Methods included from Hookable
Constructor Details
#initialize(*args, &block) ⇒ TextView
Returns a new instance of TextView.
18 19 20 21 |
# File 'lib/reflex/text_view.rb', line 18 def initialize (*args, &block) @outdated = false super end |
Instance Attribute Details
#font ⇒ Object
Returns the value of attribute font.
16 17 18 |
# File 'lib/reflex/text_view.rb', line 16 def font @font end |
Instance Method Details
#content_size ⇒ Object
23 24 25 26 27 28 |
# File 'lib/reflex/text_view.rb', line 23 def content_size () s = string return 0, 0 unless s && window font = @font || window.painter.font [font.width(s), font.height].map &:ceil end |
#on_data_update(e) ⇒ Object
39 40 41 42 |
# File 'lib/reflex/text_view.rb', line 39 def on_data_update (e) @outdated = true super end |
#on_draw(e) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/reflex/text_view.rb', line 30 def on_draw (e) @image = create_text_image if @outdated return unless @image pa = e.painter pa.color 1 pa.image @image end |