kchart

kchartParameter3dConfigPage.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 "kchartParameter3dConfigPage.h"
21#include "kchartParameter3dConfigPage.moc"
22
23#include <tdeapplication.h>
24#include <kdialog.h>
25#include <tdelocale.h>
26#include <tqlayout.h>
27#include <tqlabel.h>
28#include <tqcheckbox.h>
29#include <tqbuttongroup.h>
30#include <tqwhatsthis.h>
31
32#include "kchart_params.h"
33
34namespace KChart
35{
36
37KChartParameter3dConfigPage::KChartParameter3dConfigPage( KChartParams* params,
38 TQWidget* parent ) :
39 TQWidget( parent ),m_params( params )
40{
41 TQGridLayout* layout = new TQGridLayout(this, 2, 2,KDialog::marginHint(),KDialog::spacingHint());
42
43
44 TQButtonGroup* gb = new TQButtonGroup( 0, TQt::Vertical,
45 i18n("3D Parameters"), this );
46 gb->layout()->setSpacing(KDialog::spacingHint());
47 gb->layout()->setMargin(KDialog::marginHint());
48
49 // The grid layout inside the buttongroup.
50 TQGridLayout *grid1 = new TQGridLayout(gb->layout(), 5, 3);
51 layout->addWidget(gb,0,0);
52
53 // The main on/off checkbox.
54 bar3d=new TQCheckBox(i18n("3D bar"),gb);
55 TQWhatsThis::add(bar3d, i18n("If checked, this will enable 3D mode for viewing the bars. You can then add a shadow and set the angle and depth for 3D."));
56 grid1->addWidget(bar3d,0,0);
57
58 connect(bar3d, TQ_SIGNAL(toggled ( bool )),
59 this, TQ_SLOT(slotChange3DParameter(bool)));
60
61 // Checkbox for shadows
62 drawShadowColor=new TQCheckBox(i18n("Draw dark shadow"),gb);
63 TQWhatsThis::add(drawShadowColor, i18n("If checked, this will add a dark shadow on the 3D bars."));
64 grid1->addWidget(drawShadowColor,1,0);
65
66 TQLabel *tmpLabel = new TQLabel( i18n( "Angle:" ), gb );
67 tmpLabel->resize( tmpLabel->sizeHint() );
68 grid1->addWidget(tmpLabel,2,0);
69
70 angle3d=new KIntNumInput(0, gb, 10);
71 TQWhatsThis::add(angle3d, i18n("You can set here the angle for the 3D effect from 0 to 90. 90 will give you flat bars without any 3D effect.\nDefault is 45."));
72 grid1->addWidget(angle3d,2,1);
73 angle3d->setRange(0, 90, 1);
74
75 tmpLabel = new TQLabel( i18n( "Depth:" ), gb );
76 tmpLabel->resize( tmpLabel->sizeHint() );
77 grid1->addWidget(tmpLabel,3,0);
78
79 depth=new KDoubleNumInput(0, gb);
80 TQWhatsThis::add(depth, i18n("You can set here the depth of the 3D effect from 0 to 2. 0 will give you no depth at all.\nDefault is 1."));
81 depth->resize(100,depth->sizeHint().height());
82 grid1->addWidget(depth,3,1);
83 depth->setRange(0, 2.0, 0.1);
84
85 gb->setAlignment(TQt::AlignLeft);
86 grid1->addColSpacing(0,depth->width());
87 grid1->addColSpacing(0,angle3d->width());
88 grid1->setColStretch(2,1);
89 grid1->setRowStretch(4,1);
90
91 //it's not good but I don't know how
92 //to reduce space
93 //layout->addColSpacing(1,300);
94}
95
96
97void KChartParameter3dConfigPage::slotChange3DParameter(bool b)
98{
99 angle3d->setEnabled(b);
100 depth->setEnabled(b);
101 drawShadowColor->setEnabled(b);
102}
103
104
105void KChartParameter3dConfigPage::init()
106{
107 bool state=m_params->threeDBars();
108 bar3d->setChecked(state);
109
110 drawShadowColor->setChecked(m_params->threeDShadowColors());
111 angle3d->setValue( m_params->threeDBarAngle() );
112 depth->setValue( m_params->threeDBarDepth() );
113 slotChange3DParameter(state);
114}
115
116
117void KChartParameter3dConfigPage::apply()
118{
119 m_params->setThreeDBars(bar3d->isChecked());
120 m_params->setThreeDBarAngle( angle3d->value() );
121 m_params->setThreeDBarDepth( depth->value() );
122 m_params->setThreeDShadowColors( drawShadowColor->isChecked());
123}
124
125
126} //KChart namespace