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 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:))]
138 #[unsafe(method_family = init)]
139 pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
140
141 #[cfg(feature = "NSScrollView")]
142 #[unsafe(method(initWithScrollView:orientation:))]
143 #[unsafe(method_family = init)]
144 pub fn initWithScrollView_orientation(
145 this: Allocated<Self>,
146 scroll_view: Option<&NSScrollView>,
147 orientation: NSRulerOrientation,
148 ) -> Retained<Self>;
149
150 #[cfg(feature = "NSScrollView")]
151 #[unsafe(method(scrollView))]
153 #[unsafe(method_family = none)]
154 pub fn scrollView(&self) -> Option<Retained<NSScrollView>>;
155
156 #[cfg(feature = "NSScrollView")]
157 #[unsafe(method(setScrollView:))]
161 #[unsafe(method_family = none)]
162 pub fn setScrollView(&self, scroll_view: Option<&NSScrollView>);
163
164 #[unsafe(method(orientation))]
165 #[unsafe(method_family = none)]
166 pub fn orientation(&self) -> NSRulerOrientation;
167
168 #[unsafe(method(setOrientation:))]
170 #[unsafe(method_family = none)]
171 pub fn setOrientation(&self, orientation: NSRulerOrientation);
172
173 #[cfg(feature = "objc2-core-foundation")]
174 #[unsafe(method(baselineLocation))]
176 #[unsafe(method_family = none)]
177 pub fn baselineLocation(&self) -> CGFloat;
178
179 #[cfg(feature = "objc2-core-foundation")]
180 #[unsafe(method(requiredThickness))]
181 #[unsafe(method_family = none)]
182 pub fn requiredThickness(&self) -> CGFloat;
183
184 #[cfg(feature = "objc2-core-foundation")]
185 #[unsafe(method(ruleThickness))]
186 #[unsafe(method_family = none)]
187 pub fn ruleThickness(&self) -> CGFloat;
188
189 #[cfg(feature = "objc2-core-foundation")]
190 #[unsafe(method(setRuleThickness:))]
192 #[unsafe(method_family = none)]
193 pub fn setRuleThickness(&self, rule_thickness: CGFloat);
194
195 #[cfg(feature = "objc2-core-foundation")]
196 #[unsafe(method(reservedThicknessForMarkers))]
197 #[unsafe(method_family = none)]
198 pub fn reservedThicknessForMarkers(&self) -> CGFloat;
199
200 #[cfg(feature = "objc2-core-foundation")]
201 #[unsafe(method(setReservedThicknessForMarkers:))]
203 #[unsafe(method_family = none)]
204 pub fn setReservedThicknessForMarkers(&self, reserved_thickness_for_markers: CGFloat);
205
206 #[cfg(feature = "objc2-core-foundation")]
207 #[unsafe(method(reservedThicknessForAccessoryView))]
208 #[unsafe(method_family = none)]
209 pub fn reservedThicknessForAccessoryView(&self) -> CGFloat;
210
211 #[cfg(feature = "objc2-core-foundation")]
212 #[unsafe(method(setReservedThicknessForAccessoryView:))]
214 #[unsafe(method_family = none)]
215 pub fn setReservedThicknessForAccessoryView(
216 &self,
217 reserved_thickness_for_accessory_view: CGFloat,
218 );
219
220 #[unsafe(method(measurementUnits))]
222 #[unsafe(method_family = none)]
223 pub fn measurementUnits(&self) -> Retained<NSRulerViewUnitName>;
224
225 #[unsafe(method(setMeasurementUnits:))]
229 #[unsafe(method_family = none)]
230 pub fn setMeasurementUnits(&self, measurement_units: &NSRulerViewUnitName);
231
232 #[cfg(feature = "objc2-core-foundation")]
233 #[unsafe(method(originOffset))]
234 #[unsafe(method_family = none)]
235 pub fn originOffset(&self) -> CGFloat;
236
237 #[cfg(feature = "objc2-core-foundation")]
238 #[unsafe(method(setOriginOffset:))]
240 #[unsafe(method_family = none)]
241 pub fn setOriginOffset(&self, origin_offset: CGFloat);
242
243 #[unsafe(method(clientView))]
245 #[unsafe(method_family = none)]
246 pub fn clientView(&self) -> Option<Retained<NSView>>;
247
248 #[unsafe(method(setClientView:))]
252 #[unsafe(method_family = none)]
253 pub fn setClientView(&self, client_view: Option<&NSView>);
254
255 #[cfg(feature = "NSRulerMarker")]
256 #[unsafe(method(addMarker:))]
257 #[unsafe(method_family = none)]
258 pub fn addMarker(&self, marker: &NSRulerMarker);
259
260 #[cfg(feature = "NSRulerMarker")]
261 #[unsafe(method(removeMarker:))]
262 #[unsafe(method_family = none)]
263 pub fn removeMarker(&self, marker: &NSRulerMarker);
264
265 #[cfg(feature = "NSRulerMarker")]
266 #[unsafe(method(markers))]
267 #[unsafe(method_family = none)]
268 pub fn markers(&self) -> Option<Retained<NSArray<NSRulerMarker>>>;
269
270 #[cfg(feature = "NSRulerMarker")]
271 #[unsafe(method(setMarkers:))]
275 #[unsafe(method_family = none)]
276 pub fn setMarkers(&self, markers: Option<&NSArray<NSRulerMarker>>);
277
278 #[cfg(all(feature = "NSEvent", feature = "NSRulerMarker"))]
279 #[unsafe(method(trackMarker:withMouseEvent:))]
280 #[unsafe(method_family = none)]
281 pub fn trackMarker_withMouseEvent(&self, marker: &NSRulerMarker, event: &NSEvent) -> bool;
282
283 #[unsafe(method(accessoryView))]
284 #[unsafe(method_family = none)]
285 pub fn accessoryView(&self) -> Option<Retained<NSView>>;
286
287 #[unsafe(method(setAccessoryView:))]
289 #[unsafe(method_family = none)]
290 pub fn setAccessoryView(&self, accessory_view: Option<&NSView>);
291
292 #[cfg(feature = "objc2-core-foundation")]
293 #[unsafe(method(moveRulerlineFromLocation:toLocation:))]
294 #[unsafe(method_family = none)]
295 pub fn moveRulerlineFromLocation_toLocation(
296 &self,
297 old_location: CGFloat,
298 new_location: CGFloat,
299 );
300
301 #[unsafe(method(invalidateHashMarks))]
303 #[unsafe(method_family = none)]
304 pub fn invalidateHashMarks(&self);
305
306 #[unsafe(method(drawHashMarksAndLabelsInRect:))]
307 #[unsafe(method_family = none)]
308 pub fn drawHashMarksAndLabelsInRect(&self, rect: NSRect);
309
310 #[unsafe(method(drawMarkersInRect:))]
311 #[unsafe(method_family = none)]
312 pub fn drawMarkersInRect(&self, rect: NSRect);
313
314 #[unsafe(method(isFlipped))]
316 #[unsafe(method_family = none)]
317 pub fn isFlipped(&self) -> bool;
318 );
319}
320
321#[cfg(all(feature = "NSResponder", feature = "NSView"))]
323impl NSRulerView {
324 extern_methods!(
325 #[unsafe(method(initWithFrame:))]
326 #[unsafe(method_family = init)]
327 pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
328 );
329}
330
331#[cfg(all(feature = "NSResponder", feature = "NSView"))]
333impl NSRulerView {
334 extern_methods!(
335 #[unsafe(method(init))]
336 #[unsafe(method_family = init)]
337 pub fn init(this: Allocated<Self>) -> Retained<Self>;
338 );
339}
340
341#[cfg(all(feature = "NSResponder", feature = "NSView"))]
343impl NSRulerView {
344 extern_methods!(
345 #[unsafe(method(new))]
346 #[unsafe(method_family = new)]
347 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
348 );
349}
350
351#[cfg(all(feature = "NSResponder", feature = "NSView"))]
353impl NSView {
354 extern_methods!(
355 #[cfg(feature = "NSRulerMarker")]
356 #[unsafe(method(rulerView:shouldMoveMarker:))]
357 #[unsafe(method_family = none)]
358 pub fn rulerView_shouldMoveMarker(
359 &self,
360 ruler: &NSRulerView,
361 marker: &NSRulerMarker,
362 ) -> bool;
363
364 #[cfg(all(feature = "NSRulerMarker", feature = "objc2-core-foundation"))]
365 #[unsafe(method(rulerView:willMoveMarker:toLocation:))]
366 #[unsafe(method_family = none)]
367 pub fn rulerView_willMoveMarker_toLocation(
368 &self,
369 ruler: &NSRulerView,
370 marker: &NSRulerMarker,
371 location: CGFloat,
372 ) -> CGFloat;
373
374 #[cfg(feature = "NSRulerMarker")]
375 #[unsafe(method(rulerView:didMoveMarker:))]
376 #[unsafe(method_family = none)]
377 pub fn rulerView_didMoveMarker(&self, ruler: &NSRulerView, marker: &NSRulerMarker);
378
379 #[cfg(feature = "NSRulerMarker")]
380 #[unsafe(method(rulerView:shouldRemoveMarker:))]
381 #[unsafe(method_family = none)]
382 pub fn rulerView_shouldRemoveMarker(
383 &self,
384 ruler: &NSRulerView,
385 marker: &NSRulerMarker,
386 ) -> bool;
387
388 #[cfg(feature = "NSRulerMarker")]
389 #[unsafe(method(rulerView:didRemoveMarker:))]
390 #[unsafe(method_family = none)]
391 pub fn rulerView_didRemoveMarker(&self, ruler: &NSRulerView, marker: &NSRulerMarker);
392
393 #[cfg(feature = "NSRulerMarker")]
394 #[unsafe(method(rulerView:shouldAddMarker:))]
395 #[unsafe(method_family = none)]
396 pub fn rulerView_shouldAddMarker(
397 &self,
398 ruler: &NSRulerView,
399 marker: &NSRulerMarker,
400 ) -> bool;
401
402 #[cfg(all(feature = "NSRulerMarker", feature = "objc2-core-foundation"))]
403 #[unsafe(method(rulerView:willAddMarker:atLocation:))]
404 #[unsafe(method_family = none)]
405 pub fn rulerView_willAddMarker_atLocation(
406 &self,
407 ruler: &NSRulerView,
408 marker: &NSRulerMarker,
409 location: CGFloat,
410 ) -> CGFloat;
411
412 #[cfg(feature = "NSRulerMarker")]
413 #[unsafe(method(rulerView:didAddMarker:))]
414 #[unsafe(method_family = none)]
415 pub fn rulerView_didAddMarker(&self, ruler: &NSRulerView, marker: &NSRulerMarker);
416
417 #[cfg(feature = "NSEvent")]
418 #[unsafe(method(rulerView:handleMouseDown:))]
419 #[unsafe(method_family = none)]
420 pub fn rulerView_handleMouseDown(&self, ruler: &NSRulerView, event: &NSEvent);
421
422 #[unsafe(method(rulerView:willSetClientView:))]
423 #[unsafe(method_family = none)]
424 pub fn rulerView_willSetClientView(&self, ruler: &NSRulerView, new_client: &NSView);
425
426 #[cfg(feature = "objc2-core-foundation")]
427 #[unsafe(method(rulerView:locationForPoint:))]
428 #[unsafe(method_family = none)]
429 pub fn rulerView_locationForPoint(&self, ruler: &NSRulerView, point: NSPoint) -> CGFloat;
430
431 #[cfg(feature = "objc2-core-foundation")]
432 #[unsafe(method(rulerView:pointForLocation:))]
433 #[unsafe(method_family = none)]
434 pub fn rulerView_pointForLocation(&self, ruler: &NSRulerView, point: CGFloat) -> NSPoint;
435 );
436}