| 1 | // Aseprite |
| 2 | // Copyright (C) 2018 David Capello |
| 3 | // |
| 4 | // This program is distributed under the terms of |
| 5 | // the End-User License Agreement for Aseprite. |
| 6 | |
| 7 | #ifndef APP_UI_EXPR_ENTRY_H_INCLUDED |
| 8 | #define APP_UI_EXPR_ENTRY_H_INCLUDED |
| 9 | #pragma once |
| 10 | |
| 11 | #include "ui/entry.h" |
| 12 | |
| 13 | namespace app { |
| 14 | |
| 15 | // Support math expressions. |
| 16 | class ExprEntry : public ui::Entry { |
| 17 | public: |
| 18 | ExprEntry(); |
| 19 | |
| 20 | int decimals() const { return m_decimals; } |
| 21 | void setDecimals(int decimals) { m_decimals = decimals; } |
| 22 | |
| 23 | protected: |
| 24 | bool onProcessMessage(ui::Message* msg) override; |
| 25 | void onChange() override; |
| 26 | int onGetTextInt() const override; |
| 27 | double onGetTextDouble() const override; |
| 28 | |
| 29 | virtual void onFormatExprFocusLeave(std::string& buf); |
| 30 | |
| 31 | int m_decimals; |
| 32 | }; |
| 33 | |
| 34 | } // namespace app |
| 35 | |
| 36 | #endif |
| 37 | |