cxx_qt_lib/core/qt.rs
1// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
2// SPDX-FileContributor: Andrew Hayzen <andrew.hayzen@kdab.com>
3//
4// SPDX-License-Identifier: MIT OR Apache-2.0
5
6#[cxx::bridge(namespace = "Qt")]
7mod ffi {
8 /// This enum type defines what happens to the aspect ratio when scaling an rectangle.
9 #[repr(i32)]
10 enum AspectRatioMode {
11 /// The size is scaled freely. The aspect ratio is not preserved.
12 IgnoreAspectRatio,
13 /// The size is scaled to a rectangle as large as possible inside a given rectangle, preserving the aspect ratio.
14 KeepAspectRatio,
15 /// The size is scaled to a rectangle as small as possible outside a given rectangle, preserving the aspect ratio.
16 KeepAspectRatioByExpanding,
17 }
18
19 #[repr(i32)]
20 enum CaseSensitivity {
21 CaseInsensitive,
22 CaseSensitive,
23 }
24
25 #[repr(i32)]
26 enum DateFormat {
27 TextDate = 0,
28 ISODateWithMs = 9,
29 ISODate = 1,
30 RFC2822Date = 8,
31 }
32
33 #[repr(i32)]
34 enum SplitBehaviorFlags {
35 KeepEmptyParts,
36 SkipEmptyParts,
37 }
38
39 #[repr(i32)]
40 enum TimeSpec {
41 /// Local time, controlled by a system time-zone setting.
42 LocalTime,
43 /// Coordinated Universal Time.
44 UTC,
45 /// An offset in seconds from Coordinated Universal Time.
46 OffsetFromUTC,
47 /// A named time zone.
48 TimeZone,
49 }
50
51 /// This enum type defines whether image transformations (e.g., scaling) should be smooth or not.
52 #[repr(i32)]
53 enum TransformationMode {
54 /// The transformation is performed quickly, with no smoothing.
55 FastTransformation,
56 /// The resulting image is transformed using bilinear filtering.
57 SmoothTransformation,
58 }
59
60 /// This enum type defines the pen styles that can be drawn using QPainter.
61 #[repr(i32)]
62 enum PenStyle {
63 /// no line at all. For example, QPainter::drawRect() fills but does not draw any boundary line.
64 NoPen,
65 /// A plain line.
66 SolidLine,
67 /// Dashes separated by a few pixels.
68 DashLine,
69 /// Dots separated by a few pixels.
70 DotLine,
71 /// Alternate dots and dashes.
72 DashDotLine,
73 /// One dash, two dots, one dash, two dots.
74 DashDotDotLine,
75 /// A custom pattern defined using QPainterPathStroker::setDashPattern().
76 CustomDashLine,
77 }
78
79 /// This enum type defines the line endcap style
80 #[repr(i32)]
81 enum PenCapStyle {
82 FlatCap = 0x00,
83 SquareCap = 0x10,
84 RoundCap = 0x20,
85 MPenCapStyle = 0x30,
86 }
87
88 /// This enum type defines the line join style.
89 #[repr(i32)]
90 enum PenJoinStyle {
91 MiterJoin = 0x00,
92 BevelJoin = 0x40,
93 RoundJoin = 0x80,
94 SvgMiterJoin = 0x100,
95 MPenJoinStyle = 0x1c0,
96 }
97
98 #[repr(i32)]
99 enum FillRule {
100 /// Specifies that the region is filled using the odd even fill rule.
101 /// With this rule, we determine whether a point is inside the shape by using
102 /// the following method. Draw a horizontal line from the point to a location
103 /// outside the shape, and count the number of intersections. If the number of
104 /// intersections is an odd number, the point is inside the shape. This mode is the default.
105 OddEvenFill,
106 /// Specifies that the region is filled using the non zero winding rule.
107 /// With this rule, we determine whether a point is inside the shape by using the following method.
108 /// Draw a horizontal line from the point to a location outside the shape. Determine whether
109 /// the direction of the line at each intersection point is up or down. The winding number is determined
110 /// by summing the direction of each intersection. If the number is non zero, the point is inside the shape.
111 /// This fill mode can also in most cases be considered as the intersection of closed shapes.
112 WindingFill,
113 }
114
115 /// This enum type specifies the direction of Qt's layouts and text handling.
116 #[repr(i32)]
117 enum LayoutDirection {
118 LeftToRight,
119 RightToLeft,
120 LayoutDirectionAuto,
121 }
122
123 /// This enum type specifies the background mode
124 #[repr(i32)]
125 enum BGMode {
126 TransparentMode,
127 OpaqueMode,
128 }
129
130 #[repr(i32)]
131 enum ClipOperation {
132 NoClip,
133 ReplaceClip,
134 IntersectClip,
135 }
136
137 /// This enum is used by QPainter::drawRoundedRect() and QPainterPath::addRoundedRect()
138 /// functions to specify the radii of rectangle corners with respect to the dimensions
139 /// of the bounding rectangles specified.
140 #[repr(i32)]
141 enum SizeMode {
142 /// Specifies the size using absolute measurements.
143 AbsoluteSize,
144 /// Specifies the size relative to the bounding rectangle, typically using percentage measurements.
145 RelativeSize,
146 }
147
148 unsafe extern "C++" {
149 include!("cxx-qt-lib/qt.h");
150 type AspectRatioMode;
151 type CaseSensitivity;
152 type DateFormat;
153 type SplitBehaviorFlags;
154 type TimeSpec;
155 type TransformationMode;
156 type PenStyle;
157 type PenCapStyle;
158 type PenJoinStyle;
159 type FillRule;
160 type LayoutDirection;
161 type BGMode;
162 type ClipOperation;
163 type SizeMode;
164 }
165}
166
167pub use ffi::{
168 AspectRatioMode, BGMode, CaseSensitivity, ClipOperation, DateFormat, FillRule, LayoutDirection,
169 PenCapStyle, PenJoinStyle, PenStyle, SizeMode, SplitBehaviorFlags, TimeSpec,
170 TransformationMode,
171};
172
173// Reexport ConnectionType from cxx-qt
174pub use cxx_qt::ConnectionType;