#include "kchartWizardSelectChartTypePage.h" #include "kchart_params.h" #include "kchart_view.h" #include "kchart_factory.h" #include "kchart_part.h" #include #include #include #include #include #include #include namespace KChart { KChartButton::KChartButton(TQWidget *parent, const TQString & _text, const TQPixmap &_pixmap) : TQVBox(parent) { // The button m_button = new TQPushButton(this); m_button->setPixmap(_pixmap); m_button->setToggleButton( true ); // The text TQLabel *label = new TQLabel(_text, this); label->setSizePolicy(TQSizePolicy::Fixed,TQSizePolicy::Fixed); setSizePolicy(TQSizePolicy::Expanding,TQSizePolicy::Fixed); } KChartButton::~KChartButton() { } // ================================================================ KChartWizardSelectChartTypePage::KChartWizardSelectChartTypePage( TQWidget* parent, KChartPart* chart ) : TQWidget( parent ), m_chart( chart ) { m_typeBG = new TQButtonGroup( this ); m_typeBG->setExclusive( true ); m_typeBG->hide(); // m_typeBG->resize m_colPos=0; m_rowPos=0; m_layout = new TQGridLayout(this, 3, 4, 5); m_layout->setRowStretch(0, 0); m_layout->setRowStretch(1, 0); m_layout->setRowStretch(2, 0); addButton( i18n( "Bar" ), "chart_bar", KChartParams::Bar ); addButton( i18n( "Lines" ), "chart_line", KChartParams::Line ); addButton( i18n( "Area" ), "chart_area", KChartParams::Area ); #if 0 addButton( i18n( "Bars & Lines" ), "chart_barlines", KChartParams::BarLines ); #endif addButton( i18n("Hi-Lo-Close"), "chart_hilo", KChartParams::HiLo ); addButton( i18n("Box & Whisker "), "chart_boxwhisker", KChartParams::BoxWhisker ); incPos(); incPos(); addButton( i18n( "Pie" ), "chart_pie", KChartParams::Pie ); addButton( i18n( "Ring" ), "chart_ring", KChartParams::Ring ); addButton( i18n( "Polar" ), "chart_polar", KChartParams::Polar); TQPushButton *current = ((TQPushButton*)m_typeBG->find( m_chart->params()->chartType() )); if (current != NULL) { current->setOn( true ); } m_type = m_chart->params()->chartType(); connect( m_typeBG, TQ_SIGNAL( clicked( int ) ), this, TQ_SLOT( chartTypeSelected( int ) ) ); //// parent->resize( 425, 256 ); // parent->resize(xstep*5+50, ystep*4 + 100); } void KChartWizardSelectChartTypePage::addButton(const TQString &name, const TQString &icon_name, int type) { KChartButton *button = new KChartButton( this, name, BarIcon( icon_name, TDEIcon::SizeMedium, TDEIcon::DefaultState, KChartFactory::global()) ); m_layout->addWidget(button, m_rowPos, m_colPos); m_typeBG->insert( button->button(), type ); incPos(); } void KChartWizardSelectChartTypePage::incPos() { if (m_colPos == 3) { m_colPos=0; m_rowPos++; //place the next button in the second row } else m_colPos++; } void KChartWizardSelectChartTypePage::chartTypeSelected( int type ) { m_type = (KChartParams::ChartType) type; emit chartChange(type); } void KChartWizardSelectChartTypePage::apply() { m_chart->params()->setChartType( m_type ); } } //namespace KChart #include "kchartWizardSelectChartTypePage.moc"