1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct NSRulerOrientation(pub NSUInteger);
17impl NSRulerOrientation {
18 #[doc(alias = "NSHorizontalRuler")]
19 pub const HorizontalRuler: Self = Self(0);
20 #[doc(alias = "NSVerticalRuler")]
21 pub const VerticalRuler: Self = Self(1);
22}
23
24unsafe impl Encode for NSRulerOrientation {
25 const ENCODING: Encoding = NSUInteger::ENCODING;
26}
27
28unsafe impl RefEncode for NSRulerOrientation {
29 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
30}
31
32pub type NSRulerViewUnitName = NSString;
35
36extern "C" {
37 pub static NSRulerViewUnitInches: &'static NSRulerViewUnitName;
39}
40
41extern "C" {
42 pub static NSRulerViewUnitCentimeters: &'static NSRulerViewUnitName;
44}
45
46extern "C" {
47 pub static NSRulerViewUnitPoints: &'static NSRulerViewUnitName;
49}
50
51extern "C" {
52 pub static NSRulerViewUnitPicas: &'static NSRulerViewUnitName;
54}
55
56extern_class!(
57 #[unsafe(super(NSView, NSResponder, NSObject))]
59 #[derive(Debug, PartialEq, Eq, Hash)]
60 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
61 pub struct NSRulerView;
62);
63
64#[cfg(all(
65 feature = "NSAccessibilityProtocols",
66 feature = "NSResponder",
67 feature = "NSView"
68))]
69unsafe impl NSAccessibility for NSRulerView {}
70
71#[cfg(all(
72 feature = "NSAccessibilityProtocols",
73 feature = "NSResponder",
74 feature = "NSView"
75))]
76unsafe impl NSAccessibilityElementProtocol for NSRulerView {}
77
78#[cfg(all(feature = "NSAnimation", feature = "NSResponder", feature = "NSView"))]
79unsafe impl NSAnimatablePropertyContainer for NSRulerView {}
80
81#[cfg(all(feature = "NSAppearance", feature = "NSResponder", feature = "NSView"))]
82unsafe impl NSAppearanceCustomization for NSRulerView {}
83
84#[cfg(all(feature = "NSResponder", feature = "NSView"))]
85unsafe impl NSCoding for NSRulerView {}
86
87#[cfg(all(feature = "NSDragging", feature = "NSResponder", feature = "NSView"))]
88unsafe impl NSDraggingDestination for NSRulerView {}
89
90#[cfg(all(feature = "NSResponder", feature = "NSView"))]
91unsafe impl NSObjectProtocol for NSRulerView {}
92
93#[cfg(all(
94 feature = "NSResponder",
95 feature = "NSUserInterfaceItemIdentification",
96 feature = "NSView"
97))]
98unsafe impl NSUserInterfaceItemIdentification for NSRulerView {}
99
100#[cfg(all(feature = "NSResponder", feature = "NSView"))]
101impl NSRulerView {
102 extern_methods!(
103 #[cfg(feature = "objc2-core-foundation")]
104 #[unsafe(method(registerUnitWithName:abbreviation:unitToPointsConversionFactor:stepUpCycle:stepDownCycle:))]
106 #[unsafe(method_family = none)]
107 pub unsafe fn registerUnitWithName_abbreviation_unitToPointsConversionFactor_stepUpCycle_stepDownCycle(
108 unit_name: &NSRulerViewUnitName,
109 abbreviation: &NSString,
110 conversion_factor: CGFloat,
111 step_up_cycle: &NSArray<NSNumber>,
112 step_down_cycle: &NSArray<NSNumber>,
113 mtm: MainThreadMarker,
114 );
115
116 #[unsafe(method(initWithCoder:))]
118 #[unsafe(method_family = init)]
119 pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
120
121 #[cfg(feature = "NSScrollView")]
122 #[unsafe(method(initWithScrollView:orientation:))]
123 #[unsafe(method_family = init)]
124 pub unsafe fn initWithScrollView_orientation(
125 this: Allocated<Self>,
126 scroll_view: Option<&NSScrollView>,
127 orientation: NSRulerOrientation,
128 ) -> Retained<Self>;
129
130 #[cfg(feature = "NSScrollView")]
131 #[unsafe(method(scrollView))]
133 #[unsafe(method_family = none)]
134 pub unsafe fn scrollView(&self) -> Option<Retained<NSScrollView>>;
135
136 #[cfg(feature = "NSScrollView")]
137 #[unsafe(method(setScrollView:))]
140 #[unsafe(method_family = none)]
141 pub unsafe fn setScrollView(&self, scroll_view: Option<&NSScrollView>);
142
143 #[unsafe(method(orientation))]
144 #[unsafe(method_family = none)]
145 pub unsafe fn orientation(&self) -> NSRulerOrientation;
146
147 #[unsafe(method(setOrientation:))]
149 #[unsafe(method_family = none)]
150 pub unsafe fn setOrientation(&self, orientation: NSRulerOrientation);
151
152 #[cfg(feature = "objc2-core-foundation")]
153 #[unsafe(method(baselineLocation))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn baselineLocation(&self) -> CGFloat;
157
158 #[cfg(feature = "objc2-core-foundation")]
159 #[unsafe(method(requiredThickness))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn requiredThickness(&self) -> CGFloat;
162
163 #[cfg(feature = "objc2-core-foundation")]
164 #[unsafe(method(ruleThickness))]
165 #[unsafe(method_family = none)]
166 pub unsafe fn ruleThickness(&self) -> CGFloat;
167
168 #[cfg(feature = "objc2-core-foundation")]
169 #[unsafe(method(setRuleThickness:))]
171 #[unsafe(method_family = none)]
172 pub unsafe fn setRuleThickness(&self, rule_thickness: CGFloat);
173
174 #[cfg(feature = "objc2-core-foundation")]
175 #[unsafe(method(reservedThicknessForMarkers))]
176 #[unsafe(method_family = none)]
177 pub unsafe fn reservedThicknessForMarkers(&self) -> CGFloat;
178
179 #[cfg(feature = "objc2-core-foundation")]
180 #[unsafe(method(setReservedThicknessForMarkers:))]
182 #[unsafe(method_family = none)]
183 pub unsafe fn setReservedThicknessForMarkers(
184 &self,
185 reserved_thickness_for_markers: CGFloat,
186 );
187
188 #[cfg(feature = "objc2-core-foundation")]
189 #[unsafe(method(reservedThicknessForAccessoryView))]
190 #[unsafe(method_family = none)]
191 pub unsafe fn reservedThicknessForAccessoryView(&self) -> CGFloat;
192
193 #[cfg(feature = "objc2-core-foundation")]
194 #[unsafe(method(setReservedThicknessForAccessoryView:))]
196 #[unsafe(method_family = none)]
197 pub unsafe fn setReservedThicknessForAccessoryView(
198 &self,
199 reserved_thickness_for_accessory_view: CGFloat,
200 );
201
202 #[unsafe(method(measurementUnits))]
204 #[unsafe(method_family = none)]
205 pub unsafe fn measurementUnits(&self) -> Retained<NSRulerViewUnitName>;
206
207 #[unsafe(method(setMeasurementUnits:))]
209 #[unsafe(method_family = none)]
210 pub unsafe fn setMeasurementUnits(&self, measurement_units: &NSRulerViewUnitName);
211
212 #[cfg(feature = "objc2-core-foundation")]
213 #[unsafe(method(originOffset))]
214 #[unsafe(method_family = none)]
215 pub unsafe fn originOffset(&self) -> CGFloat;
216
217 #[cfg(feature = "objc2-core-foundation")]
218 #[unsafe(method(setOriginOffset:))]
220 #[unsafe(method_family = none)]
221 pub unsafe fn setOriginOffset(&self, origin_offset: CGFloat);
222
223 #[unsafe(method(clientView))]
225 #[unsafe(method_family = none)]
226 pub unsafe fn clientView(&self) -> Option<Retained<NSView>>;
227
228 #[unsafe(method(setClientView:))]
231 #[unsafe(method_family = none)]
232 pub unsafe fn setClientView(&self, client_view: Option<&NSView>);
233
234 #[cfg(feature = "NSRulerMarker")]
235 #[unsafe(method(addMarker:))]
236 #[unsafe(method_family = none)]
237 pub unsafe fn addMarker(&self, marker: &NSRulerMarker);
238
239 #[cfg(feature = "NSRulerMarker")]
240 #[unsafe(method(removeMarker:))]
241 #[unsafe(method_family = none)]
242 pub unsafe fn removeMarker(&self, marker: &NSRulerMarker);
243
244 #[cfg(feature = "NSRulerMarker")]
245 #[unsafe(method(markers))]
246 #[unsafe(method_family = none)]
247 pub unsafe fn markers(&self) -> Option<Retained<NSArray<NSRulerMarker>>>;
248
249 #[cfg(feature = "NSRulerMarker")]
250 #[unsafe(method(setMarkers:))]
252 #[unsafe(method_family = none)]
253 pub unsafe fn setMarkers(&self, markers: Option<&NSArray<NSRulerMarker>>);
254
255 #[cfg(all(feature = "NSEvent", feature = "NSRulerMarker"))]
256 #[unsafe(method(trackMarker:withMouseEvent:))]
257 #[unsafe(method_family = none)]
258 pub unsafe fn trackMarker_withMouseEvent(
259 &self,
260 marker: &NSRulerMarker,
261 event: &NSEvent,
262 ) -> bool;
263
264 #[unsafe(method(accessoryView))]
265 #[unsafe(method_family = none)]
266 pub unsafe fn accessoryView(&self) -> Option<Retained<NSView>>;
267
268 #[unsafe(method(setAccessoryView:))]
270 #[unsafe(method_family = none)]
271 pub unsafe fn setAccessoryView(&self, accessory_view: Option<&NSView>);
272
273 #[cfg(feature = "objc2-core-foundation")]
274 #[unsafe(method(moveRulerlineFromLocation:toLocation:))]
275 #[unsafe(method_family = none)]
276 pub unsafe fn moveRulerlineFromLocation_toLocation(
277 &self,
278 old_location: CGFloat,
279 new_location: CGFloat,
280 );
281
282 #[unsafe(method(invalidateHashMarks))]
284 #[unsafe(method_family = none)]
285 pub unsafe fn invalidateHashMarks(&self);
286
287 #[unsafe(method(drawHashMarksAndLabelsInRect:))]
288 #[unsafe(method_family = none)]
289 pub unsafe fn drawHashMarksAndLabelsInRect(&self, rect: NSRect);
290
291 #[unsafe(method(drawMarkersInRect:))]
292 #[unsafe(method_family = none)]
293 pub unsafe fn drawMarkersInRect(&self, rect: NSRect);
294
295 #[unsafe(method(isFlipped))]
297 #[unsafe(method_family = none)]
298 pub unsafe fn isFlipped(&self) -> bool;
299 );
300}
301
302#[cfg(all(feature = "NSResponder", feature = "NSView"))]
304impl NSRulerView {
305 extern_methods!(
306 #[unsafe(method(initWithFrame:))]
307 #[unsafe(method_family = init)]
308 pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
309 );
310}
311
312#[cfg(all(feature = "NSResponder", feature = "NSView"))]
314impl NSRulerView {
315 extern_methods!(
316 #[unsafe(method(init))]
317 #[unsafe(method_family = init)]
318 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
319 );
320}
321
322#[cfg(all(feature = "NSResponder", feature = "NSView"))]
324impl NSRulerView {
325 extern_methods!(
326 #[unsafe(method(new))]
327 #[unsafe(method_family = new)]
328 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
329 );
330}
331
332#[cfg(all(feature = "NSResponder", feature = "NSView"))]
334impl NSView {
335 extern_methods!(
336 #[cfg(feature = "NSRulerMarker")]
337 #[unsafe(method(rulerView:shouldMoveMarker:))]
338 #[unsafe(method_family = none)]
339 pub unsafe fn rulerView_shouldMoveMarker(
340 &self,
341 ruler: &NSRulerView,
342 marker: &NSRulerMarker,
343 ) -> bool;
344
345 #[cfg(all(feature = "NSRulerMarker", feature = "objc2-core-foundation"))]
346 #[unsafe(method(rulerView:willMoveMarker:toLocation:))]
347 #[unsafe(method_family = none)]
348 pub unsafe fn rulerView_willMoveMarker_toLocation(
349 &self,
350 ruler: &NSRulerView,
351 marker: &NSRulerMarker,
352 location: CGFloat,
353 ) -> CGFloat;
354
355 #[cfg(feature = "NSRulerMarker")]
356 #[unsafe(method(rulerView:didMoveMarker:))]
357 #[unsafe(method_family = none)]
358 pub unsafe fn rulerView_didMoveMarker(&self, ruler: &NSRulerView, marker: &NSRulerMarker);
359
360 #[cfg(feature = "NSRulerMarker")]
361 #[unsafe(method(rulerView:shouldRemoveMarker:))]
362 #[unsafe(method_family = none)]
363 pub unsafe fn rulerView_shouldRemoveMarker(
364 &self,
365 ruler: &NSRulerView,
366 marker: &NSRulerMarker,
367 ) -> bool;
368
369 #[cfg(feature = "NSRulerMarker")]
370 #[unsafe(method(rulerView:didRemoveMarker:))]
371 #[unsafe(method_family = none)]
372 pub unsafe fn rulerView_didRemoveMarker(&self, ruler: &NSRulerView, marker: &NSRulerMarker);
373
374 #[cfg(feature = "NSRulerMarker")]
375 #[unsafe(method(rulerView:shouldAddMarker:))]
376 #[unsafe(method_family = none)]
377 pub unsafe fn rulerView_shouldAddMarker(
378 &self,
379 ruler: &NSRulerView,
380 marker: &NSRulerMarker,
381 ) -> bool;
382
383 #[cfg(all(feature = "NSRulerMarker", feature = "objc2-core-foundation"))]
384 #[unsafe(method(rulerView:willAddMarker:atLocation:))]
385 #[unsafe(method_family = none)]
386 pub unsafe fn rulerView_willAddMarker_atLocation(
387 &self,
388 ruler: &NSRulerView,
389 marker: &NSRulerMarker,
390 location: CGFloat,
391 ) -> CGFloat;
392
393 #[cfg(feature = "NSRulerMarker")]
394 #[unsafe(method(rulerView:didAddMarker:))]
395 #[unsafe(method_family = none)]
396 pub unsafe fn rulerView_didAddMarker(&self, ruler: &NSRulerView, marker: &NSRulerMarker);
397
398 #[cfg(feature = "NSEvent")]
399 #[unsafe(method(rulerView:handleMouseDown:))]
400 #[unsafe(method_family = none)]
401 pub unsafe fn rulerView_handleMouseDown(&self, ruler: &NSRulerView, event: &NSEvent);
402
403 #[unsafe(method(rulerView:willSetClientView:))]
404 #[unsafe(method_family = none)]
405 pub unsafe fn rulerView_willSetClientView(&self, ruler: &NSRulerView, new_client: &NSView);
406
407 #[cfg(feature = "objc2-core-foundation")]
408 #[unsafe(method(rulerView:locationForPoint:))]
409 #[unsafe(method_family = none)]
410 pub unsafe fn rulerView_locationForPoint(
411 &self,
412 ruler: &NSRulerView,
413 point: NSPoint,
414 ) -> CGFloat;
415
416 #[cfg(feature = "objc2-core-foundation")]
417 #[unsafe(method(rulerView:pointForLocation:))]
418 #[unsafe(method_family = none)]
419 pub unsafe fn rulerView_pointForLocation(
420 &self,
421 ruler: &NSRulerView,
422 point: CGFloat,
423 ) -> NSPoint;
424 );
425}