www.pudn.com > calculator.rar > simple.cpp


/****************************************************************************
**
** Copyright (C) 2000-2006 TROLLTECH ASA. All rights reserved.
**
** This file is part of the Phone Edition of the Qtopia Toolkit.
**
** Licensees holding a valid license agreement from Trolltech or any of its
** authorized distributors may use this file in accordance with
** the License Agreement provided with the Licensed Software.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
** information about Trolltech's Commercial License Agreements.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**
**
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/

#include <qtopia/qtopiaapplication.h>

#include <QDesktopWidget>

#include "simple.h"
#include "../doubleinstruction.h"


FormSimple::FormSimple(QWidget *parent) : DecimalInputWidget(parent) {

setObjectName( tr("Simple") );

InputWidgetLayout = new QGridLayout(this);
InputWidgetLayout->setSpacing( 3 );
InputWidgetLayout->setMargin( 0 );

init(0, 0);
}


void FormSimple::init(int fromRow, int fromCol)
{
QRect screenRect = QtopiaApplication::desktop()->availableGeometry();
bool portrait = screenRect.width() < screenRect.height();
if ( portrait ) {
DecimalInputWidget::init(fromRow+1, fromCol);
} else {
DecimalInputWidget::init(fromRow, fromCol);
}

QFont big(font());
#ifndef QTOPIA_PHONE
big.setPointSize(qMin(big.pointSize()*2,18));
#else
big.setPointSize(qMin(big.pointSize()*2,14));
#endif

QPushButton *PBMPlus = new QPushButton(this);
PBMPlus->setSizePolicy(sizePolicy());
PBMPlus->setText(tr("M+"));
PBMPlus->setFont(big);

QPushButton *PBMC = new QPushButton(this);
PBMC->setSizePolicy(sizePolicy());
PBMC->setText(tr("MC"));
PBMC->setFont(big);

QPushButton *PBMR = new QPushButton(this);
PBMR->setSizePolicy(sizePolicy());
PBMR->setText(tr("MR"));
PBMR->setFont(big);

QPushButton *PBCE = new QPushButton(this);
PBCE->setSizePolicy(sizePolicy());
PBCE->setText(tr("CE/C"));
PBCE->setFont(big);

#ifdef QTOPIA_PHONE
PBMPlus->setFocusPolicy(Qt::NoFocus);
PBMC->setFocusPolicy(Qt::NoFocus);
PBMR->setFocusPolicy(Qt::NoFocus);
PBCE->setFocusPolicy(Qt::NoFocus);
#endif

if (portrait) {
InputWidgetLayout->addWidget(PBCE, 0, 3);
InputWidgetLayout->addWidget(PBMC, 0, 1);
InputWidgetLayout->addWidget(PBMR, 0, 2);
InputWidgetLayout->addWidget(PBMPlus, 0, 0);
} else {
InputWidgetLayout->addWidget(PBCE, 0, 4);
InputWidgetLayout->addWidget(PBMC, 1, 4);
InputWidgetLayout->addWidget(PBMR, 2, 4);
InputWidgetLayout->addWidget(PBMPlus, 3, 4);
}

connect (PBCE, SIGNAL(clicked()), this, SLOT(CEClicked()));
connect (PBMR, SIGNAL(clicked()), this, SLOT(MRClicked()));
connect (PBMC, SIGNAL(clicked()), this, SLOT(MCClicked()));
connect (PBMPlus, SIGNAL(clicked()), this, SLOT(MPlusClicked()));
}


void FormSimple::showEvent ( QShowEvent *e ) {
systemEngine->setAccType("Double"); // No tr

QWidget::showEvent(e);
}

void FormSimple::CEClicked() {
systemEngine->dualReset();
}
void FormSimple::MCClicked() {
systemEngine->memoryReset();
}
void FormSimple::MRClicked() {
systemEngine->memoryRecall();
}
void FormSimple::MPlusClicked() {
systemEngine->memorySave();
}