]> sigrok.org Git - pulseview.git/blame_incremental - pv/view/viewitempaintparams.hpp
Ruler: Don't use a function that is only available in recent boost versions
[pulseview.git] / pv / view / viewitempaintparams.hpp
... / ...
CommitLineData
1/*
2 * This file is part of the PulseView project.
3 *
4 * Copyright (C) 2014 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_ROWITEMPAINTPARAMS_HPP
22#define PULSEVIEW_PV_VIEW_ROWITEMPAINTPARAMS_HPP
23
24#include "pv/util.hpp"
25
26#include <QFont>
27
28namespace pv {
29namespace view {
30
31class ViewItemPaintParams
32{
33public:
34 ViewItemPaintParams(
35 const QRect &rect, double scale, const pv::util::Timestamp& offset);
36
37 QRect rect() const {
38 return rect_;
39 }
40
41 double scale() const {
42 return scale_;
43 }
44
45 const pv::util::Timestamp& offset() const {
46 return offset_;
47 }
48
49 int left() const {
50 return rect_.left();
51 }
52
53 int right() const {
54 return rect_.right();
55 }
56
57 int top() const {
58 return rect_.top();
59 }
60
61 int bottom() const {
62 return rect_.bottom();
63 }
64
65 int width() const {
66 return rect_.width();
67 }
68
69 int height() const {
70 return rect_.height();
71 }
72
73 double pixels_offset() const {
74 return (offset_ / scale_).convert_to<double>();
75 }
76
77public:
78 static QFont font();
79
80 static int text_height();
81
82private:
83 QRect rect_;
84 double scale_;
85 pv::util::Timestamp offset_;
86};
87
88} // namespace view
89} // namespace pv
90
91#endif // PULSEVIEW_PV_VIEW_ROWITEMPAINTPARAMS_HPP