Module: Bowline::Desktop::WindowMethods

Included in:
MainWindow, Window
Defined in:
lib/bowline/desktop/window_methods.rb

Overview

:nodoc:

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object

The methods won’t exist on window if Bowline::Desktop isn’t enabled



74
75
76
# File 'lib/bowline/desktop/window_methods.rb', line 74

def method_missing(sym, *args)
  Bowline::Desktop.enabled? ? super : nil
end

Instance Method Details

#center(direction = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/bowline/desktop/window_methods.rb', line 6

def center(direction = nil)
  direction = 
  case direction
  when :both       then Window::BOTH
  when :horizontal then Window::HORIZONTAL
  when :vertical   then Window::VERTICAL
  when :center     then Window::CENTRE_ON_SCREEN
  else
    Window::BOTH
  end
  _center(direction)
end

#deallocated?Boolean

Window was shut; setup! needs to be called again

Returns:

  • (Boolean)


68
69
70
# File 'lib/bowline/desktop/window_methods.rb', line 68

def deallocated?
  id == -1
end

#file=(path) ⇒ Object Also known as: load_file



19
20
21
22
23
24
25
26
27
28
# File 'lib/bowline/desktop/window_methods.rb', line 19

def file=(path)
  if path.is_a?(Symbol)
    path = File.join(APP_ROOT, "public", path.to_s)
  end
  if File.extname(path).blank?
    path += ".html"
  end
  path = File.expand_path(path, APP_ROOT)
  self._file = path
end

#height=(h) ⇒ Object



62
63
64
# File 'lib/bowline/desktop/window_methods.rb', line 62

def height=(h)
  set_size(-1, h)
end

#select_dir(options = {}) ⇒ Object



54
55
56
# File 'lib/bowline/desktop/window_methods.rb', line 54

def select_dir(options = {})
  _select_dir(options[:message], options[:default_path])
end

#select_file(options = {}) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/bowline/desktop/window_methods.rb', line 38

def select_file(options = {})
  flags = 0
  flags |= Window::FD_OPEN if options[:open]
  flags |= Window::FD_SAVE if options[:save]
  flags |= Window::FD_OVERWRITE_PROMPT if options[:overwrite_prompt]
  flags |= Window::FD_FILE_MUST_EXIST  if options[:file_must_exist]
  _select_file(
    options[:message],
    options[:default_path],
    options[:default_filename],
    options[:default_extension],
    options[:wildcard],
    flags
  )
end

#url=(address) ⇒ Object



31
32
33
34
35
36
# File 'lib/bowline/desktop/window_methods.rb', line 31

def url=(address)
  unless address.is_a?(URI)
    address = URI.parse(address)
  end
  self._url = address.to_s
end

#width=(w) ⇒ Object



58
59
60
# File 'lib/bowline/desktop/window_methods.rb', line 58

def width=(w)
  set_size(w, -1)
end