Class: RobotHead
- Defined in:
- ext/ruby/qtruby/examples/graphicsview/dragdroprobot/robot.rb
Constant Summary collapse
- Type =
Qt::GraphicsItem::UserType + 1
Instance Method Summary collapse
- #boundingRect ⇒ Object
-
#initialize(parent) ⇒ RobotHead
constructor
A new instance of RobotHead.
- #paint(painter, option, widget) ⇒ Object
- #type ⇒ Object
Methods inherited from RobotPart
#dragEnterEvent, #dragLeaveEvent, #dropEvent
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(parent) ⇒ RobotHead
Returns a new instance of RobotHead.
66 67 68 |
# File 'ext/ruby/qtruby/examples/graphicsview/dragdroprobot/robot.rb', line 66 def initialize(parent) super(parent) end |
Instance Method Details
#boundingRect ⇒ Object
70 71 72 |
# File 'ext/ruby/qtruby/examples/graphicsview/dragdroprobot/robot.rb', line 70 def boundingRect return Qt::RectF.new(-15, -50, 30, 50) end |
#paint(painter, option, widget) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'ext/ruby/qtruby/examples/graphicsview/dragdroprobot/robot.rb', line 74 def paint(painter, option, ) if @pixmap.null? painter.brush = Qt::Brush.new(@dragOver ? @color.light(130) : @color) painter.drawRoundRect(-10, -30, 20, 30) painter.brush = Qt::Brush.new(Qt::white) painter.drawEllipse(-7, -3 - 20, 7, 7) painter.drawEllipse(0, -3 - 20, 7, 7) painter.brush = Qt::Brush.new(Qt::black) painter.drawEllipse(-5, -1 - 20, 2, 2) painter.drawEllipse(2, -1 - 20, 2, 2) painter.pen = Qt::Pen.new(Qt::Brush.new(Qt::black), 2) painter.brush = Qt::NoBrush painter.drawArc(-6, -2 - 20, 12, 15, 190 * 16, 160 * 16) else painter.scale(0.2272, 0.2824) painter.drawPixmap(Qt::PointF.new(-15 * 4.4, -50 * 3.54), @pixmap) end end |