/* * Copyright (c) 2019-2020, Sergey Bugaev * Copyright (c) 2021, Glenford Williams * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include "Calculator.h" #include "Keypad.h" #include "KeypadValue.h" #include #include class CalculatorWidget final : public GUI::Widget { C_OBJECT(CalculatorWidget) public: virtual ~CalculatorWidget() override = default; String get_entry(); void set_entry(KeypadValue); private: CalculatorWidget(); void add_operation_button(GUI::Button&, Calculator::Operation); void add_digit_button(GUI::Button&, int digit); void mimic_pressed_button(RefPtr); void perform_operation(Calculator::Operation operation); void update_display(); virtual void keydown_event(GUI::KeyEvent&) override; Calculator m_calculator; Keypad m_keypad; RefPtr m_entry; RefPtr m_label; RefPtr m_digit_button[10]; RefPtr m_mem_add_button; RefPtr m_mem_save_button; RefPtr m_mem_recall_button; RefPtr m_mem_clear_button; RefPtr m_clear_button; RefPtr m_clear_error_button; RefPtr m_backspace_button; RefPtr m_decimal_point_button; RefPtr m_sign_button; RefPtr m_add_button; RefPtr m_subtract_button; RefPtr m_multiply_button; RefPtr m_divide_button; RefPtr m_sqrt_button; RefPtr m_inverse_button; RefPtr m_percent_button; RefPtr m_equals_button; };