void subString() { strncpy(sub, oper+substart, 16); clrLine(2); set_lcd_addr(0x40); type_lcd(sub); set_lcd_addr(0x40); }
void stdMode(char key, Flag *flag){ int i; char a = hex2asc(key); //convert to ascii kbuf[kidx] = a; // and store in kbuf if(key<10 && flag->nlock == false){ //if 0 - 9 if(kidx < 16){ flag->olock = false; // reset operator lock wait_keyup(); // wait to release key kidx++; //increment index display(kbuf, kidx,0x40); } } //end if(c<10) else{ //c !<10 switch(key){ /* case 0xB: sprintf(s, "%g", d); clear_lcd(); set_lcd_addr(0x40); type_lcd(s); wait_keyup(); break;*/ case 0xE: //if decimal (*) key if(flag->deci == false){ flag->deci = true; wait_keyup(); //wait to release key kbuf[kidx++] = '.'; //store '.' in kbuf display(kbuf, kidx, 0x40); } break; case 0xA: //if Postfix (A) key if(flag->post == false) { flag->post = true; //set flag to indicate input will be in postfix notation led_on(0); //turn on led 0 clrLine(2); kidx = 0; //reset index kbuf[kidx] = '\0'; //clear keypad buffer for new input } else { flag->post = false; //back to prefix mode led_off(0); //turn off led 0 clrLine(2); kidx = 0; kbuf[kidx] = '\0'; } wait_keyup(); break; case 0xC: //if delete (C) key if(kidx > 0){ //make sure index does not go below 0 if(is_number(kbuf[kidx-1])) flag->olock = true; if(kbuf[kidx-1] == '.') flag->deci = false; if(kbuf[kidx-1] == '(') flag->leftpar -= 1; if(kbuf[kidx-1] == ')') { flag->leftpar += 1; flag->nlock = false; flag->olock = false; } else flag->olock = true; kbuf[--kidx] = '\0'; //delete char at i by changing to null char clrLine(2); display(kbuf, kidx, 0x40); } wait_keyup(); break; case 0xD: //if shift (D) key flag->shift = true; wait_keyup(); //wait to release key break; case 0xF: //if negative (#) key if(flag->neg == false){ flag->neg = true; for(i = kidx; i > 0; i--){ kbuf[i] = kbuf[i-1]; } kbuf[0] = '-'; kidx++; } else{ flag->neg = false; for(i = 0; i < kidx; i++){ kbuf[i] = kbuf[i+1]; } kidx--; } clrLine(2); display(kbuf, kidx, 0x40); wait_keyup(); break; default: break; } //switch } //end else (c !< 10) }
void shiftMode(char key, Flag *flag){ switch(key){ case 0xA: //if memory set (A) key - save number midx = kidx; strcpy(mem, kbuf); //copy data from kbuf to mem flag->save = true; led_on(1); //turn on 2nd led to indicate saved number wait_keyup(); break; case 0xB: //if memory recall (B) key - get saved number if(flag->save == true){ flag->olock = false; flag->nlock = true; strcpy(kbuf, mem); kidx = midx; //kbuf[kidx] = '\0'; clrLine(2); //clear line 2 display(kbuf, kidx, 0x40); wait_keyup(); } break; case 0x1: //if plus '+' (1) key addOper('+', flag); break; case 0x2: //if minus '-' (2) key addOper('-', flag); break; case 0x3: //if mod '%' (3) key addOper('%', flag); break; case 0x4: //if multiply '*' (4) key addOper('*', flag); break; case 0x5: //if divide key '/' (5) key addOper('/', flag); break; case 0x6: //if power '^' (6) key addOper('^', flag); break; case 0x7: //if left parenthesis '(' (7) key if(flag->olock == true){ flag->leftpar += 1; kbuf[kidx++] = '('; display(kbuf,kidx, 0x40); wait_keyup(); } break; case 0x8: //if right parenthesis ')' (8) key if(flag->leftpar>0 && flag->olock==false){ //if '(' present flag->leftpar -= 1; kbuf[kidx++] = ')'; display(kbuf,kidx, 0x40); flag->nlock = true; //nlock = true to stop taking number inputs wait_keyup(); } break; case 0x9: //if factorial '!' (9) key addOper('!', flag); break; case 0xC: //if clear (C) key flag->nlock = false; flag->olock = true; flag->deci = false; flag = createFlag(); clear_lcd(); kidx = 0; //reset kbuf index kbuf[kidx] = '\0'; //clear kbuf oidx = 0; //reset oper index oper[oidx] = '\0'; //clear oper substart = 0; set_lcd_addr(0x40); wait_keyup(); //wait to release key break; case 0xD: // if shift (D) key flag->shift = false; wait_keyup(); //wait to release key break; case 0xF: //if equal (#) key clrLine(1); //-------------------- if(oidx > 0){ strcat(oper, kbuf); oidx += kidx; } else{ oidx = kidx; strcpy(oper, kbuf); } oper[oidx++] = ' '; flag->nlock = false; flag->deci = false; kidx = 0; //------------------- --oidx; //remove space display(oper, oidx, 0x40); wait_keyup(); break; case 0x0: break; default: break; } //end switch }
void CFWL_FormTP::DrawCloseBox(CFX_Graphics* pGraphics, const CFX_RectF* pRect, FWLTHEME_STATE eState, CFX_Matrix* pMatrix, int32_t iActive) { FX_FLOAT fRight = pRect->right(); FX_FLOAT fBottom = pRect->bottom(); FX_FLOAT fWidth = pRect->width; FX_FLOAT fHeight = pRect->height; pGraphics->SaveGraphState(); CFX_RectF rt(*pRect); pGraphics->SetLineWidth(1.0f); CFX_Path path; path.Create(); path.AddRectangle(rt.left + 1, rt.top, fWidth - 2, 1); path.AddRectangle(rt.left, rt.top + 1, 1, fHeight - 2); path.AddRectangle(fRight - 1, rt.top + 1, 1, fHeight - 2); path.AddRectangle(rt.left + 1, fBottom - 1, fWidth - 2, 1); CFX_Color crFill; crFill = m_pThemeData->clrBtnEdgeOut[iActive]; pGraphics->SetFillColor(&crFill); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); path.Clear(); path.AddRectangle(rt.left + 1, rt.top + 1, 1, 1); path.AddRectangle(fRight - 2, rt.top + 1, 1, 1); path.AddRectangle(rt.left + 1, fBottom - 2, 1, 1); path.AddRectangle(fRight - 2, fBottom - 2, 1, 1); crFill = m_pThemeData->clrBtnCornerLight[iActive][eState - 1]; pGraphics->SetFillColor(&crFill); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); path.Clear(); path.AddRectangle(rt.left + 2, rt.top + 1, fWidth - 4, 1); path.AddRectangle(rt.left + 1, rt.top + 2, 1, fHeight - 4); crFill = m_pThemeData->clrCloseBtEdgeLight[iActive][eState - 1]; pGraphics->SetFillColor(&crFill); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); path.Clear(); path.AddRectangle(fRight - 2, rt.top + 2, 1, fHeight - 4); path.AddRectangle(rt.left + 2, fBottom - 2, fWidth - 4, 1); crFill = m_pThemeData->clrCloseBtEdgeDark[iActive][eState - 1]; pGraphics->SetFillColor(&crFill); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); path.Clear(); path.AddRectangle(pRect->left + 2, pRect->top + 2, fWidth - 4, fHeight - 4); DrawAxialShading(pGraphics, pRect->left + 2, pRect->top + 2, fRight - 2, fBottom - 2, m_pThemeData->clrCloseBtBKStart[iActive][eState - 1], m_pThemeData->clrCloseBtBKEnd[iActive][eState - 1], &path, FXFILL_WINDING, pMatrix); CFX_RectF rtX(*pRect); rtX.Inflate(-5, -5); path.Clear(); FX_FLOAT frtXRight = rtX.right(); FX_FLOAT frtXBottom = rtX.bottom(); path.AddLine(rtX.left, rtX.top + 1, frtXRight - 1, frtXBottom); path.AddLine(rtX.left, rtX.top, frtXRight, frtXBottom); path.AddLine(rtX.left + 1, rtX.top, frtXRight, frtXBottom - 1); path.AddLine(rtX.left, frtXBottom - 1, frtXRight - 1, rtX.top); path.AddLine(rtX.left, frtXBottom, frtXRight, rtX.top); path.AddLine(rtX.left + 1, frtXBottom, frtXRight, rtX.top + 1); CFX_Color clrLine(0xffffffff); pGraphics->SetLineWidth(1.0f); pGraphics->SetStrokeColor(&clrLine); pGraphics->StrokePath(&path, pMatrix); pGraphics->RestoreGraphState(); }