You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
251 lines
4.9 KiB
251 lines
4.9 KiB
#ifndef MATHEMAGICS_H
|
|
#define MATHEMAGICS_H
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include <config.h>
|
|
#endif
|
|
|
|
#include <kapp.h>
|
|
#include <qwidget.h>
|
|
#include <qvaluelist.h>
|
|
#include <qptrlist.h>
|
|
#include <kmainwindow.h>
|
|
#include <kaction.h>
|
|
#include <qmap.h>
|
|
#include <qguardedptr.h>
|
|
|
|
#include "stacklevel.h"
|
|
#include "optiondialog.h"
|
|
#include "kparanoidline.h"
|
|
|
|
class KListAction;
|
|
class EditAction;
|
|
class ComboAction;
|
|
class QComboBox;
|
|
class QCloseEvent;
|
|
class QPushButton;
|
|
class QVBoxLayout;
|
|
class QScrollView;
|
|
class KToggleAction;
|
|
class MathKeypad;
|
|
|
|
class Mathemagics : public KMainWindow
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
/** construtor */
|
|
Mathemagics(QWidget* parent=0, const char *name=0, WFlags f = 0);
|
|
/** destructor */
|
|
~Mathemagics();
|
|
|
|
void updateStack();
|
|
|
|
protected slots:
|
|
void runFormula(const QString &);
|
|
bool runCommand(const QString &);
|
|
void openFile(const QString &filename);
|
|
void saveFile(const QString &filename);
|
|
void slotOpen();
|
|
|
|
void clearHistory();
|
|
void scrollToBottom();
|
|
|
|
void keypadClosing();
|
|
void insertChar(const QString &);
|
|
|
|
void configureToolBars();
|
|
void newToolBarConfig();
|
|
void keyBindings();
|
|
void toggleKeypad(bool);
|
|
|
|
void slotEnter();
|
|
void slotAdd();
|
|
void slotSubtract();
|
|
void slotMultiply();
|
|
void slotDivide();
|
|
void slotBackspace();
|
|
void slotKeypadBackspace();
|
|
|
|
void slotModulo();
|
|
void slotPercent();
|
|
void slotInverse();
|
|
void slotRaiseE();
|
|
void slotSqrt();
|
|
void slotSquared();
|
|
void slotSine();
|
|
void slotCosine();
|
|
void slotTangent();
|
|
void slotEEX();
|
|
void slotRaiseTen();
|
|
void slotLn();
|
|
void slotFactorial();
|
|
void slotPower();
|
|
void slotNegative();
|
|
void slotAnd();
|
|
void slotOr();
|
|
void slotXOr();
|
|
void slotLsh();
|
|
void slotRsh();
|
|
void slotDup2();
|
|
void slotDrop();
|
|
|
|
void slotUpdateStackLevel(int);
|
|
void slotRoll(int);
|
|
void slotRestoreStack();
|
|
void slotRevert();
|
|
|
|
void slotPushHighlighted(const QString&);
|
|
|
|
void slotConfigure();
|
|
void slotConfigureHide();
|
|
void slotConfigureDestroy();
|
|
void slotUpdateConfiguration();
|
|
|
|
void slotBaseChanged(int id);
|
|
void slotAngleChanged(int id);
|
|
|
|
protected:
|
|
void closeEvent(QCloseEvent *);
|
|
|
|
private:
|
|
QPtrList<StackLevel> stackLevels;
|
|
void recreateStackLevels();
|
|
QScrollView *topLevel;
|
|
QWidget *boxParent;
|
|
QVBoxLayout *bigBox;
|
|
EditAction* LineEdit;
|
|
ComboAction* HistoryBox;
|
|
|
|
KListAction *baseGroup;
|
|
KListAction *angGroup;
|
|
KListAction *formulae;
|
|
|
|
MathKeypad *keypad;
|
|
|
|
QValueList<double> *Stack;
|
|
QValueList<double> *SavedStack;
|
|
QStringList entryNums;
|
|
|
|
bool parseArgs(unsigned int reqArgs = 0, bool autoEnter = 1, bool save = 1);
|
|
|
|
double angConv(const double theDouble);
|
|
double angOut(const double theDouble);
|
|
QString theAngle();
|
|
|
|
int testArgs();
|
|
bool getArgs(unsigned int num);
|
|
QValueList<double> args;
|
|
|
|
double format(QString theString, bool *ok=0);
|
|
QString format(double theDouble);
|
|
|
|
void saveStack();
|
|
void enter();
|
|
|
|
int fact(int n);
|
|
|
|
//QStatusBar *statusBar;
|
|
int dispTime;
|
|
|
|
void error();
|
|
void changeStatus(QString text);
|
|
void changeStatusError(QString text);
|
|
void changeStatus(double * res, char op);
|
|
void changeStatus(double * res, QString op, bool prepend = 0);
|
|
|
|
void level5Return();
|
|
void level4Return();
|
|
void level3Return();
|
|
void level2Return();
|
|
void level1Return();
|
|
|
|
void roll(unsigned int index);
|
|
void rolld(unsigned int index);
|
|
|
|
ConfigureDialog * optionDialog;
|
|
|
|
//constants
|
|
double pi;
|
|
|
|
bool noSave;
|
|
bool enterMode;
|
|
|
|
// configuration options
|
|
int numStackLevels;
|
|
bool showPeriod;
|
|
bool fixedPrec;
|
|
int histNum;
|
|
bool histDetail;
|
|
int formatPrec;
|
|
bool toSaveStack;
|
|
bool delDrops;
|
|
int base;
|
|
int angle;
|
|
bool beep;
|
|
|
|
KToggleAction *keypadAct;
|
|
KToggleAction *InvButton;
|
|
KToggleAction *HypButton;
|
|
|
|
// map names to their formulae
|
|
QMap<QString, QString> formulas;
|
|
QStringList defFormulas;
|
|
// map names to their help
|
|
QMap<QString, QString> help;
|
|
|
|
// variables
|
|
QMap<QString, double> variables;
|
|
QStringList defVariables;
|
|
};
|
|
|
|
class EditAction : public KAction
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
EditAction( const QString& text, int accel, const QObject *receiver, const char *member, QObject* parent, const char* name );
|
|
~EditAction();
|
|
|
|
virtual int plug( QWidget *w, int index = -1 );
|
|
virtual void unplug( QWidget *w );
|
|
QString text() { return m_combo? m_combo->text() : QString::null; }
|
|
QGuardedPtr<KParanoidLine> edit();
|
|
|
|
public slots:
|
|
void clear();
|
|
void append(QString);
|
|
void insert(QString);
|
|
|
|
signals:
|
|
void plugged();
|
|
|
|
private:
|
|
QGuardedPtr<KParanoidLine> m_combo;
|
|
const QObject *m_receiver;
|
|
const char *m_member;
|
|
};
|
|
|
|
class ComboAction : public KAction
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
ComboAction( const QString& text, int accel, const QObject *receiver, const char *member, QObject* parent, const char* name );
|
|
~ComboAction();
|
|
virtual int plug( QWidget *w, int index = -1 );
|
|
virtual void unplug( QWidget *w );
|
|
|
|
QGuardedPtr<QComboBox> combo();
|
|
|
|
signals:
|
|
void plugged();
|
|
|
|
private:
|
|
QGuardedPtr<QComboBox> m_combo;
|
|
const QObject *m_receiver;
|
|
const char *m_member;
|
|
};
|
|
|
|
#endif
|