Class: RubyMVC::Toolkit::WxRuby::WebView
- Inherits:
-
Wx::HtmlWindow
- Object
- Wx::HtmlWindow
- RubyMVC::Toolkit::WxRuby::WebView
show all
- Includes:
- SignalHandler, Common
- Defined in:
- lib/ruby_mvc/toolkit/peers/wxruby/web_view.rb
Instance Method Summary
collapse
Methods included from Common
#title, #title=
#signal_connect, #signal_disconnect, #signal_emit
Constructor Details
#initialize(options = {}, &block) ⇒ WebView
Returns a new instance of WebView.
34
35
36
37
38
39
40
41
42
|
# File 'lib/ruby_mvc/toolkit/peers/wxruby/web_view.rb', line 34
def initialize(options = {}, &block)
super(WxRuby.parent(options))
set_background_colour(Wx::WHITE)
if self.respond_to? :evt_html_link_clicked
evt_html_link_clicked self, :on_link_clicked
end
@history = BrowserHistory.new
end
|
Instance Method Details
#append_html(html = "", &block) ⇒ Object
91
92
93
94
95
96
97
98
|
# File 'lib/ruby_mvc/toolkit/peers/wxruby/web_view.rb', line 91
def append_html(html = "", &block)
h = html || ""
h << block.call if block
@history.current[:content] << h
append_to_page(h)
end
|
#can_go_back? ⇒ Boolean
48
49
50
|
# File 'lib/ruby_mvc/toolkit/peers/wxruby/web_view.rb', line 48
def can_go_back?
@history.has_prev?
end
|
#can_go_forward? ⇒ Boolean
52
53
54
|
# File 'lib/ruby_mvc/toolkit/peers/wxruby/web_view.rb', line 52
def can_go_forward?
@history.has_next?
end
|
#go_back ⇒ Object
56
57
58
|
# File 'lib/ruby_mvc/toolkit/peers/wxruby/web_view.rb', line 56
def go_back
load_entry @history.prev
end
|
#go_forward ⇒ Object
60
61
62
|
# File 'lib/ruby_mvc/toolkit/peers/wxruby/web_view.rb', line 60
def go_forward
load_entry @history.next
end
|
#load_html(html, base_uri = nil) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/ruby_mvc/toolkit/peers/wxruby/web_view.rb', line 77
def load_html(html, base_uri = nil)
if base_uri
if base_uri != @history.current[:uri]
@history << { :uri => base_uri, :content => html }
else
@history.current[:content] = html
end
else
@history << { :uri => base_uri, :content => html }
end
load_entry(@history.current)
end
|
#location ⇒ Object
44
45
46
|
# File 'lib/ruby_mvc/toolkit/peers/wxruby/web_view.rb', line 44
def location
@history.current
end
|
#on_link_clicked(link) ⇒ Object
– wxRuby event handlers ++
104
105
106
107
108
109
110
|
# File 'lib/ruby_mvc/toolkit/peers/wxruby/web_view.rb', line 104
def on_link_clicked(link)
if link.is_a? Wx::HtmlLinkEvent
link = link.link_info
end
signal_emit("navigation-requested", self, link.href, link.target)
end
|
#open(uri) ⇒ Object
64
65
66
67
|
# File 'lib/ruby_mvc/toolkit/peers/wxruby/web_view.rb', line 64
def open(uri)
@history << { :uri => uri }
load_entry(@history.current)
end
|
#reload ⇒ Object
73
74
75
|
# File 'lib/ruby_mvc/toolkit/peers/wxruby/web_view.rb', line 73
def reload
load_entry(@history.current)
end
|
#stop_loading ⇒ Object
69
70
71
|
# File 'lib/ruby_mvc/toolkit/peers/wxruby/web_view.rb', line 69
def stop_loading
end
|