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.
-
#layout_instructions ⇒ Object
Returns the value of attribute layout_instructions.
-
#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.
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 |
# File 'lib/gtk2html.rb', line 516 def initialize(html, irb: false) @html = html @doc = Htmle.new(html, callback: self) @area = area = Gtk::DrawingArea.new @layout = layout = Gtk::Layout.new = nil client_code = [] window = Gtk::Window.new @width = 320 @height = 240 @window = window window.set_default_size(@width, @height) @dirty = true layout.signal_connect("expose_event") do width, height = window.size @dirty = true if [@width, @height] != [width, height] if @dirty then @layout_instructions = prepare_layout @doc end drawing = Gtk2HTML::DrawingInstructions.new layout 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 layout_instructions = prepare_layout @doc = Gtk2HTML::WidgetInstructions.new layout .render layout_instructions @layout.put area, 0, 0 window.add(@layout).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.
513 514 515 |
# File 'lib/gtk2html.rb', line 513 def doc @doc end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
514 515 516 |
# File 'lib/gtk2html.rb', line 514 def height @height end |
#html ⇒ Object
Returns the value of attribute html.
513 514 515 |
# File 'lib/gtk2html.rb', line 513 def html @html end |
#layout_instructions ⇒ Object
Returns the value of attribute layout_instructions.
513 514 515 |
# File 'lib/gtk2html.rb', line 513 def layout_instructions @layout_instructions end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
514 515 516 |
# File 'lib/gtk2html.rb', line 514 def width @width end |
#window ⇒ Object (readonly)
Returns the value of attribute window.
514 515 516 |
# File 'lib/gtk2html.rb', line 514 def window @window end |
Instance Method Details
#onmousemove(x, y) ⇒ Object
593 594 595 |
# File 'lib/gtk2html.rb', line 593 def onmousemove(x,y) end |
#refresh ⇒ Object
597 598 599 600 |
# File 'lib/gtk2html.rb', line 597 def refresh() @dirty = true @area.queue_draw end |