Sha256: 173496c694171ae27c73264ce9cfb1aea6c73942ff4cd0658aad4f95c90ab00b
Contents?: true
Size: 983 Bytes
Versions: 7
Compression:
Stored size: 983 Bytes
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 & 2 rubygems