Sha256: b0372f5a430e98e70e44edec37962bf3706e5470acc85bd27db8d0acc880c651
Contents?: true
Size: 1.15 KB
Versions: 7
Compression:
Stored size: 1.15 KB
Contents
require 'Qt' class CannonField < Qt::Widget signals 'angleChanged(int)' slots 'setAngle(int)' def initialize(parent = nil) super @currentAngle = 45 setPalette( Qt::Palette.new( Qt::Color.new( 250, 250, 200) ) ) setAutoFillBackground(true) end def setAngle( degrees ) if degrees < 5 degrees = 5 elsif degrees > 70 degrees = 70 end if @currentAngle == degrees return end @currentAngle = degrees repaint() emit angleChanged( @currentAngle ) end def paintEvent( event ) painter = Qt::Painter.new( self ) painter.setPen( Qt::NoPen ) painter.setBrush( Qt::Brush.new(Qt::blue) ) painter.translate( 0, rect().bottom() ) painter.drawPie( Qt::Rect.new(-35, -35, 70, 70), 0, 90*16 ) painter.rotate( - @currentAngle ) painter.drawRect( Qt::Rect.new(33, -4, 15, 8) ) painter.end() end def sizePolicy() return Qt::SizePolicy.new( Qt::SizePolicy::Expanding, Qt::SizePolicy::Expanding ) end end
Version data entries
7 entries across 7 versions & 1 rubygems