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
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 |
# File 'lib/gtk2html.rb', line 413 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.
410 411 412 |
# File 'lib/gtk2html.rb', line 410 def doc @doc end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
411 412 413 |
# File 'lib/gtk2html.rb', line 411 def height @height end |
#html ⇒ Object
Returns the value of attribute html.
410 411 412 |
# File 'lib/gtk2html.rb', line 410 def html @html end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
411 412 413 |
# File 'lib/gtk2html.rb', line 411 def width @width end |
#window ⇒ Object (readonly)
Returns the value of attribute window.
411 412 413 |
# File 'lib/gtk2html.rb', line 411 def window @window end |
Instance Method Details
#onmousemove(x, y) ⇒ Object
483 484 485 |
# File 'lib/gtk2html.rb', line 483 def onmousemove(x,y) end |
#refresh ⇒ Object
487 488 489 490 |
# File 'lib/gtk2html.rb', line 487 def refresh() @dirty = true @area.queue_draw end |