Class: Hourglass::Runner::ShellWrapper

Inherits:
Delegator
  • Object
show all
Includes:
ShellListener
Defined in:
lib/hourglass/runner.rb

Constant Summary collapse

@@sizes =
{}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ShellWrapper

Returns a new instance of ShellWrapper.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/hourglass/runner.rb', line 21

def initialize(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  @name = options['name']
  @shell = Swt::Widgets::Shell.new(*args)

  width, height = @@sizes[name] || options['default_size'] || [600, 400]
  @shell.set_size(width, height)

  if options['center']
    pt = options['center']
    @shell.set_location(pt.x - (width / 2), pt.y - (height / 2))
  end
  @shell.layout = Swt::Layout::FillLayout.new
  @shell.add_shell_listener(self)
  super(@shell)
end

Instance Attribute Details

#frame_xObject (readonly)

Returns the value of attribute frame_x.



16
17
18
# File 'lib/hourglass/runner.rb', line 16

def frame_x
  @frame_x
end

#frame_yObject (readonly)

Returns the value of attribute frame_y.



16
17
18
# File 'lib/hourglass/runner.rb', line 16

def frame_y
  @frame_y
end

#nameObject (readonly)

Returns the value of attribute name.



16
17
18
# File 'lib/hourglass/runner.rb', line 16

def name
  @name
end

#shellObject (readonly) Also known as: __getobj__

Returns the value of attribute shell.



16
17
18
# File 'lib/hourglass/runner.rb', line 16

def shell
  @shell
end

Instance Method Details

#set_client_area_size(width, height) ⇒ Object



54
55
56
# File 'lib/hourglass/runner.rb', line 54

def set_client_area_size(width, height)
  @shell.set_size(width + @frame_x, height + @frame_y)
end

#shellActivated(event) ⇒ Object



48
49
50
51
52
# File 'lib/hourglass/runner.rb', line 48

def shellActivated(event)
  client_area = @shell.client_area
  @frame_x = @shell.size.x - client_area.width
  @frame_y = @shell.size.y - client_area.height
end

#shellClosed(event) ⇒ Object



42
43
44
45
46
# File 'lib/hourglass/runner.rb', line 42

def shellClosed(event)
  # remember the shell size
  point = @shell.get_size
  @@sizes[@name] = [point.x, point.y]
end

#shellDeactivated(event) ⇒ Object



41
# File 'lib/hourglass/runner.rb', line 41

def shellDeactivated(event); end

#shellDeiconified(event) ⇒ Object



40
# File 'lib/hourglass/runner.rb', line 40

def shellDeiconified(event); end

#shellIconified(event) ⇒ Object

To satisfy ShellListener



39
# File 'lib/hourglass/runner.rb', line 39

def shellIconified(event); end