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
//! 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::*;

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

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

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

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

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

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

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

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

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

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

#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSSlider {
    extern_methods!(
        #[cfg(feature = "NSSliderCell")]
        #[unsafe(method(sliderType))]
        #[unsafe(method_family = none)]
        pub fn sliderType(&self) -> NSSliderType;

        #[cfg(feature = "NSSliderCell")]
        /// Setter for [`sliderType`][Self::sliderType].
        #[unsafe(method(setSliderType:))]
        #[unsafe(method_family = none)]
        pub fn setSliderType(&self, slider_type: NSSliderType);

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

        /// Setter for [`minValue`][Self::minValue].
        #[unsafe(method(setMinValue:))]
        #[unsafe(method_family = none)]
        pub fn setMinValue(&self, min_value: c_double);

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

        /// Setter for [`maxValue`][Self::maxValue].
        #[unsafe(method(setMaxValue:))]
        #[unsafe(method_family = none)]
        pub fn setMaxValue(&self, max_value: c_double);

        /// The value this slider will be filled from. This slider will be filled from its `neutralValue` to its current value. If `neutralValue` has not been explicitly set before, access to `neutralValue` will return `minValue`.
        #[unsafe(method(neutralValue))]
        #[unsafe(method_family = none)]
        pub fn neutralValue(&self) -> c_double;

        /// Setter for [`neutralValue`][Self::neutralValue].
        #[unsafe(method(setNeutralValue:))]
        #[unsafe(method_family = none)]
        pub fn setNeutralValue(&self, neutral_value: c_double);

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

        /// Setter for [`altIncrementValue`][Self::altIncrementValue].
        #[unsafe(method(setAltIncrementValue:))]
        #[unsafe(method_family = none)]
        pub fn setAltIncrementValue(&self, alt_increment_value: c_double);

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

        #[cfg(feature = "NSEvent")]
        #[unsafe(method(acceptsFirstMouse:))]
        #[unsafe(method_family = none)]
        pub fn acceptsFirstMouse(&self, event: Option<&NSEvent>) -> bool;

        /// Setter for [`isVertical`][Self::isVertical].
        #[unsafe(method(setVertical:))]
        #[unsafe(method_family = none)]
        pub fn setVertical(&self, vertical: bool);

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

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

        #[cfg(feature = "NSTintProminence")]
        /// The tint prominence of the slider. The automatic behavior for a regular slider tints its track fill, while a slider with tick marks is untinted. Setting the tint prominence will override this default behavior and choose an explicit track fill tint behavior. See ``NSTintProminence`` for a list of possible values.
        #[unsafe(method(tintProminence))]
        #[unsafe(method_family = none)]
        pub fn tintProminence(&self) -> NSTintProminence;

        #[cfg(feature = "NSTintProminence")]
        /// Setter for [`tintProminence`][Self::tintProminence].
        #[unsafe(method(setTintProminence:))]
        #[unsafe(method_family = none)]
        pub fn setTintProminence(&self, tint_prominence: NSTintProminence);
    );
}

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

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

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

/// NSSliderVerticalGetter.
#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSSlider {
    extern_methods!();
}

/// NSTickMarkSupport.
#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSSlider {
    extern_methods!(
        #[unsafe(method(numberOfTickMarks))]
        #[unsafe(method_family = none)]
        pub fn numberOfTickMarks(&self) -> NSInteger;

        /// Setter for [`numberOfTickMarks`][Self::numberOfTickMarks].
        #[unsafe(method(setNumberOfTickMarks:))]
        #[unsafe(method_family = none)]
        pub fn setNumberOfTickMarks(&self, number_of_tick_marks: NSInteger);

        #[cfg(feature = "NSSliderCell")]
        #[unsafe(method(tickMarkPosition))]
        #[unsafe(method_family = none)]
        pub fn tickMarkPosition(&self) -> NSTickMarkPosition;

        #[cfg(feature = "NSSliderCell")]
        /// Setter for [`tickMarkPosition`][Self::tickMarkPosition].
        #[unsafe(method(setTickMarkPosition:))]
        #[unsafe(method_family = none)]
        pub fn setTickMarkPosition(&self, tick_mark_position: NSTickMarkPosition);

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

        /// Setter for [`allowsTickMarkValuesOnly`][Self::allowsTickMarkValuesOnly].
        #[unsafe(method(setAllowsTickMarkValuesOnly:))]
        #[unsafe(method_family = none)]
        pub fn setAllowsTickMarkValuesOnly(&self, allows_tick_mark_values_only: bool);

        #[unsafe(method(tickMarkValueAtIndex:))]
        #[unsafe(method_family = none)]
        pub fn tickMarkValueAtIndex(&self, index: NSInteger) -> c_double;

        #[unsafe(method(rectOfTickMarkAtIndex:))]
        #[unsafe(method_family = none)]
        pub fn rectOfTickMarkAtIndex(&self, index: NSInteger) -> NSRect;

        #[unsafe(method(indexOfTickMarkAtPoint:))]
        #[unsafe(method_family = none)]
        pub fn indexOfTickMarkAtPoint(&self, point: NSPoint) -> NSInteger;

        #[unsafe(method(closestTickMarkValueToValue:))]
        #[unsafe(method_family = none)]
        pub fn closestTickMarkValueToValue(&self, value: c_double) -> c_double;
    );
}

/// NSSliderConvenience.
#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSSlider {
    extern_methods!(
        /// Creates a continuous horizontal slider over the range 0.0 to 1.0. The default value is 0.0.
        ///
        /// Parameter `target`: The target object that receives action messages from the control.
        ///
        /// Parameter `action`: The action message sent by the control.
        ///
        /// Returns: An initialized slider control.
        ///
        /// # Safety
        ///
        /// - `target` should be of the correct type.
        /// - `action` must be a valid selector.
        #[unsafe(method(sliderWithTarget:action:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sliderWithTarget_action(
            target: Option<&AnyObject>,
            action: Option<Sel>,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        /// Creates a continuous horizontal slider that represents values over a specified range.
        ///
        /// Parameter `value`: The initial value displayed by the control.
        ///
        /// Parameter `minValue`: The minimum value represented by the control.
        ///
        /// Parameter `maxValue`: The maximum value represented by the control.
        ///
        /// Parameter `target`: The target object that receives action messages from the control.
        ///
        /// Parameter `action`: The action message sent by the control.
        ///
        /// Returns: An initialized slider control.
        ///
        /// # Safety
        ///
        /// - `target` should be of the correct type.
        /// - `action` must be a valid selector.
        #[unsafe(method(sliderWithValue:minValue:maxValue:target:action:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sliderWithValue_minValue_maxValue_target_action(
            value: c_double,
            min_value: c_double,
            max_value: c_double,
            target: Option<&AnyObject>,
            action: Option<Sel>,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;
    );
}

/// NSSliderDeprecated.
#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
impl NSSlider {
    extern_methods!(
        #[cfg(feature = "NSCell")]
        /// # Safety
        ///
        /// `cell` might not allow `None`.
        #[deprecated = "-setTitleCell: had no effect since 10.0"]
        #[unsafe(method(setTitleCell:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTitleCell(&self, cell: Option<&NSCell>);

        #[deprecated = "-titleCell has returned nil since 10.0"]
        #[unsafe(method(titleCell))]
        #[unsafe(method_family = none)]
        pub fn titleCell(&self) -> Option<Retained<AnyObject>>;

        #[cfg(feature = "NSColor")]
        /// # Safety
        ///
        /// `new_color` might not allow `None`.
        #[deprecated = "-setTitleColor: had no effect since 10.0"]
        #[unsafe(method(setTitleColor:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTitleColor(&self, new_color: Option<&NSColor>);

        #[cfg(feature = "NSColor")]
        #[deprecated = "-titleColor has returned nil since 10.0"]
        #[unsafe(method(titleColor))]
        #[unsafe(method_family = none)]
        pub fn titleColor(&self) -> Option<Retained<NSColor>>;

        #[cfg(feature = "NSFont")]
        /// # Safety
        ///
        /// `font_obj` might not allow `None`.
        #[deprecated = "-setTitleFont: had no effect since 10.0"]
        #[unsafe(method(setTitleFont:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTitleFont(&self, font_obj: Option<&NSFont>);

        #[cfg(feature = "NSFont")]
        #[deprecated = "-titleFont has returned nil since 10.0"]
        #[unsafe(method(titleFont))]
        #[unsafe(method_family = none)]
        pub fn titleFont(&self) -> Option<Retained<NSFont>>;

        #[deprecated = "-title has returned nil since 10.0"]
        #[unsafe(method(title))]
        #[unsafe(method_family = none)]
        pub fn title(&self) -> Option<Retained<NSString>>;

        /// # Safety
        ///
        /// `string` might not allow `None`.
        #[deprecated = "-setTitle: had no effect since 10.0"]
        #[unsafe(method(setTitle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTitle(&self, string: Option<&NSString>);

        #[cfg(feature = "objc2-core-foundation")]
        #[deprecated = "-knobThickness has returned 0 since 10.0"]
        #[unsafe(method(setKnobThickness:))]
        #[unsafe(method_family = none)]
        pub fn setKnobThickness(&self, thickness: CGFloat);

        #[cfg(feature = "NSImage")]
        /// # Safety
        ///
        /// `background_image` might not allow `None`.
        #[deprecated = "-setImage: had no effect since 10.0"]
        #[unsafe(method(setImage:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setImage(&self, background_image: Option<&NSImage>);

        #[cfg(feature = "NSImage")]
        #[deprecated = "-image has returned nil since 10.0"]
        #[unsafe(method(image))]
        #[unsafe(method_family = none)]
        pub fn image(&self) -> Option<Retained<NSImage>>;
    );
}