|
|
|
@ -14,7 +14,7 @@ using std::string, std::wstring; |
|
|
|
|
|
|
|
|
|
enum class Event { |
|
|
|
|
NUMBER, ADD, SUB, MUL, |
|
|
|
|
DIV, CLR, NEG, EQ, PUSH, DUP |
|
|
|
|
DIV, CLR, NEG, EQ, PUSH, DUP, DEL |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const std::unordered_map<string, wstring> LABELS { |
|
|
|
@ -25,7 +25,7 @@ const std::unordered_map<string, wstring> LABELS { |
|
|
|
|
{"btn8", L"8"}, {"btn9", L"9"}, {"mul", L"*"}, |
|
|
|
|
{"sub", L"-"}, {"add", L"+"}, {"neg", L"±"}, |
|
|
|
|
{"div", L"/"}, {"eq", L"="}, |
|
|
|
|
{"push", L"^"}, {"pop", L"v"} }; |
|
|
|
|
{"push", L"^"}, {"pop", L"v"}, {"del", L"DEL"}}; |
|
|
|
|
|
|
|
|
|
const std::unordered_map<wchar_t, Event> EVENTS { |
|
|
|
|
{L'0', Event::NUMBER}, {L'1', Event::NUMBER}, |
|
|
|
@ -37,7 +37,7 @@ const std::unordered_map<wchar_t, Event> EVENTS { |
|
|
|
|
{L'+', Event::ADD}, {L'/', Event::DIV}, |
|
|
|
|
{L'C', Event::CLR}, {L'^', Event::PUSH}, |
|
|
|
|
{L'±', Event::NEG}, {L'v', Event::DUP}, |
|
|
|
|
{L'=', Event::EQ} }; |
|
|
|
|
{L'=', Event::EQ}, {L'D', Event::DEL}}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Calculator { |
|
|
|
@ -93,6 +93,11 @@ struct Calculator { |
|
|
|
|
case ADD: do_op(ADD); break; |
|
|
|
|
case SUB: do_op(SUB); break; |
|
|
|
|
case DIV: do_op(DIV); break; |
|
|
|
|
case DEL: |
|
|
|
|
if(input.size() > 0) { |
|
|
|
|
input.pop_back(); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case CLR: |
|
|
|
|
input = L""; |
|
|
|
|
stack.clear(); |
|
|
|
@ -142,7 +147,7 @@ struct CalculatorUI { |
|
|
|
|
"[btn7|btn8|btn9]" |
|
|
|
|
"[btn4|btn5|btn6]" |
|
|
|
|
"[btn1|btn2|btn3]" |
|
|
|
|
"[neg |btn0|_ ]"); |
|
|
|
|
"[neg |btn0|del]"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void init() { |
|
|
|
|