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