kchart

kchartParameterPieConfigPage.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2001,2002,2003,2004 Laurent Montel <montel@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include "kchartParameterPieConfigPage.h"
21
22#include "kchartParameterPieConfigPage.moc"
23
24#include <tdeapplication.h>
25#include <tdelocale.h>
26#include <kdebug.h>
27#include <kdialog.h>
28
29#include <tqlayout.h>
30#include <tqlabel.h>
31#include <tqbuttongroup.h>
32#include <tqcheckbox.h>
33#include <tqlineedit.h>
34#include <tqradiobutton.h>
35#include <tqspinbox.h>
36#include <tqvbuttongroup.h>
37#include <tqwhatsthis.h>
38
39#include "kchart_params.h"
40
41namespace KChart
42{
43
44KChartParameterPieConfigPage::KChartParameterPieConfigPage( KChartParams* params,
45 TQWidget* parent ) :
46 TQWidget( parent ),_params( params )
47{
48 TQVBoxLayout *toplevel = new TQVBoxLayout( this, 10 );
49 TQVBoxLayout *grid1 = new TQVBoxLayout(this);
50 toplevel->addLayout( grid1 );
51
52 TQVButtonGroup* gb = new TQVButtonGroup( i18n( "Parameter" ), this );
53 grid1->addWidget(gb);
54
55 pie3d = new TQCheckBox(i18n("Pie 3D"), gb);
56 TQWhatsThis::add(pie3d, i18n("Uncheck this option if you do not want a 3D effect for your pie."));
57 drawShadowColor=new TQCheckBox(i18n("Draw shadow color"), gb);
58 TQWhatsThis::add(drawShadowColor, i18n("Uncheck this option if you do not want a shadow color on a 3D pie."));
59
60 TQLabel *label = new TQLabel( i18n( "Explode factor (%):" ), gb );
61 explode = new TQSpinBox(0, 100, 1, gb);
62 TQWhatsThis::add(explode, i18n("This will place gaps between the segments of your pie. Default is 0 which means the pie is a whole."));
63
64 label = new TQLabel( i18n( "Start angle:" ), gb );
65 angle = new TQSpinBox(0, 90, 1, gb);
66 TQWhatsThis::add(angle, i18n("This will set the orientation of your pie. Default is 0."));
67
68 label = new TQLabel( i18n( "3D-depth:" ), gb );
69 depth = new TQSpinBox(0, 40, 1, gb);
70 TQWhatsThis::add(depth, i18n("Set the depth from 0 to 40 of the 3D effect, if you have checked Pie 3D. Default is 20."));
71
72 grid1->activate();
73
74 connect(pie3d,TQ_SIGNAL(toggled ( bool )),this, TQ_SLOT(active3DPie(bool)));
75}
76
77void KChartParameterPieConfigPage::active3DPie(bool b)
78{
79 drawShadowColor->setEnabled(b);
80 depth->setEnabled(b);
81}
82
83void KChartParameterPieConfigPage::init()
84{
85 bool state=_params->threeDPies();
86 pie3d->setChecked(state);
87 depth->setEnabled(state);
88 active3DPie(state);
89
90 explode->setValue((int)(_params->explodeFactor() * 100));
91 depth->setValue( _params->threeDPieHeight() );
92 drawShadowColor->setChecked(_params->threeDShadowColors());
93 angle->setValue( _params->pieStart() );
94
95}
96
97
98void KChartParameterPieConfigPage::apply()
99{
100 _params->setThreeDPies( pie3d->isChecked() );
101 if( _params->threeDPies() ) {
102 _params->setThreeDPieHeight( depth->value() );
103 }
104 _params->setThreeDShadowColors( drawShadowColor->isChecked());
105 _params->setExplodeFactor(((double)(explode->value()))/100.0);
106 _params->setPieStart( angle->value() );
107}
108
109} //KChart namespace