]> sigrok.org Git - pulseview.git/blob - pv/view/rowitem.h
Header: Keep a shared_ptr of the clicked item
[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 "selectableitem.h"
25
26 namespace pv {
27 namespace view {
28
29 class RowItemOwner;
30
31 class RowItem : public SelectableItem
32 {
33         Q_OBJECT
34
35 public:
36         /**
37          * Constructor.
38          */
39         RowItem();
40
41         /**
42          * Returns true if the item is visible and enabled.
43          */
44         virtual bool enabled() const = 0;
45
46         /**
47          * Gets the vertical layout offset of this signal.
48          */
49         int v_offset() const;
50
51         /**
52          * Sets the vertical layout offset of this signal.
53          */
54         void set_v_offset(int v_offset);
55
56         /**
57          * Gets the owner this trace in the view trace hierachy.
58          */
59         pv::view::RowItemOwner* owner() const;
60
61         /**
62          * Sets the owner this trace in the view trace hierachy.
63          * @param The new owner of the trace.
64          */
65         void set_owner(pv::view::RowItemOwner *owner);
66
67         /**
68          * Gets the y-offset of the axis.
69          */
70         int get_y() const;
71
72         /**
73          * Gets the drag point of the row item.
74          */
75         QPoint point() const;
76
77         /**
78          * Paints the background layer of the trace with a QPainter
79          * @param p the QPainter to paint into.
80          * @param left the x-coordinate of the left edge of the signal
81          * @param right the x-coordinate of the right edge of the signal
82          **/
83         virtual void paint_back(QPainter &p, int left, int right);
84
85         /**
86          * Paints the mid-layer of the trace with a QPainter
87          * @param p the QPainter to paint into.
88          * @param left the x-coordinate of the left edge of the signal
89          * @param right the x-coordinate of the right edge of the signal
90          **/
91         virtual void paint_mid(QPainter &p, int left, int right);
92
93         /**
94          * Paints the foreground layer of the trace with a QPainter
95          * @param p the QPainter to paint into.
96          * @param left the x-coordinate of the left edge of the signal
97          * @param right the x-coordinate of the right edge of the signal
98          **/
99         virtual void paint_fore(QPainter &p, int left, int right);
100
101         /**
102          * Paints the signal label.
103          * @param p the QPainter to paint into.
104          * @param right the x-coordinate of the right edge of the header
105          *      area.
106          * @param hover true if the label is being hovered over by the mouse.
107          */
108         virtual void paint_label(QPainter &p, int right, bool hover) = 0;
109
110         /**
111          * Computes the outline rectangle of a label.
112          * @param right the x-coordinate of the right edge of the header
113          *      area.
114          * @return Returns the rectangle of the signal label.
115          */
116         virtual QRectF label_rect(int right) const = 0;
117
118 public:
119         virtual void hover_point_changed();
120
121 Q_SIGNALS:
122         void appearance_changed();
123
124 protected:
125         pv::view::RowItemOwner *_owner;
126
127         int _v_offset;
128 };
129
130 } // namespace view
131 } // namespace pv
132
133 #endif // PULSEVIEW_PV_VIEW_HEADERITEM_H