summaryrefslogtreecommitdiffstats
path: root/kchart/kchartParameter3dConfigPage.cc
blob: 760c978610e9f78ff09be4448c92c643501df13b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/* This file is part of the KDE project
   Copyright (C) 2001,2002,2003,2004 Laurent Montel <montel@kde.org>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#include "kchartParameter3dConfigPage.h"
#include "kchartParameter3dConfigPage.moc"

#include <kapplication.h>
#include <kdialog.h>
#include <klocale.h>
#include <tqlayout.h>
#include <tqlabel.h>
#include <tqcheckbox.h>
#include <tqbuttongroup.h>
#include <tqwhatsthis.h>

#include "kchart_params.h"

namespace KChart
{

KChartParameter3dConfigPage::KChartParameter3dConfigPage( KChartParams* params,
                                                          TQWidget* parent ) :
    TQWidget( parent ),m_params( params )
{
  TQGridLayout* tqlayout = new TQGridLayout(this, 2, 2,KDialog::marginHint(),KDialog::spacingHint());


  TQButtonGroup* gb = new TQButtonGroup( 0, Qt::Vertical, 
				       i18n("3D Parameters"), this );
  gb->tqlayout()->setSpacing(KDialog::spacingHint());
  gb->tqlayout()->setMargin(KDialog::marginHint());

  // The grid tqlayout inside the buttongroup.
  TQGridLayout *grid1 = new TQGridLayout(gb->tqlayout(), 5, 3);
  tqlayout->addWidget(gb,0,0);

  // The main on/off checkbox.
  bar3d=new TQCheckBox(i18n("3D bar"),gb);
  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."));
  grid1->addWidget(bar3d,0,0);

  connect(bar3d, TQT_SIGNAL(toggled ( bool )),
	  this,  TQT_SLOT(slotChange3DParameter(bool)));

  // Checkbox for shadows
  drawShadowColor=new TQCheckBox(i18n("Draw dark shadow"),gb);
  TQWhatsThis::add(drawShadowColor, i18n("If checked, this will add a dark shadow on the 3D bars."));
  grid1->addWidget(drawShadowColor,1,0);

  TQLabel *tmpLabel = new TQLabel( i18n( "Angle:" ), gb );
  tmpLabel->resize( tmpLabel->tqsizeHint() );
  grid1->addWidget(tmpLabel,2,0);

  angle3d=new KIntNumInput(0, gb, 10);
  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."));
  grid1->addWidget(angle3d,2,1);
  angle3d->setRange(0, 90, 1);

  tmpLabel = new TQLabel( i18n( "Depth:" ), gb );
  tmpLabel->resize( tmpLabel->tqsizeHint() );
  grid1->addWidget(tmpLabel,3,0);

  depth=new KDoubleNumInput(0, gb);
  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."));
  depth->resize(100,depth->tqsizeHint().height());
  grid1->addWidget(depth,3,1);
  depth->setRange(0, 2.0, 0.1);
  
  gb->tqsetAlignment(TQt::AlignLeft);
  grid1->addColSpacing(0,depth->width());
  grid1->addColSpacing(0,angle3d->width());
  grid1->setColStretch(2,1);
  grid1->setRowStretch(4,1);

  //it's not good but I don't know how
  //to reduce space
  //tqlayout->addColSpacing(1,300);
}


void KChartParameter3dConfigPage::slotChange3DParameter(bool b)
{
    angle3d->setEnabled(b);
    depth->setEnabled(b);
    drawShadowColor->setEnabled(b);
}


void KChartParameter3dConfigPage::init()
{
    bool state=m_params->threeDBars();
    bar3d->setChecked(state);

    drawShadowColor->setChecked(m_params->threeDShadowColors());
    angle3d->setValue( m_params->threeDBarAngle() );
    depth->setValue( m_params->threeDBarDepth() );
    slotChange3DParameter(state);
}


void KChartParameter3dConfigPage::apply()
{
    m_params->setThreeDBars(bar3d->isChecked());
    m_params->setThreeDBarAngle( angle3d->value() );
    m_params->setThreeDBarDepth( depth->value() );
    m_params->setThreeDShadowColors( drawShadowColor->isChecked());
}


}  //KChart namespace