Class: Shul::Window

Inherits:
Object
  • Object
show all
Defined in:
lib/shul.rb

Defined Under Namespace

Classes: Radiogroup

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shoes, doc) ⇒ Window

Returns a new instance of Window.



412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
# File 'lib/shul.rb', line 412

def initialize(shoes, doc)
  
  @shoes = shoes
  @width, @height = 100, 100
  
  @doc = doc
  
  def @doc.element_by_id(id)
    self.root.element("//*[@id='#{id}']")
  end      

  @doc.root.elements.each do |x| 
    method(x.name.sub(':','_').to_sym).call(x) unless x.name == 'script'
  end   
  
  @doc.root.xpath('script').each {|x| script x }
  
  h = @doc.root.attributes
  
  if h[:onkeypress] then
    shoes.keypress do |k| 
      method(h[:onkeypress][/^[a-z]\w+/].to_sym).call(k)
    end
  end
  
  icon = h[:icon]
  
  if icon then
    
    file = Tempfile.new('shoes').path
    File.write file, RXFHelper.read(icon).first
    shoes.win.icon = file
    
  end

end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



410
411
412
# File 'lib/shul.rb', line 410

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



410
411
412
# File 'lib/shul.rb', line 410

def width
  @width
end

Class Method Details

.element_by_id(id) ⇒ Object



419
420
421
# File 'lib/shul.rb', line 419

def @doc.element_by_id(id)
  self.root.element("//*[@id='#{id}']")
end

Instance Method Details

#add_element(node) ⇒ Object



449
450
451
452
453
454
# File 'lib/shul.rb', line 449

def add_element(node)

  node.obj = method(node.name.sub(':','_').to_sym).call(node)            
  refresh()

end

#refreshObject



456
457
458
# File 'lib/shul.rb', line 456

def refresh
  @shoes.flush if @shoes
end

#remove_element(node) ⇒ Object



460
461
462
463
# File 'lib/shul.rb', line 460

def remove_element(node)
  node.obj.clear
  refresh()
end