Class: Gtk2HTML::Main
- Inherits:
-
Object
- Object
- Gtk2HTML::Main
- Defined in:
- lib/gtk2html.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
Returns the value of attribute doc.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#html ⇒ Object
Returns the value of attribute html.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
-
#window ⇒ Object
readonly
Returns the value of attribute window.
Instance Method Summary collapse
-
#initialize(html, irb: false) ⇒ Main
constructor
A new instance of Main.
- #onmousemove(x, y) ⇒ Object
- #refresh ⇒ Object
Constructor Details
#initialize(html, irb: false) ⇒ Main
Returns a new instance of Main.
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 |
# File 'lib/gtk2html.rb', line 362 def initialize(html, irb: false) @html = html @doc = Htmle.new(html, callback: self) @area = area = Gtk::DrawingArea.new client_code = [] window = Gtk::Window.new @width = 320 @height = 240 @window = window window.set_default_size(@width, @height) @dirty = true area.signal_connect("expose_event") do width, height = window.size @dirty = true if [@width, @height] != [width, height] if @dirty then Thread.new { @doc.root.xpath('//script').each {|x| eval x.text.unescape } } @width, @height = window.size instructions = Gtk2HTML::Render.new(@doc, @width, @height).to_a @layout_instructions = Gtk2HTML::Layout.new(instructions).to_a end drawing = Gtk2HTML::DrawingInstructions.new area drawing.render @layout_instructions @dirty = false end area.add_events(Gdk::Event::POINTER_MOTION_MASK) area.signal_connect('motion_notify_event') do |item, event| @doc.root.xpath('//*[@onmousemove]').each do |x| eval x.onmousemove() if x.hotspot? event.x, event.y end end area.add_events(Gdk::Event::BUTTON_PRESS_MASK) area.signal_connect "button_press_event" do |item,event| @doc.root.xpath('//*[@onmousedown]').each do |x| eval x.onmousedown() if x.hotspot? event.x, event.y end end window.add(area).show_all window.show_all.signal_connect("destroy"){Gtk.main_quit} irb ? Thread.new {Gtk.main } : Gtk.main end |
Instance Attribute Details
#doc ⇒ Object
Returns the value of attribute doc.
359 360 361 |
# File 'lib/gtk2html.rb', line 359 def doc @doc end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
360 361 362 |
# File 'lib/gtk2html.rb', line 360 def height @height end |
#html ⇒ Object
Returns the value of attribute html.
359 360 361 |
# File 'lib/gtk2html.rb', line 359 def html @html end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
360 361 362 |
# File 'lib/gtk2html.rb', line 360 def width @width end |
#window ⇒ Object (readonly)
Returns the value of attribute window.
360 361 362 |
# File 'lib/gtk2html.rb', line 360 def window @window end |
Instance Method Details
#onmousemove(x, y) ⇒ Object
432 433 434 |
# File 'lib/gtk2html.rb', line 432 def onmousemove(x,y) end |
#refresh ⇒ Object
436 437 438 439 |
# File 'lib/gtk2html.rb', line 436 def refresh() @dirty = true @area.queue_draw end |