objc2-app-kit 0.3.2

Bindings to the AppKit framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrulerorientation?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSRulerOrientation(pub NSUInteger);
impl NSRulerOrientation {
    #[doc(alias = "NSHorizontalRuler")]
    pub const HorizontalRuler: Self = Self(0);
    #[doc(alias = "NSVerticalRuler")]
    pub const VerticalRuler: Self = Self(1);
}

unsafe impl Encode for NSRulerOrientation {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSRulerOrientation {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrulerviewunitname?language=objc)
// NS_TYPED_EXTENSIBLE_ENUM
pub type NSRulerViewUnitName = NSString;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrulerviewunitinches?language=objc)
    pub static NSRulerViewUnitInches: &'static NSRulerViewUnitName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrulerviewunitcentimeters?language=objc)
    pub static NSRulerViewUnitCentimeters: &'static NSRulerViewUnitName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrulerviewunitpoints?language=objc)
    pub static NSRulerViewUnitPoints: &'static NSRulerViewUnitName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrulerviewunitpicas?language=objc)
    pub static NSRulerViewUnitPicas: &'static NSRulerViewUnitName;
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrulerview?language=objc)
    #[unsafe(super(NSView, NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "NSResponder", feature = "NSView"))]
    pub struct NSRulerView;
);

#[cfg(all(
    feature = "NSAccessibilityProtocols",
    feature = "NSResponder",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSAccessibility for NSRulerView {}
);

#[cfg(all(
    feature = "NSAccessibilityProtocols",
    feature = "NSResponder",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSAccessibilityElementProtocol for NSRulerView {}
);

#[cfg(all(feature = "NSAnimation", feature = "NSResponder", feature = "NSView"))]
extern_conformance!(
    unsafe impl NSAnimatablePropertyContainer for NSRulerView {}
);

#[cfg(all(feature = "NSAppearance", feature = "NSResponder", feature = "NSView"))]
extern_conformance!(
    unsafe impl NSAppearanceCustomization for NSRulerView {}
);

#[cfg(all(feature = "NSResponder", feature = "NSView"))]
extern_conformance!(
    unsafe impl NSCoding for NSRulerView {}
);

#[cfg(all(feature = "NSDragging", feature = "NSResponder", feature = "NSView"))]
extern_conformance!(
    unsafe impl NSDraggingDestination for NSRulerView {}
);

#[cfg(all(feature = "NSResponder", feature = "NSView"))]
extern_conformance!(
    unsafe impl NSObjectProtocol for NSRulerView {}
);

#[cfg(all(
    feature = "NSResponder",
    feature = "NSUserInterfaceItemIdentification",
    feature = "NSView"
))]
extern_conformance!(
    unsafe impl NSUserInterfaceItemIdentification for NSRulerView {}
);

#[cfg(all(feature = "NSResponder", feature = "NSView"))]
impl NSRulerView {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        /// *********************** Registering new units ************************
        #[unsafe(method(registerUnitWithName:abbreviation:unitToPointsConversionFactor:stepUpCycle:stepDownCycle:))]
        #[unsafe(method_family = none)]
        pub fn registerUnitWithName_abbreviation_unitToPointsConversionFactor_stepUpCycle_stepDownCycle(
            unit_name: &NSRulerViewUnitName,
            abbreviation: &NSString,
            conversion_factor: CGFloat,
            step_up_cycle: &NSArray<NSNumber>,
            step_down_cycle: &NSArray<NSNumber>,
            mtm: MainThreadMarker,
        );

        /// ************************** Initialization ***************************
        ///
        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;

        #[cfg(feature = "NSScrollView")]
        #[unsafe(method(initWithScrollView:orientation:))]
        #[unsafe(method_family = init)]
        pub fn initWithScrollView_orientation(
            this: Allocated<Self>,
            scroll_view: Option<&NSScrollView>,
            orientation: NSRulerOrientation,
        ) -> Retained<Self>;

        #[cfg(feature = "NSScrollView")]
        /// ************************** Basic setup ***************************
        #[unsafe(method(scrollView))]
        #[unsafe(method_family = none)]
        pub fn scrollView(&self) -> Option<Retained<NSScrollView>>;

        #[cfg(feature = "NSScrollView")]
        /// Setter for [`scrollView`][Self::scrollView].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setScrollView:))]
        #[unsafe(method_family = none)]
        pub fn setScrollView(&self, scroll_view: Option<&NSScrollView>);

        #[unsafe(method(orientation))]
        #[unsafe(method_family = none)]
        pub fn orientation(&self) -> NSRulerOrientation;

        /// Setter for [`orientation`][Self::orientation].
        #[unsafe(method(setOrientation:))]
        #[unsafe(method_family = none)]
        pub fn setOrientation(&self, orientation: NSRulerOrientation);

        #[cfg(feature = "objc2-core-foundation")]
        /// ************************** Ruler geometry ***************************
        #[unsafe(method(baselineLocation))]
        #[unsafe(method_family = none)]
        pub fn baselineLocation(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(requiredThickness))]
        #[unsafe(method_family = none)]
        pub fn requiredThickness(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(ruleThickness))]
        #[unsafe(method_family = none)]
        pub fn ruleThickness(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`ruleThickness`][Self::ruleThickness].
        #[unsafe(method(setRuleThickness:))]
        #[unsafe(method_family = none)]
        pub fn setRuleThickness(&self, rule_thickness: CGFloat);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(reservedThicknessForMarkers))]
        #[unsafe(method_family = none)]
        pub fn reservedThicknessForMarkers(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`reservedThicknessForMarkers`][Self::reservedThicknessForMarkers].
        #[unsafe(method(setReservedThicknessForMarkers:))]
        #[unsafe(method_family = none)]
        pub fn setReservedThicknessForMarkers(&self, reserved_thickness_for_markers: CGFloat);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(reservedThicknessForAccessoryView))]
        #[unsafe(method_family = none)]
        pub fn reservedThicknessForAccessoryView(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`reservedThicknessForAccessoryView`][Self::reservedThicknessForAccessoryView].
        #[unsafe(method(setReservedThicknessForAccessoryView:))]
        #[unsafe(method_family = none)]
        pub fn setReservedThicknessForAccessoryView(
            &self,
            reserved_thickness_for_accessory_view: CGFloat,
        );

        /// ************************** Rule configuration ***************************
        #[unsafe(method(measurementUnits))]
        #[unsafe(method_family = none)]
        pub fn measurementUnits(&self) -> Retained<NSRulerViewUnitName>;

        /// Setter for [`measurementUnits`][Self::measurementUnits].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setMeasurementUnits:))]
        #[unsafe(method_family = none)]
        pub fn setMeasurementUnits(&self, measurement_units: &NSRulerViewUnitName);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(originOffset))]
        #[unsafe(method_family = none)]
        pub fn originOffset(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`originOffset`][Self::originOffset].
        #[unsafe(method(setOriginOffset:))]
        #[unsafe(method_family = none)]
        pub fn setOriginOffset(&self, origin_offset: CGFloat);

        /// ************************** Client view setup ***************************
        #[unsafe(method(clientView))]
        #[unsafe(method_family = none)]
        pub fn clientView(&self) -> Option<Retained<NSView>>;

        /// Setter for [`clientView`][Self::clientView].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setClientView:))]
        #[unsafe(method_family = none)]
        pub fn setClientView(&self, client_view: Option<&NSView>);

        #[cfg(feature = "NSRulerMarker")]
        #[unsafe(method(addMarker:))]
        #[unsafe(method_family = none)]
        pub fn addMarker(&self, marker: &NSRulerMarker);

        #[cfg(feature = "NSRulerMarker")]
        #[unsafe(method(removeMarker:))]
        #[unsafe(method_family = none)]
        pub fn removeMarker(&self, marker: &NSRulerMarker);

        #[cfg(feature = "NSRulerMarker")]
        #[unsafe(method(markers))]
        #[unsafe(method_family = none)]
        pub fn markers(&self) -> Option<Retained<NSArray<NSRulerMarker>>>;

        #[cfg(feature = "NSRulerMarker")]
        /// Setter for [`markers`][Self::markers].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setMarkers:))]
        #[unsafe(method_family = none)]
        pub fn setMarkers(&self, markers: Option<&NSArray<NSRulerMarker>>);

        #[cfg(all(feature = "NSEvent", feature = "NSRulerMarker"))]
        #[unsafe(method(trackMarker:withMouseEvent:))]
        #[unsafe(method_family = none)]
        pub fn trackMarker_withMouseEvent(&self, marker: &NSRulerMarker, event: &NSEvent) -> bool;

        #[unsafe(method(accessoryView))]
        #[unsafe(method_family = none)]
        pub fn accessoryView(&self) -> Option<Retained<NSView>>;

        /// Setter for [`accessoryView`][Self::accessoryView].
        #[unsafe(method(setAccessoryView:))]
        #[unsafe(method_family = none)]
        pub fn setAccessoryView(&self, accessory_view: Option<&NSView>);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(moveRulerlineFromLocation:toLocation:))]
        #[unsafe(method_family = none)]
        pub fn moveRulerlineFromLocation_toLocation(
            &self,
            old_location: CGFloat,
            new_location: CGFloat,
        );

        /// ********************* Drawing and hash invalidation **********************
        #[unsafe(method(invalidateHashMarks))]
        #[unsafe(method_family = none)]
        pub fn invalidateHashMarks(&self);

        #[unsafe(method(drawHashMarksAndLabelsInRect:))]
        #[unsafe(method_family = none)]
        pub fn drawHashMarksAndLabelsInRect(&self, rect: NSRect);

        #[unsafe(method(drawMarkersInRect:))]
        #[unsafe(method_family = none)]
        pub fn drawMarkersInRect(&self, rect: NSRect);

        /// ************************** Key overrides ***************************
        #[unsafe(method(isFlipped))]
        #[unsafe(method_family = none)]
        pub fn isFlipped(&self) -> bool;
    );
}

/// Methods declared on superclass `NSView`.
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
impl NSRulerView {
    extern_methods!(
        #[unsafe(method(initWithFrame:))]
        #[unsafe(method_family = init)]
        pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSResponder`.
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
impl NSRulerView {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
impl NSRulerView {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

/// NSRulerMarkerClientViewDelegation.
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
impl NSView {
    extern_methods!(
        #[cfg(feature = "NSRulerMarker")]
        #[unsafe(method(rulerView:shouldMoveMarker:))]
        #[unsafe(method_family = none)]
        pub fn rulerView_shouldMoveMarker(
            &self,
            ruler: &NSRulerView,
            marker: &NSRulerMarker,
        ) -> bool;

        #[cfg(all(feature = "NSRulerMarker", feature = "objc2-core-foundation"))]
        #[unsafe(method(rulerView:willMoveMarker:toLocation:))]
        #[unsafe(method_family = none)]
        pub fn rulerView_willMoveMarker_toLocation(
            &self,
            ruler: &NSRulerView,
            marker: &NSRulerMarker,
            location: CGFloat,
        ) -> CGFloat;

        #[cfg(feature = "NSRulerMarker")]
        #[unsafe(method(rulerView:didMoveMarker:))]
        #[unsafe(method_family = none)]
        pub fn rulerView_didMoveMarker(&self, ruler: &NSRulerView, marker: &NSRulerMarker);

        #[cfg(feature = "NSRulerMarker")]
        #[unsafe(method(rulerView:shouldRemoveMarker:))]
        #[unsafe(method_family = none)]
        pub fn rulerView_shouldRemoveMarker(
            &self,
            ruler: &NSRulerView,
            marker: &NSRulerMarker,
        ) -> bool;

        #[cfg(feature = "NSRulerMarker")]
        #[unsafe(method(rulerView:didRemoveMarker:))]
        #[unsafe(method_family = none)]
        pub fn rulerView_didRemoveMarker(&self, ruler: &NSRulerView, marker: &NSRulerMarker);

        #[cfg(feature = "NSRulerMarker")]
        #[unsafe(method(rulerView:shouldAddMarker:))]
        #[unsafe(method_family = none)]
        pub fn rulerView_shouldAddMarker(
            &self,
            ruler: &NSRulerView,
            marker: &NSRulerMarker,
        ) -> bool;

        #[cfg(all(feature = "NSRulerMarker", feature = "objc2-core-foundation"))]
        #[unsafe(method(rulerView:willAddMarker:atLocation:))]
        #[unsafe(method_family = none)]
        pub fn rulerView_willAddMarker_atLocation(
            &self,
            ruler: &NSRulerView,
            marker: &NSRulerMarker,
            location: CGFloat,
        ) -> CGFloat;

        #[cfg(feature = "NSRulerMarker")]
        #[unsafe(method(rulerView:didAddMarker:))]
        #[unsafe(method_family = none)]
        pub fn rulerView_didAddMarker(&self, ruler: &NSRulerView, marker: &NSRulerMarker);

        #[cfg(feature = "NSEvent")]
        #[unsafe(method(rulerView:handleMouseDown:))]
        #[unsafe(method_family = none)]
        pub fn rulerView_handleMouseDown(&self, ruler: &NSRulerView, event: &NSEvent);

        #[unsafe(method(rulerView:willSetClientView:))]
        #[unsafe(method_family = none)]
        pub fn rulerView_willSetClientView(&self, ruler: &NSRulerView, new_client: &NSView);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(rulerView:locationForPoint:))]
        #[unsafe(method_family = none)]
        pub fn rulerView_locationForPoint(&self, ruler: &NSRulerView, point: NSPoint) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(rulerView:pointForLocation:))]
        #[unsafe(method_family = none)]
        pub fn rulerView_pointForLocation(&self, ruler: &NSRulerView, point: CGFloat) -> NSPoint;
    );
}