kspread Library API Documentation

configdlg.cpp

00001 /*
00002 
00003  $Id: configdlg.cpp 399247 2005-03-20 16:49:54Z johnflux $
00004 
00005  KCalc
00006 
00007  Copyright (C) Bernd Johannes Wuebben
00008                wuebben@math.cornell.edu
00009            wuebben@kde.org
00010 
00011  This program is free software; you can redistribute it and/or
00012  modify it under the terms of the GNU General Public License
00013  as published by the Free Software Foundation; either version 2
00014  of the License, or (at your option) any later version.
00015 
00016  This program is distributed in the hope that it will be useful,
00017  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  GNU General Public License for more details.
00020 
00021  You should have received a copy of the GNU General Public License
00022  along with this program; if not, write to the Free Software
00023  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00024 
00025  */
00026 
00027 #include "configdlg.h"
00028 
00029 #include <klocale.h>
00030 #include <kdialog.h>
00031 #include <qlayout.h>
00032 
00033 // Undefine HAVE_LONG_DOUBLE for Beta 4 since RedHat 5.0 comes with a borken
00034 // glibc
00035 
00036 #ifdef HAVE_LONG_DOUBLE
00037 #undef HAVE_LONG_DOUBLE
00038 #endif
00039 
00040 ConfigDlg::ConfigDlg(QWidget *parent, const char *name, DefStruct *defstruct)
00041   : QDialog(parent, name)
00042 {
00043   defst = defstruct;
00044 
00045   QVBoxLayout *lay1 = new QVBoxLayout( this );
00046   lay1->setMargin( KDialog::marginHint() );
00047   lay1->setSpacing( KDialog::spacingHint() );
00048 
00049   box = new QGroupBox(0, Qt::Vertical, i18n("Defaults"), this, "box");
00050   box->layout()->setSpacing(KDialog::spacingHint());
00051   box->layout()->setMargin(KDialog::marginHint());
00052 
00053   QGridLayout *grid1 = new QGridLayout(box->layout(),8,2);
00054   label1 = new QLabel(box);
00055   label1->setText(i18n("Foreground color:"));
00056   grid1->addWidget(label1,0,0);
00057 
00058   button1 = new KColorButton( box, "button1" );
00059   grid1->addWidget(button1,0,1);
00060   button1->setColor( defst->forecolor );
00061 
00062   connect(button1 , SIGNAL( changed( const QColor & ) ),
00063              this, SLOT( set_fore_color( const QColor & ) ) );
00064 
00065   label2 = new QLabel(box);
00066   grid1->addWidget(label2,1,0);
00067   label2->setText(i18n("Background color:"));
00068 
00069   button2 = new KColorButton( box, "button2" );
00070   grid1->addWidget(button2,1,1);
00071   button2->setColor( defst->backcolor );
00072 
00073   connect(button2 , SIGNAL( changed( const QColor & ) ),
00074              this, SLOT( set_background_color( const QColor & ) ) );
00075 
00076 
00077   //  connect(button2,SIGNAL(clicked()),this,SLOT(set_background_color()));
00078 
00079 
00080   label5 = new QLabel(box);
00081   grid1->addWidget(label5,2,0);
00082   label5->setText(i18n("Precision:"));
00083 
00084   int maxprec;
00085 #ifdef HAVE_LONG_DOUBLE
00086   maxprec = 16 ;
00087 #else
00088   maxprec = 12 ;
00089 #endif
00090 
00091   precspin = new QSpinBox( box );
00092   precspin->setRange( 0, maxprec );
00093   grid1->addWidget(precspin,2,1);
00094 
00095   if( defst->precision <= maxprec)
00096     precspin->setValue(defst->precision);
00097   else
00098     precspin->setValue(maxprec);
00099 
00100 
00101   cb = new QCheckBox(box);
00102   grid1->addWidget(cb,3,0);
00103   cb->setText(i18n("Set fixed precision at:"));
00104   if(defst->fixed)
00105     cb->setChecked(true);
00106 
00107   int fixprec;
00108 #ifdef HAVE_LONG_DOUBLE
00109   fixprec = 14 ;
00110 #else
00111   fixprec = 10 ;
00112 #endif
00113 
00114   precspin2 = new QSpinBox( box );
00115   precspin2->setRange(0,fixprec);
00116   grid1->addWidget(precspin2,3,1);
00117 
00118   if( defst->fixedprecision <= fixprec)
00119     precspin2->setValue(defst->fixedprecision);
00120   else
00121     precspin2->setValue(fixprec);
00122 
00123 
00124 
00125   cb2 = new QCheckBox(box);
00126   grid1->addWidget(cb2,4,0);
00127   cb2->setText(i18n("Beep on error"));
00128   if(defst->beep)
00129     cb2->setChecked(true);
00130 
00131 
00132   stylegroup = new QButtonGroup(box,"stylegroup");
00133   grid1->addMultiCellWidget(stylegroup,5,7,0,1);
00134   stylegroup->setFrameStyle(QFrame::NoFrame);
00135 
00136   QGridLayout *grid2 = new QGridLayout(stylegroup,2,2,KDialog::marginHint(), KDialog::spacingHint());
00137 
00138   trigstyle = new QRadioButton(i18n("Trigonometry mode"),stylegroup,"trigstyle");
00139   grid2->addWidget(trigstyle,0,0);
00140   trigstyle->adjustSize();
00141   trigstyle->setChecked(defst->style == 0 );
00142 
00143   statstyle = new QRadioButton(i18n("Statistical mode"),stylegroup,"Stats");
00144   grid2->addWidget(statstyle,1,0);
00145   statstyle->adjustSize();
00146   statstyle->setChecked(defst->style == 1 );
00147 
00148   sheetstyle = new QRadioButton(i18n("Sheet mode"),stylegroup,"Sheet");
00149   grid2->addWidget(sheetstyle,2,0);
00150   sheetstyle->adjustSize();
00151 
00152   sheetstyle->setChecked(defst->style == 2 );
00153   button3 = new QPushButton(stylegroup);
00154   grid2->addWidget(button3,0,1);
00155   button3->setText(i18n("Help"));
00156 
00157   connect(button3,SIGNAL(clicked()),this,SLOT(help()));
00158 
00159   lay1->addWidget(box);
00160   connect(parent,SIGNAL(applyButtonPressed()),SLOT(okButton()));
00161 }
00162 
00163 void ConfigDlg::help()
00164 {
00165 }
00166 
00167 void ConfigDlg::okButton()
00168 {
00169   defst->precision = precspin->value();
00170   defst->fixedprecision = precspin2->value();
00171   defst->fixed = cb->isChecked();
00172   defst->beep = cb2->isChecked();
00173 
00174 
00175   if( trigstyle->isChecked())
00176     defst->style = 0;
00177   else if ( statstyle->isChecked() )
00178     defst->style = 1;
00179   else
00180     defst->style = 2;
00181 }
00182 
00183 void ConfigDlg::cancelbutton()
00184 {
00185   reject();
00186 }
00187 
00188 void ConfigDlg::set_fore_color(const QColor &_color)
00189 {
00190         defst->forecolor=_color;
00191 }
00192 
00193 void ConfigDlg::set_background_color( const QColor &_color )
00194 {
00195         defst->backcolor=_color;
00196 }
00197 
00198 #include "configdlg.moc"
KDE Logo
This file is part of the documentation for kspread Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:42:44 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003