📄 gwcalc.cpp
字号:
voidgwCalcMain::InsertButtonS08() // Configuration Editor // // Popup a Configuration Dialog //{ int i, k, x, y; char value[40]; // on Linux Desktop the Dialog is placed directly // on the right side of the main widget x = this->x(); y = this->y(); cedit = new ConfigEdit(x+MAINWIDTH+8, y); cedit->fmt->setCurrentItem(CalculatorFmt - 1); cedit->an->setCurrentItem(CalculatorAutoAns); cedit->am->setCurrentItem(CalculatorAutoHighlight); // Popup the Dialog k = cedit->exec(); if (k == QDialog::Accepted) { CalculatorFmt = cedit->fmt->currentItem() + 1; CalculatorAutoAns = cedit->an->currentItem(); CalculatorAutoHighlight = cedit->am->currentItem(); }}gwCalcMain::gwCalcMain() // Main Widget // // setup of the main widge{ setGeometry (0, 16, MAINWIDTH, MAINHEIGHT); setCaption (VERSION); ifkt = 3; iinv = 0; ihyp = 0; cclr = new QPalette( QColor( 80, 255, 80)); cexe = new QPalette( QColor(255, 80, 80)); cfkt = new QPalette( QColor( 0, 192,192)); qp01a = new QPixmap ((const char **) ln_xpm ); qp02a = new QPixmap ((const char **) e_xpm ); qp03a = new QPixmap ((const char **) y_xpm ); qp04a = new QPixmap ((const char **) log10_xpm ); qp05a = new QPixmap ((const char **) x_xpm ); qp06a = new QPixmap ((const char **) bsqrt_xpm); qp07a = new QPixmap ((const char **) log2_xpm); qp08a = new QPixmap ((const char **) exp_xpm); qp09a = new QPixmap ((const char **) quad_xpm); qp10a = new QPixmap ((const char **) log_xpm); qp11a = new QPixmap ((const char **) div_xpm); qp12a = new QPixmap ((const char **) sqrt_xpm); qp01b = new QPixmap ((const char **) inv_xpm); qp02b = new QPixmap ((const char **) hyp_xpm); qleer = new QPixmap ((const char **) leer_xpm); qp04b = new QPixmap ((const char **) sin_xpm); qp05b = new QPixmap ((const char **) cos_xpm); qp06b = new QPixmap ((const char **) tan_xpm); qp07b = new QPixmap ((const char **) csc_xpm); qp08b = new QPixmap ((const char **) sec_xpm); qp09b = new QPixmap ((const char **) cot_xpm); qp01c = new QPixmap ((const char **) abs_xpm); qp02c = new QPixmap ((const char **) sign_xpm); qp04c = new QPixmap ((const char **) atan2_xpm); // LCD-Display; Results display lcd = new QLabel (this); lcd->setGeometry (LCD_OF, 4,LCD_MX, LCD_MY); lcd->setAlignment(AlignRight | AlignBottom | SingleLine); lcd->setFont (QFont("Helvetica", FONT20, QFont::Bold)); lcd->setBackgroundColor(QColor(100,100, 255)); lcdexp = new QLabel (this); lcdexp->setGeometry (LCD_OF+LCD_MX, 4,LCD_EX, LCD_MY); lcdexp->setAlignment(AlignRight | AlignTop | SingleLine); lcdexp->setFont (QFont("Helvetica", FONT16, QFont::Bold)); lcdexp->setBackgroundColor(QColor(100,100, 255)); // HYP/INV Signal ql01 = new QLabel(this); ql01->setGeometry (4, 1, LCD_OF-6, 15); ql01->setFont (QFont("Helvetica", FONT08, QFont::Normal)); ql02 = new QLabel(this); ql02->setGeometry (4, 15, LCD_OF-6, 15); ql02->setFont (QFont("Helvetica", FONT08, QFont::Normal)); // Input Field inpfeld = new gwCalcEdit(this); inpfeld->setGeometry (1, 8+LCD_MY, MAINWIDTH-2, 45); inpfeld->setMaxLineLength(25); inpfeld->setWordWrap(QMultiLineEdit::WidgetWidth); s01 = new QPushButton("SW", this); s01->setGeometry (3*FKTBTN/2-7-2*SWBTN, TOPLINE-4-SWBTN,2*SWBTN,SWBTN); QPixmap tqp ((const char **) switch_xpm); s01->setPixmap(tqp); s05 = new QPushButton("RAD", this); s05->setGeometry (3*FKTBTN/2-3, TOPLINE-4-SWBTN,2*SWBTN,SWBTN); s05->setFont (QFont("Helvetica", FONT12, QFont::Normal)); s02 = new QPushButton("FKT", this); s02->setGeometry (3*FKTBTN-6, TOPLINE-4-SWBTN,2*SWBTN,SWBTN); s02->setFont (QFont("Helvetica", FONT12, QFont::Normal)); s03 = new QPushButton("HIS", this); s03->setGeometry (3*FKTBTN-6+BTNSIZE, TOPLINE-4-SWBTN,2*SWBTN,SWBTN); s03->setFont (QFont("Helvetica", FONT12, QFont::Normal)); s04 = new QPushButton("VAR", this); s04->setGeometry (3*FKTBTN-6+2*BTNSIZE, TOPLINE-4-SWBTN,2*SWBTN,SWBTN); s04->setFont (QFont("Helvetica", FONT12, QFont::Normal)); s06 = new QPushButton("", this); s06->setGeometry (3*FKTBTN-4+3*BTNSIZE, TOPLINE-4-SWBTN,SWBTN,SWBTN); QPixmap tqp6 ((const char **) up_xpm); s06->setPixmap(tqp6); s07 = new QPushButton("", this); s07->setGeometry (3*FKTBTN-4+3*BTNSIZE+SWBTN, TOPLINE-4-SWBTN,SWBTN,SWBTN); QPixmap tqp7 ((const char **) down_xpm); s07->setPixmap(tqp7); s08 = new QPushButton("C", this); s08->setGeometry (3*FKTBTN-3+3*BTNSIZE+2*SWBTN, TOPLINE-4-SWBTN,SWBTN,SWBTN); b01 = new QPushButton("1", this); b01->setGeometry (3*FKTBTN+5,TOPLINE+2*BTNSIZE,BTNSIZE,BTNSIZE); b01->setFont (QFont("Helvetica", FONT18, QFont::Normal)); b02 = new QPushButton("2", this); b02->setGeometry (3*FKTBTN+5+BTNSIZE,TOPLINE+2*BTNSIZE,BTNSIZE,BTNSIZE); b02->setFont (QFont("Helvetica", FONT18, QFont::Normal)); b03 = new QPushButton("3", this); b03->setGeometry (3*FKTBTN+5+2*BTNSIZE,TOPLINE+2*BTNSIZE, BTNSIZE,BTNSIZE); b03->setFont (QFont("Helvetica", FONT18, QFont::Normal)); b04 = new QPushButton("4", this); b04->setGeometry (3*FKTBTN+5 ,TOPLINE+BTNSIZE,BTNSIZE,BTNSIZE); b04->setFont (QFont("Helvetica", FONT18, QFont::Normal)); b05 = new QPushButton("5", this); b05->setGeometry (3*FKTBTN+5+BTNSIZE,TOPLINE+BTNSIZE,BTNSIZE,BTNSIZE); b05->setFont (QFont("Helvetica", FONT18, QFont::Normal)); b06 = new QPushButton("6", this); b06->setGeometry (3*FKTBTN+5+2*BTNSIZE,TOPLINE+BTNSIZE,BTNSIZE,BTNSIZE); b06->setFont (QFont("Helvetica", FONT18, QFont::Normal)); b07 = new QPushButton("7", this); b07->setGeometry (3*FKTBTN+5,TOPLINE,BTNSIZE,BTNSIZE); b07->setFont (QFont("Helvetica", FONT18, QFont::Normal)); b08 = new QPushButton("8", this); b08->setGeometry (3*FKTBTN+5+BTNSIZE,TOPLINE,BTNSIZE,BTNSIZE); b08->setFont (QFont("Helvetica", FONT18, QFont::Normal)); b09 = new QPushButton("9", this); b09->setGeometry (3*FKTBTN+5+2*BTNSIZE,TOPLINE,BTNSIZE,BTNSIZE); b09->setFont (QFont("Helvetica", FONT18, QFont::Normal)); b10 = new QPushButton("0", this); b10->setGeometry (3*FKTBTN+5,TOPLINE+3*BTNSIZE,BTNSIZE,BTNSIZE); b10->setFont (QFont("Helvetica", FONT18, QFont::Normal)); b11 = new QPushButton(",", this); b11->setGeometry (3*FKTBTN+5+BTNSIZE,TOPLINE+3*BTNSIZE,BTNSIZE,BTNSIZE); b11->setFont (QFont("Helvetica", FONT18, QFont::Normal)); b12 = new QPushButton("EE", this); b12->setGeometry (3*FKTBTN+5+2*BTNSIZE,TOPLINE+3*BTNSIZE, BTNSIZE,BTNSIZE); b12->setFont (QFont("Helvetica", FONT18, QFont::Normal)); b15 = new QPushButton("Pi", this); b15->setGeometry (3*FKTBTN+5,2+TOPLINE+4*BTNSIZE,BTNSIZE,BTNSIZE); QPixmap tqp1 ((const char **) pi_xpm); b15->setPixmap(tqp1); b15->setFont (QFont("Helvetica", FONT16, QFont::Normal)); b16 = new QPushButton("(", this); b16->setGeometry (3*FKTBTN+5+BTNSIZE,2+TOPLINE+4*BTNSIZE, BTNSIZE,BTNSIZE); b16->setFont (QFont("Helvetica", FONT18, QFont::Normal)); b17 = new QPushButton(")", this); b17->setGeometry (3*FKTBTN+5+2*BTNSIZE,2+TOPLINE+4*BTNSIZE, BTNSIZE,BTNSIZE); b17->setFont (QFont("Helvetica", FONT18, QFont::Normal)); b18 = new QPushButton("/", this); b18->setGeometry (3*FKTBTN+9+3*BTNSIZE,TOPLINE,BTNSIZE,BTNSIZE); b18->setFont (QFont("Helvetica", FONT18, QFont::Normal)); b19 = new QPushButton("x", this); b19->setGeometry (3*FKTBTN+9+3*BTNSIZE,TOPLINE+BTNSIZE, BTNSIZE,BTNSIZE); b19->setFont (QFont("Helvetica", FONT18, QFont::Normal)); b20 = new QPushButton("-", this); b20->setGeometry (3*FKTBTN+9+3*BTNSIZE,TOPLINE+2*BTNSIZE, BTNSIZE,BTNSIZE); b20->setFont (QFont("Helvetica", FONT18, QFont::Normal)); b21 = new QPushButton("+", this); b21->setGeometry (3*FKTBTN+9+3*BTNSIZE,TOPLINE+3*BTNSIZE, BTNSIZE,BTNSIZE); b21->setFont (QFont("Helvetica", FONT18, QFont::Normal)); p01 = new QPushButton(":", this); p01->setGeometry (3*FKTBTN+9+3*BTNSIZE,2+TOPLINE+4*BTNSIZE, CHRBTN,CHRBTN); p01->setFont (QFont("Helvetica", FONT16, QFont::Bold)); p02 = new QPushButton(";", this); p02->setGeometry (3*FKTBTN+9+3*BTNSIZE+CHRBTN,2+TOPLINE+4*BTNSIZE, CHRBTN,CHRBTN); p02->setFont (QFont("Helvetica", FONT16, QFont::Bold)); p03 = new QPushButton("=", this); p03->setGeometry (3*FKTBTN+9+3*BTNSIZE,2+TOPLINE+4*BTNSIZE+CHRBTN, CHRBTN,CHRBTN); p03->setFont (QFont("Helvetica", FONT16, QFont::Bold)); p04 = new QPushButton(" ", this); p04->setGeometry (3*FKTBTN+9+3*BTNSIZE+CHRBTN,2+TOPLINE+4*BTNSIZE+CHRBTN, CHRBTN,CHRBTN); p04->setFont (QFont("Helvetica", FONT16, QFont::Bold)); f01 = new QPushButton("ln", this ); f01->setGeometry ( 0,TOPLINE,FKTBTN,FKTBTN); f01->setPalette(*cfkt); f02 = new QPushButton("e^x", this ); f02->setGeometry ( FKTBTN,TOPLINE,FKTBTN,FKTBTN); f02->setPalette(*cfkt); f03 = new QPushButton("y^x", this ); f03->setGeometry (2*FKTBTN,TOPLINE,FKTBTN,FKTBTN); f03->setPalette(*cfkt); f04 = new QPushButton("log10", this ); f04->setGeometry ( 0,TOPLINE+FKTBTN,FKTBTN,FKTBTN); f04->setPalette(*cfkt); f05 = new QPushButton("10^", this ); f05->setGeometry ( FKTBTN,TOPLINE+FKTBTN,FKTBTN,FKTBTN); f05->setPalette(*cfkt); f06 = new QPushButton("x^(1/x)",this ); f06->setGeometry (2*FKTBTN,TOPLINE+FKTBTN,FKTBTN,FKTBTN); f06->setPalette(*cfkt); f07 = new QPushButton("log2", this ); f07->setGeometry ( 0,TOPLINE+2*FKTBTN,FKTBTN,FKTBTN); f07->setPalette(*cfkt); f08 = new QPushButton("2^", this ); f08->setGeometry ( FKTBTN,TOPLINE+2*FKTBTN,FKTBTN,FKTBTN); f08->setPalette(*cfkt); f09 = new QPushButton("x^2", this ); f09->setGeometry (2*FKTBTN,TOPLINE+2*FKTBTN,FKTBTN,FKTBTN); f09->setPalette(*cfkt); f10 = new QPushButton("1/x", this); f10->setGeometry ( 0,TOPLINE+3*FKTBTN,FKTBTN,FKTBTN); f10->setPalette(*cfkt); f11 = new QPushButton("abs", this); f11->setGeometry ( FKTBTN,TOPLINE+3*FKTBTN,FKTBTN,FKTBTN); f11->setPalette(*cfkt); f12 = new QPushButton("sqrt", this); f12->setGeometry (2*FKTBTN,TOPLINE+3*FKTBTN,FKTBTN,FKTBTN); f12->setPalette(*cfkt); b13 = new QPushButton("CLR", this); b13->setGeometry ( 0 ,2+TOPLINE+4*FKTBTN, 3*FKTBTN/2,(5*BTNSIZE-4*FKTBTN)/2); b13->setFont (QFont("Helvetica", FONT16, QFont::Bold)); b13->setPalette(*cclr ); b14 = new QPushButton("ANS", this); b14->setGeometry ( 0 ,2+TOPLINE+4*FKTBTN+(5*BTNSIZE-4*FKTBTN)/2, 3*FKTBTN/2,(5*BTNSIZE-4*FKTBTN)/2); b14->setFont (QFont("Helvetica", FONT16, QFont::Bold)); b23 = new QPushButton("DEL", this); b23->setGeometry (3*FKTBTN/2,2+TOPLINE+4*FKTBTN, 3*FKTBTN/2,(5*BTNSIZE-4*FKTBTN)/2); b23->setFont (QFont("Helvetica", FONT16, QFont::Bold)); b24 = new QPushButton("EXE", this); b24->setGeometry (3*FKTBTN/2,2+TOPLINE+4*FKTBTN+(5*BTNSIZE-4*FKTBTN)/2, 3*FKTBTN/2,(5*BTNSIZE-4*FKTBTN)/2); b24->setFont (QFont("Helvetica", FONT16, QFont::Bold)); b24->setPalette(*cexe ); InsertButtonS01(); connect (b01, SIGNAL(clicked()), this, SLOT (InsertButtonB01())); connect (b02, SIGNAL(clicked()), this, SLOT (InsertButtonB02())); connect (b03, SIGNAL(clicked()), this, SLOT (InsertButtonB03())); connect (b04, SIGNAL(clicked()), this, SLOT (InsertButtonB04())); connect (b05, SIGNAL(clicked()), this, SLOT (InsertButtonB05())); connect (b06, SIGNAL(clicked()), this, SLOT (InsertButtonB06())); connect (b07, SIGNAL(clicked()), this, SLOT (InsertButtonB07())); connect (b08, SIGNAL(clicked()), this, SLOT (InsertButtonB08())); connect (b09, SIGNAL(clicked()), this, SLOT (InsertButtonB09())); connect (b10, SIGNAL(clicked()), this, SLOT (InsertButtonB10())); connect (b11, SIGNAL(clicked()), this, SLOT (InsertButtonB11())); connect (b12, SIGNAL(clicked()), this, SLOT (InsertButtonB12())); connect (b13, SIGNAL(clicked()), this, SLOT (InsertButtonB13())); connect (b14, SIGNAL(clicked()), this, SLOT (InsertButtonB14())); connect (b15, SIGNAL(clicked()), this, SLOT (InsertButtonB15())); connect (b16, SIGNAL(clicked()), this, SLOT (InsertButtonB16())); connect (b17, SIGNAL(clicked()), this, SLOT (InsertButtonB17())); connect (b18, SIGNAL(clicked()), this, SLOT (InsertButtonB18())); connect (b19, SIGNAL(clicked()), this, SLOT (InsertButtonB19())); connect (b20, SIGNAL(clicked()), this, SLOT (InsertButtonB20())); connect (b21, SIGNAL(clicked()), this, SLOT (InsertButtonB21())); connect (b23, SIGNAL(clicked()), this, SLOT (InsertButtonB23())); connect (b24, SIGNAL(clicked()), this, SLOT (InsertButtonB24())); connect (f01, SIGNAL(clicked()), this, SLOT (InsertButtonF01())); connect (f02, SIGNAL(clicked()), this, SLOT (InsertButtonF02())); connect (f03, SIGNAL(clicked()), this, SLOT (InsertButtonF03())); connect (f04, SIGNAL(clicked()), this, SLOT (InsertButtonF04())); connect (f05, SIGNAL(clicked()), this, SLOT (InsertButtonF05())); connect (f06, SIGNAL(clicked()), this, SLOT (InsertButtonF06())); connect (f07, SIGNAL(clicked()), this, SLOT (InsertButtonF07())); connect (f08, SIGNAL(clicked()), this, SLOT (InsertButtonF08())); connect (f09, SIGNAL(clicked()), this, SLOT (InsertButtonF09())); connect (f10, SIGNAL(clicked()), this, SLOT (InsertButtonF10())); connect (f11, SIGNAL(clicked()), this, SLOT (InsertButtonF11())); connect (f12, SIGNAL(clicked()), this, SLOT (InsertButtonF12())); connect (p01, SIGNAL(clicked()), this, SLOT (InsertButtonP01())); connect (p02, SIGNAL(clicked()), this, SLOT (InsertButtonP02())); connect (p03, SIGNAL(clicked()), this, SLOT (InsertButtonP03())); connect (p04, SIGNAL(clicked()), this, SLOT (InsertButtonP04())); connect (s01, SIGNAL(clicked()), this, SLOT (InsertButtonS01())); connect (s02, SIGNAL(clicked()), this, SLOT (InsertButtonS02())); connect (s03, SIGNAL(clicked()), this, SLOT (InsertButtonS03())); connect (s04, SIGNAL(clicked()), this, SLOT (InsertButtonS04())); connect (s05, SIGNAL(clicked()), this, SLOT (InsertButtonS05())); connect (s06, SIGNAL(clicked()), this, SLOT (InsertButtonS06())); connect (s07, SIGNAL(clicked()), this, SLOT (InsertButtonS07())); connect (s08, SIGNAL(clicked()), this, SLOT (InsertButtonS08())); connect (inpfeld, SIGNAL(returnPressed()), this, SLOT (InputReturn()));}intmain (int argc, char ** argv){ FILE *config;#ifdef ZAURUS QPEApplication a(argc, argv);#else char npath[PATH_MAX], syspath[PATH_MAX]; char *env; QApplication a(argc, argv);#endif // initialize main widget and clipboard gwCalcMain w; clipboard = a.clipboard(); CalculatorCmdHistoryAnz = 0; // find the configuration file // this file holds all informations, which should be // available after restart of the programm#ifdef ZAURUS system("cd /home/root/Applications; mkdir gwCalc"); config = fopen ("/home/root/Applications/gwCalc/gwcalc.conf", "rt");#else env = getenv("HOME"); if (env) strcpy(npath, env); else strcpy(npath, "/tmp"); strcat(npath, "/.kde/share/apps/gwcalc"); // create a subdirectory for the configuration file; // there is a error message, if the directory already // exists; this is ignored at the moment strcpy(syspath, "mkdir "); strcat(syspath, npath); system(syspath); strcat(npath, "/gwcalc.conf"); config = fopen (npath, "rt"); #endif if (config) { ReadHistory(config); fclose(config); } CalculatorCmdCurhist = CalculatorCmdHistoryAnz; // now show the main widget a.setMainWidget (&w); w.show(); w.InsertButtonS05(); w.InsertButtonS05(); w.InsertButtonB24(); a.exec(); // programm end: save configuration#ifdef ZAURUS config = fopen ("/home/root/Applications/gwCalc/gwcalc.conf", "wt");#else config = fopen (npath, "wt");#endif if (config) { WriteHistory(config); fclose(config); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -