QElectroTech  0.8-dev
qtextorientationwidget.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2020 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>
24 class 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:
72  QFont text_font_;
74  QHash<QString, qreal> text_size_hash_;
80  bool read_only_;
81 
82  private:
83  QString getMostUsableStringForRadius(const qreal &);
84  void generateTextSizeHash();
85  bool positionIsASquare(const QPointF &, double * = nullptr);
86 };
87 #endif
QTextOrientationWidget::~QTextOrientationWidget
~QTextOrientationWidget() override
Definition: qtextorientationwidget.cpp:55
QTextOrientationWidget::paintEvent
void paintEvent(QPaintEvent *) override
Definition: qtextorientationwidget.cpp:178
QTextOrientationWidget::read_only_
bool read_only_
Whether this widget is read only.
Definition: qtextorientationwidget.h:80
QTextOrientationWidget
Definition: qtextorientationwidget.h:24
QTextOrientationWidget::setUsableTexts
void setUsableTexts(const QStringList &)
Definition: qtextorientationwidget.cpp:118
qtextorientationwidget.h
QTextOrientationWidget::usableTexts
QStringList usableTexts() const
Definition: qtextorientationwidget.cpp:140
QTextOrientationWidget::current_orientation_
double current_orientation_
current angle
Definition: qtextorientationwidget.h:68
QTextOrientationWidget::text_size_hash_
QHash< QString, qreal > text_size_hash_
Associate available example texts with their length (in pixels)
Definition: qtextorientationwidget.h:74
QTextOrientationWidget::sizeHint
QSize sizeHint() const override
Definition: qtextorientationwidget.cpp:161
QTextOrientationWidget::highlight_angle_
double highlight_angle_
Specific angle to be highlighted.
Definition: qtextorientationwidget.h:76
QTextOrientationWidget::squares_interval_
double squares_interval_
Interval between commonly used angles (represented by squares), in degrees.
Definition: qtextorientationwidget.h:66
QTextOrientationWidget::isReadOnly
bool isReadOnly() const
Definition: qtextorientationwidget.cpp:147
QTextOrientationWidget::QTextOrientationWidget
QTextOrientationWidget(const QTextOrientationWidget &)
QTextOrientationWidget::must_highlight_angle_
bool must_highlight_angle_
Whether to highlight a specific angle.
Definition: qtextorientationwidget.h:78
QTextOrientationWidget::QTextOrientationWidget
QTextOrientationWidget(QWidget *=nullptr)
Definition: qtextorientationwidget.cpp:28
QTextOrientationWidget::setDisplayText
void setDisplayText(bool)
Definition: qtextorientationwidget.cpp:100
QTextOrientationWidget::getMostUsableStringForRadius
QString getMostUsableStringForRadius(const qreal &)
Definition: qtextorientationwidget.cpp:280
QTextOrientationWidget::operator=
QTextOrientationWidget & operator=(const QTextOrientationWidget &)
QTextOrientationWidget::setOrientation
void setOrientation(const double &)
Definition: qtextorientationwidget.cpp:63
QTextOrientationWidget::font
QFont font() const
Definition: qtextorientationwidget.cpp:93
QTextOrientationWidget::positionIsASquare
bool positionIsASquare(const QPointF &, double *=nullptr)
Definition: qtextorientationwidget.cpp:325
QTextOrientationWidget::textDisplayed
bool textDisplayed() const
Definition: qtextorientationwidget.cpp:107
QET::Icons::ro
QIcon ro
Definition: qeticons.cpp:200
QTextOrientationWidget::heightForWidth
int heightForWidth(int) const override
Definition: qtextorientationwidget.cpp:170
QTextOrientationWidget::setReadOnly
void setReadOnly(bool)
Definition: qtextorientationwidget.cpp:154
QTextOrientationWidget::orientation
double orientation() const
Definition: qtextorientationwidget.cpp:73
QTextOrientationWidget::display_text_
bool display_text_
Whether to display an example text.
Definition: qtextorientationwidget.h:70
QTextOrientationWidget::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *) override
Definition: qtextorientationwidget.cpp:247
QTextOrientationWidget::setFont
void setFont(const QFont &)
Definition: qtextorientationwidget.cpp:81
QTextOrientationWidget::text_font_
QFont text_font_
Font used to render the example text.
Definition: qtextorientationwidget.h:72
QET::Icons::tr
QIcon tr
Definition: qeticons.cpp:206
QTextOrientationWidget::orientationChanged
void orientationChanged(double)
QTextOrientationWidget::generateTextSizeHash
void generateTextSizeHash()
Definition: qtextorientationwidget.cpp:309
QTextOrientationWidget::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *) override
Definition: qtextorientationwidget.cpp:262