Class: Hourglass::Runner::BrowserWrapper
- Inherits:
-
Delegator
- Object
- Delegator
- Hourglass::Runner::BrowserWrapper
- Includes:
- CloseWindowListener, OpenWindowListener, ProgressListener, TitleListener, VisibilityWindowListener
- Defined in:
- lib/hourglass/runner.rb
Instance Attribute Summary collapse
-
#browser ⇒ Object
(also: #__getobj__)
readonly
Returns the value of attribute browser.
Instance Method Summary collapse
- #changed(event) ⇒ Object
- #close(event) ⇒ Object
- #completed(event) ⇒ Object
- #hide(event) ⇒ Object
-
#initialize(shell_wrapper) ⇒ BrowserWrapper
constructor
A new instance of BrowserWrapper.
- #open(event) ⇒ Object
- #outer_body_height ⇒ Object
- #outer_body_width ⇒ Object
- #show(event) ⇒ Object
Constructor Details
#initialize(shell_wrapper) ⇒ BrowserWrapper
Returns a new instance of BrowserWrapper.
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/hourglass/runner.rb', line 69 def initialize(shell_wrapper) @shell_wrapper = shell_wrapper @browser = Swt::Browser.new(shell_wrapper.shell, Swt::SWT::NONE) @browser.add_open_window_listener(self) @browser.add_close_window_listener(self) @browser.add_visibility_window_listener(self) @browser.add_title_listener(self) @browser.add_progress_listener(self) super(@browser) end |
Instance Attribute Details
#browser ⇒ Object (readonly) Also known as: __getobj__
Returns the value of attribute browser.
66 67 68 |
# File 'lib/hourglass/runner.rb', line 66 def browser @browser end |
Instance Method Details
#changed(event) ⇒ Object
110 111 112 113 114 115 116 |
# File 'lib/hourglass/runner.rb', line 110 def changed(event) # For TitleListener and ProgressListener case event when TitleEvent @shell_wrapper.set_text(event.title) end end |
#close(event) ⇒ Object
94 95 96 97 |
# File 'lib/hourglass/runner.rb', line 94 def close(event) # For CloseWindowListener @shell_wrapper.close end |
#completed(event) ⇒ Object
118 119 120 121 |
# File 'lib/hourglass/runner.rb', line 118 def completed(event) # For ProgressListener @shell_wrapper.set_client_area_size(outer_body_width, outer_body_height); end |
#hide(event) ⇒ Object
99 100 101 102 |
# File 'lib/hourglass/runner.rb', line 99 def hide(event) # For VisibilityWindowListener @shell_wrapper.visible = false end |
#open(event) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/hourglass/runner.rb', line 80 def open(event) # For OpenWindowListener # pop-up support if event.required display = @shell_wrapper.get_display location = display.get_cursor_location popup_shell = ShellWrapper.new(display, Swt::SWT::APPLICATION_MODAL | Swt::SWT::TITLE | Swt::SWT::CLOSE | Swt::SWT::RESIZE, 'name' => 'popup', 'center' => location, 'default_size' => [675, 200]) popup_browser = BrowserWrapper.new(popup_shell) event.browser = popup_browser.browser else puts "Not required!" end end |
#outer_body_height ⇒ Object
127 128 129 |
# File 'lib/hourglass/runner.rb', line 127 def outer_body_height browser.evaluate("return $('body').outerHeight(true);") end |
#outer_body_width ⇒ Object
123 124 125 |
# File 'lib/hourglass/runner.rb', line 123 def outer_body_width browser.evaluate("return $('body').outerWidth(true);") end |
#show(event) ⇒ Object
104 105 106 107 108 |
# File 'lib/hourglass/runner.rb', line 104 def show(event) # For VisibilityWindowListener @shell_wrapper.location = event.location if event.location @shell_wrapper.open end |