QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
qtextorientationwidget.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef Q_TEXT_ORIENTATION_WIDGET_H
19#define Q_TEXT_ORIENTATION_WIDGET_H
20#include <QtWidgets>
24class QTextOrientationWidget : public QWidget {
25 Q_OBJECT
26
27 // constructors, destructor
28 public:
29 QTextOrientationWidget(QWidget * = nullptr);
30 ~QTextOrientationWidget() override;
31 private:
34
35 // methods
36 public:
37 double orientation() const;
38 void setFont(const QFont &);
39 QFont font() const;
40 void setDisplayText(bool);
41 bool textDisplayed() const;
42 void setUsableTexts(const QStringList &);
43 QStringList usableTexts() const;
44 bool isReadOnly() const;
45 void setReadOnly(bool);
46
47 public slots:
48 void setOrientation(const double &);
49
50 protected:
51 QSize sizeHint () const override;
52 int heightForWidth(int) const override;
53 void paintEvent(QPaintEvent *) override;
54 void mouseMoveEvent(QMouseEvent *) override;
55 void mouseReleaseEvent(QMouseEvent *) override;
56
57 signals:
61 void orientationChanged(double);
62
63 // attributes
64 private:
74 QHash<QString, qreal> text_size_hash_;
81
82 private:
83 QString getMostUsableStringForRadius(const qreal &);
85 bool positionIsASquare(const QPointF &, double * = nullptr);
86};
87#endif
Definition qtextorientationwidget.h:24
double squares_interval_
Interval between commonly used angles (represented by squares), in degrees.
Definition qtextorientationwidget.h:66
QFont text_font_
Font used to render the example text.
Definition qtextorientationwidget.h:72
double orientation() const
Definition qtextorientationwidget.cpp:75
bool read_only_
Whether this widget is read only.
Definition qtextorientationwidget.h:80
~QTextOrientationWidget() override
Definition qtextorientationwidget.cpp:56
bool must_highlight_angle_
Whether to highlight a specific angle.
Definition qtextorientationwidget.h:78
QHash< QString, qreal > text_size_hash_
Associate available example texts with their length (in pixels)
Definition qtextorientationwidget.h:74
QTextOrientationWidget & operator=(const QTextOrientationWidget &)
void setUsableTexts(const QStringList &)
Definition qtextorientationwidget.cpp:123
double current_orientation_
current angle
Definition qtextorientationwidget.h:68
bool textDisplayed() const
Definition qtextorientationwidget.cpp:111
bool isReadOnly() const
Definition qtextorientationwidget.cpp:153
void mouseReleaseEvent(QMouseEvent *) override
Definition qtextorientationwidget.cpp:277
QSize sizeHint() const override
Definition qtextorientationwidget.cpp:168
void mouseMoveEvent(QMouseEvent *) override
Definition qtextorientationwidget.cpp:256
void setReadOnly(bool)
Definition qtextorientationwidget.cpp:161
int heightForWidth(int) const override
Definition qtextorientationwidget.cpp:178
void orientationChanged(double)
void paintEvent(QPaintEvent *) override
Definition qtextorientationwidget.cpp:187
double highlight_angle_
Specific angle to be highlighted.
Definition qtextorientationwidget.h:76
bool positionIsASquare(const QPointF &, double *=nullptr)
Definition qtextorientationwidget.cpp:347
void generateTextSizeHash()
Definition qtextorientationwidget.cpp:330
QStringList usableTexts() const
Definition qtextorientationwidget.cpp:145
QTextOrientationWidget(const QTextOrientationWidget &)
void setOrientation(const double &)
Definition qtextorientationwidget.cpp:65
QString getMostUsableStringForRadius(const qreal &)
Definition qtextorientationwidget.cpp:301
void setDisplayText(bool)
Definition qtextorientationwidget.cpp:104
QFont font() const
Definition qtextorientationwidget.cpp:96
bool display_text_
Whether to display an example text.
Definition qtextorientationwidget.h:70
void setFont(const QFont &)
Definition qtextorientationwidget.cpp:84