21#include "kchartParameterConfigPage.h"
22#include "kchartParameterConfigPage.moc"
24#include <tdeapplication.h>
28#include <tqcheckbox.h>
29#include <tqlineedit.h>
31#include <tqbuttongroup.h>
32#include <tqradiobutton.h>
33#include <tqvbuttongroup.h>
34#include <tdefontdialog.h>
35#include <tqwhatsthis.h>
38#include "kchart_params.h"
43KChartParameterConfigPage::KChartParameterConfigPage( KChartParams* params,
45 TQWidget( parent ),_params( params )
48 TQVBoxLayout* toplevel =
new TQVBoxLayout(
this, 10 );
50 TQGridLayout* layout =
new TQGridLayout( 1, 3 );
51 toplevel->addLayout( layout );
54 TQButtonGroup* gb1 =
new TQButtonGroup( 0, TQt::Vertical, i18n(
"Parameters"),
this );
55 gb1->layout()->setSpacing(KDialog::spacingHint());
56 gb1->layout()->setMargin(KDialog::marginHint());
57 TQGridLayout *grid1 =
new TQGridLayout(gb1->layout(),9,1);
59 grid =
new TQCheckBox( i18n(
"Grid" ), gb1 );
60 TQWhatsThis::add(grid, i18n(
"If this is checked, the grid is shown. If you uncheck this option, the grid will not be displayed anymore."));
61 grid1->addWidget(grid, 0, 0);
64 yaxis =
new TQCheckBox( i18n(
"Y-axis" ), gb1);
65 TQWhatsThis::add(yaxis, i18n(
"If this is checked, the Y-axis is shown. If you uncheck this option, the Y-axis and the Y grid lines will not be displayed anymore."));
66 connect( yaxis, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( axisChanged() ) );
67 grid1->addWidget(yaxis, 1, 0);
70 xaxis =
new TQCheckBox( i18n(
"X-axis" ), gb1 );
71 TQWhatsThis::add(xaxis, i18n(
"If this is checked, the X-axis is shown. If you uncheck this option, the X-axis and the X grid lines will not be displayed anymore."));
72 connect( xaxis, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( axisChanged() ) );
73 grid1->addWidget(xaxis, 2, 0);
77 xlabel =
new TQCheckBox( i18n(
"Has X-label" ), gb1 );
78 grid1->addWidget(xlabel,3,0);
80 yaxis2 =
new TQCheckBox( i18n(
"Y-axis 2" ), gb1 );
81 grid1->addWidget(yaxis2,4,0);
85 lineMarker =
new TQCheckBox( i18n(
"Line marker" ), gb1 );
86 grid1->addWidget(lineMarker, 4, 0);
89 llabel =
new TQCheckBox( i18n(
"Legend" ), gb1 );
90 grid1->addWidget(llabel,6,0);
94 TQButtonGroup* gb2 =
new TQButtonGroup( 0, TQt::Vertical,
95 i18n(
"Settings"),
this );
96 gb2->layout()->setSpacing(KDialog::spacingHint());
97 gb2->layout()->setMargin(KDialog::marginHint());
98 TQGridLayout *grid2 =
new TQGridLayout(gb2->layout(),8,1);
100 TQBoxLayout * l =
new TQVBoxLayout( grid2 );
102 TQHBoxLayout * top =
new TQHBoxLayout( l );
104 TQLabel *tmpLabel =
new TQLabel( i18n(
"X-title:" ), gb2 );
105 top->addWidget(tmpLabel);
107 tmpLabel =
new TQLabel( i18n(
"Y-title:" ), gb2 );
108 top->addWidget(tmpLabel);
110 TQHBoxLayout * bottom =
new TQHBoxLayout( l );
111 xtitle=
new TQLineEdit( gb2 );
112 TQWhatsThis::add(xtitle, i18n(
"Write the title for the X-axis here, if you want a title. The color for this title is set in the Colors tab, in the same dialog, and the font is set in the Font tab."));
113 bottom->addWidget(xtitle);
114 ytitle=
new TQLineEdit( gb2 );
115 TQWhatsThis::add(ytitle, i18n(
"Write the title for the Y-axis here, if you want a title. The color for this title is set in the Colors tab, in the same dialog, and the font is set in the Font tab."));
116 bottom->addWidget(ytitle);
119 TQVButtonGroup *scaletype =
new TQVButtonGroup(i18n(
"Scale Types"), gb2);
120 lin =
new TQRadioButton( i18n(
"Linear scale"), scaletype);
121 TQWhatsThis::add(lin, i18n(
"This sets the Y-axis to be linear. This is default."));
122 log =
new TQRadioButton( i18n(
"Logarithmic scale"), scaletype);
123 TQWhatsThis::add(log, i18n(
"This sets the Y-axis to be logarithmic."));
124 grid2->addWidget(scaletype, 1, 0);
127 TQVButtonGroup *precision =
new TQVButtonGroup(i18n(
"Precision for Numerical Left Axis"), gb2);
128 grid2->addWidget(precision, 2, 0);
129 TQRadioButton * automatic_precision =
new TQRadioButton( i18n(
"Automatic precision"), precision);
130 TQWhatsThis::add(automatic_precision, i18n(
"This sets the precision as automatic which means that KChart decides what precision to apply."));
131 automatic_precision->setChecked(
true);
132 max =
new TQRadioButton( i18n(
"Decimal precision:"), precision);
133 TQWhatsThis::add(max, i18n(
"This sets the Y-axis precision. For example, if you choose a precision of 2, the value 5 will be displayed as 5.00 alongside the Y-axis."));
134 connect(automatic_precision, TQ_SIGNAL(toggled(
bool)),
this,
135 TQ_SLOT(automatic_precision_toggled(
bool)) );
136 maximum_length =
new TQSpinBox(0, 15, 1, precision );
137 TQWhatsThis::add(maximum_length, i18n(
"Set the precision you want to display for the Y-axis, if you choose Decimal precision. The range is 0 to 15; 2 being the default."));
138 maximum_length->setValue(2);
141 tmpLabel =
new TQLabel( i18n(
"Y-label format:" ), gb2 );
142 grid2->addWidget(tmpLabel,0,1);
144 ylabel_fmt=
new TQLineEdit( gb2 );
145 ylabel_fmt->setMaximumWidth(130);
146 grid2->addWidget(ylabel_fmt,1,1);
147 ylabel_fmt->setEnabled(
false);
149 tmpLabel =
new TQLabel( i18n(
"Y-title 2:" ), gb2 );
150 grid2->addWidget(tmpLabel,2,1);
152 ytitle2=
new TQLineEdit( gb2 );
153 ytitle2->setMaximumWidth(130);
154 grid2->addWidget(ytitle2,3,1);
156 tmpLabel =
new TQLabel( i18n(
"Y-label format 2:" ), gb2 );
157 grid2->addWidget(tmpLabel,4,1);
159 ylabel2_fmt=
new TQLineEdit( gb2 );
160 ylabel2_fmt->setMaximumWidth(130);
161 grid2->addWidget(ylabel2_fmt,5,1);
163 layout->addWidget(gb1,0,0);
164 layout->addWidget(gb2,0,1);
177 void KChartParameterConfigPage::changeXaxisState(
bool )
181 xlabel->setEnabled(
true);
183 xlabel->setEnabled(
false);
187void KChartParameterConfigPage::init()
193 grid->setChecked(_params->showGrid());
195 xaxis->setChecked(_params->axisVisible(KDChartAxisParams::AxisPosBottom));
196 yaxis->setChecked(_params->axisVisible(KDChartAxisParams::AxisPosLeft));
199 llabel->setChecked(_params->legendPosition()!=KDChartParams::NoLegend);
203 if ( _params->chartType() == KDChartParams::Line ) {
204 lineMarker->setEnabled(
true);
205 lineMarker->setChecked(_params->lineMarker());
208 lineMarker->setEnabled(
false);
209 lineMarker->setChecked(
false);
225 yaxis2->setEnabled(
false);
226 ylabel2_fmt->setEnabled(
false);
227 ytitle2->setEnabled(
false);
239 xlabel->setEnabled(
false);
242 xtitle->setText( _params->axisTitle( KDChartAxisParams::AxisPosBottom) );
243 ytitle->setText( _params->axisTitle( KDChartAxisParams::AxisPosLeft) );
247 if ( _params->axisParams( KDChartAxisParams::AxisPosLeft ).axisCalcMode() ==
248 KDChartAxisParams::AxisCalcLinear )
249 lin->setChecked(
true);
251 log->setChecked(
true);
253 if ( _params->axisParams( KDChartAxisParams::AxisPosLeft ).axisDigitsBehindComma() ==
255 maximum_length->setEnabled(
false);
258 max->setChecked(
true);
259 maximum_length->setValue( _params->axisParams( KDChartAxisParams::AxisPosLeft ).axisDigitsBehindComma() );
264void KChartParameterConfigPage::apply()
267 _params->setLegendPosition(llabel->isChecked() ? KDChartParams::LegendRight :
KDChartParams::NoLegend);
270 _params->setAxisVisible(KDChartAxisParams::AxisPosBottom,xaxis->isChecked());
271 _params->setAxisVisible(KDChartAxisParams::AxisPosLeft,yaxis->isChecked());
273 _params->setAxisShowGrid(KDChartAxisParams::AxisPosLeft,
275 _params->setAxisShowGrid(KDChartAxisParams::AxisPosBottom,
278 _params->setAxisTitle( KDChartAxisParams::AxisPosBottom, xtitle->text() );
279 _params->setAxisTitle( KDChartAxisParams::AxisPosLeft, ytitle->text() );
321 if( _params->chartType() == KDChartParams::Line )
322 _params->setLineMarker(lineMarker->isChecked());
328 params = _params->axisParams( KDChartAxisParams::AxisPosLeft );
330 if (lin->isChecked())
334 if(params.
axisCalcMode() != KDChartAxisParams::AxisCalcLogarithmic)
338 _params->setChartType( KChartParams::Line );
343 if ( maximum_length->isEnabled() )
348 _params->setAxisParams( KDChartAxisParams::AxisPosLeft, params );
352void KChartParameterConfigPage::automatic_precision_toggled(
bool toggled)
355 maximum_length->setEnabled(
false);
357 maximum_length->setEnabled(
true);
360void KChartParameterConfigPage::axisChanged()
362 if ( !xaxis->isChecked() || !yaxis->isChecked() )
364 xtitle->setEnabled(
false );
365 ytitle->setEnabled(
false );
369 xtitle->setEnabled(
true );
370 ytitle->setEnabled(
true );
Provide access to the chart axis parameters.
#define KDCHART_AXIS_LABELS_AUTO_DIGITS
Use this to specify that the number of digits to be shown on the axis labels behind the comma is to b...
access the chart axis parameters.
void setAxisCalcMode(AxisCalcMode axisCalcMode)
enum AxisCalcMode { AxisCalcLinear, AxisCalcLogarithmic }; The axis calculation mode.
void setAxisDigitsBehindComma(const int digits)
Specifies the number of digits to be printed behind the comma on the axis labels.
AxisCalcMode axisCalcMode() const
Returns the axis calculation mode configured in this params object.
Bundles the display parameters of a chart.