diff options
Diffstat (limited to 'tutorial/t8/cannon.cpp')
-rw-r--r-- | tutorial/t8/cannon.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tutorial/t8/cannon.cpp b/tutorial/t8/cannon.cpp new file mode 100644 index 000000000..d5f3b6ba0 --- /dev/null +++ b/tutorial/t8/cannon.cpp @@ -0,0 +1,45 @@ +/**************************************************************** +** +** Implementation CannonField class, TQt tutorial 8 +** +****************************************************************/ + +#include "cannon.h" +#include <qpainter.h> + + +CannonField::CannonField( TQWidget *parent, const char *name ) + : TQWidget( parent, name ) +{ + ang = 45; + setPalette( TQPalette( TQColor( 250, 250, 200) ) ); +} + + +void CannonField::setAngle( int degrees ) +{ + if ( degrees < 5 ) + degrees = 5; + if ( degrees > 70 ) + degrees = 70; + if ( ang == degrees ) + return; + ang = degrees; + repaint(); + emit angleChanged( ang ); +} + + +void CannonField::paintEvent( TQPaintEvent * ) +{ + TQString s = "Angle = " + TQString::number( ang ); + TQPainter p( this ); + p.drawText( 200, 200, s ); +} + + +TQSizePolicy CannonField::sizePolicy() const +{ + return TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Expanding ); +} + |