23#include "KPrPolygonPreview.h"
29KPrPolygonPreview::KPrPolygonPreview( TQWidget* parent,
const char* name)
30 : TQFrame( parent, name )
32 setFrameStyle( WinPanel | Sunken );
33 setBackgroundColor( white );
35 setMinimumSize( 200, 100 );
39void KPrPolygonPreview::drawContents( TQPainter *painter )
41 double angle = 2 * M_PI / nCorners;
42 double diameter =
static_cast<double>( TQMAX( width(), height() ) - 10 );
43 double radius = diameter * 0.5;
45 painter->setWindow( tqRound( -radius ), tqRound( -radius ), tqRound( diameter ), tqRound( diameter ) );
46 painter->setViewport( 5, 5, width() - 10, height() - 10 );
47 painter->setPen( pen );
48 painter->setBrush( brush );
50 TQPointArray points( isConcave ? nCorners * 2 : nCorners );
51 points.setPoint( 0, 0, tqRound( -radius ) );
56 double r = radius - ( sharpness / 100.0 * radius );
57 for (
int i = 1; i < nCorners * 2; ++i ) {
64 xp = radius * sin( a );
65 yp = -radius * cos( a );
68 points.setPoint( i, (
int)xp, (
int)yp );
73 for (
int i = 1; i < nCorners; ++i ) {
74 double xp = radius * sin( a );
75 double yp = -radius * cos( a );
77 points.setPoint( i, (
int)xp, (
int)yp );
80 painter->drawPolygon( points );
84void KPrPolygonPreview::slotConvexConcave(
bool convexConcave )
86 isConcave = convexConcave;
91void KPrPolygonPreview::slotConvexPolygon()
98void KPrPolygonPreview::slotConcavePolygon()
105void KPrPolygonPreview::slotCornersValue(
int value )
112void KPrPolygonPreview::slotSharpnessValue(
int value )
119#include "KPrPolygonPreview.moc"