Class: SvgNativeView

Inherits:
Qt::Widget show all
Defined in:
ext/ruby/qtruby/examples/painting/svgviewer/svgview.rb

Instance Method Summary collapse

Methods inherited from Qt::Widget

#raise

Methods inherited from Qt::Base

#%, #&, #*, #**, #+, #-, #-@, #/, #<, #<<, #<=, #==, #>, #>=, #>>, #QCOMPARE, #QEXPECT_FAIL, #QFAIL, #QSKIP, #QTEST, #QVERIFY, #QVERIFY2, #QWARN, #^, ancestors, #is_a?, #methods, private_slots, #protected_methods, #public_methods, q_classinfo, q_signal, q_slot, signals, #singleton_methods, slots, #|, #~

Constructor Details

#initialize(file, parent) ⇒ SvgNativeView

Returns a new instance of SvgNativeView.



83
84
85
86
87
88
# File 'ext/ruby/qtruby/examples/painting/svgviewer/svgview.rb', line 83

def initialize(file, parent)
    super(parent)
    @doc = Qt::SvgRenderer.new(file, self)
    connect(@doc, SIGNAL(:repaintNeeded),
            self, SLOT(:update))
end

Instance Method Details

#paintEvent(event) ⇒ Object



90
91
92
93
94
95
# File 'ext/ruby/qtruby/examples/painting/svgviewer/svgview.rb', line 90

def paintEvent(event)
    p = Qt::Painter.new(self)
    p.setViewport(0, 0, width(), height())
    @doc.render(p)
       p.end
end

#sizeHintObject



97
98
99
100
101
102
# File 'ext/ruby/qtruby/examples/painting/svgviewer/svgview.rb', line 97

def sizeHint()
    if @doc
        return @doc.defaultSize()
       end
    return super()
end

#wheelEvent(e) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'ext/ruby/qtruby/examples/painting/svgviewer/svgview.rb', line 104

def wheelEvent(e)
    diff = 0.1
    size = @doc.defaultSize()
    w  = size.width()
    h = size.height()
    if e.delta() > 0
        w = (width() + width() * diff)
        h = (height() + height() * diff)
    else
        w = (width() - width() * diff)
        h = (height() - height() * diff)
    end
    resize(w, h)
end