]> sigrok.org Git - pulseview.git/blob - pv/view/rowitem.h
2133db878188ba906f17619d2d8a1c06fb250f06
[pulseview.git] / pv / view / rowitem.h
1 /*
2  * This file is part of the PulseView project.
3  *
4  * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
5  *
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 2 of the License, or
9  * (at your option) any later version.
10  *
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.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19  */
20
21 #ifndef PULSEVIEW_PV_VIEW_HEADERITEM_H
22 #define PULSEVIEW_PV_VIEW_HEADERITEM_H
23
24 #include <memory>
25
26 #include "selectableitem.h"
27
28 namespace pv {
29 namespace view {
30
31 class RowItemOwner;
32
33 class RowItem : public SelectableItem,
34         public std::enable_shared_from_this<pv::view::RowItem>
35 {
36         Q_OBJECT
37
38 public:
39         /**
40          * Constructor.
41          */
42         RowItem();
43
44         /**
45          * Returns true if the item is visible and enabled.
46          */
47         virtual bool enabled() const = 0;
48
49         /**
50          * Gets the vertical layout offset of this signal.
51          */
52         int v_offset() const;
53
54         /**
55          * Sets the vertical layout offset of this signal.
56          */
57         void set_v_offset(int v_offset);
58
59         /**
60          * Gets the owner this trace in the view trace hierachy.
61          */
62         pv::view::RowItemOwner* owner() const;
63
64         /**
65          * Sets the owner this trace in the view trace hierachy.
66          * @param The new owner of the trace.
67          */
68         void set_owner(pv::view::RowItemOwner *owner);
69
70         /**
71          * Gets the y-offset of the axis.
72          */
73         int get_y() const;
74
75         /**
76          * Gets the drag point of the row item.
77          */
78         QPoint point() const;
79
80         /**
81          * Paints the background layer of the trace with a QPainter
82          * @param p the QPainter to paint into.
83          * @param left the x-coordinate of the left edge of the signal
84          * @param right the x-coordinate of the right edge of the signal
85          **/
86         virtual void paint_back(QPainter &p, int left, int right);
87
88         /**
89          * Paints the mid-layer of the trace with a QPainter
90          * @param p the QPainter to paint into.
91          * @param left the x-coordinate of the left edge of the signal
92          * @param right the x-coordinate of the right edge of the signal
93          **/
94         virtual void paint_mid(QPainter &p, int left, int right);
95
96         /**
97          * Paints the foreground layer of the trace with a QPainter
98          * @param p the QPainter to paint into.
99          * @param left the x-coordinate of the left edge of the signal
100          * @param right the x-coordinate of the right edge of the signal
101          **/
102         virtual void paint_fore(QPainter &p, int left, int right);
103
104         /**
105          * Paints the signal label.
106          * @param p the QPainter to paint into.
107          * @param right the x-coordinate of the right edge of the header
108          *      area.
109          * @param hover true if the label is being hovered over by the mouse.
110          */
111         virtual void paint_label(QPainter &p, int right, bool hover) = 0;
112
113         /**
114          * Computes the outline rectangle of a label.
115          * @param right the x-coordinate of the right edge of the header
116          *      area.
117          * @return Returns the rectangle of the signal label.
118          */
119         virtual QRectF label_rect(int right) const = 0;
120
121 public:
122         virtual void hover_point_changed();
123
124 Q_SIGNALS:
125         void appearance_changed();
126
127 protected:
128         pv::view::RowItemOwner *_owner;
129
130         int _v_offset;
131 };
132
133 } // namespace view
134 } // namespace pv
135
136 #endif // PULSEVIEW_PV_VIEW_HEADERITEM_H