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.



452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
# File 'lib/shul.rb', line 452

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.



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

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



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

def width
  @width
end

Class Method Details

.element_by_id(id) ⇒ Object



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

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

Instance Method Details

#add_element(node) ⇒ Object



490
491
492
493
494
495
# File 'lib/shul.rb', line 490

def add_element(node)

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

end

#refreshObject



497
498
499
# File 'lib/shul.rb', line 497

def refresh
  @shoes.flush if @shoes
end

#remove_element(node) ⇒ Object



501
502
503
504
505
506
# File 'lib/shul.rb', line 501

def remove_element(node)

  node.obj.clear
  node.obj = nil
  refresh()
end