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 NSUsableScrollerParts(pub NSUInteger);
17impl NSUsableScrollerParts {
18 #[doc(alias = "NSNoScrollerParts")]
19 pub const NoScrollerParts: Self = Self(0);
20 #[doc(alias = "NSOnlyScrollerArrows")]
21 #[deprecated = "Scroller arrows are not used anymore."]
22 pub const OnlyScrollerArrows: Self = Self(1);
23 #[doc(alias = "NSAllScrollerParts")]
24 pub const AllScrollerParts: Self = Self(2);
25}
26
27unsafe impl Encode for NSUsableScrollerParts {
28 const ENCODING: Encoding = NSUInteger::ENCODING;
29}
30
31unsafe impl RefEncode for NSUsableScrollerParts {
32 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
33}
34
35#[repr(transparent)]
38#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
39pub struct NSScrollerPart(pub NSUInteger);
40impl NSScrollerPart {
41 #[doc(alias = "NSScrollerNoPart")]
42 pub const NoPart: Self = Self(0);
43 #[doc(alias = "NSScrollerDecrementPage")]
44 pub const DecrementPage: Self = Self(1);
45 #[doc(alias = "NSScrollerKnob")]
46 pub const Knob: Self = Self(2);
47 #[doc(alias = "NSScrollerIncrementPage")]
48 pub const IncrementPage: Self = Self(3);
49 #[doc(alias = "NSScrollerDecrementLine")]
50 #[deprecated = "Scroller arrows are not used anymore."]
51 pub const DecrementLine: Self = Self(4);
52 #[doc(alias = "NSScrollerIncrementLine")]
53 #[deprecated = "Scroller arrows are not used anymore."]
54 pub const IncrementLine: Self = Self(5);
55 #[doc(alias = "NSScrollerKnobSlot")]
56 pub const KnobSlot: Self = Self(6);
57}
58
59unsafe impl Encode for NSScrollerPart {
60 const ENCODING: Encoding = NSUInteger::ENCODING;
61}
62
63unsafe impl RefEncode for NSScrollerPart {
64 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
65}
66
67#[repr(transparent)]
70#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
71pub struct NSScrollerStyle(pub NSInteger);
72impl NSScrollerStyle {
73 #[doc(alias = "NSScrollerStyleLegacy")]
74 pub const Legacy: Self = Self(0);
75 #[doc(alias = "NSScrollerStyleOverlay")]
76 pub const Overlay: Self = Self(1);
77}
78
79unsafe impl Encode for NSScrollerStyle {
80 const ENCODING: Encoding = NSInteger::ENCODING;
81}
82
83unsafe impl RefEncode for NSScrollerStyle {
84 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
85}
86
87#[repr(transparent)]
90#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
91pub struct NSScrollerKnobStyle(pub NSInteger);
92impl NSScrollerKnobStyle {
93 #[doc(alias = "NSScrollerKnobStyleDefault")]
94 pub const Default: Self = Self(0);
95 #[doc(alias = "NSScrollerKnobStyleDark")]
96 pub const Dark: Self = Self(1);
97 #[doc(alias = "NSScrollerKnobStyleLight")]
98 pub const Light: Self = Self(2);
99}
100
101unsafe impl Encode for NSScrollerKnobStyle {
102 const ENCODING: Encoding = NSInteger::ENCODING;
103}
104
105unsafe impl RefEncode for NSScrollerKnobStyle {
106 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
107}
108
109extern_class!(
110 #[unsafe(super(NSControl, NSView, NSResponder, NSObject))]
112 #[derive(Debug, PartialEq, Eq, Hash)]
113 #[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
114 pub struct NSScroller;
115);
116
117#[cfg(all(
118 feature = "NSAccessibilityProtocols",
119 feature = "NSControl",
120 feature = "NSResponder",
121 feature = "NSView"
122))]
123extern_conformance!(
124 unsafe impl NSAccessibility for NSScroller {}
125);
126
127#[cfg(all(
128 feature = "NSAccessibilityProtocols",
129 feature = "NSControl",
130 feature = "NSResponder",
131 feature = "NSView"
132))]
133extern_conformance!(
134 unsafe impl NSAccessibilityElementProtocol for NSScroller {}
135);
136
137#[cfg(all(
138 feature = "NSAnimation",
139 feature = "NSControl",
140 feature = "NSResponder",
141 feature = "NSView"
142))]
143extern_conformance!(
144 unsafe impl NSAnimatablePropertyContainer for NSScroller {}
145);
146
147#[cfg(all(
148 feature = "NSAppearance",
149 feature = "NSControl",
150 feature = "NSResponder",
151 feature = "NSView"
152))]
153extern_conformance!(
154 unsafe impl NSAppearanceCustomization for NSScroller {}
155);
156
157#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
158extern_conformance!(
159 unsafe impl NSCoding for NSScroller {}
160);
161
162#[cfg(all(
163 feature = "NSControl",
164 feature = "NSDragging",
165 feature = "NSResponder",
166 feature = "NSView"
167))]
168extern_conformance!(
169 unsafe impl NSDraggingDestination for NSScroller {}
170);
171
172#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
173extern_conformance!(
174 unsafe impl NSObjectProtocol for NSScroller {}
175);
176
177#[cfg(all(
178 feature = "NSControl",
179 feature = "NSResponder",
180 feature = "NSUserInterfaceItemIdentification",
181 feature = "NSView"
182))]
183extern_conformance!(
184 unsafe impl NSUserInterfaceItemIdentification for NSScroller {}
185);
186
187#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
188impl NSScroller {
189 extern_methods!(
190 #[unsafe(method(isCompatibleWithOverlayScrollers))]
191 #[unsafe(method_family = none)]
192 pub unsafe fn isCompatibleWithOverlayScrollers(mtm: MainThreadMarker) -> bool;
193
194 #[cfg(all(feature = "NSCell", feature = "objc2-core-foundation"))]
195 #[unsafe(method(scrollerWidthForControlSize:scrollerStyle:))]
196 #[unsafe(method_family = none)]
197 pub unsafe fn scrollerWidthForControlSize_scrollerStyle(
198 control_size: NSControlSize,
199 scroller_style: NSScrollerStyle,
200 mtm: MainThreadMarker,
201 ) -> CGFloat;
202
203 #[unsafe(method(preferredScrollerStyle))]
204 #[unsafe(method_family = none)]
205 pub unsafe fn preferredScrollerStyle(mtm: MainThreadMarker) -> NSScrollerStyle;
206
207 #[unsafe(method(scrollerStyle))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn scrollerStyle(&self) -> NSScrollerStyle;
210
211 #[unsafe(method(setScrollerStyle:))]
213 #[unsafe(method_family = none)]
214 pub unsafe fn setScrollerStyle(&self, scroller_style: NSScrollerStyle);
215
216 #[unsafe(method(knobStyle))]
217 #[unsafe(method_family = none)]
218 pub unsafe fn knobStyle(&self) -> NSScrollerKnobStyle;
219
220 #[unsafe(method(setKnobStyle:))]
222 #[unsafe(method_family = none)]
223 pub unsafe fn setKnobStyle(&self, knob_style: NSScrollerKnobStyle);
224
225 #[unsafe(method(rectForPart:))]
226 #[unsafe(method_family = none)]
227 pub unsafe fn rectForPart(&self, part_code: NSScrollerPart) -> NSRect;
228
229 #[unsafe(method(checkSpaceForParts))]
230 #[unsafe(method_family = none)]
231 pub unsafe fn checkSpaceForParts(&self);
232
233 #[unsafe(method(usableParts))]
234 #[unsafe(method_family = none)]
235 pub unsafe fn usableParts(&self) -> NSUsableScrollerParts;
236
237 #[cfg(feature = "NSCell")]
238 #[unsafe(method(controlSize))]
239 #[unsafe(method_family = none)]
240 pub unsafe fn controlSize(&self) -> NSControlSize;
241
242 #[cfg(feature = "NSCell")]
243 #[unsafe(method(setControlSize:))]
245 #[unsafe(method_family = none)]
246 pub unsafe fn setControlSize(&self, control_size: NSControlSize);
247
248 #[unsafe(method(drawKnob))]
249 #[unsafe(method_family = none)]
250 pub unsafe fn drawKnob(&self);
251
252 #[unsafe(method(drawKnobSlotInRect:highlight:))]
253 #[unsafe(method_family = none)]
254 pub unsafe fn drawKnobSlotInRect_highlight(&self, slot_rect: NSRect, flag: bool);
255
256 #[unsafe(method(testPart:))]
257 #[unsafe(method_family = none)]
258 pub unsafe fn testPart(&self, point: NSPoint) -> NSScrollerPart;
259
260 #[cfg(feature = "NSEvent")]
261 #[unsafe(method(trackKnob:))]
262 #[unsafe(method_family = none)]
263 pub unsafe fn trackKnob(&self, event: &NSEvent);
264
265 #[unsafe(method(hitPart))]
266 #[unsafe(method_family = none)]
267 pub unsafe fn hitPart(&self) -> NSScrollerPart;
268
269 #[cfg(feature = "objc2-core-foundation")]
270 #[unsafe(method(knobProportion))]
271 #[unsafe(method_family = none)]
272 pub unsafe fn knobProportion(&self) -> CGFloat;
273
274 #[cfg(feature = "objc2-core-foundation")]
275 #[unsafe(method(setKnobProportion:))]
277 #[unsafe(method_family = none)]
278 pub unsafe fn setKnobProportion(&self, knob_proportion: CGFloat);
279 );
280}
281
282#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
284impl NSScroller {
285 extern_methods!(
286 #[unsafe(method(initWithFrame:))]
287 #[unsafe(method_family = init)]
288 pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
289
290 #[unsafe(method(initWithCoder:))]
291 #[unsafe(method_family = init)]
292 pub unsafe fn initWithCoder(
293 this: Allocated<Self>,
294 coder: &NSCoder,
295 ) -> Option<Retained<Self>>;
296 );
297}
298
299#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
301impl NSScroller {
302 extern_methods!(
303 #[unsafe(method(init))]
304 #[unsafe(method_family = init)]
305 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
306 );
307}
308
309#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
311impl NSScroller {
312 extern_methods!(
313 #[unsafe(method(new))]
314 #[unsafe(method_family = new)]
315 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
316 );
317}
318
319extern "C" {
320 pub static NSPreferredScrollerStyleDidChangeNotification: &'static NSNotificationName;
322}
323
324#[deprecated = "Scroller arrows are not used anymore."]
327#[repr(transparent)]
328#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
329pub struct NSScrollArrowPosition(pub NSUInteger);
330impl NSScrollArrowPosition {
331 #[doc(alias = "NSScrollerArrowsMaxEnd")]
332 pub const ScrollerArrowsMaxEnd: Self = Self(0);
333 #[doc(alias = "NSScrollerArrowsMinEnd")]
334 pub const ScrollerArrowsMinEnd: Self = Self(1);
335 #[doc(alias = "NSScrollerArrowsDefaultSetting")]
336 pub const ScrollerArrowsDefaultSetting: Self = Self(0);
337 #[doc(alias = "NSScrollerArrowsNone")]
338 pub const ScrollerArrowsNone: Self = Self(2);
339}
340
341unsafe impl Encode for NSScrollArrowPosition {
342 const ENCODING: Encoding = NSUInteger::ENCODING;
343}
344
345unsafe impl RefEncode for NSScrollArrowPosition {
346 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
347}
348
349#[deprecated = "Scroller arrows are not used anymore."]
352#[repr(transparent)]
353#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
354pub struct NSScrollerArrow(pub NSUInteger);
355impl NSScrollerArrow {
356 #[doc(alias = "NSScrollerIncrementArrow")]
357 pub const IncrementArrow: Self = Self(0);
358 #[doc(alias = "NSScrollerDecrementArrow")]
359 pub const DecrementArrow: Self = Self(1);
360}
361
362unsafe impl Encode for NSScrollerArrow {
363 const ENCODING: Encoding = NSUInteger::ENCODING;
364}
365
366unsafe impl RefEncode for NSScrollerArrow {
367 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
368}
369
370#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
372impl NSScroller {
373 extern_methods!(
374 #[cfg(all(feature = "NSCell", feature = "objc2-core-foundation"))]
375 #[deprecated = "Use +scrollerWidthForControlSize:scrollerStyle: instead"]
376 #[unsafe(method(scrollerWidthForControlSize:))]
377 #[unsafe(method_family = none)]
378 pub unsafe fn scrollerWidthForControlSize(
379 control_size: NSControlSize,
380 mtm: MainThreadMarker,
381 ) -> CGFloat;
382
383 #[cfg(feature = "objc2-core-foundation")]
384 #[deprecated = "Use +scrollerWidthForControlSize:scrollerStyle: instead"]
385 #[unsafe(method(scrollerWidth))]
386 #[unsafe(method_family = none)]
387 pub unsafe fn scrollerWidth(mtm: MainThreadMarker) -> CGFloat;
388
389 #[cfg(feature = "objc2-core-foundation")]
390 #[deprecated]
391 #[unsafe(method(setFloatValue:knobProportion:))]
392 #[unsafe(method_family = none)]
393 pub unsafe fn setFloatValue_knobProportion(&self, value: c_float, proportion: CGFloat);
394
395 #[deprecated = "Has had no effect since 10.7"]
396 #[unsafe(method(arrowsPosition))]
397 #[unsafe(method_family = none)]
398 pub unsafe fn arrowsPosition(&self) -> NSScrollArrowPosition;
399
400 #[deprecated = "Has had no effect since 10.7"]
402 #[unsafe(method(setArrowsPosition:))]
403 #[unsafe(method_family = none)]
404 pub unsafe fn setArrowsPosition(&self, arrows_position: NSScrollArrowPosition);
405
406 #[cfg(feature = "NSCell")]
407 #[deprecated = "Has had no effect since 10.7"]
408 #[unsafe(method(controlTint))]
409 #[unsafe(method_family = none)]
410 pub unsafe fn controlTint(&self) -> NSControlTint;
411
412 #[cfg(feature = "NSCell")]
413 #[deprecated = "Has had no effect since 10.7"]
415 #[unsafe(method(setControlTint:))]
416 #[unsafe(method_family = none)]
417 pub unsafe fn setControlTint(&self, control_tint: NSControlTint);
418
419 #[deprecated = "Has had no effect since 10.7"]
420 #[unsafe(method(highlight:))]
421 #[unsafe(method_family = none)]
422 pub unsafe fn highlight(&self, flag: bool);
423
424 #[cfg(feature = "NSEvent")]
425 #[deprecated = "Not invoked since 10.7"]
426 #[unsafe(method(trackScrollButtons:))]
427 #[unsafe(method_family = none)]
428 pub unsafe fn trackScrollButtons(&self, event: &NSEvent);
429
430 #[deprecated = "Not invoked on any macOS version"]
431 #[unsafe(method(drawParts))]
432 #[unsafe(method_family = none)]
433 pub unsafe fn drawParts(&self);
434
435 #[deprecated = "Scrollers don't have arrows as of 10.7"]
436 #[unsafe(method(drawArrow:highlight:))]
437 #[unsafe(method_family = none)]
438 pub unsafe fn drawArrow_highlight(&self, which_arrow: NSScrollerArrow, flag: bool);
439 );
440}