kchart

kchartWizardLabelsLegendPage.cpp
1#include "kchartWizardLabelsLegendPage.h"
2#include "kchart_view.h"
3#include "kchart_part.h"
4
5#include <tqbuttongroup.h>
6#include <tqlineedit.h>
7#include <tqradiobutton.h>
8#include <tqlabel.h>
9#include <tdelocale.h>
10#include <tdefontdialog.h>
11#include <tqlayout.h>
12#include <tqpushbutton.h>
13#include <tqcolor.h>
14
15#include "kchart_params.h"
16
17namespace KChart
18{
19
20KChartWizardLabelsLegendPage::KChartWizardLabelsLegendPage( TQWidget* parent, KChartPart* chart ) :
21 TQWidget( parent ),
22 _chart( chart )
23{
24#if 0
25 ytitle2=true;
26#endif
27
28 KDChartAxisParams leftparams;
29 leftparams = _chart->params()->axisParams( KDChartAxisParams::AxisPosLeft );
30 KDChartAxisParams bottomparams;
31 bottomparams = _chart->params()->axisParams( KDChartAxisParams::AxisPosBottom );
32 x_color=bottomparams.axisLineColor();
33 y_color=leftparams.axisLineColor();
34 xlabel=bottomparams.axisLabelsFont();
35 ylabel=leftparams.axisLabelsFont();
36
37 TQGridLayout *grid1 = new TQGridLayout(this,2,2,KDialog::marginHint(), KDialog::spacingHint());
38
39 TQGroupBox* tmpTQGroupBox;
40 tmpTQGroupBox = new TQGroupBox( this, "GroupBox_1" );
41 tmpTQGroupBox->setFrameStyle( 49 );
42
43 TQGridLayout *grid2 = new TQGridLayout(tmpTQGroupBox,4,4,KDialog::marginHint(), KDialog::spacingHint());
44
45 TQLabel* titleLA = new TQLabel( i18n( "Title:" ),tmpTQGroupBox );
46 grid2->addWidget(titleLA,0,0);
47
48 _titleED = new TQLineEdit( tmpTQGroupBox );
49 grid2->addWidget(_titleED,0,1);
50 _titleED->setText( _chart->params()->header1Text() );
51
52 titlefont = new TQPushButton( tmpTQGroupBox );
53 grid2->addWidget(titlefont,0,2);
54 titlefont->setText(i18n("Font..."));
55
56 titlecolor=new KColorButton(tmpTQGroupBox);
57 grid2->addWidget(titlecolor,0,3);
58 title_color=_chart->params()->headerFooterColor( KDChartParams::HdFtPosHeader );
59 titlecolor->setColor( title_color );
60
61
62 TQLabel* xlabelLA = new TQLabel( i18n( "X-title:" ), tmpTQGroupBox );
63 //xlabelLA->setEnabled(false); //Not supported by kdChart yet
64 grid2->addWidget(xlabelLA,1,0);
65
66 _xlabelED = new TQLineEdit( tmpTQGroupBox );
67 //_xlabelED->setEnabled(false); //Not supported by kdChart yet
68 _xlabelED->setText(_chart->params()->axisTitle( KDChartAxisParams::AxisPosBottom));
69 grid2->addWidget(_xlabelED,1,1);
70
71 xtitlefont = new TQPushButton( tmpTQGroupBox );
72 xtitlefont->setText(i18n("Font..."));
73 //xtitlefont->setEnabled(false); //Not supported by kdChart yet
74 grid2->addWidget(xtitlefont,1,2);
75
76 xtitlecolor=new KColorButton(tmpTQGroupBox);
77 // PENDING(kalle) Put back in
78 // x_color=_chart->params()->XTitleColor;
79 xtitlecolor->setColor( x_color );
80 //xtitlecolor->setEnabled(false); //Not supported by kdChart yet
81 grid2->addWidget(xtitlecolor,1,3);
82
83
84 TQLabel* ylabelLA = new TQLabel( i18n( "Y-title:" ), tmpTQGroupBox );
85 //ylabelLA->setEnabled(false); //Not supported by kdChart yet
86 grid2->addWidget(ylabelLA,2,0);
87
88 _ylabelED = new TQLineEdit( tmpTQGroupBox );
89 //_ylabelED->setEnabled(false); //Not supported by kdChart yet
90 _ylabelED->setText(_chart->params()->axisTitle( KDChartAxisParams::AxisPosLeft));
91 grid2->addWidget(_ylabelED,2,1);
92
93
94 ytitlefont = new TQPushButton( tmpTQGroupBox);
95 ytitlefont->setText(i18n("Font..."));
96 //ytitlefont->setEnabled(false); //Not supported by kdChart yet
97 grid2->addWidget(ytitlefont,2,2);
98
99 ytitlecolor=new KColorButton(tmpTQGroupBox);
100 //ytitlecolor->setEnabled(false); //Not supported by kdChart yet
101 // PENDING(kalle) Put back in
102 // y_color=_chart->params()->YTitleColor;
103 ytitlecolor->setColor( y_color );
104 grid2->addWidget(ytitlecolor,2,3);
105
106#if 0
107 //ytitle2 doesn't work
108 TQLabel* ylabelLA2 = new TQLabel( i18n( "Y-title 2:" ), tmpTQGroupBox );
109 ylabelLA2->setEnabled(false); //Not supported by kdChart yet
110 grid2->addWidget(ylabelLA2,3,0);
111
112 _ylabel2ED = new TQLineEdit( tmpTQGroupBox );
113 _ylabel2ED->setEnabled(false); //Not supported by kdChart yet
114 // PENDING(kalle) Put back in
115 // _ylabel2ED->setText(_chart->params()->ytitle2);
116 grid2->addWidget(_ylabel2ED,3,1);
117
118 ytitle2font = new TQPushButton( tmpTQGroupBox);
119 ytitle2font->setText(i18n("Font..."));
120 ytitle2font->setEnabled(false); //Not supported by kdChart yet
121 grid2->addWidget(ytitle2font,3,2);
122
123 ytitle2color=new KColorButton(tmpTQGroupBox);
124 ytitle2color->setEnabled(false); //Not supported by kdChart yet
125 // PENDING(kalle) Put back in
126 // y_color2=_chart->params()->YTitle2Color;
127 ytitle2color->setColor( y_color2 );
128 grid2->addWidget(ytitle2color,3,3);
129#endif
130
131 // PENDING(kalle) Put back in
132 // xlabel=_chart->params()->xTitleFont();
133 // ylabel=_chart->params()->yTitleFont();
134
135
136 TQLabel* lab = new TQLabel( i18n( "Legend title:" ), tmpTQGroupBox );
137 grid2->addWidget(lab,3,0);
138
139 _legendTitleText = new TQLineEdit( tmpTQGroupBox );
140 grid2->addWidget(_legendTitleText,3,1);
141 _legendTitleText->setText( _chart->params()->legendTitleText() );
142
143
144 legendTitleFont = new TQPushButton( tmpTQGroupBox );
145 legendTitleFont->setText(i18n("Font..."));
146 _legendTitleFont=_chart->params()->legendTitleFont();
147 grid2->addWidget(legendTitleFont,3,2);
148
149 legendTitleColor=new KColorButton(tmpTQGroupBox);
150 _legendTitleColor=_chart->params()->legendTitleTextColor();
151 legendTitleColor->setColor( _legendTitleColor );
152 grid2->addWidget(legendTitleColor,3,3);
153
154
155 lab = new TQLabel( i18n( "Legend text:" ), tmpTQGroupBox );
156 grid2->addWidget(lab,4,0);
157
158 legendTextFont = new TQPushButton( tmpTQGroupBox );
159 _legendTextFont=_chart->params()->legendFont();
160 legendTextFont->setText(i18n("Font..."));
161 grid2->addWidget(legendTextFont,4,2);
162
163 legendTextColor=new KColorButton(tmpTQGroupBox);
164 _legendTextColor=_chart->params()->legendTextColor();
165 legendTextColor->setColor( _legendTextColor );
166 grid2->addWidget(legendTextColor,4,3);
167
168 title=_chart->params()->header1Font();
169 grid1->addWidget(tmpTQGroupBox,0,0);
170
171 connect(xtitlefont,TQ_SIGNAL(clicked()),this,TQ_SLOT(changeXLabelFont()));
172 connect(ytitlefont,TQ_SIGNAL(clicked()),this,TQ_SLOT(changeYLabelFont()));
173#if 0
174 connect(ytitle2font,TQ_SIGNAL(clicked()),this,TQ_SLOT(changeY2LabelFont()));
175#endif
176 connect(titlefont,TQ_SIGNAL(clicked()),this,TQ_SLOT(changeTitleFont()));
177 connect(legendTitleFont,TQ_SIGNAL(clicked()),this,TQ_SLOT(changeLegendTitleFont()));
178
179 connect(legendTextFont,TQ_SIGNAL(clicked()),this,TQ_SLOT(changeLegendTextFont()));
180
181 connect(xtitlecolor,TQ_SIGNAL(changed( const TQColor & )),
182 this,TQ_SLOT(changeXLabelColor(const TQColor &)));
183 connect(ytitlecolor,TQ_SIGNAL(changed( const TQColor & )),
184 this,TQ_SLOT(changeYLabelColor(const TQColor &)));
185 connect(titlecolor,TQ_SIGNAL(changed( const TQColor & )),
186 this,TQ_SLOT(changeTitleColor(const TQColor &)));
187#if 0
188 connect(ytitle2color,TQ_SIGNAL(changed( const TQColor & )),
189 this,TQ_SLOT(changeYTitle2Color(const TQColor &)));
190#endif
191 connect(legendTitleColor,TQ_SIGNAL(changed( const TQColor & )),
192 this,TQ_SLOT(changeLegendTitleColor(const TQColor &)));
193
194 connect(legendTextColor,TQ_SIGNAL(changed( const TQColor & )),
195 this,TQ_SLOT(changeLegendTextColor(const TQColor &)));
196
197}
198
199
200KChartWizardLabelsLegendPage::~KChartWizardLabelsLegendPage()
201{
202 // _chart->removeAutoUpdate( preview );
203}
204
205void KChartWizardLabelsLegendPage::changeLegendTextFont()
206{
207 if (TDEFontDialog::getFont( _legendTextFont,false,this ) == TQDialog::Rejected )
208 return;
209}
210
211void KChartWizardLabelsLegendPage::changeLegendTitleFont()
212{
213 if (TDEFontDialog::getFont( _legendTitleFont,false,this ) == TQDialog::Rejected )
214 return;
215}
216
217void KChartWizardLabelsLegendPage::changeXLabelFont()
218{
219 if (TDEFontDialog::getFont( xlabel,false,this ) == TQDialog::Rejected )
220 return;
221}
222
223void KChartWizardLabelsLegendPage::changeYLabelFont()
224{
225 if (TDEFontDialog::getFont( ylabel ,false,this ) == TQDialog::Rejected )
226 return;
227}
228
229#if 0
230void KChartWizardLabelsLegendPage::changeY2LabelFont()
231{
232 if (TDEFontDialog::getFont( ylabel2, false, this ) == TQDialog::Rejected )
233 return;
234}
235#endif
236
237void KChartWizardLabelsLegendPage::changeTitleFont()
238{
239 if (TDEFontDialog::getFont( title ,false,this ) == TQDialog::Rejected )
240 return;
241
242}
243
244void KChartWizardLabelsLegendPage::changeLegendTextColor(const TQColor &_color)
245{
246 _legendTextColor=_color;
247}
248
249void KChartWizardLabelsLegendPage::changeXLabelColor(const TQColor &_color)
250{
251 x_color=_color;
252}
253
254void KChartWizardLabelsLegendPage::changeYLabelColor(const TQColor &_color)
255{
256 y_color=_color;
257}
258
259void KChartWizardLabelsLegendPage::changeTitleColor(const TQColor &_color)
260{
261 title_color=_color;
262}
263
264#if 0
265void KChartWizardLabelsLegendPage::changeYTitle2Color(const TQColor &_color)
266{
267 y_color2=_color;
268}
269#endif
270
271void KChartWizardLabelsLegendPage::changeLegendTitleColor(const TQColor &_color)
272{
273 _legendTitleColor=_color;
274}
275
276void KChartWizardLabelsLegendPage::paintEvent( TQPaintEvent * )
277{
278#if 0
279 if( ytitle2 ) {
280 _ylabel2ED->setEnabled(true);
281 ytitle2color->setEnabled(true);
282 }
283 else {
284 _ylabel2ED->setEnabled(false);
285 ytitle2color->setEnabled(false);
286 }
287#endif
288}
289
290void KChartWizardLabelsLegendPage::apply( )
291{
292 _chart->params()->setHeader1Text( _titleED->text() );
293
294 // PENDING(kalle) Put back in
295 // _chart->params()->setXTitleFont(xlabel);
296 // _chart->params()->setYTitleFont(ylabel);
297 // _chart->params()->xtitle= _xlabelED->text();
298 // _chart->params()->ytitle= _ylabelED->text();
299 // _chart->params()->XTitleColor=x_color;
300 // _chart->params()->YTitleColor=y_color;
301 // _chart->params()->YTitle2Color=y_color2;
302 // _chart->params()->ytitle2=_ylabel2ED->text();
303
304 _chart->params()->setHeaderFooterColor( KDChartParams::HdFtPosHeader, title_color );
305 _chart->params()->setHeaderFooterFont( KDChartParams::HdFtPosHeader, title, true, title.pointSize()*4 );
306 _chart->params()->setAxisTitle( KDChartAxisParams::AxisPosBottom, _xlabelED->text() );
307 _chart->params()->setAxisTitle( KDChartAxisParams::AxisPosLeft, _ylabelED->text() );
308
309 _chart->params()->setLegendTitleText(_legendTitleText->text());
310 _chart->params()->setLegendTitleTextColor(_legendTitleColor);
311 _chart->params()->setLegendTitleFont( _legendTitleFont,false);
312 _chart->params()->setLegendTitleFontRelSize( _legendTitleFont.pointSize()*4 );
313 _chart->params()->setLegendTextColor(_legendTextColor);
314 _chart->params()->setLegendFont( _legendTextFont,false);
315 _chart->params()->setLegendFontRelSize( _legendTextFont.pointSize()*4 );
316
317 KDChartAxisParams leftparams;
318 leftparams = _chart->params()->axisParams( KDChartAxisParams::AxisPosLeft );
319 KDChartAxisParams bottomparams;
320 bottomparams = _chart->params()->axisParams( KDChartAxisParams::AxisPosBottom );
321 if( x_color.isValid() )
322 bottomparams.setAxisLineColor( x_color );
323 if( y_color.isValid() )
324 leftparams.setAxisLineColor( y_color );
325 if(bottomparams.axisLabelsFont()!=xlabel){
326 bottomparams.setAxisLabelsFont( xlabel,false );
327 bottomparams.setAxisLabelsFontRelSize( xlabel.pointSize()*4 );
328 }
329 if(leftparams.axisLabelsFont()!=ylabel){
330 leftparams.setAxisLabelsFont( ylabel,false );
331 leftparams.setAxisLabelsFontRelSize( ylabel.pointSize()*4 );
332 }
333
334 _chart->params()->setAxisParams( KDChartAxisParams::AxisPosBottom, bottomparams );
335 _chart->params()->setAxisParams( KDChartAxisParams::AxisPosLeft, leftparams );
336}
337
338} //KChart namespace
339
340#include "kchartWizardLabelsLegendPage.moc"
access the chart axis parameters.
void setAxisLineColor(TQColor axisLineColor)
Specifies the axis line colour.
void setAxisLabelsFont(TQFont axisLabelsFont, bool useFontSize)
Specifies the axis labels font.
TQFont axisLabelsFont() const
Returns the axis labels font.
void setAxisLabelsFontRelSize(int axisLabelsFontRelSize)
Specifies the axis labels relative font size.
TQColor axisLineColor() const
Returns the axis line colour.