summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-03-09 21:46:21 (UTC)
committer llornkcor <llornkcor>2002-03-09 21:46:21 (UTC)
commit80be7dabb1e1390e4d412c785d9f44e2293b2d5d (patch) (side-by-side diff)
tree04daeda225b3be914885adaf6c46cf3b83ce123c
parent53fd2f87c62cf60e8326110f11838661d0521b63 (diff)
downloadopie-80be7dabb1e1390e4d412c785d9f44e2293b2d5d.zip
opie-80be7dabb1e1390e4d412c785d9f44e2293b2d5d.tar.gz
opie-80be7dabb1e1390e4d412c785d9f44e2293b2d5d.tar.bz2
fixed weirdness with the inlined xpm's- for some odd and unknown reason
they weren't showing correctly anymore...
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/calculator/calculatorimpl.cpp73
1 files changed, 67 insertions, 6 deletions
diff --git a/noncore/tools/calculator/calculatorimpl.cpp b/noncore/tools/calculator/calculatorimpl.cpp
index 3a6efe4..0925073 100644
--- a/noncore/tools/calculator/calculatorimpl.cpp
+++ b/noncore/tools/calculator/calculatorimpl.cpp
@@ -1,97 +1,155 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*
* 01/14/2002 Charles-Edouard Ruault <ce@ruault.com>
* Added support for Temperature conversions.
*/
+// Sat 03-09-2002 L.J. Potter added the inlined pixmaps here
#include "calculatorimpl.h"
#include <qpe/resource.h>
#include <qpe/qmath.h>
#include <qpe/qpeapplication.h>
#include <qpushbutton.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qfont.h>
#include <qlayout.h>
#include <qstringlist.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qmessagebox.h>
#include <math.h>
+/* XPM */
+static char *oneoverx_xpm[] = {
+/* width height num_colors chars_per_pixel */
+" 13 11 2 1",
+/* colors */
+". c None",
+"# c #000000",
+/* pixels */
+"......#......",
+".....##......",
+"......#......"
+".....###.....",
+".............",
+"..#########..",
+".............",
+"....##.##....",
+"......#......",
+"......#......",
+"....##.##....",
+};
+/* XPM */
+static char *ythrootofx_xpm[] = {
+/* width height num_colors chars_per_pixel */
+" 13 11 2 1",
+/* colors */
+". c None",
+"# c #000000",
+/* pixels */
+"#.#..........",
+"#.#..........",
+"###...#######",
+"..#..#.......",
+"###..#.......",
+".....#.#...#.",
+".#..#...#.#..",
+"#.#.#....#...",
+"..#.#...#.#..",
+"...#...#...#.",
+"...#........."
+};
+/* XPM */
+static char *xtopowerofy_xpm[] = {
+/* width height num_colors chars_per_pixel */
+" 9 8 2 1",
+/* colors */
+". c None",
+"# c #000000",
+/* pixels */
+"......#.#",
+"......#.#",
+"......###",
+"#...#...#",
+".#.#..###",
+"..#......",
+".#.#.....",
+"#...#...."
+};
CalculatorImpl::CalculatorImpl( QWidget * parent, const char * name,
WFlags f )
: Calculator( parent, name, f )
{
- xtopowerofy = Resource::loadPixmap("xtopowerofy");
- ythrootofx = Resource::loadPixmap("ythrootofx");
- oneoverx = Resource::loadPixmap("oneoverx");
+// xtopowerofy = Resource::loadPixmap("xtopowerofy");
+// ythrootofx = Resource::loadPixmap("ythrootofx");
+// oneoverx = Resource::loadPixmap("oneoverx");
memMark = new QLabel( "m", LCD );
memMark->setFont( QFont( "helvetica", 12, QFont::Bold, TRUE ) );
memMark->resize( 12, 12 );
memMark->move( 4, 2 );
memMark->hide();
mem = 0;
PushButtonMR->setEnabled( FALSE );
current_mode = max_mode = conversion_mode_count = 0;
last_conversion = -1;
//bgr_command.insert( PushButtonFunction);
bgr_command.insert( PushButtonMPlus);
bgr_command.insert( PushButtonMR);
bgr_command.insert( PushButtonMC);
bgr_command.insert( PushButtonCE);
connect( &bgr_command, SIGNAL(clicked(int) ), this, SLOT(command_buttons(int)));
bgr_digits.insert(PushButton0);
bgr_digits.insert(PushButton1);
bgr_digits.insert(PushButton2);
bgr_digits.insert(PushButton3);
bgr_digits.insert(PushButton4);
bgr_digits.insert(PushButton5);
bgr_digits.insert(PushButton6);
bgr_digits.insert(PushButton7);
bgr_digits.insert(PushButton8);
bgr_digits.insert(PushButton9);
connect( &bgr_digits, SIGNAL(clicked(int) ), this, SLOT(enterNumber(int)));
bgr_std.insert(PushButtonEquals);
bgr_std.insert(PushButtonDecimal);
bgr_std.insert(PushButtonAdd);
bgr_std.insert(PushButtonMinus);
bgr_std.insert(PushButtonDivide);
bgr_std.insert(PushButtonTimes);
connect( &bgr_std, SIGNAL(clicked(int) ), this, SLOT(std_buttons(int)));
// change the / to a proper division signal
PushButtonDivide->setText(QChar(0xF7));
func_buttons[0] = PushButtonF1;
func_buttons[1] = PushButtonF2;
func_buttons[2] = PushButtonF3;
func_buttons[3] = PushButtonF4;
@@ -244,104 +302,107 @@ void CalculatorImpl::do_convert(int button) {
/ (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + last_conversion])
* (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + button])
+ postoffset_list[(current_mode - pre_conv_modes_count) * func_button_count + button];;
LCD->display( num );
acc = num;
}
}
last_conversion = button;
}
}
void CalculatorImpl::function_button(int mode){
if ( state == sError )
clear();
// dont need the next line when using a popup menu
current_mode = mode;
// reset the last conv
last_conversion = -1;
// set the caption
this->setCaption( captions[current_mode] );
reset_conv();
for ( int x = 0 ; x < changeable_func_button_count ; x++ ) {
QPushButton* tmpbutton = func_buttons[x];
// if its a conversion , make it a toggle button
if ( current_mode >= pre_conv_modes_count && current_mode <= (max_mode - post_conv_modes_count) ) {
tmpbutton->setToggleButton(TRUE);
} else {
tmpbutton->setToggleButton(FALSE);
}
tmpbutton->setText( faces[current_mode * func_button_count + x] );
}
if ( current_mode == 0 ) display_pixmap_faces();
if ( current_mode >= pre_conv_modes_count && current_mode <= (max_mode - post_conv_modes_count) ) {
bgr_function.setExclusive(TRUE);
} else {
bgr_function.setExclusive(FALSE);
}
}
void CalculatorImpl::display_pixmap_faces() {
+ QPixmap image0( ( const char** ) xtopowerofy_xpm);
QPushButton* tmpbutton = func_buttons[5];
- tmpbutton->setPixmap(xtopowerofy);
+ tmpbutton->setPixmap(image0);
+ QPixmap image1( ( const char** ) ythrootofx_xpm);
tmpbutton = func_buttons[6];
- tmpbutton->setPixmap(ythrootofx);
+ tmpbutton->setPixmap(image1);
+ QPixmap image2( ( const char** ) oneoverx_xpm);
tmpbutton = func_buttons[3];
- tmpbutton->setPixmap(oneoverx);
+ tmpbutton->setPixmap(image2);
}
void CalculatorImpl::clear() {
acc = num = 0;
operationStack.clear();
state = sStart;
numDecimals = 0;
numOpenBraces = 0;
flPoint = FALSE;
LCD->display( 0 );
fake = QString::null;
reset_conv();
}
void CalculatorImpl::reset_conv() {
for ( int x = 0 ; x < changeable_func_button_count ; x++ ) {
QPushButton* tmpbutton = func_buttons[x];
// dont carry any selections into the next mode
if ( tmpbutton->state() == QPushButton::On ) {
tmpbutton->toggle();
}
}
last_conversion = -1;
}
void CalculatorImpl::std_buttons(int button)
{
if ( state == sError )
return;
execOp( (Operation)(button + oSum) );
}
void CalculatorImpl::std_funcs(int button) {
if ( state == sError )
return;
if ( current_mode < pre_conv_modes_count ||
button > changeable_func_button_count-1 ) {
Operation op;
if ( button < 10 )
op = (Operation)(button + oSin);
else if ( button == 10 )
op = oOpenBrace;
else
op = oCloseBrace;
execOp( op );