Class: RenderArea

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

Overview

** ** Copyright © 2004-2005 Trolltech AS. All rights reserved. ** ** This file is part of the example classes of the Qt Toolkit. ** ** This file may be used under the terms of the GNU General Public ** License version 2.0 as published by the Free Software Foundation ** and appearing in the file LICENSE.GPL included in the packaging of ** this file. Please review the following information to ensure GNU ** General Public Licensing requirements will be met: ** www.trolltech.com/products/qt/opensource.html ** ** If you are unsure which license is appropriate for your use, please ** review the following information: ** www.trolltech.com/products/qt/licensing.html or contact the ** sales department at [email protected]. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. **

** Translated to QtRuby by Richard Dale

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(path, parent = nil) ⇒ RenderArea

Returns a new instance of RenderArea.



34
35
36
37
38
39
40
41
42
43
44
# File 'ext/ruby/qtruby/examples/painting/painterpaths/renderarea.rb', line 34

def initialize(path, parent = nil)
    super(parent)
    @penWidth = 1
    @rotationAngle = 0
  @path = path
  @fillColor1 = Qt::Color.new
  @fillColor2 = Qt::Color.new
  @penWidth = 0
  @penColor = Qt::Color.new
    setBackgroundRole(Qt::Palette::Base)
end

Instance Method Details

#fillRule=(rule) ⇒ Object



54
55
56
57
# File 'ext/ruby/qtruby/examples/painting/painterpaths/renderarea.rb', line 54

def fillRule=(rule)
    @path.fillRule = rule
    update()
end

#minimumSizeHintObject



46
47
48
# File 'ext/ruby/qtruby/examples/painting/painterpaths/renderarea.rb', line 46

def minimumSizeHint()
    return Qt::Size.new(50, 50)
end

#paintEvent(event) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'ext/ruby/qtruby/examples/painting/painterpaths/renderarea.rb', line 80

def paintEvent(event)
    painter = Qt::Painter.new(self)
    painter.renderHint = Qt::Painter::Antialiasing
    painter.scale(width() / 100.0, height() / 100.0)
    painter.translate(50.0, 50.0)
    painter.rotate(-@rotationAngle)
    painter.translate(-50.0, -50.0)

    painter.pen = Qt::Pen.new(Qt::Brush.new(@penColor), @penWidth, Qt::SolidLine, Qt::RoundCap,
                        Qt::RoundJoin)
    gradient = Qt::LinearGradient.new(0, 0, 0, 100)
    gradient.setColorAt(0.0, @fillColor1)
    gradient.setColorAt(1.0, @fillColor2)
    painter.brush = Qt::Brush.new(gradient)
    painter.drawPath(@path)
  painter.end
end

#penColor=(color) ⇒ Object



70
71
72
73
# File 'ext/ruby/qtruby/examples/painting/painterpaths/renderarea.rb', line 70

def penColor=(color)
    @penColor = color
    update()
end

#penWidth=(width) ⇒ Object



65
66
67
68
# File 'ext/ruby/qtruby/examples/painting/painterpaths/renderarea.rb', line 65

def penWidth=(width)
    @penWidth = width
    update()
end

#rotationAngle=(degrees) ⇒ Object



75
76
77
78
# File 'ext/ruby/qtruby/examples/painting/painterpaths/renderarea.rb', line 75

def rotationAngle=(degrees)
    @rotationAngle = degrees
    update()
end

#setFillGradient(color1, color2) ⇒ Object



59
60
61
62
63
# File 'ext/ruby/qtruby/examples/painting/painterpaths/renderarea.rb', line 59

def setFillGradient(color1, color2)
    @fillColor1 = color1
    @fillColor2 = color2
    update()
end

#sizeHintObject



50
51
52
# File 'ext/ruby/qtruby/examples/painting/painterpaths/renderarea.rb', line 50

def sizeHint()
    return Qt::Size.new(100, 100)
end