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.
136 lines
5.3 KiB
136 lines
5.3 KiB
#include <qevent.h>
|
|
#include <qlayout.h>
|
|
#include <qwhatsthis.h>
|
|
#include <qtooltip.h>
|
|
|
|
#include <kdialog.h>
|
|
#include <klocale.h>
|
|
|
|
#include "keypad.h"
|
|
|
|
CharButton::CharButton(const QString &text, QWidget *parent, const char *name)
|
|
: QPushButton(text, parent, name)
|
|
{
|
|
setAutoRepeat(true);
|
|
setAccel(text);
|
|
m_text = text;
|
|
connect(this, SIGNAL(clicked()), this, SLOT(emitClicked()));
|
|
}
|
|
|
|
void CharButton::emitClicked()
|
|
{
|
|
emit clicked(m_text);
|
|
}
|
|
|
|
MathKeypad::MathKeypad(QWidget *parent, const char *name)
|
|
: QWidget(parent, name)
|
|
{
|
|
QVBoxLayout *vlayout = new QVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
|
|
|
|
QPushButton *focusButton = new QPushButton(i18n("Press to Focus Keypad"), this);
|
|
connect(focusButton, SIGNAL(clicked()), this, SLOT(setFocus()));
|
|
vlayout->addWidget(focusButton);
|
|
|
|
QGridLayout *midBox = new QGridLayout(vlayout, 5, 4, KDialog::spacingHint());
|
|
|
|
QPushButton *EnterButton = new QPushButton(i18n("Enter"), this);
|
|
EnterButton->setAccel(Key_Enter);
|
|
QWhatsThis::add(EnterButton, i18n("Enter expression onto stack"));
|
|
midBox->addMultiCellWidget(EnterButton, 0, 0, 0, 1);
|
|
connect(EnterButton, SIGNAL(clicked()), this, SIGNAL(enter()));
|
|
|
|
QPushButton *EEXButton = new QPushButton("&EEX", this);
|
|
QWhatsThis::add(EEXButton, i18n("Enters an E into line edit. When evaluated, the number directly before the E (no space on either side of the E) is multiplied by 10 raised to the number directly after the E. Only in Decimal mode."));
|
|
midBox->addWidget(EEXButton, 0, 2);
|
|
connect(EEXButton, SIGNAL(clicked()), this, SIGNAL(eex()));
|
|
|
|
QPushButton *BackSpaceButton = new QPushButton("<-", this);
|
|
QToolTip::add(BackSpaceButton, i18n("Inversed: Clear"));
|
|
BackSpaceButton->setAutoRepeat(true);
|
|
BackSpaceButton->setAccel(Key_Backspace);
|
|
midBox->addWidget(BackSpaceButton, 0, 3);
|
|
connect(BackSpaceButton, SIGNAL(clicked()), this, SIGNAL(backspace()));
|
|
|
|
CharButton *PeriodButton = new CharButton(".", this);
|
|
PeriodButton->setAccel(Key_Period);
|
|
connect(PeriodButton, SIGNAL(clicked(const QString &)), this, SIGNAL(insertChar(const QString &)));
|
|
midBox->addWidget(PeriodButton, 4, 2);
|
|
|
|
CharButton *SpaceButton = new CharButton(" ", this);
|
|
SpaceButton->setText(i18n("Spc"));
|
|
SpaceButton->setAccel(Key_Space);
|
|
connect(SpaceButton, SIGNAL(clicked(const QString &)), this, SIGNAL(insertChar(const QString &)));
|
|
midBox->addWidget(SpaceButton, 4, 1);
|
|
|
|
CharButton *KP0Button = new CharButton(QString::number(0), this);
|
|
connect(KP0Button, SIGNAL(clicked(const QString &)), this, SIGNAL(insertChar(const QString &)));
|
|
midBox->addWidget(KP0Button, 4, 0);
|
|
|
|
CharButton *KP1Button = new CharButton(QString::number(1), this);
|
|
connect(KP1Button, SIGNAL(clicked(const QString &)), this, SIGNAL(insertChar(const QString &)));
|
|
midBox->addWidget(KP1Button, 3, 0);
|
|
|
|
CharButton *KP2Button = new CharButton(QString::number(2), this);
|
|
connect(KP2Button, SIGNAL(clicked(const QString &)), this, SIGNAL(insertChar(const QString &)));
|
|
midBox->addWidget(KP2Button, 3, 1);
|
|
|
|
CharButton *KP3Button = new CharButton(QString::number(3), this);
|
|
connect(KP3Button, SIGNAL(clicked(const QString &)), this, SIGNAL(insertChar(const QString &)));
|
|
midBox->addWidget(KP3Button, 3, 2);
|
|
|
|
CharButton *KP4Button = new CharButton(QString::number(4), this);
|
|
connect(KP4Button, SIGNAL(clicked(const QString &)), this, SIGNAL(insertChar(const QString &)));
|
|
midBox->addWidget(KP4Button, 2, 0);
|
|
|
|
CharButton *KP5Button = new CharButton(QString::number(5), this);
|
|
connect(KP5Button, SIGNAL(clicked(const QString &)), this, SIGNAL(insertChar(const QString &)));
|
|
midBox->addWidget(KP5Button, 2, 1);
|
|
|
|
CharButton *KP6Button = new CharButton(QString::number(6), this);
|
|
connect(KP6Button, SIGNAL(clicked(const QString &)), this, SIGNAL(insertChar(const QString &)));
|
|
midBox->addWidget(KP6Button, 2, 2);
|
|
|
|
CharButton *KP7Button = new CharButton(QString::number(7), this);
|
|
connect(KP7Button, SIGNAL(clicked(const QString &)), this, SIGNAL(insertChar(const QString &)));
|
|
midBox->addWidget(KP7Button, 1, 0);
|
|
|
|
CharButton *KP8Button = new CharButton(QString::number(8), this);
|
|
connect(KP8Button, SIGNAL(clicked(const QString &)), this, SIGNAL(insertChar(const QString &)));
|
|
midBox->addWidget(KP8Button, 1, 1);
|
|
|
|
CharButton *KP9Button = new CharButton(QString::number(9), this);
|
|
connect(KP9Button, SIGNAL(clicked(const QString &)), this, SIGNAL(insertChar(const QString &)));
|
|
midBox->addWidget(KP9Button, 1, 2);
|
|
|
|
QPushButton *DivideButton = new QPushButton("/", this);
|
|
DivideButton->setAccel(Key_Slash);
|
|
connect(DivideButton, SIGNAL(clicked()), this, SIGNAL(divide()));
|
|
midBox->addWidget(DivideButton, 1, 3);
|
|
|
|
QPushButton *MultiplyButton = new QPushButton("*", this);
|
|
MultiplyButton->setAccel(Key_Asterisk);
|
|
connect(MultiplyButton, SIGNAL(clicked()), this, SIGNAL(multiply()));
|
|
midBox->addWidget(MultiplyButton, 2, 3);
|
|
|
|
QPushButton *SubtractionButton = new QPushButton("-", this);
|
|
SubtractionButton->setAccel(Key_Minus);
|
|
connect(SubtractionButton, SIGNAL(clicked()), this, SIGNAL(subtract()));
|
|
midBox->addWidget(SubtractionButton, 3, 3);
|
|
|
|
QPushButton *AdditionButton = new QPushButton("+", this);
|
|
AdditionButton->setAccel(Key_Plus);
|
|
connect(AdditionButton, SIGNAL(clicked()), this, SIGNAL(add()));
|
|
midBox->addWidget(AdditionButton, 4, 3);
|
|
|
|
setCaption(i18n("Keypad") + " - Mathemagics");
|
|
}
|
|
|
|
void MathKeypad::closeEvent(QCloseEvent *e)
|
|
{
|
|
emit closing();
|
|
|
|
e->accept();
|
|
}
|
|
|
|
#include "keypad.moc"
|