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))]
69extern_conformance!(
70 unsafe impl NSAccessibility for NSRulerView {}
71);
72
73#[cfg(all(
74 feature = "NSAccessibilityProtocols",
75 feature = "NSResponder",
76 feature = "NSView"
77))]
78extern_conformance!(
79 unsafe impl NSAccessibilityElementProtocol for NSRulerView {}
80);
81
82#[cfg(all(feature = "NSAnimation", feature = "NSResponder", feature = "NSView"))]
83extern_conformance!(
84 unsafe impl NSAnimatablePropertyContainer for NSRulerView {}
85);
86
87#[cfg(all(feature = "NSAppearance", feature = "NSResponder", feature = "NSView"))]
88extern_conformance!(
89 unsafe impl NSAppearanceCustomization for NSRulerView {}
90);
91
92#[cfg(all(feature = "NSResponder", feature = "NSView"))]
93extern_conformance!(
94 unsafe impl NSCoding for NSRulerView {}
95);
96
97#[cfg(all(feature = "NSDragging", feature = "NSResponder", feature = "NSView"))]
98extern_conformance!(
99 unsafe impl NSDraggingDestination for NSRulerView {}
100);
101
102#[cfg(all(feature = "NSResponder", feature = "NSView"))]
103extern_conformance!(
104 unsafe impl NSObjectProtocol for NSRulerView {}
105);
106
107#[cfg(all(
108 feature = "NSResponder",
109 feature = "NSUserInterfaceItemIdentification",
110 feature = "NSView"
111))]
112extern_conformance!(
113 unsafe impl NSUserInterfaceItemIdentification for NSRulerView {}
114);
115
116#[cfg(all(feature = "NSResponder", feature = "NSView"))]
117impl NSRulerView {
118 extern_methods!(
119 #[cfg(feature = "objc2-core-foundation")]
120 #[unsafe(method(registerUnitWithName:abbreviation:unitToPointsConversionFactor:stepUpCycle:stepDownCycle:))]
122 #[unsafe(method_family = none)]
123 pub unsafe fn registerUnitWithName_abbreviation_unitToPointsConversionFactor_stepUpCycle_stepDownCycle(
124 unit_name: &NSRulerViewUnitName,
125 abbreviation: &NSString,
126 conversion_factor: CGFloat,
127 step_up_cycle: &NSArray<NSNumber>,
128 step_down_cycle: &NSArray<NSNumber>,
129 mtm: MainThreadMarker,
130 );
131
132 #[unsafe(method(initWithCoder:))]
134 #[unsafe(method_family = init)]
135 pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
136
137 #[cfg(feature = "NSScrollView")]
138 #[unsafe(method(initWithScrollView:orientation:))]
139 #[unsafe(method_family = init)]
140 pub unsafe fn initWithScrollView_orientation(
141 this: Allocated<Self>,
142 scroll_view: Option<&NSScrollView>,
143 orientation: NSRulerOrientation,
144 ) -> Retained<Self>;
145
146 #[cfg(feature = "NSScrollView")]
147 #[unsafe(method(scrollView))]
149 #[unsafe(method_family = none)]
150 pub unsafe fn scrollView(&self) -> Option<Retained<NSScrollView>>;
151
152 #[cfg(feature = "NSScrollView")]
153 #[unsafe(method(setScrollView:))]
156 #[unsafe(method_family = none)]
157 pub unsafe fn setScrollView(&self, scroll_view: Option<&NSScrollView>);
158
159 #[unsafe(method(orientation))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn orientation(&self) -> NSRulerOrientation;
162
163 #[unsafe(method(setOrientation:))]
165 #[unsafe(method_family = none)]
166 pub unsafe fn setOrientation(&self, orientation: NSRulerOrientation);
167
168 #[cfg(feature = "objc2-core-foundation")]
169 #[unsafe(method(baselineLocation))]
171 #[unsafe(method_family = none)]
172 pub unsafe fn baselineLocation(&self) -> CGFloat;
173
174 #[cfg(feature = "objc2-core-foundation")]
175 #[unsafe(method(requiredThickness))]
176 #[unsafe(method_family = none)]
177 pub unsafe fn requiredThickness(&self) -> CGFloat;
178
179 #[cfg(feature = "objc2-core-foundation")]
180 #[unsafe(method(ruleThickness))]
181 #[unsafe(method_family = none)]
182 pub unsafe fn ruleThickness(&self) -> CGFloat;
183
184 #[cfg(feature = "objc2-core-foundation")]
185 #[unsafe(method(setRuleThickness:))]
187 #[unsafe(method_family = none)]
188 pub unsafe fn setRuleThickness(&self, rule_thickness: CGFloat);
189
190 #[cfg(feature = "objc2-core-foundation")]
191 #[unsafe(method(reservedThicknessForMarkers))]
192 #[unsafe(method_family = none)]
193 pub unsafe fn reservedThicknessForMarkers(&self) -> CGFloat;
194
195 #[cfg(feature = "objc2-core-foundation")]
196 #[unsafe(method(setReservedThicknessForMarkers:))]
198 #[unsafe(method_family = none)]
199 pub unsafe fn setReservedThicknessForMarkers(
200 &self,
201 reserved_thickness_for_markers: CGFloat,
202 );
203
204 #[cfg(feature = "objc2-core-foundation")]
205 #[unsafe(method(reservedThicknessForAccessoryView))]
206 #[unsafe(method_family = none)]
207 pub unsafe fn reservedThicknessForAccessoryView(&self) -> CGFloat;
208
209 #[cfg(feature = "objc2-core-foundation")]
210 #[unsafe(method(setReservedThicknessForAccessoryView:))]
212 #[unsafe(method_family = none)]
213 pub unsafe fn setReservedThicknessForAccessoryView(
214 &self,
215 reserved_thickness_for_accessory_view: CGFloat,
216 );
217
218 #[unsafe(method(measurementUnits))]
220 #[unsafe(method_family = none)]
221 pub unsafe fn measurementUnits(&self) -> Retained<NSRulerViewUnitName>;
222
223 #[unsafe(method(setMeasurementUnits:))]
225 #[unsafe(method_family = none)]
226 pub unsafe fn setMeasurementUnits(&self, measurement_units: &NSRulerViewUnitName);
227
228 #[cfg(feature = "objc2-core-foundation")]
229 #[unsafe(method(originOffset))]
230 #[unsafe(method_family = none)]
231 pub unsafe fn originOffset(&self) -> CGFloat;
232
233 #[cfg(feature = "objc2-core-foundation")]
234 #[unsafe(method(setOriginOffset:))]
236 #[unsafe(method_family = none)]
237 pub unsafe fn setOriginOffset(&self, origin_offset: CGFloat);
238
239 #[unsafe(method(clientView))]
241 #[unsafe(method_family = none)]
242 pub unsafe fn clientView(&self) -> Option<Retained<NSView>>;
243
244 #[unsafe(method(setClientView:))]
247 #[unsafe(method_family = none)]
248 pub unsafe fn setClientView(&self, client_view: Option<&NSView>);
249
250 #[cfg(feature = "NSRulerMarker")]
251 #[unsafe(method(addMarker:))]
252 #[unsafe(method_family = none)]
253 pub unsafe fn addMarker(&self, marker: &NSRulerMarker);
254
255 #[cfg(feature = "NSRulerMarker")]
256 #[unsafe(method(removeMarker:))]
257 #[unsafe(method_family = none)]
258 pub unsafe fn removeMarker(&self, marker: &NSRulerMarker);
259
260 #[cfg(feature = "NSRulerMarker")]
261 #[unsafe(method(markers))]
262 #[unsafe(method_family = none)]
263 pub unsafe fn markers(&self) -> Option<Retained<NSArray<NSRulerMarker>>>;
264
265 #[cfg(feature = "NSRulerMarker")]
266 #[unsafe(method(setMarkers:))]
268 #[unsafe(method_family = none)]
269 pub unsafe fn setMarkers(&self, markers: Option<&NSArray<NSRulerMarker>>);
270
271 #[cfg(all(feature = "NSEvent", feature = "NSRulerMarker"))]
272 #[unsafe(method(trackMarker:withMouseEvent:))]
273 #[unsafe(method_family = none)]
274 pub unsafe fn trackMarker_withMouseEvent(
275 &self,
276 marker: &NSRulerMarker,
277 event: &NSEvent,
278 ) -> bool;
279
280 #[unsafe(method(accessoryView))]
281 #[unsafe(method_family = none)]
282 pub unsafe fn accessoryView(&self) -> Option<Retained<NSView>>;
283
284 #[unsafe(method(setAccessoryView:))]
286 #[unsafe(method_family = none)]
287 pub unsafe fn setAccessoryView(&self, accessory_view: Option<&NSView>);
288
289 #[cfg(feature = "objc2-core-foundation")]
290 #[unsafe(method(moveRulerlineFromLocation:toLocation:))]
291 #[unsafe(method_family = none)]
292 pub unsafe fn moveRulerlineFromLocation_toLocation(
293 &self,
294 old_location: CGFloat,
295 new_location: CGFloat,
296 );
297
298 #[unsafe(method(invalidateHashMarks))]
300 #[unsafe(method_family = none)]
301 pub unsafe fn invalidateHashMarks(&self);
302
303 #[unsafe(method(drawHashMarksAndLabelsInRect:))]
304 #[unsafe(method_family = none)]
305 pub unsafe fn drawHashMarksAndLabelsInRect(&self, rect: NSRect);
306
307 #[unsafe(method(drawMarkersInRect:))]
308 #[unsafe(method_family = none)]
309 pub unsafe fn drawMarkersInRect(&self, rect: NSRect);
310
311 #[unsafe(method(isFlipped))]
313 #[unsafe(method_family = none)]
314 pub unsafe fn isFlipped(&self) -> bool;
315 );
316}
317
318#[cfg(all(feature = "NSResponder", feature = "NSView"))]
320impl NSRulerView {
321 extern_methods!(
322 #[unsafe(method(initWithFrame:))]
323 #[unsafe(method_family = init)]
324 pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
325 );
326}
327
328#[cfg(all(feature = "NSResponder", feature = "NSView"))]
330impl NSRulerView {
331 extern_methods!(
332 #[unsafe(method(init))]
333 #[unsafe(method_family = init)]
334 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
335 );
336}
337
338#[cfg(all(feature = "NSResponder", feature = "NSView"))]
340impl NSRulerView {
341 extern_methods!(
342 #[unsafe(method(new))]
343 #[unsafe(method_family = new)]
344 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
345 );
346}
347
348#[cfg(all(feature = "NSResponder", feature = "NSView"))]
350impl NSView {
351 extern_methods!(
352 #[cfg(feature = "NSRulerMarker")]
353 #[unsafe(method(rulerView:shouldMoveMarker:))]
354 #[unsafe(method_family = none)]
355 pub unsafe fn rulerView_shouldMoveMarker(
356 &self,
357 ruler: &NSRulerView,
358 marker: &NSRulerMarker,
359 ) -> bool;
360
361 #[cfg(all(feature = "NSRulerMarker", feature = "objc2-core-foundation"))]
362 #[unsafe(method(rulerView:willMoveMarker:toLocation:))]
363 #[unsafe(method_family = none)]
364 pub unsafe fn rulerView_willMoveMarker_toLocation(
365 &self,
366 ruler: &NSRulerView,
367 marker: &NSRulerMarker,
368 location: CGFloat,
369 ) -> CGFloat;
370
371 #[cfg(feature = "NSRulerMarker")]
372 #[unsafe(method(rulerView:didMoveMarker:))]
373 #[unsafe(method_family = none)]
374 pub unsafe fn rulerView_didMoveMarker(&self, ruler: &NSRulerView, marker: &NSRulerMarker);
375
376 #[cfg(feature = "NSRulerMarker")]
377 #[unsafe(method(rulerView:shouldRemoveMarker:))]
378 #[unsafe(method_family = none)]
379 pub unsafe fn rulerView_shouldRemoveMarker(
380 &self,
381 ruler: &NSRulerView,
382 marker: &NSRulerMarker,
383 ) -> bool;
384
385 #[cfg(feature = "NSRulerMarker")]
386 #[unsafe(method(rulerView:didRemoveMarker:))]
387 #[unsafe(method_family = none)]
388 pub unsafe fn rulerView_didRemoveMarker(&self, ruler: &NSRulerView, marker: &NSRulerMarker);
389
390 #[cfg(feature = "NSRulerMarker")]
391 #[unsafe(method(rulerView:shouldAddMarker:))]
392 #[unsafe(method_family = none)]
393 pub unsafe fn rulerView_shouldAddMarker(
394 &self,
395 ruler: &NSRulerView,
396 marker: &NSRulerMarker,
397 ) -> bool;
398
399 #[cfg(all(feature = "NSRulerMarker", feature = "objc2-core-foundation"))]
400 #[unsafe(method(rulerView:willAddMarker:atLocation:))]
401 #[unsafe(method_family = none)]
402 pub unsafe fn rulerView_willAddMarker_atLocation(
403 &self,
404 ruler: &NSRulerView,
405 marker: &NSRulerMarker,
406 location: CGFloat,
407 ) -> CGFloat;
408
409 #[cfg(feature = "NSRulerMarker")]
410 #[unsafe(method(rulerView:didAddMarker:))]
411 #[unsafe(method_family = none)]
412 pub unsafe fn rulerView_didAddMarker(&self, ruler: &NSRulerView, marker: &NSRulerMarker);
413
414 #[cfg(feature = "NSEvent")]
415 #[unsafe(method(rulerView:handleMouseDown:))]
416 #[unsafe(method_family = none)]
417 pub unsafe fn rulerView_handleMouseDown(&self, ruler: &NSRulerView, event: &NSEvent);
418
419 #[unsafe(method(rulerView:willSetClientView:))]
420 #[unsafe(method_family = none)]
421 pub unsafe fn rulerView_willSetClientView(&self, ruler: &NSRulerView, new_client: &NSView);
422
423 #[cfg(feature = "objc2-core-foundation")]
424 #[unsafe(method(rulerView:locationForPoint:))]
425 #[unsafe(method_family = none)]
426 pub unsafe fn rulerView_locationForPoint(
427 &self,
428 ruler: &NSRulerView,
429 point: NSPoint,
430 ) -> CGFloat;
431
432 #[cfg(feature = "objc2-core-foundation")]
433 #[unsafe(method(rulerView:pointForLocation:))]
434 #[unsafe(method_family = none)]
435 pub unsafe fn rulerView_pointForLocation(
436 &self,
437 ruler: &NSRulerView,
438 point: CGFloat,
439 ) -> NSPoint;
440 );
441}