Debian Codegraph @

utils/fgqcanvas/fgcanvastext.h

raw symbols SCIP
1 //
2 // Copyright (C) 2017 James Turner [email protected]
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License as
6 // published by the Free Software Foundation; either version 2 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but
10 // WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 #ifndef FGCANVASTEXT_H
19 #define FGCANVASTEXT_H
20
21 #include <QFont>
22 #include <QFontMetricsF>
23
24 #include "fgcanvaselement.h"
25
26 class TextCanvasItem;
27
28 class FGCanvasText : public FGCanvasElement
29 {
30 public:
31 FGCanvasText(FGCanvasGroup* pr, LocalProp* prop);
32
33 CanvasItem* createQuickItem(QQuickItem *parent) override;
34 CanvasItem* quickItem() const override;
35
36 void dumpElement() override;
37 protected:
38 virtual void doPaint(FGCanvasPaintContext* context) const override;
39 void doPolish() override;
40
41 virtual void markStyleDirty() override;
42
43 void doDestroy() override;
44
45 private:
46 bool onChildAdded(LocalProp *prop) override;
47
48 void onTextChanged(QVariant var);
49
50 void setDrawMode(QVariant var);
51
52 void markFontDirty();
53
54 void onFontLoaded(QByteArray name);
55 private:
56 void rebuildFont() const;
57 void rebuildAlignment(QVariant var) const;
58
59 QString _text;
60
61 mutable Qt::Alignment _alignment;
62 mutable bool _fontDirty = true;
63 mutable QFont _font;
64 mutable QFontMetricsF _metrics;
65
66 TextCanvasItem* _quickItem = nullptr;
67 };
68
69
70 #endif // FGCANVASTEXT_H