QElectroTech  0.70
qtextorientationwidget.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 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
double squares_interval_
Interval between commonly used angles (represented by squares), in degrees.
double highlight_angle_
Specific angle to be highlighted.
QString getMostUsableStringForRadius(const qreal &)
void paintEvent(QPaintEvent *) override
double current_orientation_
current angle
void setOrientation(const double &)
bool display_text_
Whether to display an example text.
void setUsableTexts(const QStringList &)
void mouseReleaseEvent(QMouseEvent *) override
QHash< QString, qreal > text_size_hash_
Associate available example texts with their length (in pixels)
bool read_only_
Whether this widget is read only.
void mouseMoveEvent(QMouseEvent *) override
int heightForWidth(int) const override
bool positionIsASquare(const QPointF &, double *=nullptr)
QSize sizeHint() const override
bool must_highlight_angle_
Whether to highlight a specific angle.
QTextOrientationWidget(QWidget *=nullptr)
QTextOrientationWidget & operator=(const QTextOrientationWidget &)
void orientationChanged(double)
QFont text_font_
Font used to render the example text.