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 NSSegmentSwitchTracking(pub NSUInteger);
17impl NSSegmentSwitchTracking {
18 #[doc(alias = "NSSegmentSwitchTrackingSelectOne")]
19 pub const SelectOne: Self = Self(0);
20 #[doc(alias = "NSSegmentSwitchTrackingSelectAny")]
21 pub const SelectAny: Self = Self(1);
22 #[doc(alias = "NSSegmentSwitchTrackingMomentary")]
23 pub const Momentary: Self = Self(2);
24 #[doc(alias = "NSSegmentSwitchTrackingMomentaryAccelerator")]
25 pub const MomentaryAccelerator: Self = Self(3);
26}
27
28unsafe impl Encode for NSSegmentSwitchTracking {
29 const ENCODING: Encoding = NSUInteger::ENCODING;
30}
31
32unsafe impl RefEncode for NSSegmentSwitchTracking {
33 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36#[repr(transparent)]
39#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
40pub struct NSSegmentStyle(pub NSInteger);
41impl NSSegmentStyle {
42 #[doc(alias = "NSSegmentStyleAutomatic")]
43 pub const Automatic: Self = Self(0);
44 #[doc(alias = "NSSegmentStyleRounded")]
45 pub const Rounded: Self = Self(1);
46 #[doc(alias = "NSSegmentStyleRoundRect")]
47 pub const RoundRect: Self = Self(3);
48 #[doc(alias = "NSSegmentStyleTexturedSquare")]
49 pub const TexturedSquare: Self = Self(4);
50 #[doc(alias = "NSSegmentStyleSmallSquare")]
51 pub const SmallSquare: Self = Self(6);
52 #[doc(alias = "NSSegmentStyleSeparated")]
53 pub const Separated: Self = Self(8);
54 #[doc(alias = "NSSegmentStyleTexturedRounded")]
55 pub const TexturedRounded: Self = Self(2);
56 #[doc(alias = "NSSegmentStyleCapsule")]
57 pub const Capsule: Self = Self(5);
58}
59
60unsafe impl Encode for NSSegmentStyle {
61 const ENCODING: Encoding = NSInteger::ENCODING;
62}
63
64unsafe impl RefEncode for NSSegmentStyle {
65 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
66}
67
68#[repr(transparent)]
71#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
72pub struct NSSegmentDistribution(pub NSInteger);
73impl NSSegmentDistribution {
74 #[doc(alias = "NSSegmentDistributionFit")]
76 pub const Fit: Self = Self(0);
77 #[doc(alias = "NSSegmentDistributionFill")]
79 pub const Fill: Self = Self(1);
80 #[doc(alias = "NSSegmentDistributionFillEqually")]
82 pub const FillEqually: Self = Self(2);
83 #[doc(alias = "NSSegmentDistributionFillProportionally")]
85 pub const FillProportionally: Self = Self(3);
86}
87
88unsafe impl Encode for NSSegmentDistribution {
89 const ENCODING: Encoding = NSInteger::ENCODING;
90}
91
92unsafe impl RefEncode for NSSegmentDistribution {
93 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
94}
95
96extern_class!(
97 #[unsafe(super(NSControl, NSView, NSResponder, NSObject))]
99 #[derive(Debug, PartialEq, Eq, Hash)]
100 #[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
101 pub struct NSSegmentedControl;
102);
103
104#[cfg(all(
105 feature = "NSAccessibilityProtocols",
106 feature = "NSControl",
107 feature = "NSResponder",
108 feature = "NSView"
109))]
110unsafe impl NSAccessibility for NSSegmentedControl {}
111
112#[cfg(all(
113 feature = "NSAccessibilityProtocols",
114 feature = "NSControl",
115 feature = "NSResponder",
116 feature = "NSView"
117))]
118unsafe impl NSAccessibilityElementProtocol for NSSegmentedControl {}
119
120#[cfg(all(
121 feature = "NSAnimation",
122 feature = "NSControl",
123 feature = "NSResponder",
124 feature = "NSView"
125))]
126unsafe impl NSAnimatablePropertyContainer for NSSegmentedControl {}
127
128#[cfg(all(
129 feature = "NSAppearance",
130 feature = "NSControl",
131 feature = "NSResponder",
132 feature = "NSView"
133))]
134unsafe impl NSAppearanceCustomization for NSSegmentedControl {}
135
136#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
137unsafe impl NSCoding for NSSegmentedControl {}
138
139#[cfg(all(
140 feature = "NSControl",
141 feature = "NSDragging",
142 feature = "NSResponder",
143 feature = "NSView"
144))]
145unsafe impl NSDraggingDestination for NSSegmentedControl {}
146
147#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
148unsafe impl NSObjectProtocol for NSSegmentedControl {}
149
150#[cfg(all(
151 feature = "NSControl",
152 feature = "NSResponder",
153 feature = "NSUserInterfaceCompression",
154 feature = "NSView"
155))]
156unsafe impl NSUserInterfaceCompression for NSSegmentedControl {}
157
158#[cfg(all(
159 feature = "NSControl",
160 feature = "NSResponder",
161 feature = "NSUserInterfaceItemIdentification",
162 feature = "NSView"
163))]
164unsafe impl NSUserInterfaceItemIdentification for NSSegmentedControl {}
165
166#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
167impl NSSegmentedControl {
168 extern_methods!(
169 #[unsafe(method(segmentCount))]
170 #[unsafe(method_family = none)]
171 pub unsafe fn segmentCount(&self) -> NSInteger;
172
173 #[unsafe(method(setSegmentCount:))]
175 #[unsafe(method_family = none)]
176 pub unsafe fn setSegmentCount(&self, segment_count: NSInteger);
177
178 #[unsafe(method(selectedSegment))]
179 #[unsafe(method_family = none)]
180 pub unsafe fn selectedSegment(&self) -> NSInteger;
181
182 #[unsafe(method(setSelectedSegment:))]
184 #[unsafe(method_family = none)]
185 pub unsafe fn setSelectedSegment(&self, selected_segment: NSInteger);
186
187 #[unsafe(method(selectSegmentWithTag:))]
188 #[unsafe(method_family = none)]
189 pub unsafe fn selectSegmentWithTag(&self, tag: NSInteger) -> bool;
190
191 #[cfg(feature = "objc2-core-foundation")]
192 #[unsafe(method(setWidth:forSegment:))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn setWidth_forSegment(&self, width: CGFloat, segment: NSInteger);
195
196 #[cfg(feature = "objc2-core-foundation")]
197 #[unsafe(method(widthForSegment:))]
198 #[unsafe(method_family = none)]
199 pub unsafe fn widthForSegment(&self, segment: NSInteger) -> CGFloat;
200
201 #[cfg(feature = "NSImage")]
202 #[unsafe(method(setImage:forSegment:))]
203 #[unsafe(method_family = none)]
204 pub unsafe fn setImage_forSegment(&self, image: Option<&NSImage>, segment: NSInteger);
205
206 #[cfg(feature = "NSImage")]
207 #[unsafe(method(imageForSegment:))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn imageForSegment(&self, segment: NSInteger) -> Option<Retained<NSImage>>;
210
211 #[cfg(feature = "NSCell")]
212 #[unsafe(method(setImageScaling:forSegment:))]
213 #[unsafe(method_family = none)]
214 pub unsafe fn setImageScaling_forSegment(
215 &self,
216 scaling: NSImageScaling,
217 segment: NSInteger,
218 );
219
220 #[cfg(feature = "NSCell")]
221 #[unsafe(method(imageScalingForSegment:))]
222 #[unsafe(method_family = none)]
223 pub unsafe fn imageScalingForSegment(&self, segment: NSInteger) -> NSImageScaling;
224
225 #[unsafe(method(setLabel:forSegment:))]
226 #[unsafe(method_family = none)]
227 pub unsafe fn setLabel_forSegment(&self, label: &NSString, segment: NSInteger);
228
229 #[unsafe(method(labelForSegment:))]
230 #[unsafe(method_family = none)]
231 pub unsafe fn labelForSegment(&self, segment: NSInteger) -> Option<Retained<NSString>>;
232
233 #[cfg(feature = "NSMenu")]
234 #[unsafe(method(setMenu:forSegment:))]
235 #[unsafe(method_family = none)]
236 pub unsafe fn setMenu_forSegment(&self, menu: Option<&NSMenu>, segment: NSInteger);
237
238 #[cfg(feature = "NSMenu")]
239 #[unsafe(method(menuForSegment:))]
240 #[unsafe(method_family = none)]
241 pub unsafe fn menuForSegment(&self, segment: NSInteger) -> Option<Retained<NSMenu>>;
242
243 #[unsafe(method(setSelected:forSegment:))]
244 #[unsafe(method_family = none)]
245 pub unsafe fn setSelected_forSegment(&self, selected: bool, segment: NSInteger);
246
247 #[unsafe(method(isSelectedForSegment:))]
248 #[unsafe(method_family = none)]
249 pub unsafe fn isSelectedForSegment(&self, segment: NSInteger) -> bool;
250
251 #[unsafe(method(setEnabled:forSegment:))]
252 #[unsafe(method_family = none)]
253 pub unsafe fn setEnabled_forSegment(&self, enabled: bool, segment: NSInteger);
254
255 #[unsafe(method(isEnabledForSegment:))]
256 #[unsafe(method_family = none)]
257 pub unsafe fn isEnabledForSegment(&self, segment: NSInteger) -> bool;
258
259 #[unsafe(method(setToolTip:forSegment:))]
260 #[unsafe(method_family = none)]
261 pub unsafe fn setToolTip_forSegment(&self, tool_tip: Option<&NSString>, segment: NSInteger);
262
263 #[unsafe(method(toolTipForSegment:))]
264 #[unsafe(method_family = none)]
265 pub unsafe fn toolTipForSegment(&self, segment: NSInteger) -> Option<Retained<NSString>>;
266
267 #[unsafe(method(setTag:forSegment:))]
268 #[unsafe(method_family = none)]
269 pub unsafe fn setTag_forSegment(&self, tag: NSInteger, segment: NSInteger);
270
271 #[unsafe(method(tagForSegment:))]
272 #[unsafe(method_family = none)]
273 pub unsafe fn tagForSegment(&self, segment: NSInteger) -> NSInteger;
274
275 #[unsafe(method(setShowsMenuIndicator:forSegment:))]
276 #[unsafe(method_family = none)]
277 pub unsafe fn setShowsMenuIndicator_forSegment(
278 &self,
279 shows_menu_indicator: bool,
280 segment: NSInteger,
281 );
282
283 #[unsafe(method(showsMenuIndicatorForSegment:))]
284 #[unsafe(method_family = none)]
285 pub unsafe fn showsMenuIndicatorForSegment(&self, segment: NSInteger) -> bool;
286
287 #[unsafe(method(segmentStyle))]
288 #[unsafe(method_family = none)]
289 pub unsafe fn segmentStyle(&self) -> NSSegmentStyle;
290
291 #[unsafe(method(setSegmentStyle:))]
293 #[unsafe(method_family = none)]
294 pub unsafe fn setSegmentStyle(&self, segment_style: NSSegmentStyle);
295
296 #[unsafe(method(isSpringLoaded))]
297 #[unsafe(method_family = none)]
298 pub unsafe fn isSpringLoaded(&self) -> bool;
299
300 #[unsafe(method(setSpringLoaded:))]
302 #[unsafe(method_family = none)]
303 pub unsafe fn setSpringLoaded(&self, spring_loaded: bool);
304
305 #[unsafe(method(trackingMode))]
306 #[unsafe(method_family = none)]
307 pub unsafe fn trackingMode(&self) -> NSSegmentSwitchTracking;
308
309 #[unsafe(method(setTrackingMode:))]
311 #[unsafe(method_family = none)]
312 pub unsafe fn setTrackingMode(&self, tracking_mode: NSSegmentSwitchTracking);
313
314 #[unsafe(method(doubleValueForSelectedSegment))]
315 #[unsafe(method_family = none)]
316 pub unsafe fn doubleValueForSelectedSegment(&self) -> c_double;
317
318 #[cfg(feature = "NSColor")]
319 #[unsafe(method(selectedSegmentBezelColor))]
320 #[unsafe(method_family = none)]
321 pub unsafe fn selectedSegmentBezelColor(&self) -> Option<Retained<NSColor>>;
322
323 #[cfg(feature = "NSColor")]
324 #[unsafe(method(setSelectedSegmentBezelColor:))]
326 #[unsafe(method_family = none)]
327 pub unsafe fn setSelectedSegmentBezelColor(
328 &self,
329 selected_segment_bezel_color: Option<&NSColor>,
330 );
331
332 #[unsafe(method(indexOfSelectedItem))]
333 #[unsafe(method_family = none)]
334 pub unsafe fn indexOfSelectedItem(&self) -> NSInteger;
335
336 #[cfg(feature = "NSText")]
337 #[unsafe(method(setAlignment:forSegment:))]
338 #[unsafe(method_family = none)]
339 pub unsafe fn setAlignment_forSegment(
340 &self,
341 alignment: NSTextAlignment,
342 segment: NSInteger,
343 );
344
345 #[cfg(feature = "NSText")]
346 #[unsafe(method(alignmentForSegment:))]
347 #[unsafe(method_family = none)]
348 pub unsafe fn alignmentForSegment(&self, segment: NSInteger) -> NSTextAlignment;
349
350 #[unsafe(method(segmentDistribution))]
351 #[unsafe(method_family = none)]
352 pub unsafe fn segmentDistribution(&self) -> NSSegmentDistribution;
353
354 #[unsafe(method(setSegmentDistribution:))]
356 #[unsafe(method_family = none)]
357 pub unsafe fn setSegmentDistribution(&self, segment_distribution: NSSegmentDistribution);
358
359 #[cfg(feature = "NSUserInterfaceCompression")]
360 #[unsafe(method(compressWithPrioritizedCompressionOptions:))]
361 #[unsafe(method_family = none)]
362 pub unsafe fn compressWithPrioritizedCompressionOptions(
363 &self,
364 prioritized_options: &NSArray<NSUserInterfaceCompressionOptions>,
365 );
366
367 #[cfg(feature = "NSUserInterfaceCompression")]
368 #[unsafe(method(minimumSizeWithPrioritizedCompressionOptions:))]
369 #[unsafe(method_family = none)]
370 pub unsafe fn minimumSizeWithPrioritizedCompressionOptions(
371 &self,
372 prioritized_options: &NSArray<NSUserInterfaceCompressionOptions>,
373 ) -> NSSize;
374
375 #[cfg(feature = "NSUserInterfaceCompression")]
376 #[unsafe(method(activeCompressionOptions))]
377 #[unsafe(method_family = none)]
378 pub unsafe fn activeCompressionOptions(
379 &self,
380 ) -> Retained<NSUserInterfaceCompressionOptions>;
381 );
382}
383
384#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
386impl NSSegmentedControl {
387 extern_methods!(
388 #[unsafe(method(initWithFrame:))]
389 #[unsafe(method_family = init)]
390 pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
391
392 #[unsafe(method(initWithCoder:))]
393 #[unsafe(method_family = init)]
394 pub unsafe fn initWithCoder(
395 this: Allocated<Self>,
396 coder: &NSCoder,
397 ) -> Option<Retained<Self>>;
398 );
399}
400
401#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
403impl NSSegmentedControl {
404 extern_methods!(
405 #[unsafe(method(init))]
406 #[unsafe(method_family = init)]
407 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
408 );
409}
410
411#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
413impl NSSegmentedControl {
414 extern_methods!(
415 #[unsafe(method(new))]
416 #[unsafe(method_family = new)]
417 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
418 );
419}
420
421#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
423impl NSSegmentedControl {
424 extern_methods!(
425 #[unsafe(method(segmentedControlWithLabels:trackingMode:target:action:))]
437 #[unsafe(method_family = none)]
438 pub unsafe fn segmentedControlWithLabels_trackingMode_target_action(
439 labels: &NSArray<NSString>,
440 tracking_mode: NSSegmentSwitchTracking,
441 target: Option<&AnyObject>,
442 action: Option<Sel>,
443 mtm: MainThreadMarker,
444 ) -> Retained<Self>;
445
446 #[cfg(feature = "NSImage")]
447 #[unsafe(method(segmentedControlWithImages:trackingMode:target:action:))]
459 #[unsafe(method_family = none)]
460 pub unsafe fn segmentedControlWithImages_trackingMode_target_action(
461 images: &NSArray<NSImage>,
462 tracking_mode: NSSegmentSwitchTracking,
463 target: Option<&AnyObject>,
464 action: Option<Sel>,
465 mtm: MainThreadMarker,
466 ) -> Retained<Self>;
467 );
468}