21#include "kchartFontConfigPage.h"
23#include "kchartFontConfigPage.moc"
25#include <tdeapplication.h>
27#include <kcolorbutton.h>
32#include <tqlineedit.h>
34#include <tqpushbutton.h>
36#include <tqwhatsthis.h>
38#include <tdefontdialog.h>
45#include "kchart_params.h"
48class KChartFontListBoxItem :
public TQListBoxText
51 KChartFontListBoxItem( TQListBox* lb,
const TQString& text = TQString() ) :
52 TQListBoxText( lb, text ) {}
53 KChartFontListBoxItem(
const TQString& text = TQString() ) :
54 TQListBoxText( text ) {}
56 void setFont(
const TQFont& font ) {
65 void paint( TQPainter* painter )
68 painter->setFont( _font );
69 TQListBoxText::paint( painter );
84KChartFontConfigPage::KChartFontConfigPage( KChartParams* params,
86 KDChartTableData *dat) :
87 TQWidget( parent ), m_params( params ), data(dat)
89 TQGridLayout *grid =
new TQGridLayout(
this,4,3,KDialog::marginHint(), KDialog::spacingHint());
92 m_list =
new TQListBox(
this);
93 m_list->resize( m_list->sizeHint() );
94 grid->addWidget(m_list, 0, 0);
97 m_fontButton =
new TQPushButton(
this);
98 m_fontButton->setText(i18n(
"Font..."));
99 TQWhatsThis::add(m_fontButton, i18n(
"Select an item in the list above and click on this button to display the TDE font dialog in order to choose a new font for this item."));
100 m_fontButton->resize( m_fontButton->sizeHint() );
101 grid->addWidget( m_fontButton, 1, 0);
105 TDEFontChooser *fontChooser =
new TDEFontChooser(
this,
"fontChooser");
106 grid->addMultiCellWidget(fontChooser, 0, 2, 1, 1);
109 grid->setColStretch(2, 1);
110 grid->setRowStretch(3, 1);
112 connect( m_fontButton, TQ_SIGNAL(clicked()),
113 this, TQ_SLOT(changeLabelFont()));
114 connect( m_list, TQ_SIGNAL(doubleClicked ( TQListBoxItem * )),
115 this, TQ_SLOT(changeLabelFont()));
122void KChartFontConfigPage::initList()
124 if ( m_params->chartType() != KChartParams::Pie
125 && m_params->chartType() != KChartParams::Ring ) {
126 m_list->insertItem(
new KChartFontListBoxItem( i18n(
"X-Title")));
127 m_list->insertItem(
new KChartFontListBoxItem( i18n(
"Y-Title")));
128 m_list->insertItem(
new KChartFontListBoxItem( i18n(
"X-Axis")));
129 m_list->insertItem(
new KChartFontListBoxItem( i18n(
"Y-Axis")));
130 m_list->insertItem(
new KChartFontListBoxItem( i18n(
"All Axes")));
133 m_list->insertItem(i18n(
"Label"));
134 m_list->setCurrentItem(0);
139void KChartFontConfigPage::changeLabelFont()
142 TQButton::ToggleState *state = 0;
143 bool diffAxes =
false;
145 if (m_list->currentText()==i18n(
"X-Title")) {
147 state = &xTitleIsRelative;
148 }
else if(m_list->currentText()==i18n(
"Y-Title")) {
150 state = &yTitleIsRelative;
151 }
else if(m_list->currentText()==i18n(
"X-Axis")) {
153 state = &xAxisIsRelative;
154 }
else if(m_list->currentText()==i18n(
"Y-Axis")) {
156 state = &yAxisIsRelative;
157 }
else if(m_list->currentText()==i18n(
"All Axes")) {
159 }
else if(m_list->currentText()==i18n(
"Label")) {
161 state = &labelIsRelative;
164 kdDebug( 35001 ) <<
"Pb in listBox" << endl;
169 TQButton::ToggleState newState
170 = (xAxisIsRelative == yAxisIsRelative)
171 ? (xAxisIsRelative ? TQButton::On : TQButton::Off)
172 : TQButton::NoChange;
173 if (TDEFontDialog::getFontDiff( newFont,
178 &newState ) != TQDialog::Rejected) {
179 if ( TDEFontChooser::FamilyList & flags ) {
180 xAxis.setFamily( newFont.family() );
181 yAxis.setFamily( newFont.family() );
184 if ( TDEFontChooser::StyleList & flags ) {
185 xAxis.setWeight( newFont.weight() );
186 xAxis.setItalic( newFont.italic() );
187 xAxis.setUnderline( newFont.underline() );
188 xAxis.setStrikeOut( newFont.strikeOut() );
190 yAxis.setWeight( newFont.weight() );
191 yAxis.setItalic( newFont.italic() );
192 yAxis.setUnderline( newFont.underline() );
193 yAxis.setStrikeOut( newFont.strikeOut() );
196 if ( TDEFontChooser::SizeList & flags ) {
197 xAxis.setPointSize( newFont.pointSize() );
198 yAxis.setPointSize( newFont.pointSize() );
205 if ( TQButton::NoChange != newState ) {
206 xAxisIsRelative = newState;
207 yAxisIsRelative = newState;
211 else if ( font && state ) {
212 TQFont newFont( *font );
213 TQButton::ToggleState newState = *state;
214 if (TDEFontDialog::getFont( newFont,
218 &newState ) != TQDialog::Rejected) {
220 if ( TQButton::NoChange != newState )
227void KChartFontConfigPage::init()
230 leftparms = m_params->axisParams( KDChartAxisParams::AxisPosLeft );
232 rightparms = m_params->axisParams( KDChartAxisParams::AxisPosRight );
234 bottomparms = m_params->axisParams( KDChartAxisParams::AxisPosBottom );
238 ? TQButton::On : TQButton::Off;
240 if ( TQButton::On == xAxisIsRelative )
245 ? TQButton::On : TQButton::Off;
247 if ( TQButton::On == yAxisIsRelative )
254 xTitle = m_params->axisTitleFont( KDChartAxisParams::AxisPosBottom );
255 yTitle = m_params->axisTitleFont( KDChartAxisParams::AxisPosLeft );
256 xTitle.setPointSize( m_params->axisTitleFontRelSize( KDChartAxisParams::AxisPosBottom ) );
257 yTitle.setPointSize( m_params->axisTitleFontRelSize( KDChartAxisParams::AxisPosLeft ) );
268void KChartFontConfigPage::apply()
272 leftparms = m_params->axisParams( KDChartAxisParams::AxisPosLeft );
274 rightparms = m_params->axisParams( KDChartAxisParams::AxisPosRight );
276 bottomparms = m_params->axisParams( KDChartAxisParams::AxisPosBottom );
279 if ( TQButton::On == yAxisIsRelative )
286 if ( TQButton::On == yAxisIsRelative )
290 if ( TQButton::On == xAxisIsRelative )
294 m_params->setAxisParams( KDChartAxisParams::AxisPosLeft, leftparms );
295 m_params->setAxisParams( KDChartAxisParams::AxisPosRight, rightparms );
296 m_params->setAxisParams( KDChartAxisParams::AxisPosBottom, bottomparms );
302 m_params->setAxisTitleFont( KDChartAxisParams::AxisPosLeft, yTitle );
303 m_params->setAxisTitleFont( KDChartAxisParams::AxisPosBottom, xTitle );
304 m_params->setAxisTitleFontRelSize( KDChartAxisParams::AxisPosLeft, yTitle.pointSize() );
305 m_params->setAxisTitleFontRelSize( KDChartAxisParams::AxisPosBottom, xTitle.pointSize() );
access the chart axis parameters.
void setAxisLabelsFont(TQFont axisLabelsFont, bool useFontSize)
Specifies the axis labels font.
TQFont axisLabelsFont() const
Returns the axis labels font.
int axisLabelsFontRelSize() const
Returns the axis labels relative font size.
bool axisLabelsFontUseRelSize() const
Returns whether the fix axis font size is used.
void setAxisLabelsFontRelSize(int axisLabelsFontRelSize)
Specifies the axis labels relative font size.