Class: Shoes::TextBlock

Inherits:
Basic show all
Defined in:
lib/shoes/basic.rb,
lib/shoes/style.rb

Direct Known Subclasses

Banner, Caption, Inscription, Para, Subtitle, Tagline, Title

Instance Attribute Summary collapse

Attributes inherited from Basic

#args, #dps, #initials, #ln, #parent, #pl

Attributes included from Mod

#hover_proc, #hovered, #leave_proc, #margin_bottom, #margin_left, #margin_right, #margin_top

Instance Method Summary collapse

Methods inherited from Basic

#center_at, #fix_size, #hide, #move2, #move3, #set_args, #show, #toggle

Methods included from Mod

#click, #hided, #hover, #leave, #release, #set_margin

Constructor Details

#initialize(args) ⇒ TextBlock

Returns a new instance of TextBlock.



203
204
205
206
# File 'lib/shoes/basic.rb', line 203

def initialize args
  @links = []
  super
end

Instance Attribute Details

Returns the value of attribute links.



207
208
209
# File 'lib/shoes/basic.rb', line 207

def links
  @links
end

Instance Method Details

#clearObject



223
224
225
226
227
# File 'lib/shoes/basic.rb', line 223

def clear
  @links.each &:clear
  @links.clear
  super
end

#move(x, y) ⇒ Object



219
220
221
222
# File 'lib/shoes/basic.rb', line 219

def move x, y
  self.text = @args[:markup]
  super
end

#positioning(x, y, max) ⇒ Object



215
216
217
218
# File 'lib/shoes/basic.rb', line 215

def positioning x, y, max
  self.text = @args[:markup]
  super.tap{|s| s.height += (@margin_top + @margin_bottom) if s == self}
end

#style(args = nil) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/shoes/style.rb', line 34

def style args = nil
  return @args unless args
  set_args args
  return if @app.cs.isDisposed

  @width = (@left + parent.width <= @app.width) ? parent.width : @app.width - @left
  @width = initials[:width] unless initials[:width].zero?
  @width = 1 unless @width > 0

  if @real
    @real.setWidth @width
    @height = @real.getBounds(0, @markup.length - 1).height
    @app.cs.redraw @left, @top, @width, @height, false unless @app.cs.isDisposed
  else
    m = self.class.to_s.downcase[7..-1]
    @app.send m, @markup, @args.merge({width: @width, create_real: true, nocontrol: true})
  end
end

#textObject



208
209
210
# File 'lib/shoes/basic.rb', line 208

def text
  @args[:markup]
end

#text=(s) ⇒ Object Also known as: replace



211
212
213
# File 'lib/shoes/basic.rb', line 211

def text= s
  style markup: s
end