1use crate::QPoint;
7use cxx::{type_id, ExternType};
8use std::fmt;
9
10#[cxx::bridge]
11mod ffi {
12 unsafe extern "C++" {
13 include!("cxx-qt-lib/qline.h");
14 type QLine = super::QLine;
15 include!("cxx-qt-lib/qpoint.h");
16 type QPoint = crate::QPoint;
17 include!("cxx-qt-lib/qstring.h");
18 type QString = crate::QString;
19 include!("cxx-qt-lib/qlinef.h");
20 #[allow(dead_code)]
21 type QLineF = crate::QLineF;
22
23 fn p1(self: &QLine) -> QPoint;
25
26 fn p2(self: &QLine) -> QPoint;
28
29 fn x1(self: &QLine) -> i32;
31
32 fn x2(self: &QLine) -> i32;
34
35 fn y1(self: &QLine) -> i32;
37
38 fn y2(self: &QLine) -> i32;
40
41 fn center(self: &QLine) -> QPoint;
43
44 fn dx(self: &QLine) -> i32;
46
47 fn dy(self: &QLine) -> i32;
49
50 #[rust_name = "is_null"]
52 fn isNull(self: &QLine) -> bool;
53
54 #[rust_name = "set_p1"]
56 fn setP1(self: &mut QLine, p1: &QPoint);
57
58 #[rust_name = "set_p2"]
60 fn setP2(self: &mut QLine, p1: &QPoint);
61
62 #[rust_name = "set_line"]
64 fn setLine(self: &mut QLine, x1: i32, y1: i32, x2: i32, y2: i32);
65
66 #[rust_name = "set_points"]
68 fn setPoints(self: &mut QLine, p1: &QPoint, p2: &QPoint);
69
70 #[cfg(any(cxxqt_qt_version_at_least_7, cxxqt_qt_version_at_least_6_4))]
73 #[rust_name = "to_linef"]
74 fn toLineF(self: &QLine) -> QLineF;
75
76 fn translate(self: &mut QLine, offset: &QPoint);
78
79 fn translated(self: &QLine, offset: &QPoint) -> QLine;
81 }
82
83 #[namespace = "rust::cxxqtlib1"]
84 unsafe extern "C++" {
85 include!("cxx-qt-lib/common.h");
86
87 #[doc(hidden)]
88 #[rust_name = "qline_default"]
89 fn construct() -> QLine;
90
91 #[doc(hidden)]
92 #[rust_name = "qline_new"]
93 fn construct(pt1: QPoint, pt2: QPoint) -> QLine;
94
95 #[doc(hidden)]
96 #[rust_name = "qline_to_qstring"]
97 fn toQString(value: &QLine) -> QString;
98 }
99}
100
101#[derive(Debug, Clone, PartialEq, Eq)]
103#[repr(C)]
104pub struct QLine {
105 pt1: QPoint,
106 pt2: QPoint,
107}
108
109impl QLine {
110 pub fn new(pt1: QPoint, pt2: QPoint) -> Self {
112 ffi::qline_new(pt1, pt2)
113 }
114}
115
116impl Default for QLine {
117 fn default() -> Self {
119 ffi::qline_default()
120 }
121}
122
123impl fmt::Display for QLine {
124 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
125 write!(f, "{}", ffi::qline_to_qstring(self))
126 }
127}
128
129unsafe impl ExternType for QLine {
133 type Id = type_id!("QLine");
134 type Kind = cxx::kind::Trivial;
135}