Class: Java::OrgEclipseSwtWidgets::Widget

Inherits:
Object
  • Object
show all
Includes:
Sweet::Component
Defined in:
lib/sweet/swt/widget.rb

Instance Attribute Summary

Attributes included from Sweet::Component

#app

Instance Method Summary collapse

Methods included from Sweet::Component

#append, included, #meta, #method_missing, #options=, #perform, #sweeten

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Sweet::Component

Instance Method Details

#grid_data=(*options) ⇒ Object

TODO unify this layout mess somehow TODO hierarchical hash for nicer client code



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sweet/swt/widget.rb', line 14

def grid_data=(*options)
  opts = {}
  options.each do |(k, v)|
    opts[k] = v
  end
  ax, ay = opts[:align]
  gx, gy = opts[:grab]
  sx, sy = opts[:span]
  args = [ax || swt::BEGINNING, ay || swt::CENTER,
    gx || false, gy || false, sx || 1, sy || 1]
  puts args.inspect
  args.map!{|v| v.is_a?(Symbol) ? v.swt_const : v}
  Sweet.debug args.inspect
  l = layouts::GridData.new(*args)
  self.layout_data = l
end

#heightObject



49
50
51
# File 'lib/sweet/swt/widget.rb', line 49

def height
  size.y
end

#height=(value) ⇒ Object



52
53
54
# File 'lib/sweet/swt/widget.rb', line 52

def height=(value)
  self.size = nil, value
end

#hideObject



34
35
36
# File 'lib/sweet/swt/widget.rb', line 34

def hide
  self.visible = false
end


65
66
67
# File 'lib/sweet/swt/widget.rb', line 65

def popup(&block)
  self.menu = make_menu(:popup, &block)
end

#row_data=(x, y = nil) ⇒ Object



30
31
32
# File 'lib/sweet/swt/widget.rb', line 30

def row_data=(x, y = nil)
  self.layout_data = layouts::RowData.new(x || swt::DEFAULT, y || swt::DEFAULT)
end

#showObject



37
38
39
# File 'lib/sweet/swt/widget.rb', line 37

def show
  self.visible = true
end

#size=(*s) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/sweet/swt/widget.rb', line 56

def size=(*s)
  Sweet.debug "size=(#{s.inspect})"
  nw, nh = s.flatten
  nw ||= width
  nh ||= height
  Sweet.debug "setSize(#{nw.inspect}, #{nh.inspect})"
  setSize(nw, nh)
end

#sweet_block_handler(handler, &block) ⇒ Object



6
7
8
9
10
# File 'lib/sweet/swt/widget.rb', line 6

def sweet_block_handler(handler, &block)
  return false unless handler.is_a? Numeric
  addListener handler, &block
  true
end

#widthObject



41
42
43
# File 'lib/sweet/swt/widget.rb', line 41

def width
  size.x
end

#width=(value) ⇒ Object



44
45
46
47
# File 'lib/sweet/swt/widget.rb', line 44

def width=(value)
  Sweet.debug "width=(#{value.inspect})"
  setSize(value, height)
end