00001
00002 #include "kchartWizardSelectChartTypePage.h"
00003 #include "kchart_params.h"
00004 #include "kchart_view.h"
00005 #include "kchart_factory.h"
00006 #include "kchart_part.h"
00007
00008 #include <qbuttongroup.h>
00009 #include <qframe.h>
00010 #include <qpushbutton.h>
00011 #include <qlabel.h>
00012
00013 #include <klocale.h>
00014 #include <kglobal.h>
00015 #include <kiconloader.h>
00016
00017 namespace KChart
00018 {
00019
00020
00021 KChartButton::KChartButton(QWidget *parent, const QString & _text, const QPixmap &_pixmap)
00022 : QVBox(parent)
00023 {
00024
00025 m_button = new QPushButton(this);
00026 m_button->setPixmap(_pixmap);
00027 m_button->setToggleButton( true );
00028
00029
00030 QLabel *label = new QLabel(_text, this);
00031 label->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
00032 setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
00033 }
00034
00035 KChartButton::~KChartButton()
00036 {
00037 }
00038
00039
00040
00041
00042
00043 KChartWizardSelectChartTypePage::KChartWizardSelectChartTypePage( QWidget* parent,
00044 KChartPart* chart )
00045 : QWidget( parent ),
00046 m_chart( chart )
00047 {
00048 m_typeBG = new QButtonGroup( this );
00049 m_typeBG->setExclusive( true );
00050 m_typeBG->hide();
00051
00052
00053 m_colPos=0;
00054 m_rowPos=0;
00055 m_layout = new QGridLayout(this, 3, 4, 5);
00056 m_layout->setRowStretch(0, 0);
00057 m_layout->setRowStretch(1, 0);
00058 m_layout->setRowStretch(2, 0);
00059
00060 addButton( i18n( "Bar" ), "chart_bar", KChartParams::Bar );
00061 addButton( i18n( "Lines" ), "chart_line", KChartParams::Line );
00062 addButton( i18n( "Area" ), "chart_area", KChartParams::Area );
00063 #if 0
00064 addButton( i18n( "Bars & Lines" ), "chart_barlines", KChartParams::BarLines );
00065 #endif
00066
00067 addButton( i18n("Hi-Lo-Close"), "chart_hilo", KChartParams::HiLo );
00068 addButton( i18n("Box & Whisker "), "chart_boxwhisker", KChartParams::BoxWhisker );
00069 incPos();
00070 incPos();
00071
00072 addButton( i18n( "Pie" ), "chart_pie", KChartParams::Pie );
00073 addButton( i18n( "Ring" ), "chart_ring", KChartParams::Ring );
00074 addButton( i18n( "Polar" ), "chart_polar", KChartParams::Polar);
00075
00076 QPushButton *current = ((QPushButton*)m_typeBG->find( m_chart->params()->chartType() ));
00077 if (current != NULL) {
00078 current->setOn( true );
00079 }
00080
00081 m_type = m_chart->params()->chartType();
00082 connect( m_typeBG, SIGNAL( clicked( int ) ),
00083 this, SLOT( chartTypeSelected( int ) ) );
00084
00086
00087 }
00088
00089
00090 void KChartWizardSelectChartTypePage::addButton(const QString &name,
00091 const QString &icon_name,
00092 int type)
00093 {
00094 KChartButton *button = new KChartButton( this, name,
00095 BarIcon( icon_name,
00096 KIcon::SizeMedium,
00097 KIcon::DefaultState,
00098 KChartFactory::global()) );
00099 m_layout->addWidget(button, m_rowPos, m_colPos);
00100 m_typeBG->insert( button->button(), type );
00101
00102 incPos();
00103 }
00104
00105 void KChartWizardSelectChartTypePage::incPos()
00106 {
00107 if (m_colPos == 3) {
00108 m_colPos=0;
00109 m_rowPos++;
00110 }
00111 else
00112 m_colPos++;
00113 }
00114
00115 void KChartWizardSelectChartTypePage::chartTypeSelected( int type )
00116 {
00117 m_type = (KChartParams::ChartType) type;
00118 emit chartChange(type);
00119 }
00120
00121 void KChartWizardSelectChartTypePage::apply()
00122 {
00123 m_chart->params()->setChartType( m_type );
00124 }
00125
00126 }
00127
00128 #include "kchartWizardSelectChartTypePage.moc"