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))]
110extern_conformance!(
111 unsafe impl NSAccessibility for NSSegmentedControl {}
112);
113
114#[cfg(all(
115 feature = "NSAccessibilityProtocols",
116 feature = "NSControl",
117 feature = "NSResponder",
118 feature = "NSView"
119))]
120extern_conformance!(
121 unsafe impl NSAccessibilityElementProtocol for NSSegmentedControl {}
122);
123
124#[cfg(all(
125 feature = "NSAnimation",
126 feature = "NSControl",
127 feature = "NSResponder",
128 feature = "NSView"
129))]
130extern_conformance!(
131 unsafe impl NSAnimatablePropertyContainer for NSSegmentedControl {}
132);
133
134#[cfg(all(
135 feature = "NSAppearance",
136 feature = "NSControl",
137 feature = "NSResponder",
138 feature = "NSView"
139))]
140extern_conformance!(
141 unsafe impl NSAppearanceCustomization for NSSegmentedControl {}
142);
143
144#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
145extern_conformance!(
146 unsafe impl NSCoding for NSSegmentedControl {}
147);
148
149#[cfg(all(
150 feature = "NSControl",
151 feature = "NSDragging",
152 feature = "NSResponder",
153 feature = "NSView"
154))]
155extern_conformance!(
156 unsafe impl NSDraggingDestination for NSSegmentedControl {}
157);
158
159#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
160extern_conformance!(
161 unsafe impl NSObjectProtocol for NSSegmentedControl {}
162);
163
164#[cfg(all(
165 feature = "NSControl",
166 feature = "NSResponder",
167 feature = "NSUserInterfaceCompression",
168 feature = "NSView"
169))]
170extern_conformance!(
171 unsafe impl NSUserInterfaceCompression for NSSegmentedControl {}
172);
173
174#[cfg(all(
175 feature = "NSControl",
176 feature = "NSResponder",
177 feature = "NSUserInterfaceItemIdentification",
178 feature = "NSView"
179))]
180extern_conformance!(
181 unsafe impl NSUserInterfaceItemIdentification for NSSegmentedControl {}
182);
183
184#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
185impl NSSegmentedControl {
186 extern_methods!(
187 #[unsafe(method(segmentCount))]
188 #[unsafe(method_family = none)]
189 pub unsafe fn segmentCount(&self) -> NSInteger;
190
191 #[unsafe(method(setSegmentCount:))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn setSegmentCount(&self, segment_count: NSInteger);
195
196 #[unsafe(method(selectedSegment))]
197 #[unsafe(method_family = none)]
198 pub unsafe fn selectedSegment(&self) -> NSInteger;
199
200 #[unsafe(method(setSelectedSegment:))]
202 #[unsafe(method_family = none)]
203 pub unsafe fn setSelectedSegment(&self, selected_segment: NSInteger);
204
205 #[unsafe(method(selectSegmentWithTag:))]
206 #[unsafe(method_family = none)]
207 pub unsafe fn selectSegmentWithTag(&self, tag: NSInteger) -> bool;
208
209 #[cfg(feature = "objc2-core-foundation")]
210 #[unsafe(method(setWidth:forSegment:))]
211 #[unsafe(method_family = none)]
212 pub unsafe fn setWidth_forSegment(&self, width: CGFloat, segment: NSInteger);
213
214 #[cfg(feature = "objc2-core-foundation")]
215 #[unsafe(method(widthForSegment:))]
216 #[unsafe(method_family = none)]
217 pub unsafe fn widthForSegment(&self, segment: NSInteger) -> CGFloat;
218
219 #[cfg(feature = "NSImage")]
220 #[unsafe(method(setImage:forSegment:))]
221 #[unsafe(method_family = none)]
222 pub unsafe fn setImage_forSegment(&self, image: Option<&NSImage>, segment: NSInteger);
223
224 #[cfg(feature = "NSImage")]
225 #[unsafe(method(imageForSegment:))]
226 #[unsafe(method_family = none)]
227 pub unsafe fn imageForSegment(&self, segment: NSInteger) -> Option<Retained<NSImage>>;
228
229 #[cfg(feature = "NSCell")]
230 #[unsafe(method(setImageScaling:forSegment:))]
231 #[unsafe(method_family = none)]
232 pub unsafe fn setImageScaling_forSegment(
233 &self,
234 scaling: NSImageScaling,
235 segment: NSInteger,
236 );
237
238 #[cfg(feature = "NSCell")]
239 #[unsafe(method(imageScalingForSegment:))]
240 #[unsafe(method_family = none)]
241 pub unsafe fn imageScalingForSegment(&self, segment: NSInteger) -> NSImageScaling;
242
243 #[unsafe(method(setLabel:forSegment:))]
244 #[unsafe(method_family = none)]
245 pub unsafe fn setLabel_forSegment(&self, label: &NSString, segment: NSInteger);
246
247 #[unsafe(method(labelForSegment:))]
248 #[unsafe(method_family = none)]
249 pub unsafe fn labelForSegment(&self, segment: NSInteger) -> Option<Retained<NSString>>;
250
251 #[cfg(feature = "NSMenu")]
252 #[unsafe(method(setMenu:forSegment:))]
253 #[unsafe(method_family = none)]
254 pub unsafe fn setMenu_forSegment(&self, menu: Option<&NSMenu>, segment: NSInteger);
255
256 #[cfg(feature = "NSMenu")]
257 #[unsafe(method(menuForSegment:))]
258 #[unsafe(method_family = none)]
259 pub unsafe fn menuForSegment(&self, segment: NSInteger) -> Option<Retained<NSMenu>>;
260
261 #[unsafe(method(setSelected:forSegment:))]
262 #[unsafe(method_family = none)]
263 pub unsafe fn setSelected_forSegment(&self, selected: bool, segment: NSInteger);
264
265 #[unsafe(method(isSelectedForSegment:))]
266 #[unsafe(method_family = none)]
267 pub unsafe fn isSelectedForSegment(&self, segment: NSInteger) -> bool;
268
269 #[unsafe(method(setEnabled:forSegment:))]
270 #[unsafe(method_family = none)]
271 pub unsafe fn setEnabled_forSegment(&self, enabled: bool, segment: NSInteger);
272
273 #[unsafe(method(isEnabledForSegment:))]
274 #[unsafe(method_family = none)]
275 pub unsafe fn isEnabledForSegment(&self, segment: NSInteger) -> bool;
276
277 #[unsafe(method(setToolTip:forSegment:))]
278 #[unsafe(method_family = none)]
279 pub unsafe fn setToolTip_forSegment(&self, tool_tip: Option<&NSString>, segment: NSInteger);
280
281 #[unsafe(method(toolTipForSegment:))]
282 #[unsafe(method_family = none)]
283 pub unsafe fn toolTipForSegment(&self, segment: NSInteger) -> Option<Retained<NSString>>;
284
285 #[unsafe(method(setTag:forSegment:))]
286 #[unsafe(method_family = none)]
287 pub unsafe fn setTag_forSegment(&self, tag: NSInteger, segment: NSInteger);
288
289 #[unsafe(method(tagForSegment:))]
290 #[unsafe(method_family = none)]
291 pub unsafe fn tagForSegment(&self, segment: NSInteger) -> NSInteger;
292
293 #[unsafe(method(setShowsMenuIndicator:forSegment:))]
294 #[unsafe(method_family = none)]
295 pub unsafe fn setShowsMenuIndicator_forSegment(
296 &self,
297 shows_menu_indicator: bool,
298 segment: NSInteger,
299 );
300
301 #[unsafe(method(showsMenuIndicatorForSegment:))]
302 #[unsafe(method_family = none)]
303 pub unsafe fn showsMenuIndicatorForSegment(&self, segment: NSInteger) -> bool;
304
305 #[unsafe(method(segmentStyle))]
306 #[unsafe(method_family = none)]
307 pub unsafe fn segmentStyle(&self) -> NSSegmentStyle;
308
309 #[unsafe(method(setSegmentStyle:))]
311 #[unsafe(method_family = none)]
312 pub unsafe fn setSegmentStyle(&self, segment_style: NSSegmentStyle);
313
314 #[unsafe(method(isSpringLoaded))]
315 #[unsafe(method_family = none)]
316 pub unsafe fn isSpringLoaded(&self) -> bool;
317
318 #[unsafe(method(setSpringLoaded:))]
320 #[unsafe(method_family = none)]
321 pub unsafe fn setSpringLoaded(&self, spring_loaded: bool);
322
323 #[unsafe(method(trackingMode))]
324 #[unsafe(method_family = none)]
325 pub unsafe fn trackingMode(&self) -> NSSegmentSwitchTracking;
326
327 #[unsafe(method(setTrackingMode:))]
329 #[unsafe(method_family = none)]
330 pub unsafe fn setTrackingMode(&self, tracking_mode: NSSegmentSwitchTracking);
331
332 #[unsafe(method(doubleValueForSelectedSegment))]
333 #[unsafe(method_family = none)]
334 pub unsafe fn doubleValueForSelectedSegment(&self) -> c_double;
335
336 #[cfg(feature = "NSColor")]
337 #[unsafe(method(selectedSegmentBezelColor))]
338 #[unsafe(method_family = none)]
339 pub unsafe fn selectedSegmentBezelColor(&self) -> Option<Retained<NSColor>>;
340
341 #[cfg(feature = "NSColor")]
342 #[unsafe(method(setSelectedSegmentBezelColor:))]
344 #[unsafe(method_family = none)]
345 pub unsafe fn setSelectedSegmentBezelColor(
346 &self,
347 selected_segment_bezel_color: Option<&NSColor>,
348 );
349
350 #[unsafe(method(indexOfSelectedItem))]
351 #[unsafe(method_family = none)]
352 pub unsafe fn indexOfSelectedItem(&self) -> NSInteger;
353
354 #[cfg(feature = "NSText")]
355 #[unsafe(method(setAlignment:forSegment:))]
356 #[unsafe(method_family = none)]
357 pub unsafe fn setAlignment_forSegment(
358 &self,
359 alignment: NSTextAlignment,
360 segment: NSInteger,
361 );
362
363 #[cfg(feature = "NSText")]
364 #[unsafe(method(alignmentForSegment:))]
365 #[unsafe(method_family = none)]
366 pub unsafe fn alignmentForSegment(&self, segment: NSInteger) -> NSTextAlignment;
367
368 #[unsafe(method(segmentDistribution))]
369 #[unsafe(method_family = none)]
370 pub unsafe fn segmentDistribution(&self) -> NSSegmentDistribution;
371
372 #[unsafe(method(setSegmentDistribution:))]
374 #[unsafe(method_family = none)]
375 pub unsafe fn setSegmentDistribution(&self, segment_distribution: NSSegmentDistribution);
376
377 #[cfg(feature = "NSUserInterfaceCompression")]
378 #[unsafe(method(compressWithPrioritizedCompressionOptions:))]
379 #[unsafe(method_family = none)]
380 pub unsafe fn compressWithPrioritizedCompressionOptions(
381 &self,
382 prioritized_options: &NSArray<NSUserInterfaceCompressionOptions>,
383 );
384
385 #[cfg(feature = "NSUserInterfaceCompression")]
386 #[unsafe(method(minimumSizeWithPrioritizedCompressionOptions:))]
387 #[unsafe(method_family = none)]
388 pub unsafe fn minimumSizeWithPrioritizedCompressionOptions(
389 &self,
390 prioritized_options: &NSArray<NSUserInterfaceCompressionOptions>,
391 ) -> NSSize;
392
393 #[cfg(feature = "NSUserInterfaceCompression")]
394 #[unsafe(method(activeCompressionOptions))]
395 #[unsafe(method_family = none)]
396 pub unsafe fn activeCompressionOptions(
397 &self,
398 ) -> Retained<NSUserInterfaceCompressionOptions>;
399 );
400}
401
402#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
404impl NSSegmentedControl {
405 extern_methods!(
406 #[unsafe(method(initWithFrame:))]
407 #[unsafe(method_family = init)]
408 pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
409
410 #[unsafe(method(initWithCoder:))]
411 #[unsafe(method_family = init)]
412 pub unsafe fn initWithCoder(
413 this: Allocated<Self>,
414 coder: &NSCoder,
415 ) -> Option<Retained<Self>>;
416 );
417}
418
419#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
421impl NSSegmentedControl {
422 extern_methods!(
423 #[unsafe(method(init))]
424 #[unsafe(method_family = init)]
425 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
426 );
427}
428
429#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
431impl NSSegmentedControl {
432 extern_methods!(
433 #[unsafe(method(new))]
434 #[unsafe(method_family = new)]
435 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
436 );
437}
438
439#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
441impl NSSegmentedControl {
442 extern_methods!(
443 #[unsafe(method(segmentedControlWithLabels:trackingMode:target:action:))]
455 #[unsafe(method_family = none)]
456 pub unsafe fn segmentedControlWithLabels_trackingMode_target_action(
457 labels: &NSArray<NSString>,
458 tracking_mode: NSSegmentSwitchTracking,
459 target: Option<&AnyObject>,
460 action: Option<Sel>,
461 mtm: MainThreadMarker,
462 ) -> Retained<Self>;
463
464 #[cfg(feature = "NSImage")]
465 #[unsafe(method(segmentedControlWithImages:trackingMode:target:action:))]
477 #[unsafe(method_family = none)]
478 pub unsafe fn segmentedControlWithImages_trackingMode_target_action(
479 images: &NSArray<NSImage>,
480 tracking_mode: NSSegmentSwitchTracking,
481 target: Option<&AnyObject>,
482 action: Option<Sel>,
483 mtm: MainThreadMarker,
484 ) -> Retained<Self>;
485 );
486}