kchart

kchartWizardSelectChartTypePage.cpp
1
2#include "kchartWizardSelectChartTypePage.h"
3#include "kchart_params.h"
4#include "kchart_view.h"
5#include "kchart_factory.h"
6#include "kchart_part.h"
7
8#include <tqbuttongroup.h>
9#include <tqframe.h>
10#include <tqpushbutton.h>
11#include <tqlabel.h>
12
13#include <tdelocale.h>
14#include <tdeglobal.h>
15#include <kiconloader.h>
16
17namespace KChart
18{
19
20
21KChartButton::KChartButton(TQWidget *parent, const TQString & _text, const TQPixmap &_pixmap)
22 : TQVBox(parent)
23{
24 // The button
25 m_button = new TQPushButton(this);
26 m_button->setPixmap(_pixmap);
27 m_button->setToggleButton( true );
28
29 // The text
30 TQLabel *label = new TQLabel(_text, this);
31 label->setSizePolicy(TQSizePolicy::Fixed,TQSizePolicy::Fixed);
32 setSizePolicy(TQSizePolicy::Expanding,TQSizePolicy::Fixed);
33}
34
35KChartButton::~KChartButton()
36{
37}
38
39
40// ================================================================
41
42
43KChartWizardSelectChartTypePage::KChartWizardSelectChartTypePage( TQWidget* parent,
44 KChartPart* chart )
45 : TQWidget( parent ),
46 m_chart( chart )
47{
48 m_typeBG = new TQButtonGroup( this );
49 m_typeBG->setExclusive( true );
50 m_typeBG->hide();
51 // m_typeBG->resize
52
53 m_colPos=0;
54 m_rowPos=0;
55 m_layout = new TQGridLayout(this, 3, 4, 5);
56 m_layout->setRowStretch(0, 0);
57 m_layout->setRowStretch(1, 0);
58 m_layout->setRowStretch(2, 0);
59
60 addButton( i18n( "Bar" ), "chart_bar", KChartParams::Bar );
61 addButton( i18n( "Lines" ), "chart_line", KChartParams::Line );
62 addButton( i18n( "Area" ), "chart_area", KChartParams::Area );
63#if 0
64 addButton( i18n( "Bars & Lines" ), "chart_barlines", KChartParams::BarLines );
65#endif
66
67 addButton( i18n("Hi-Lo-Close"), "chart_hilo", KChartParams::HiLo );
68 addButton( i18n("Box & Whisker "), "chart_boxwhisker", KChartParams::BoxWhisker );
69 incPos();
70 incPos();
71
72 addButton( i18n( "Pie" ), "chart_pie", KChartParams::Pie );
73 addButton( i18n( "Ring" ), "chart_ring", KChartParams::Ring );
74 addButton( i18n( "Polar" ), "chart_polar", KChartParams::Polar);
75
76 TQPushButton *current = ((TQPushButton*)m_typeBG->find( m_chart->params()->chartType() ));
77 if (current != NULL) {
78 current->setOn( true );
79 }
80
81 m_type = m_chart->params()->chartType();
82 connect( m_typeBG, TQ_SIGNAL( clicked( int ) ),
83 this, TQ_SLOT( chartTypeSelected( int ) ) );
84
86 // parent->resize(xstep*5+50, ystep*4 + 100);
87}
88
89
90void KChartWizardSelectChartTypePage::addButton(const TQString &name,
91 const TQString &icon_name,
92 int type)
93{
94 KChartButton *button = new KChartButton( this, name,
95 BarIcon( icon_name,
96 TDEIcon::SizeMedium,
97 TDEIcon::DefaultState,
98 KChartFactory::global()) );
99 m_layout->addWidget(button, m_rowPos, m_colPos);
100 m_typeBG->insert( button->button(), type );
101
102 incPos();
103}
104
105void KChartWizardSelectChartTypePage::incPos()
106{
107 if (m_colPos == 3) {
108 m_colPos=0;
109 m_rowPos++; //place the next button in the second row
110 }
111 else
112 m_colPos++;
113}
114
115void KChartWizardSelectChartTypePage::chartTypeSelected( int type )
116{
117 m_type = (KChartParams::ChartType) type;
118 emit chartChange(type);
119}
120
121void KChartWizardSelectChartTypePage::apply()
122{
123 m_chart->params()->setChartType( m_type );
124}
125
126} //namespace KChart
127
128#include "kchartWizardSelectChartTypePage.moc"