Class: Shoes::TextBlock
- Defined in:
- lib/shoes/basic.rb,
lib/shoes/style.rb
Instance Attribute Summary collapse
-
#cursor ⇒ Object
Returns the value of attribute cursor.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#textcursor ⇒ Object
Returns the value of attribute textcursor.
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
- #clear ⇒ Object
- #hit(x, y) ⇒ Object
-
#initialize(args) ⇒ TextBlock
constructor
A new instance of TextBlock.
- #move(x, y) ⇒ Object
- #positioning(x, y, max) ⇒ Object
- #style(args = nil) ⇒ Object
- #text ⇒ Object
- #text=(s) ⇒ Object (also: #replace)
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.
210 211 212 213 |
# File 'lib/shoes/basic.rb', line 210 def initialize args @links = [] super end |
Instance Attribute Details
#cursor ⇒ Object
Returns the value of attribute cursor.
215 216 217 |
# File 'lib/shoes/basic.rb', line 215 def cursor @cursor end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
214 215 216 |
# File 'lib/shoes/basic.rb', line 214 def links @links end |
#textcursor ⇒ Object
Returns the value of attribute textcursor.
215 216 217 |
# File 'lib/shoes/basic.rb', line 215 def textcursor @textcursor end |
Instance Method Details
#clear ⇒ Object
231 232 233 234 235 |
# File 'lib/shoes/basic.rb', line 231 def clear @links.each &:clear @links.clear super end |
#hit(x, y) ⇒ Object
236 237 238 239 240 241 242 243 244 245 |
# File 'lib/shoes/basic.rb', line 236 def hit x, y x -= @left; y -= @top h = @real.getLineBounds(0).height text.length.times do |n| s = @real.getLocation n, false e = @real.getLocation n, true return n if (s.x..e.x).include?(x) and (s.y..(e.y+h)).include?(y) end return nil end |
#move(x, y) ⇒ Object
227 228 229 230 |
# File 'lib/shoes/basic.rb', line 227 def move x, y self.text = @args[:markup] super end |
#positioning(x, y, max) ⇒ Object
223 224 225 226 |
# File 'lib/shoes/basic.rb', line 223 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 |
#text ⇒ Object
216 217 218 |
# File 'lib/shoes/basic.rb', line 216 def text @args[:markup] end |
#text=(s) ⇒ Object Also known as: replace
219 220 221 |
# File 'lib/shoes/basic.rb', line 219 def text= s style markup: s end |