00001 #include "kchartWizardSetupAxesPage.h"
00002 #include "kchart_view.h"
00003 #include "kchart_part.h"
00004
00005 #include <qlabel.h>
00006 #include <qframe.h>
00007 #include <qlineedit.h>
00008 #include <qcheckbox.h>
00009 #include <qgroupbox.h>
00010 #include <qlayout.h>
00011 #include <klocale.h>
00012 #include <kfontdialog.h>
00013 #include <knumvalidator.h>
00014 #include <math.h>
00015 #include <float.h>
00016
00017
00018 #include <qspinbox.h>
00019 #include <qpushbutton.h>
00020 #include <qcolor.h>
00021
00022 #include "kchart_params.h"
00023
00024 namespace KChart
00025 {
00026
00027 KChartWizardSetupAxesPage::KChartWizardSetupAxesPage( QWidget* parent,
00028 KChartPart* chart ) :
00029 QWidget( parent ),
00030 _chart( chart )
00031 {
00032 chart3d=true;
00033
00034 QGridLayout *grid1 = new QGridLayout(this,2,2,KDialog::marginHint(), KDialog::spacingHint());
00035
00036 QGroupBox* tmpQGroupBox;
00037 tmpQGroupBox = new QGroupBox( this, "GroupBox_1" );
00038 tmpQGroupBox->setFrameStyle( 49 );
00039
00040 QGridLayout *grid2 = new QGridLayout(tmpQGroupBox,3,2,KDialog::marginHint(), KDialog::spacingHint());
00041
00042
00043
00044 new QLabel( i18n( "Grid Lines" ), tmpQGroupBox );
00045 gridX = new QCheckBox( i18n( "X axis:" ), tmpQGroupBox );
00046 gridY = new QCheckBox( i18n( "Y axis:" ), tmpQGroupBox );
00047
00048 gridX->setChecked(_chart->params()->showGrid());
00049 gridY->setChecked(_chart->params()->showGrid());
00050 grid2->addWidget(gridX, 0, 0);
00051 grid2->addWidget(gridY, 1, 0);
00052
00053 gridColor=new KColorButton(tmpQGroupBox);
00054
00055
00056 gridColor->setColor( colorGrid );
00057 grid2->addWidget(gridColor, 0, 1);
00058
00059 border = new QCheckBox( i18n( "Border:" ), tmpQGroupBox );
00060
00061
00062 grid2->addWidget(border, 2, 0);
00063 border->setEnabled(false);
00064
00065 borderColor=new KColorButton(tmpQGroupBox);
00066
00067
00068 borderColor->setColor( colorBorder );
00069 grid2->addWidget(borderColor,2,1);
00070 borderColor->setEnabled(false);
00071
00072 grid1->addWidget(tmpQGroupBox,0,0);
00073
00074
00075 tmpQGroupBox = new QGroupBox( this, "GroupBox_2" );
00076 tmpQGroupBox->setFrameStyle( 49 );
00077
00078 grid2 = new QGridLayout(tmpQGroupBox,3,2,KDialog::marginHint(), KDialog::spacingHint());
00079
00080 QLabel *tmpLabel;
00081 tmpLabel=new QLabel(tmpQGroupBox);
00082 tmpLabel->setText(i18n("Angle 3D:"));
00083 grid2->addWidget(tmpLabel,0,0);
00084 angle = new QSpinBox(1, 90, 1,tmpQGroupBox );
00085 angle->setValue( _chart->params()->threeDBarAngle() );
00086 grid2->addWidget(angle,0,1);
00087
00088 tmpLabel=new QLabel(tmpQGroupBox);
00089 tmpLabel->setText(i18n("Depth 3D:"));
00090 grid2->addWidget(tmpLabel,1,0);
00091 depth = new QSpinBox(1, 40, 1, tmpQGroupBox);
00092 depth->setValue( static_cast<int>( _chart->params()->threeDBarDepth() ) );
00093 grid2->addWidget(depth,1,1);
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 grid1->addWidget(tmpQGroupBox,0,1);
00105
00106 tmpQGroupBox = new QGroupBox( this, "GroupBox_3" );
00107 tmpQGroupBox->setFrameStyle( 49 );
00108
00109 grid2 = new QGridLayout(tmpQGroupBox,3,2,KDialog::marginHint(), KDialog::spacingHint());
00110
00111 tmpLabel=new QLabel(tmpQGroupBox);
00112 tmpLabel->setText(i18n("Y interval:"));
00113 grid2->addWidget(tmpLabel,0,0);
00114
00115 QString tmp;
00116 y_interval=new QLineEdit(tmpQGroupBox);
00117 y_interval->setValidator(new KFloatValidator( y_interval));
00118 grid2->addWidget(y_interval,0,1);
00119
00120
00121
00122
00123 tmpLabel=new QLabel(tmpQGroupBox);
00124 tmpLabel->setText(i18n("Y min:"));
00125 grid2->addWidget(tmpLabel,1,0);
00126 y_min=new QLineEdit(tmpQGroupBox);
00127 y_min->setValidator(new KFloatValidator( y_min));
00128 grid2->addWidget(y_min,1,1);
00129
00130
00131
00132
00133 tmpLabel=new QLabel(tmpQGroupBox);
00134 tmpLabel->setText(i18n("Y max:"));
00135 grid2->addWidget(tmpLabel,2,0);
00136 y_max=new QLineEdit(tmpQGroupBox);
00137 y_max->setValidator(new KFloatValidator( y_max));
00138 grid2->addWidget(y_max,2,1);
00139
00140
00141
00142
00143 grid1->addWidget(tmpQGroupBox,1,0);
00144 tmpQGroupBox->setEnabled(false);
00145
00146 tmpQGroupBox = new QGroupBox( this, "GroupBox_3" );
00147 tmpQGroupBox->setFrameStyle( 49 );
00148
00149 grid2 = new QGridLayout(tmpQGroupBox,3,2,KDialog::marginHint(), KDialog::spacingHint());
00150
00151 tmpLabel=new QLabel(tmpQGroupBox);
00152 tmpLabel->setText(i18n("Y-label format:"));
00153 grid2->addWidget(tmpLabel,0,0);
00154 ylabel_fmt=new QLineEdit(tmpQGroupBox);
00155 grid2->addWidget(ylabel_fmt,0,1);
00156
00157
00158
00159
00160
00161
00162 ylabelFont = new QPushButton( tmpQGroupBox);
00163 grid2->addWidget(ylabelFont,1,0);
00164 ylabelFont->setText(i18n("Font..."));
00165
00166
00167
00168 ylabelColor=new KColorButton(tmpQGroupBox);
00169 grid2->addWidget(ylabelColor,1,1);
00170
00171
00172 ylabelColor->setColor( ycolor );
00173
00174 #if 0
00175 tmpLabel=new QLabel(tmpQGroupBox);
00176 tmpLabel->setText(i18n("Y-label 2 format:"));
00177 grid2->addWidget(tmpLabel,2,0);
00178
00179 ylabel2_fmt=new QLineEdit(tmpQGroupBox);
00180 grid2->addWidget(ylabel2_fmt,2,1);
00181
00182
00183
00184
00185
00186 #endif
00187 tmpQGroupBox->setEnabled(false);
00188 grid1->addWidget(tmpQGroupBox,1,1);
00189
00190
00191
00192 connect(ylabelFont,SIGNAL(clicked()),this,SLOT(changeLabelFont()));
00193
00194
00195 connect(ylabelColor,SIGNAL(changed( const QColor & )),
00196 this,SLOT(changeLabelColor(const QColor &)));
00197 connect(borderColor,SIGNAL(changed( const QColor & )),
00198 this,SLOT(changeBorderColor(const QColor &)));
00199 connect(gridColor,SIGNAL(changed( const QColor & )),
00200 this,SLOT(changeGridColor(const QColor &)));
00201 }
00202
00203
00204 KChartWizardSetupAxesPage::~KChartWizardSetupAxesPage()
00205 {
00206
00207 }
00208
00209 void KChartWizardSetupAxesPage::changeLabelColor(const QColor &_color)
00210 {
00211 ycolor=_color;
00212 }
00213
00214 void KChartWizardSetupAxesPage::changeBorderColor(const QColor &_color)
00215 {
00216 colorBorder=_color;
00217 }
00218
00219 void KChartWizardSetupAxesPage::changeGridColor(const QColor &_color)
00220 {
00221 colorGrid=_color;
00222 }
00223
00224 void KChartWizardSetupAxesPage::changeLabelFont()
00225 {
00226 if( KFontDialog::getFont( ylabel,false,this ) == QDialog::Rejected )
00227 return;
00228 }
00229
00230 void KChartWizardSetupAxesPage::paintEvent( QPaintEvent *)
00231 {
00232 if(chart3d) {
00233 angle->setEnabled(true);
00234 depth->setEnabled(true);
00235
00236 } else {
00237 angle->setEnabled(false);
00238 depth->setEnabled(false);
00239
00240 }
00241 }
00242
00243 void KChartWizardSetupAxesPage::apply()
00244 {
00245 _chart->params()->setAxisShowGrid(KDChartAxisParams::AxisPosLeft,gridY->isChecked() );
00246 _chart->params()->setAxisShowGrid(KDChartAxisParams::AxisPosBottom,gridX->isChecked() );
00247
00248 KDChartAxisParams leftparams;
00249 leftparams = _chart->params()->axisParams( KDChartAxisParams::AxisPosLeft );
00250
00251
00252
00253
00254
00255
00256
00257
00258 _chart->params()->setAxisParams( KDChartAxisParams::AxisPosLeft, leftparams );
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277 _chart->params()->setThreeDBarAngle( angle->value() );
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289 _chart->params()->setThreeDBarDepth( depth->value() );
00290
00291
00292
00293
00294
00295
00296
00297 }
00298
00299 }
00300
00301 #include "kchartWizardSetupAxesPage.moc"