]> sigrok.org Git - pulseview.git/blob - pv/view/rowitem.h
1aafca4be3fbfee81b663532e9e6a887601d6f12
[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          * Computes the vertical extents of the contents of this row item.
82          * @return A pair containing the minimum and maximum y-values.
83          */
84         virtual std::pair<int, int> v_extents() const = 0;
85
86         /**
87          * Paints the background layer of the trace with a QPainter
88          * @param p the QPainter to paint into.
89          * @param left the x-coordinate of the left edge of the signal
90          * @param right the x-coordinate of the right edge of the signal
91          **/
92         virtual void paint_back(QPainter &p, int left, int right);
93
94         /**
95          * Paints the mid-layer of the trace with a QPainter
96          * @param p the QPainter to paint into.
97          * @param left the x-coordinate of the left edge of the signal
98          * @param right the x-coordinate of the right edge of the signal
99          **/
100         virtual void paint_mid(QPainter &p, int left, int right);
101
102         /**
103          * Paints the foreground layer of the trace with a QPainter
104          * @param p the QPainter to paint into.
105          * @param left the x-coordinate of the left edge of the signal
106          * @param right the x-coordinate of the right edge of the signal
107          **/
108         virtual void paint_fore(QPainter &p, int left, int right);
109
110         /**
111          * Paints the signal label.
112          * @param p the QPainter to paint into.
113          * @param right the x-coordinate of the right edge of the header
114          *      area.
115          * @param hover true if the label is being hovered over by the mouse.
116          */
117         virtual void paint_label(QPainter &p, int right, bool hover) = 0;
118
119         /**
120          * Computes the outline rectangle of a label.
121          * @param right the x-coordinate of the right edge of the header
122          *      area.
123          * @return Returns the rectangle of the signal label.
124          */
125         virtual QRectF label_rect(int right) const = 0;
126
127 public:
128         virtual void hover_point_changed();
129
130 Q_SIGNALS:
131         void appearance_changed();
132
133 protected:
134         pv::view::RowItemOwner *_owner;
135
136         int _v_offset;
137 };
138
139 } // namespace view
140 } // namespace pv
141
142 #endif // PULSEVIEW_PV_VIEW_HEADERITEM_H