You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
221 lines
8.4 KiB
221 lines
8.4 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
Copyright (C) 1999 Matthias Kalle Dalheimer <kalle@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
* Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#include "kchartColorConfigPage.h"
|
||
|
#include "kchartColorConfigPage.moc"
|
||
|
|
||
12 years ago
|
#include <tdeapplication.h>
|
||
15 years ago
|
#include <kdialog.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
#include <kcolorbutton.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
14 years ago
|
#include <tqlabel.h>
|
||
|
#include <tqbuttongroup.h>
|
||
|
#include <tqwhatsthis.h>
|
||
|
#include <tqhbox.h>
|
||
12 years ago
|
#include <tdelistbox.h>
|
||
15 years ago
|
#include "kchart_params.h"
|
||
|
#include <kdebug.h>
|
||
|
|
||
|
namespace KChart
|
||
|
{
|
||
|
|
||
|
KChartColorConfigPage::KChartColorConfigPage( KChartParams* params,
|
||
14 years ago
|
TQWidget* parent,
|
||
15 years ago
|
KDChartTableData *dat ) :
|
||
14 years ago
|
TQWidget( parent ),
|
||
15 years ago
|
m_params( params ),
|
||
|
m_data( dat ),
|
||
|
index( 0 )
|
||
|
{
|
||
14 years ago
|
TQWhatsThis::add( this, i18n( "This page lets you configure the colors "
|
||
15 years ago
|
"in which your chart is displayed. Each "
|
||
|
"part of the chart can be assigned a "
|
||
|
"different color." ) );
|
||
|
|
||
14 years ago
|
TQVBoxLayout* toplevel = new TQVBoxLayout( this, 14 );
|
||
|
TQButtonGroup* gb = new TQButtonGroup( 0, Qt::Vertical, i18n("Colors"), this );
|
||
13 years ago
|
gb->layout()->setSpacing(KDialog::spacingHint());
|
||
|
gb->layout()->setMargin(KDialog::marginHint());
|
||
15 years ago
|
toplevel->addWidget( gb);
|
||
14 years ago
|
TQString wtstr;
|
||
13 years ago
|
TQGridLayout* grid = new TQGridLayout( gb->layout(), 8, 3 );
|
||
15 years ago
|
|
||
|
const int labelAlign = AlignRight | AlignVCenter;
|
||
|
int row = -1;
|
||
|
#define ADD_COLOR_BTN(btn,title,whatsthis) \
|
||
|
{ \
|
||
|
++row; \
|
||
14 years ago
|
TQLabel* l = new TQLabel( title, gb ); \
|
||
13 years ago
|
l->setAlignment( labelAlign ); \
|
||
15 years ago
|
grid->addWidget( l, row, 0 ); \
|
||
|
btn = new KColorButton( gb ); \
|
||
|
l->setBuddy( btn ); \
|
||
|
grid->addWidget( btn, row, 1 ); \
|
||
14 years ago
|
TQWhatsThis::add( l, whatsthis ); \
|
||
|
TQWhatsThis::add( btn, whatsthis ); \
|
||
15 years ago
|
}
|
||
|
ADD_COLOR_BTN(_lineCB, i18n( "&Line color:" ),
|
||
|
i18n( "This is the color that is used for drawing lines like axes." ))
|
||
|
ADD_COLOR_BTN(_gridCB, i18n( "&Grid color:" ),
|
||
|
i18n( "Here you can configure the color that is used for the "
|
||
|
"chart grid. Of course, this setting will only "
|
||
|
"take effect if grid drawing is turned on." ))
|
||
|
ADD_COLOR_BTN(_xtitleCB, i18n( "&X-title color:" ),
|
||
|
i18n( "This color is used for displaying titles for the "
|
||
|
"X (horizontal) axis." ))
|
||
|
ADD_COLOR_BTN(_ytitleCB, i18n( "&Y-title color:" ),
|
||
|
i18n( "This color is used for displaying titles for the "
|
||
|
"Y (vertical) axis." ))
|
||
|
#if 0
|
||
|
ADD_COLOR_BTN(_ytitle2CB, i18n( "Y-title color (2nd axis):" ),
|
||
|
i18n( "This color is used for displaying titles for the "
|
||
|
"second Y (vertical) axis. It only takes effect if the "
|
||
|
"chart is configured to have a second Y axis." ))
|
||
|
#endif
|
||
|
ADD_COLOR_BTN(_xlabelCB, i18n( "X-label color:" ),
|
||
|
i18n( "Here you can configure the color that is used for "
|
||
|
"labeling the X (horizontal) axis" ))
|
||
|
ADD_COLOR_BTN(_ylabelCB, i18n( "Y-label color:" ),
|
||
|
i18n( "Here you can configure the color that is used for "
|
||
|
"labeling the Y (vertical) axis" ))
|
||
|
#if 0
|
||
|
ADD_COLOR_BTN(_ylabel2CB, i18n( "Y-label color (2nd axis):" ),
|
||
|
i18n( "Here you can configure the color that is used for "
|
||
|
"labeling the second Y (vertical) axis. Of course, "
|
||
|
"this setting only takes effect if the chart is "
|
||
|
"configured to have two vertical axes." ))
|
||
|
#endif
|
||
|
ADD_COLOR_BTN(_xlineCB, i18n( "X-line color:" ),
|
||
|
i18n( "Here you can configure the line color of the X (horizontal) axis" ))
|
||
|
ADD_COLOR_BTN(_ylineCB, i18n( "Y-line color:" ),
|
||
|
i18n( "Here you can configure the line color of the Y (vertical) axis" ))
|
||
|
#if 0
|
||
|
ADD_COLOR_BTN(_yline2CB, i18n( "Y-line color (2nd axis):" ),
|
||
|
i18n( "Here you can configure the line color of "
|
||
|
"the second Y (vertical) axis. Of course, "
|
||
|
"this setting only takes effect if the chart is "
|
||
|
"configured to have two vertical axes." ))
|
||
|
#endif
|
||
|
ADD_COLOR_BTN(_xzerolineCB, i18n( "X-Zero-line color:" ),
|
||
|
i18n( "Here you can configure the zero-line's color of the X "
|
||
|
"(horizontal) axis. Of course, this setting only takes "
|
||
|
"effect if the abscissa is displaying a Zero-line." ))
|
||
|
ADD_COLOR_BTN(_yzerolineCB, i18n( "Y-Zero-line color:" ),
|
||
|
i18n( "Here you can configure the zero-line's color of the Y (vertical) axis" ))
|
||
|
#if 0
|
||
|
ADD_COLOR_BTN(_yzeroline2CB, i18n( "Y-Zero-line color (2nd axis):" ),
|
||
|
i18n( "Here you can configure the color that is used for "
|
||
|
"the Zero-line of the second Y (vertical) axis. Of course, "
|
||
|
"this setting only takes effect if the chart is "
|
||
|
"configured to have two vertical axes." ))
|
||
|
#endif
|
||
|
|
||
14 years ago
|
TQHBox* dataColorHB = new TQHBox( gb );
|
||
15 years ago
|
grid->addMultiCellWidget( dataColorHB, 0, row, 2, 2 );
|
||
12 years ago
|
_dataColorLB = new TDEListBox(dataColorHB);
|
||
15 years ago
|
_dataColorCB = new KColorButton( dataColorHB);
|
||
|
wtstr = i18n( "Choose a row/column in the list on the left and change its color using this button.");
|
||
14 years ago
|
TQWhatsThis::add( _dataColorCB, wtstr );
|
||
15 years ago
|
initDataColorList();
|
||
14 years ago
|
connect( _dataColorLB, TQT_SIGNAL(highlighted(int )), this, TQT_SLOT(changeIndex(int)));
|
||
|
connect( _dataColorLB, TQT_SIGNAL(doubleClicked ( TQListBoxItem * )), this, TQT_SLOT(activeColorButton()));
|
||
15 years ago
|
|
||
|
|
||
|
|
||
14 years ago
|
/*TQLabel* edgeLA = new TQLabel( i18n( "Edge color (pies only)" ), this );
|
||
13 years ago
|
edgeLA->setAlignment( AlignRight | AlignVCenter );
|
||
15 years ago
|
grid->addWidget( edgeLA, 6, 0 );
|
||
|
_edgeCB = new KColorButton( this );
|
||
|
grid->addWidget( _edgeCB, 6, 1 );*/
|
||
|
|
||
|
// for( int i = 0; i < NUMDATACOLORS; i++ ) {
|
||
14 years ago
|
// TQString labeltext;
|
||
15 years ago
|
// labeltext.sprintf( i18n( "Data color #%d:"), i );
|
||
14 years ago
|
// TQLabel* dataLA = new TQLabel( labeltext, this );
|
||
13 years ago
|
// dataLA->setAlignment(AlignRight | AlignVCenter);
|
||
|
// dataLA->resize( dataLA->sizeHint() );
|
||
15 years ago
|
// grid->addWidget( dataLA, i, 2 );
|
||
|
// _dataCB[i] = new KColorButton( this );
|
||
13 years ago
|
// _dataCB[i]->resize( _dataCB[i]->sizeHint() );
|
||
15 years ago
|
// grid->addWidget( _dataCB[i], i, 3 );
|
||
|
// grid->addRowSpacing(i,_textCB->height());
|
||
|
// grid->setRowStretch(i,0);
|
||
|
// grid->addColSpacing(2,dataLA->width() + 20);
|
||
|
// }
|
||
|
}
|
||
|
|
||
|
|
||
|
void KChartColorConfigPage::changeIndex(int newindex)
|
||
|
{
|
||
|
if(index > m_params->maxDataColor())
|
||
|
_dataColorLB->setEnabled(false);
|
||
|
else
|
||
|
{
|
||
|
if(!_dataColorCB->isEnabled())
|
||
|
_dataColorCB->setEnabled(true);
|
||
|
extColor[index] = _dataColorCB->color();
|
||
|
_dataColorCB->setColor(extColor[newindex]);
|
||
|
index=newindex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void KChartColorConfigPage::activeColorButton()
|
||
|
{
|
||
|
_dataColorCB->animateClick();
|
||
|
}
|
||
|
|
||
|
|
||
|
void KChartColorConfigPage::initDataColorList()
|
||
|
{
|
||
14 years ago
|
TQStringList lst;
|
||
15 years ago
|
for(uint i = 0; i < m_data->rows(); i++)
|
||
|
{
|
||
|
extColor.resize( m_params->maxDataColor() );
|
||
|
if(i<m_params->maxDataColor())
|
||
|
{
|
||
13 years ago
|
_dataColorLB->insertItem(m_params->legendText( i ).isEmpty() ? i18n("Series %1").arg(i+1) :m_params->legendText( i ) );
|
||
15 years ago
|
extColor[i] =m_params->dataColor(i);
|
||
|
}
|
||
|
}
|
||
|
_dataColorLB->setCurrentItem(0);
|
||
|
|
||
|
//Fix crash when we didn't create data
|
||
|
if ( m_data->rows() == 0 )
|
||
|
_dataColorCB->setEnabled(false);
|
||
|
else
|
||
|
_dataColorCB->setColor( extColor[index]);
|
||
|
}
|
||
|
|
||
|
|
||
|
void KChartColorConfigPage::apply()
|
||
|
{
|
||
|
//Nothing to save
|
||
|
if ( m_data->rows() == 0 )
|
||
|
return;
|
||
|
|
||
|
extColor[index] = _dataColorCB->color();
|
||
|
for(uint i =0;i<m_data->rows();i++)
|
||
|
if(i<m_params->maxDataColor())
|
||
|
m_params->setDataColor(i,extColor[i]);
|
||
|
}
|
||
|
|
||
|
} //KChart namespace
|