QCodeEditor: Update to current cpeditor/QCodeEditor fork, commit ed1196a
[smuview.git] / src / ui / widgets / monofontdisplay.hpp
blobcc0fde0c76c6563711f46653025d98b3d6898a7d
1 /*
2 * This file is part of the SmuView project.
4 * Copyright (C) 2019-2022 Frank Stettner <frank-stettner@gmx.net>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef UI_WIDGETS_MONOFONTDISPLAY_HPP
21 #define UI_WIDGETS_MONOFONTDISPLAY_HPP
23 #include <QFont>
24 #include <QFrame>
25 #include <QGridLayout>
26 #include <QLabel>
27 #include <QSpacerItem>
28 #include <QString>
30 namespace sv {
31 namespace ui {
32 namespace widgets {
34 enum class MonoFontDisplayType {
35 AutoRange,
36 AutoRangeWithSRDigits,
37 FixedRange
40 class MonoFontDisplay : public QFrame
42 Q_OBJECT
44 public:
45 MonoFontDisplay(const MonoFontDisplayType display_type,
46 const QString &unit, const QString &unit_suffix,
47 const QString &extra_text, const bool small, QWidget *parent = nullptr);
49 double value() const;
51 private:
52 const MonoFontDisplayType display_type_;
53 int total_digits_;
54 bool total_digits_changed_;
55 int sr_digits_;
56 int decimal_places_;
57 QString extra_text_;
58 bool extra_text_changed_;
59 QString unit_;
60 QString unit_si_prefix_;
61 QString unit_suffix_;
62 bool unit_changed_;
63 const bool small_;
64 double value_;
65 int ascent_diff_;
66 QGridLayout *layout_;
67 QLabel *value_label_;
68 QFont extra_font_;
69 QLabel *extra_label_;
70 QSpacerItem *extra_spacer_;
71 QLabel *unit_label_;
73 virtual void setup_ui();
74 void update_value_widget_dimensions();
75 void update_extra_widget_dimensions();
76 void update_unit_widget_dimensions();
77 void show_value(const QString &value);
78 void show_extra_text(const QString &extra_text);
79 void show_unit(const QString &unit);
81 public Q_SLOTS:
82 void set_value(const double value);
83 void set_extra_text(const QString &extra_text);
84 void set_unit(const QString &unit);
85 void set_unit_suffix(const QString &unit_suffix);
86 void set_sr_digits(const int total_digits, const int sr_digits);
87 void set_decimal_places(const int total_digits, const int decimal_places);
88 void reset_value();
89 void update_display();
93 } // namespace widgets
94 } // namespace ui
95 } // namespace sv
97 #endif // UI_WIDGETS_MONOFONTDISPLAY_HPP