📄 gwcalc.cpp
字号:
{ switch (ifkt) { case 1: inpfeld->insert("EXP("); break; case 2: if (ihyp) { ihyp = 0; ql02->setText(""); } else { ihyp = 1; ql02->setText("HYP"); } break; case 3: inpfeld->insert("SIGN("); break; }}voidgwCalcMain::InsertButtonF03(){ if (ifkt == 1) inpfeld->insert("^"); }voidgwCalcMain::InsertButtonF04(){ switch (ifkt) { case 1: inpfeld->insert("LOG10("); break; case 2: if (iinv) inpfeld->insert("A"); if (ihyp) inpfeld->insert("H"); inpfeld->insert("SIN("); iinv = 0; ihyp = 0; ql01->setText(""); ql02->setText(""); break; case 3: inpfeld->insert("ATAN2("); break; }}voidgwCalcMain::InsertButtonF05(){ if (ifkt == 1) inpfeld->insert("10^"); if (ifkt == 2) { if (iinv) inpfeld->insert("A"); if (ihyp) inpfeld->insert("H"); inpfeld->insert("COS("); iinv = 0; ihyp = 0; ql01->setText(""); ql02->setText(""); }}voidgwCalcMain::InsertButtonF06(){ if (ifkt == 1) inpfeld->insert("^(1/)"); if (ifkt == 2) { if (iinv) inpfeld->insert("A"); if (ihyp) inpfeld->insert("H"); inpfeld->insert("TAN("); iinv = 0; ihyp = 0; ql01->setText(""); ql02->setText(""); }}voidgwCalcMain::InsertButtonF07() { if (ifkt == 1) inpfeld->insert("LOG2("); if (ifkt == 2) { if (iinv) inpfeld->insert("A"); if (ihyp) inpfeld->insert("H"); inpfeld->insert("CSC("); iinv = 0; ihyp = 0; ql01->setText(""); ql02->setText(""); } }voidgwCalcMain::InsertButtonF08() { if (ifkt == 1) inpfeld->insert("2^"); if (ifkt == 2) { if (iinv) inpfeld->insert("A"); if (ihyp) inpfeld->insert("H"); inpfeld->insert("SEC("); iinv = 0; ihyp = 0; ql01->setText(""); ql02->setText(""); } }voidgwCalcMain::InsertButtonF09() { if (ifkt == 1) inpfeld->insert("^2"); if (ifkt == 2) { if (iinv) inpfeld->insert("A"); if (ihyp) inpfeld->insert("H"); inpfeld->insert("COT("); iinv = 0; ihyp = 0; ql01->setText(""); ql02->setText(""); } }voidgwCalcMain::InsertButtonF10() { if (ifkt == 1) inpfeld->insert("LOG("); }voidgwCalcMain::InsertButtonF11() { if (ifkt == 1) inpfeld->insert("^-1"); }voidgwCalcMain::InsertButtonF12() { if (ifkt == 1) inpfeld->insert("sqrt(");}// ------------------ special character keys ---------------voidgwCalcMain::InsertButtonP01() { inpfeld->insert(":"); }voidgwCalcMain::InsertButtonP02() { inpfeld->insert(";"); }voidgwCalcMain::InsertButtonP03() { inpfeld->insert("="); }voidgwCalcMain::InsertButtonP04(){ inpfeld->insert(" "); }// ------------ switches and popup keys ---------------voidgwCalcMain::InsertButtonS01() // Funktion Key Table switch // // there are two layers for the function keys // Layer 1: power functions // Layer 2: trigonometric functions // pressing this key switches between these two // layers by exchanging the labels of the buttons // and if necessary the color of the buttons{ if (ifkt == 3) ifkt = 1; else ifkt++; if (ifkt == 1) { f01->setPixmap(*qp01a); f01->setPalette(*cfkt); f02->setPixmap(*qp02a); f02->setPalette(*cfkt); f03->setPixmap(*qp03a); f04->setPixmap(*qp04a); f05->setPixmap(*qp05a); f06->setPixmap(*qp06a); f07->setPixmap(*qp07a); f08->setPixmap(*qp08a); f09->setPixmap(*qp09a); f10->setPixmap(*qp10a); f11->setPixmap(*qp11a); f12->setPixmap(*qp12a); } if (ifkt == 2) { f01->setPixmap(*qp01b); f01->setPalette(*cclr); f02->setPixmap(*qp02b); f02->setPalette(*cclr); f03->setPixmap(*qleer); f04->setPixmap(*qp04b); f05->setPixmap(*qp05b); f06->setPixmap(*qp06b); f07->setPixmap(*qp07b); f08->setPixmap(*qp08b); f09->setPixmap(*qp09b); f10->setPixmap(*qleer); f11->setPixmap(*qleer); f12->setPixmap(*qleer); } if (ifkt == 3) { f01->setPixmap(*qp01c); f01->setPalette(*cfkt); f02->setPixmap(*qp02c); f02->setPalette(*cfkt); f03->setPixmap(*qleer); f04->setPixmap(*qp04c); f05->setPixmap(*qleer); f06->setPixmap(*qleer); f07->setPixmap(*qleer); f08->setPixmap(*qleer); f09->setPixmap(*qleer); f10->setPixmap(*qleer); f11->setPixmap(*qleer); f12->setPixmap(*qleer); }}voidgwCalcMain::InsertButtonS02() // Function List Editor // // Popup the Function List Editor // // with the help of the function list editor the user can // add, modify or remove user-defined functions{ int k, x, y; // on Linux Desktop the Dialog is placed directly // on the right side of the main widget x = this->x(); y = this->y(); fkts = new FuncList(x+MAINWIDTH+8, y); // tell the dialog the adress of the functionlist fkts->setList(&CalculatorFkt[0], CalculatorFktAnz); // display the dialog k = fkts->exec(); CalculatorFktAnz = fkts->getNumber(); // the dialog notifies the selection of a function by // adding 10 to the index of the selected function // the name of the function is copied to the inputfield if (k >= 10) { inpfeld->insert(CalculatorFkt[k-9].Name); inpfeld->insert("("); }}voidgwCalcMain::InsertButtonS03() // List History; // // Popup a Dialog with the display of the // Value History; if the user presses OK after // selecting an entry in the history list, the // value is copied into the formula entry field //{ 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(); hvars = new HistList(x+MAINWIDTH+8, y); if (CalculatorHistCnt) { // transfer the history list into the history window for (i = 0; i < CalculatorHistCnt; i++) { sprintf(value, "%-14.12g", CalculatorHistory[i]); hvars->lb->insertItem(value); } // place the cursor on the last entry hvars->lb->setBottomItem(CalculatorHistCnt-1); hvars->lb->setSelected(CalculatorHistCnt-1, TRUE); hvars->lb->setSelected(CalculatorHistCnt-1, FALSE); } // Popup the Dialog k = hvars->exec(); if (k == QDialog::Accepted) { // copy the selected history entry to the input-field i = hvars->lb->currentItem(); sprintf(value, "%-14.12g", CalculatorHistory[i]); i = strlen(value); while ((i > 0) && (value[i] <= ' ')) value[i--] = 0; inpfeld->insert(value); }}voidgwCalcMain::InsertButtonS04() // List Variables Tables // // Popup a dialog for editing the variable list // in the variable list it is possible to change // the names of user-defined variables and change // the value of variables{ int i, j, k, x, y; char *name; // on Linux Desktop the Dialog is placed directly // on the right side of the main widget x = this->x(); y = this->y(); vars = new VarList(x+MAINWIDTH+8, y); // ANS is a special variable and is displayed as the first // entry vars->AddVar("ANS", CalculatorRes, 1); // insert the user-defined variables into the dialog for ( i = 0; i < CalculatorFkt[0].Vars; i++) vars->AddVar(CalculatorFkt[0].Var[i].Name, CalculatorFkt[0].Var[i].Valu, CalculatorFkt[0].Var[i].Ref); // tell the dialog the variables count vars->AddVarFinish(CalculatorFkt[0].RefCnt); // display the dialog k = vars->exec(); j = 0; if (k == QDialog::Accepted) { // transfer the user-made changes back to the variables list // release the memory of the old variables list for (i = 0; i < CalculatorFkt[0].Vars; i++) // begin at 1, free (CalculatorFkt[0].Var[i].Name); // because 0 == ANS for (i = 1; i < 100; i++) { // create the new variables list with the entrys in the dialog name = vars->GetVar(i, &CalculatorFkt[0].Var[j].Valu, &CalculatorFkt[0].Var[j].Ref); if (name) { CalculatorFkt[0].Var[j].Name = (char*) malloc(strlen(name)+1); strcpy(CalculatorFkt[0].Var[j].Name, name); j++; } CalculatorFkt[0].RefCnt = vars->GetRefCnt(); } CalculatorFkt[0].Vars = j; }}voidgwCalcMain::InsertButtonS05() // DEG/RAD switch // // toggles the behavoiur of the trigonometric functions // between Radian and Degree for input and result{ if (CalculatorRad == 1) { CalculatorRad = 2; s05->setText("DEG"); } else if (CalculatorRad == 2) { CalculatorRad = 1; s05->setText("RAD"); }}voidgwCalcMain::InsertButtonS06() // scroll thru the formula history list { if (CalculatorCmdCurhist >= 0) CalculatorCmdCurhist--; inpfeld->clear(); inpfeld->insert(CalculatorCmdHistory[CalculatorCmdCurhist]); }voidgwCalcMain::InsertButtonS07() // scroll thru the formula history list{ if (CalculatorCmdCurhist < CalculatorCmdHistoryAnz) CalculatorCmdCurhist++; inpfeld->clear(); if (CalculatorCmdCurhist < CalculatorCmdHistoryAnz) inpfeld->insert(CalculatorCmdHistory[CalculatorCmdCurhist]);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -