=begin
/****************************************************************
**
** Implementation CannonField class, Qt tutorial 8
**
****************************************************************/
=end


class  CannonField < QWidget
attr_reader:angleChanged

def initialize ( parent, name )
    super( parent, name )
    @angleChanged = RSignal.new("int")
    @ang = 45
    setPalette( QPalette.new( QColor.new( 250, 250, 200,QColor::Rgb) ) )
    catchEvent
end


def setAngle( degrees )

    if ( degrees < 5 )
	degrees = 5
    elsif ( degrees > 70 )
	degrees = 70
    end
    if ( @ang == degrees )
	return
    end
    @ang = degrees
    repaint()
    @angleChanged.sendWith( @ang )
end


def paintEvent( ev )
    #s = QString.new("Angle = ") + QString::number( @ang )
    s = "Angle = #{@ang}"
    if (@p.nil?)
       @p = QPainter.new
    end
    @p.begin(self)
    print ("position = #{s}\n")
    @p.drawText( 200, 200, s )
    @p.end
end


def sizePolicy()
    QSizePolicy.new( QSizePolicy::Expanding, QSizePolicy::Expanding )
end

end
