20#include "kchartColorConfigPage.h"
21#include "kchartColorConfigPage.moc"
23#include <tdeapplication.h>
26#include <kcolorbutton.h>
29#include <tqbuttongroup.h>
30#include <tqwhatsthis.h>
32#include <tdelistbox.h>
33#include "kchart_params.h"
39KChartColorConfigPage::KChartColorConfigPage( KChartParams* params,
41 KDChartTableData *dat ) :
47 TQWhatsThis::add(
this, i18n(
"This page lets you configure the colors "
48 "in which your chart is displayed. Each "
49 "part of the chart can be assigned a "
50 "different color." ) );
52 TQVBoxLayout* toplevel =
new TQVBoxLayout(
this, 14 );
53 TQButtonGroup* gb =
new TQButtonGroup( 0, TQt::Vertical, i18n(
"Colors"),
this );
54 gb->layout()->setSpacing(KDialog::spacingHint());
55 gb->layout()->setMargin(KDialog::marginHint());
56 toplevel->addWidget( gb);
58 TQGridLayout* grid =
new TQGridLayout( gb->layout(), 8, 3 );
60 const int labelAlign = AlignRight | AlignVCenter;
62#define ADD_COLOR_BTN(btn,title,whatsthis) \
65 TQLabel* l = new TQLabel( title, gb ); \
66 l->setAlignment( labelAlign ); \
67 grid->addWidget( l, row, 0 ); \
68 btn = new KColorButton( gb ); \
70 grid->addWidget( btn, row, 1 ); \
71 TQWhatsThis::add( l, whatsthis ); \
72 TQWhatsThis::add( btn, whatsthis ); \
74 ADD_COLOR_BTN(_lineCB, i18n(
"&Line color:" ),
75 i18n(
"This is the color that is used for drawing lines like axes." ))
76 ADD_COLOR_BTN(_gridCB, i18n(
"&Grid color:" ),
77 i18n(
"Here you can configure the color that is used for the "
78 "chart grid. Of course, this setting will only "
79 "take effect if grid drawing is turned on." ))
80 ADD_COLOR_BTN(_xtitleCB, i18n(
"&X-title color:" ),
81 i18n(
"This color is used for displaying titles for the "
82 "X (horizontal) axis." ))
83 ADD_COLOR_BTN(_ytitleCB, i18n(
"&Y-title color:" ),
84 i18n(
"This color is used for displaying titles for the "
85 "Y (vertical) axis." ))
87 ADD_COLOR_BTN(_ytitle2CB, i18n(
"Y-title color (2nd axis):" ),
88 i18n(
"This color is used for displaying titles for the "
89 "second Y (vertical) axis. It only takes effect if the "
90 "chart is configured to have a second Y axis." ))
92 ADD_COLOR_BTN(_xlabelCB, i18n(
"X-label color:" ),
93 i18n(
"Here you can configure the color that is used for "
94 "labeling the X (horizontal) axis" ))
95 ADD_COLOR_BTN(_ylabelCB, i18n(
"Y-label color:" ),
96 i18n(
"Here you can configure the color that is used for "
97 "labeling the Y (vertical) axis" ))
99 ADD_COLOR_BTN(_ylabel2CB, i18n(
"Y-label color (2nd axis):" ),
100 i18n(
"Here you can configure the color that is used for "
101 "labeling the second Y (vertical) axis. Of course, "
102 "this setting only takes effect if the chart is "
103 "configured to have two vertical axes." ))
105 ADD_COLOR_BTN(_xlineCB, i18n(
"X-line color:" ),
106 i18n(
"Here you can configure the line color of the X (horizontal) axis" ))
107 ADD_COLOR_BTN(_ylineCB, i18n(
"Y-line color:" ),
108 i18n(
"Here you can configure the line color of the Y (vertical) axis" ))
110 ADD_COLOR_BTN(_yline2CB, i18n(
"Y-line color (2nd axis):" ),
111 i18n(
"Here you can configure the line color of "
112 "the second Y (vertical) axis. Of course, "
113 "this setting only takes effect if the chart is "
114 "configured to have two vertical axes." ))
116 ADD_COLOR_BTN(_xzerolineCB, i18n(
"X-Zero-line color:" ),
117 i18n(
"Here you can configure the zero-line's color of the X "
118 "(horizontal) axis. Of course, this setting only takes "
119 "effect if the abscissa is displaying a Zero-line." ))
120 ADD_COLOR_BTN(_yzerolineCB, i18n(
"Y-Zero-line color:" ),
121 i18n(
"Here you can configure the zero-line's color of the Y (vertical) axis" ))
123 ADD_COLOR_BTN(_yzeroline2CB, i18n(
"Y-Zero-line color (2nd axis):" ),
124 i18n(
"Here you can configure the color that is used for "
125 "the Zero-line of the second Y (vertical) axis. Of course, "
126 "this setting only takes effect if the chart is "
127 "configured to have two vertical axes." ))
130 TQHBox* dataColorHB =
new TQHBox( gb );
131 grid->addMultiCellWidget( dataColorHB, 0, row, 2, 2 );
132 _dataColorLB =
new TDEListBox(dataColorHB);
133 _dataColorCB =
new KColorButton( dataColorHB);
134 wtstr = i18n(
"Choose a row/column in the list on the left and change its color using this button.");
135 TQWhatsThis::add( _dataColorCB, wtstr );
137 connect( _dataColorLB, TQ_SIGNAL(highlighted(
int )),
this, TQ_SLOT(changeIndex(
int)));
138 connect( _dataColorLB, TQ_SIGNAL(doubleClicked ( TQListBoxItem * )),
this, TQ_SLOT(activeColorButton()));
165void KChartColorConfigPage::changeIndex(
int newindex)
167 if(index > m_params->maxDataColor())
168 _dataColorLB->setEnabled(
false);
171 if(!_dataColorCB->isEnabled())
172 _dataColorCB->setEnabled(
true);
173 extColor[index] = _dataColorCB->color();
174 _dataColorCB->setColor(extColor[newindex]);
180void KChartColorConfigPage::activeColorButton()
182 _dataColorCB->animateClick();
186void KChartColorConfigPage::initDataColorList()
189 for(uint i = 0; i < m_data->rows(); i++)
191 extColor.resize( m_params->maxDataColor() );
192 if(i<m_params->maxDataColor())
194 _dataColorLB->insertItem(m_params->legendText( i ).isEmpty() ? i18n(
"Series %1").arg(i+1) :m_params->legendText( i ) );
195 extColor[i] =m_params->dataColor(i);
198 _dataColorLB->setCurrentItem(0);
201 if ( m_data->rows() == 0 )
202 _dataColorCB->setEnabled(
false);
204 _dataColorCB->setColor( extColor[index]);
208void KChartColorConfigPage::apply()
211 if ( m_data->rows() == 0 )
214 extColor[index] = _dataColorCB->color();
215 for(uint i =0;i<m_data->rows();i++)
216 if(i<m_params->maxDataColor())
217 m_params->setDataColor(i,extColor[i]);