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>
42#include "kchart_params.h"
45class KChartFontListBoxItem :
public TQListBoxText
48 KChartFontListBoxItem( TQListBox* lb,
const TQString& text = TQString() ) :
49 TQListBoxText( lb, text ) {}
50 KChartFontListBoxItem(
const TQString& text = TQString() ) :
51 TQListBoxText( text ) {}
53 void setFont(
const TQFont& font ) {
62 void paint( TQPainter* painter )
65 painter->setFont( _font );
66 TQListBoxText::paint( painter );
81KChartFontConfigPage::KChartFontConfigPage( KChartParams* params,
83 KDChartTableData *dat) :
84 TQWidget( parent ), m_params( params ), data(dat)
86 TQGridLayout *grid =
new TQGridLayout(
this,4,3,KDialog::marginHint(), KDialog::spacingHint());
89 m_list =
new TQListBox(
this);
90 m_list->resize( m_list->sizeHint() );
91 grid->addWidget(m_list, 0, 0);
94 m_fontButton =
new TQPushButton(
this);
95 m_fontButton->setText(i18n(
"Font..."));
96 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."));
97 m_fontButton->resize( m_fontButton->sizeHint() );
98 grid->addWidget( m_fontButton, 1, 0);
102 TDEFontChooser *fontChooser =
new TDEFontChooser(
this,
"fontChooser");
103 grid->addMultiCellWidget(fontChooser, 0, 2, 1, 1);
106 grid->setColStretch(2, 1);
107 grid->setRowStretch(3, 1);
109 connect( m_fontButton, TQ_SIGNAL(clicked()),
110 this, TQ_SLOT(changeLabelFont()));
111 connect( m_list, TQ_SIGNAL(doubleClicked ( TQListBoxItem * )),
112 this, TQ_SLOT(changeLabelFont()));
119void KChartFontConfigPage::initList()
121 if ( m_params->chartType() != KChartParams::Pie
122 && m_params->chartType() != KChartParams::Ring ) {
123 m_list->insertItem(
new KChartFontListBoxItem( i18n(
"X-Title")));
124 m_list->insertItem(
new KChartFontListBoxItem( i18n(
"Y-Title")));
125 m_list->insertItem(
new KChartFontListBoxItem( i18n(
"X-Axis")));
126 m_list->insertItem(
new KChartFontListBoxItem( i18n(
"Y-Axis")));
127 m_list->insertItem(
new KChartFontListBoxItem( i18n(
"All Axes")));
130 m_list->insertItem(i18n(
"Label"));
131 m_list->setCurrentItem(0);
136void KChartFontConfigPage::changeLabelFont()
139 TQButton::ToggleState *state = 0;
140 bool diffAxes =
false;
142 if (m_list->currentText()==i18n(
"X-Title")) {
144 state = &xTitleIsRelative;
145 }
else if(m_list->currentText()==i18n(
"Y-Title")) {
147 state = &yTitleIsRelative;
148 }
else if(m_list->currentText()==i18n(
"X-Axis")) {
150 state = &xAxisIsRelative;
151 }
else if(m_list->currentText()==i18n(
"Y-Axis")) {
153 state = &yAxisIsRelative;
154 }
else if(m_list->currentText()==i18n(
"All Axes")) {
156 }
else if(m_list->currentText()==i18n(
"Label")) {
158 state = &labelIsRelative;
161 kdDebug( 35001 ) <<
"Pb in listBox" << endl;
166 TQButton::ToggleState newState
167 = (xAxisIsRelative == yAxisIsRelative)
168 ? (xAxisIsRelative ? TQButton::On : TQButton::Off)
169 : TQButton::NoChange;
170 if (TDEFontDialog::getFontDiff( newFont,
175 &newState ) != TQDialog::Rejected) {
176 if ( TDEFontChooser::FamilyList & flags ) {
177 xAxis.setFamily( newFont.family() );
178 yAxis.setFamily( newFont.family() );
181 if ( TDEFontChooser::StyleList & flags ) {
182 xAxis.setWeight( newFont.weight() );
183 xAxis.setItalic( newFont.italic() );
184 xAxis.setUnderline( newFont.underline() );
185 xAxis.setStrikeOut( newFont.strikeOut() );
187 yAxis.setWeight( newFont.weight() );
188 yAxis.setItalic( newFont.italic() );
189 yAxis.setUnderline( newFont.underline() );
190 yAxis.setStrikeOut( newFont.strikeOut() );
193 if ( TDEFontChooser::SizeList & flags ) {
194 xAxis.setPointSize( newFont.pointSize() );
195 yAxis.setPointSize( newFont.pointSize() );
202 if ( TQButton::NoChange != newState ) {
203 xAxisIsRelative = newState;
204 yAxisIsRelative = newState;
208 else if ( font && state ) {
209 TQFont newFont( *font );
210 TQButton::ToggleState newState = *state;
211 if (TDEFontDialog::getFont( newFont,
215 &newState ) != TQDialog::Rejected) {
217 if ( TQButton::NoChange != newState )
224void KChartFontConfigPage::init()
227 leftparms = m_params->axisParams( KDChartAxisParams::AxisPosLeft );
229 rightparms = m_params->axisParams( KDChartAxisParams::AxisPosRight );
231 bottomparms = m_params->axisParams( KDChartAxisParams::AxisPosBottom );
235 ? TQButton::On : TQButton::Off;
237 if ( TQButton::On == xAxisIsRelative )
242 ? TQButton::On : TQButton::Off;
244 if ( TQButton::On == yAxisIsRelative )
251 xTitle = m_params->axisTitleFont( KDChartAxisParams::AxisPosBottom );
252 yTitle = m_params->axisTitleFont( KDChartAxisParams::AxisPosLeft );
253 xTitle.setPointSize( m_params->axisTitleFontRelSize( KDChartAxisParams::AxisPosBottom ) );
254 yTitle.setPointSize( m_params->axisTitleFontRelSize( KDChartAxisParams::AxisPosLeft ) );
265void KChartFontConfigPage::apply()
269 leftparms = m_params->axisParams( KDChartAxisParams::AxisPosLeft );
271 rightparms = m_params->axisParams( KDChartAxisParams::AxisPosRight );
273 bottomparms = m_params->axisParams( KDChartAxisParams::AxisPosBottom );
276 if ( TQButton::On == yAxisIsRelative )
283 if ( TQButton::On == yAxisIsRelative )
287 if ( TQButton::On == xAxisIsRelative )
291 m_params->setAxisParams( KDChartAxisParams::AxisPosLeft, leftparms );
292 m_params->setAxisParams( KDChartAxisParams::AxisPosRight, rightparms );
293 m_params->setAxisParams( KDChartAxisParams::AxisPosBottom, bottomparms );
299 m_params->setAxisTitleFont( KDChartAxisParams::AxisPosLeft, yTitle );
300 m_params->setAxisTitleFont( KDChartAxisParams::AxisPosBottom, xTitle );
301 m_params->setAxisTitleFontRelSize( KDChartAxisParams::AxisPosLeft, yTitle.pointSize() );
302 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.