summaryrefslogtreecommitdiffstats
path: root/kcalc/kcalc.h
blob: 4abceb7a8ead393b3d73f36346573346e174fcc5 (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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
/*
    KCalc, a scientific calculator for the X window system using the
    TQt widget libraries, available at no cost at http://www.troll.no

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

    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.

*/

#ifndef KCALC_H
#define KCALC_H

class TQPushButton;
class TQRadioButton;
class TQButtonGroup;
class TQHButtonGroup;
class TQWidget;
class DispLogic;
class Constants;
#include <kmainwindow.h>

/*
  Kcalc basically consist of a class for the GUI (here), a class for
  the display (dlabel.h), and one for the mathematics core
  (kcalc_core.h).

  When for example '+' is pressed, one sends the contents of the
  Display and the '+' to the core via "core.Plus(DISPLAY_AMOUNT)".
  This only updates the core. To bring the changes to the display,
  use afterwards "UpdateDisplay(true)".

  "UpdateDisplay(true)" means that the amount to be displayed should
  be taken from the core (get the result of some operation that was
  performed), "UpdateDisplay(false)" has already the information, what
  to be display (e.g. user is typing in a number).  Note that in the
  last case the core does not know the number typed in until some
  operation button is pressed, e.g. "core.Plus(display_number)".
 */

#include "config.h"

// IMPORTANT this has to come after ../config.h
#include "kcalc_core.h"
#include "kcalc_button.h"
#include "kcalc_const_button.h"

class KCalculator : public KMainWindow
{
    Q_OBJECT
  TQ_OBJECT

public:
	KCalculator(TQWidget *parent = 0, const char *name = 0);
	~KCalculator();

signals:
	void switchInverse(bool);
	void switchMode(ButtonModeFlags,bool);
	void switchShowAccels(bool);

private:
	virtual bool eventFilter( TQObject *o, TQEvent *e );
	void updateGeometry();
	void setupMainActions(void);
	void setupStatusbar(void);
	TQWidget *setupNumericKeys(TQWidget *parent);
	void setupLogicKeys(TQWidget *parent);
	void setupScientificKeys(TQWidget *parent);
	void setupStatisticKeys(TQWidget *parent);
	void setupConstantsKeys(TQWidget *parent);
	void keyPressEvent(TQKeyEvent *e);
	void keyReleaseEvent(TQKeyEvent *e);
	void set_precision();
	void set_style();
	void resetBase(void) { (BaseChooseGroup->find(1))->animateClick();};

	void UpdateDisplay(bool get_amount_from_core = false,
			   bool store_result_in_history = false);

protected slots:
    void changeButtonNames();
    void updateSettings();
    void set_colors();
    void EnterEqual();
    void showSettings();
    void slotStatshow(bool toggled);
    void slotScientificshow(bool toggled);
    void slotLogicshow(bool toggled);
    void slotConstantsShow(bool toggled);   
    void slotShowAll(void);
    void slotHideAll(void);
    void slotAngleSelected(int number);
    void slotBaseSelected(int number);
    void slotNumberclicked(int number_clicked);
    void slotEEclicked(void);
    void slotInvtoggled(bool myboolean);
    void slotMemRecallclicked(void);
    void slotMemStoreclicked(void);
    void slotSinclicked(void);
    void slotPlusMinusclicked(void);
    void slotMemPlusMinusclicked(void);
    void slotCosclicked(void);
    void slotReciclicked(void);
    void slotTanclicked(void);
    void slotFactorialclicked(void);
    void slotLogclicked(void);
    void slotSquareclicked(void);
    void slotLnclicked(void);
    void slotPowerclicked(void);
    void slotMCclicked(void);
    void slotClearclicked(void);
    void slotACclicked(void);
    void slotParenOpenclicked(void);
    void slotParenCloseclicked(void);
    void slotANDclicked(void);
    void slotXclicked(void);
    void slotDivisionclicked(void);
    void slotORclicked(void);
    void slotXORclicked(void);
    void slotPlusclicked(void);
    void slotMinusclicked(void);
    void slotLeftShiftclicked(void);
    void slotRightShiftclicked(void);
    void slotPeriodclicked(void);
    void slotEqualclicked(void);
    void slotPercentclicked(void);
    void slotRootclicked(void);
    void slotNegateclicked(void);
    void slotModclicked(void);
    void slotStatNumclicked(void);
    void slotStatMeanclicked(void);
    void slotStatStdDevclicked(void);
    void slotStatMedianclicked(void);
    void slotStatDataInputclicked(void);
    void slotStatClearDataclicked(void);
    void slotHyptoggled(bool flag);
    void slotConstclicked(int);

    void slotConstantToDisplay(int constant);
    void slotChooseScientificConst0(int option);
    void slotChooseScientificConst1(int option);
    void slotChooseScientificConst2(int option);
    void slotChooseScientificConst3(int option);
    void slotChooseScientificConst4(int option);
    void slotChooseScientificConst5(int option);

private:
	bool inverse;
	bool hyp_mode;
	KNumber memory_num;
	KNumber setvalue;

	// angle modes for trigonometric values
	enum {
	  DegMode,
	  RadMode,
	  GradMode
	} _angle_mode;


private:
    TQWidget *mSmallPage;
    TQWidget *mLargePage;
    TQWidget *mNumericPage;

    DispLogic*	calc_display; // for historic reasons in "dlabel.h"
    TQRadioButton*	pbBaseChoose[4];
    TQPushButton*	pbAngleChoose;
    TQDict<KCalcButton>	pbStat;
    TQDict<KCalcButton>	pbScientific;
    TQDict<KCalcButton>	pbLogic;
    KCalcConstButton*	pbConstant[10];
    KCalcButton* 	pbAC;
    KCalcButton* 	pbAND;
    KCalcButton* 	pbClear;
    KCalcButton* 	pbDivision;
    KCalcButton* 	pbEE;
    KCalcButton* 	pbEqual;
    KCalcButton* 	pbFactorial;
    KCalcButton* 	pbInv;
    KCalcButton* 	pbMC;
    KCalcButton* 	pbMinus;
    KCalcButton* 	pbMod;
    KCalcButton* 	pbMemPlusMinus;
    KCalcButton* 	pbMemRecall;
    KCalcButton*	pbMemStore;
    KCalcButton* 	pbOR;
    KCalcButton* 	pbParenClose;
    KCalcButton* 	pbParenOpen;
    KCalcButton* 	pbPercent;
    KCalcButton* 	pbPeriod;
    KCalcButton* 	pbPlus;
    KCalcButton* 	pbPlusMinus;
    KCalcButton* 	pbPower;
    KCalcButton* 	pbReci;
    KSquareButton* 	pbRoot;
    KCalcButton* 	pbSquare;
    KCalcButton* 	pbX;
    KCalcButton* 	pbXOR;

    Constants * tmp_const; // this is the dialog for configuring const
			   // buttons would like to remove this, but
			   // don't know how
	
    TQHButtonGroup*      BaseChooseGroup;
    // NumButtonGroup: 0-9 = digits, 0xA-0xF = hex-keys
    TQButtonGroup* 	NumButtonGroup;
    // ConstButtonGroup C1-C6
    TQButtonGroup*	ConstButtonGroup;

    KToggleAction *actionStatshow;
    KToggleAction *actionScientificshow;
    KToggleAction *actionLogicshow;
    KToggleAction *actionConstantsShow;

    TQPtrList<KCalcButton> mFunctionButtonList;
    TQPtrList<KCalcButton> mStatButtonList;
    TQPtrList<KCalcButton> mMemButtonList;
    TQPtrList<KCalcButton> mOperationButtonList;

    int				mInternalSpacing;

    CalcEngine core;
};

#endif  // KCALC_H