kpresenter

KPrPiePreview.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2005 Thorsten Zachmann <zachmann@kde.org>
3 based on work by
4 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20*/
21
22#include "KPrPiePreview.h"
23
24#include <tqpainter.h>
25
26KPrPiePreview::KPrPiePreview( TQWidget* parent, const char* name )
27 : TQFrame( parent, name )
28{
29 setFrameStyle( WinPanel | Sunken );
30 setBackgroundColor( white );
31 angle = 720; //45 * 16
32 len = 1440; //90 * 16
33 pen = TQPen( black );
34 brush = TQBrush( white );
35 type = PT_PIE;
36
37 setMinimumSize( 200, 100 );
38}
39
40void KPrPiePreview::drawContents( TQPainter* painter )
41{
42 int ow = width() - 8;
43 int oh = height() - 8;
44
45 painter->setPen( pen );
46 int pw = pen.width();
47 painter->setBrush( brush );
48
49 switch ( type )
50 {
51 case PT_PIE:
52 painter->drawPie( pw + 4, pw + 4, ow - 2 * pw, oh - 2 * pw, angle, len );
53 break;
54 case PT_ARC:
55 painter->drawArc( pw + 4, pw + 4, ow - 2 * pw, oh - 2 * pw, angle, len );
56 break;
57 case PT_CHORD:
58 painter->drawChord( pw + 4, pw + 4, ow - 2 * pw, oh - 2 * pw, angle, len );
59 break;
60 default:
61 break;
62 }
63}
64
65#include "KPrPiePreview.moc"