summaryrefslogtreecommitdiffstats
path: root/kspread/plugins/calculator/configdlg.cpp
blob: 56af25b4d1e7d29cb750ccbfcdf044cc02672371 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/*

 $Id: configdlg.cpp 466447 2005-10-02 17:54:10Z zander $

 KCalc

 Copyright (C) Bernd Johannes Wuebben
               wuebben@math.cornell.edu
	       wuebben@kde.org

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 This program 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 General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.

 */

#include "configdlg.h"

#include <tdelocale.h>
#include <kdialog.h>
#include <tqlayout.h>

// Undefine HAVE_LONG_DOUBLE for Beta 4 since RedHat 5.0 comes with a borken
// glibc

#ifdef HAVE_LONG_DOUBLE
#undef HAVE_LONG_DOUBLE
#endif

ConfigDlg::ConfigDlg(TQWidget *parent, const char *name, DefStruct *defstruct)
  : TQDialog(parent, name)
{
  defst = defstruct;

  TQVBoxLayout *lay1 = new TQVBoxLayout( this );
  lay1->setMargin( KDialog::marginHint() );
  lay1->setSpacing( KDialog::spacingHint() );

  box = new TQGroupBox(0, Qt::Vertical, i18n("Defaults"), this, "box");
  box->layout()->setSpacing(KDialog::spacingHint());
  box->layout()->setMargin(KDialog::marginHint());

  TQGridLayout *grid1 = new TQGridLayout(box->layout(),8,2);
  label1 = new TQLabel(box);
  label1->setText(i18n("Foreground color:"));
  grid1->addWidget(label1,0,0);

  button1 = new KColorButton( box, "button1" );
  grid1->addWidget(button1,0,1);
  button1->setColor( defst->forecolor );

  connect(button1 , TQT_SIGNAL( changed( const TQColor & ) ),
             this, TQT_SLOT( set_fore_color( const TQColor & ) ) );

  label2 = new TQLabel(box);
  grid1->addWidget(label2,1,0);
  label2->setText(i18n("Background color:"));

  button2 = new KColorButton( box, "button2" );
  grid1->addWidget(button2,1,1);
  button2->setColor( defst->backcolor );

  connect(button2 , TQT_SIGNAL( changed( const TQColor & ) ),
             this, TQT_SLOT( set_background_color( const TQColor & ) ) );


  //  connect(button2,TQT_SIGNAL(clicked()),this,TQT_SLOT(set_background_color()));


  label5 = new TQLabel(box);
  grid1->addWidget(label5,2,0);
  label5->setText(i18n("Precision:"));

  int maxprec;
#ifdef HAVE_LONG_DOUBLE
  maxprec = 16 ;
#else
  maxprec = 12 ;
#endif

  precspin = new TQSpinBox( box );
  precspin->setRange( 0, maxprec );
  grid1->addWidget(precspin,2,1);

  if( defst->precision <= maxprec)
    precspin->setValue(defst->precision);
  else
    precspin->setValue(maxprec);


  cb = new TQCheckBox(box);
  grid1->addWidget(cb,3,0);
  cb->setText(i18n("Set fixed precision at:"));
  if(defst->fixed)
    cb->setChecked(true);

  int fixprec;
#ifdef HAVE_LONG_DOUBLE
  fixprec = 14 ;
#else
  fixprec = 10 ;
#endif

  precspin2 = new TQSpinBox( box );
  precspin2->setRange(0,fixprec);
  grid1->addWidget(precspin2,3,1);

  if( defst->fixedprecision <= fixprec)
    precspin2->setValue(defst->fixedprecision);
  else
    precspin2->setValue(fixprec);



  cb2 = new TQCheckBox(box);
  grid1->addWidget(cb2,4,0);
  cb2->setText(i18n("Beep on error"));
  if(defst->beep)
    cb2->setChecked(true);


  stylegroup = new TQButtonGroup(box,"stylegroup");
  grid1->addMultiCellWidget(stylegroup,5,7,0,1);
  stylegroup->setFrameStyle(TQFrame::NoFrame);

  TQGridLayout *grid2 = new TQGridLayout(stylegroup,2,2,KDialog::marginHint(), KDialog::spacingHint());

  trigstyle = new TQRadioButton(i18n("Trigonometry mode"),stylegroup,"trigstyle");
  grid2->addWidget(trigstyle,0,0);
  trigstyle->adjustSize();
  trigstyle->setChecked(defst->style == 0 );

  statstyle = new TQRadioButton(i18n("Statistical mode"),stylegroup,"Stats");
  grid2->addWidget(statstyle,1,0);
  statstyle->adjustSize();
  statstyle->setChecked(defst->style == 1 );

  sheetstyle = new TQRadioButton(i18n("Sheet mode"),stylegroup,"Sheet");
  grid2->addWidget(sheetstyle,2,0);
  sheetstyle->adjustSize();

  sheetstyle->setChecked(defst->style == 2 );
  button3 = new TQPushButton(stylegroup);
  grid2->addWidget(button3,0,1);
  button3->setText(i18n("Help"));

  connect(button3,TQT_SIGNAL(clicked()),this,TQT_SLOT(help()));

  lay1->addWidget(box);
  connect(parent,TQT_SIGNAL(applyButtonPressed()),TQT_SLOT(okButton()));
}

void ConfigDlg::help()
{
}

void ConfigDlg::okButton()
{
  defst->precision = precspin->value();
  defst->fixedprecision = precspin2->value();
  defst->fixed = cb->isChecked();
  defst->beep = cb2->isChecked();


  if( trigstyle->isChecked())
    defst->style = 0;
  else if ( statstyle->isChecked() )
    defst->style = 1;
  else
    defst->style = 2;
}

void ConfigDlg::cancelbutton()
{
  reject();
}

void ConfigDlg::set_fore_color(const TQColor &_color)
{
        defst->forecolor=_color;
}

void ConfigDlg::set_background_color( const TQColor &_color )
{
        defst->backcolor=_color;
}

#include "configdlg.moc"