ORE Studio 0.0.4
Loading...
Searching...
No Matches
currency_dialog.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_WT_SERVICE_APP_CURRENCY_DIALOG_HPP
21#define ORES_WT_SERVICE_APP_CURRENCY_DIALOG_HPP
22
23#include <Wt/WDialog.h>
24#include <Wt/WLineEdit.h>
25#include <Wt/WSpinBox.h>
26#include <Wt/WComboBox.h>
27#include <Wt/WPushButton.h>
28#include <Wt/WText.h>
29#include <Wt/WSignal.h>
30
31namespace ores::wt::service::app {
32
37 std::string iso_code;
38 std::string name;
39 std::string numeric_code;
40 std::string symbol;
41 std::string fraction_symbol;
42 int fractions_per_unit = 100;
43 std::string rounding_type = "Closest";
44 int rounding_precision = 2;
45 std::string format;
46 std::string monetary_nature = "Fiat";
47 std::string market_tier = "G10";
48 int version = 0;
49};
50
54class currency_dialog : public Wt::WDialog {
55public:
56 enum class mode { add, edit };
57
58 explicit currency_dialog(mode m);
59
60 void set_currency(const currency_data& data);
61 currency_data get_currency() const;
62
63 Wt::Signal<currency_data>& saved() { return saved_; }
64
65private:
66 void setup_form();
67 void setup_buttons();
68 void on_save();
69 void validate_and_save();
70
71 mode mode_;
72 Wt::WLineEdit* iso_code_edit_;
73 Wt::WLineEdit* name_edit_;
74 Wt::WLineEdit* numeric_code_edit_;
75 Wt::WLineEdit* symbol_edit_;
76 Wt::WLineEdit* fraction_symbol_edit_;
77 Wt::WSpinBox* fractions_spinbox_;
78 Wt::WComboBox* rounding_type_combo_;
79 Wt::WSpinBox* precision_spinbox_;
80 Wt::WLineEdit* format_edit_;
81 Wt::WComboBox* monetary_nature_combo_;
82 Wt::WComboBox* market_tier_combo_;
83 Wt::WText* status_text_;
84
85 Wt::Signal<currency_data> saved_;
86};
87
88}
89
90#endif
Currency data for form binding.
Definition currency_dialog.hpp:36
Dialog for creating/editing currencies.
Definition currency_dialog.hpp:54