1use crate::common::*;
4use crate::AppKit::*;
5use crate::CoreData::*;
6use crate::Foundation::*;
7
8ns_enum!(
9 #[underlying(NSUInteger)]
10 pub enum NSButtonType {
11 NSButtonTypeMomentaryLight = 0,
12 NSButtonTypePushOnPushOff = 1,
13 NSButtonTypeToggle = 2,
14 NSButtonTypeSwitch = 3,
15 NSButtonTypeRadio = 4,
16 NSButtonTypeMomentaryChange = 5,
17 NSButtonTypeOnOff = 6,
18 NSButtonTypeMomentaryPushIn = 7,
19 NSButtonTypeAccelerator = 8,
20 NSButtonTypeMultiLevelAccelerator = 9,
21 }
22);
23
24ns_enum!(
25 #[underlying(NSUInteger)]
26 pub enum NSBezelStyle {
27 NSBezelStyleAutomatic = 0,
28 NSBezelStylePush = 1,
29 NSBezelStyleFlexiblePush = 2,
30 NSBezelStyleDisclosure = 5,
31 NSBezelStyleCircular = 7,
32 NSBezelStyleHelpButton = 9,
33 NSBezelStyleSmallSquare = 10,
34 NSBezelStyleToolbar = 11,
35 NSBezelStyleAccessoryBarAction = 12,
36 NSBezelStyleAccessoryBar = 13,
37 NSBezelStylePushDisclosure = 14,
38 NSBezelStyleBadge = 15,
39 #[deprecated]
40 NSBezelStyleShadowlessSquare = 6,
41 #[deprecated]
42 NSBezelStyleTexturedSquare = 8,
43 #[deprecated]
44 NSBezelStyleRounded = NSBezelStylePush,
45 #[deprecated]
46 NSBezelStyleRegularSquare = NSBezelStyleFlexiblePush,
47 #[deprecated]
48 NSBezelStyleTexturedRounded = NSBezelStyleToolbar,
49 #[deprecated]
50 NSBezelStyleRoundRect = NSBezelStyleAccessoryBarAction,
51 #[deprecated]
52 NSBezelStyleRecessed = NSBezelStyleAccessoryBar,
53 #[deprecated]
54 NSBezelStyleRoundedDisclosure = NSBezelStylePushDisclosure,
55 #[deprecated]
56 NSBezelStyleInline = NSBezelStyleBadge,
57 }
58);
59
60extern_class!(
61 #[derive(Debug, PartialEq, Eq, Hash)]
62 #[cfg(feature = "AppKit_NSButtonCell")]
63 pub struct NSButtonCell;
64
65 #[cfg(feature = "AppKit_NSButtonCell")]
66 unsafe impl ClassType for NSButtonCell {
67 #[inherits(NSCell, NSObject)]
68 type Super = NSActionCell;
69 type Mutability = MainThreadOnly;
70 }
71);
72
73#[cfg(feature = "AppKit_NSButtonCell")]
74unsafe impl NSAccessibility for NSButtonCell {}
75
76#[cfg(feature = "AppKit_NSButtonCell")]
77unsafe impl NSAccessibilityElementProtocol for NSButtonCell {}
78
79#[cfg(feature = "AppKit_NSButtonCell")]
80unsafe impl NSCoding for NSButtonCell {}
81
82#[cfg(feature = "AppKit_NSButtonCell")]
83unsafe impl NSCopying for NSButtonCell {}
84
85#[cfg(feature = "AppKit_NSButtonCell")]
86unsafe impl NSObjectProtocol for NSButtonCell {}
87
88#[cfg(feature = "AppKit_NSButtonCell")]
89unsafe impl NSUserInterfaceItemIdentification for NSButtonCell {}
90
91extern_methods!(
92 #[cfg(feature = "AppKit_NSButtonCell")]
93 unsafe impl NSButtonCell {
94 #[cfg(feature = "Foundation_NSString")]
95 #[method_id(@__retain_semantics Init initTextCell:)]
96 pub unsafe fn initTextCell(this: Allocated<Self>, string: &NSString) -> Id<Self>;
97
98 #[cfg(feature = "AppKit_NSImage")]
99 #[method_id(@__retain_semantics Init initImageCell:)]
100 pub unsafe fn initImageCell(this: Allocated<Self>, image: Option<&NSImage>) -> Id<Self>;
101
102 #[cfg(feature = "Foundation_NSCoder")]
103 #[method_id(@__retain_semantics Init initWithCoder:)]
104 pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Id<Self>;
105
106 #[method(bezelStyle)]
107 pub unsafe fn bezelStyle(&self) -> NSBezelStyle;
108
109 #[method(setBezelStyle:)]
110 pub unsafe fn setBezelStyle(&self, bezel_style: NSBezelStyle);
111
112 #[method(setButtonType:)]
113 pub unsafe fn setButtonType(&self, r#type: NSButtonType);
114
115 #[method(highlightsBy)]
116 pub unsafe fn highlightsBy(&self) -> NSCellStyleMask;
117
118 #[method(setHighlightsBy:)]
119 pub unsafe fn setHighlightsBy(&self, highlights_by: NSCellStyleMask);
120
121 #[method(showsStateBy)]
122 pub unsafe fn showsStateBy(&self) -> NSCellStyleMask;
123
124 #[method(setShowsStateBy:)]
125 pub unsafe fn setShowsStateBy(&self, shows_state_by: NSCellStyleMask);
126
127 #[cfg(feature = "Foundation_NSString")]
128 #[method_id(@__retain_semantics Other title)]
129 pub unsafe fn title(&self) -> Id<NSString>;
130
131 #[cfg(feature = "Foundation_NSString")]
132 #[method(setTitle:)]
133 pub unsafe fn setTitle(&self, title: Option<&NSString>);
134
135 #[cfg(feature = "Foundation_NSAttributedString")]
136 #[method_id(@__retain_semantics Other attributedTitle)]
137 pub unsafe fn attributedTitle(&self) -> Id<NSAttributedString>;
138
139 #[cfg(feature = "Foundation_NSAttributedString")]
140 #[method(setAttributedTitle:)]
141 pub unsafe fn setAttributedTitle(&self, attributed_title: &NSAttributedString);
142
143 #[cfg(feature = "Foundation_NSString")]
144 #[method_id(@__retain_semantics Other alternateTitle)]
145 pub unsafe fn alternateTitle(&self) -> Id<NSString>;
146
147 #[cfg(feature = "Foundation_NSString")]
148 #[method(setAlternateTitle:)]
149 pub unsafe fn setAlternateTitle(&self, alternate_title: &NSString);
150
151 #[cfg(feature = "Foundation_NSAttributedString")]
152 #[method_id(@__retain_semantics Other attributedAlternateTitle)]
153 pub unsafe fn attributedAlternateTitle(&self) -> Id<NSAttributedString>;
154
155 #[cfg(feature = "Foundation_NSAttributedString")]
156 #[method(setAttributedAlternateTitle:)]
157 pub unsafe fn setAttributedAlternateTitle(
158 &self,
159 attributed_alternate_title: &NSAttributedString,
160 );
161
162 #[cfg(feature = "AppKit_NSImage")]
163 #[method_id(@__retain_semantics Other alternateImage)]
164 pub unsafe fn alternateImage(&self) -> Option<Id<NSImage>>;
165
166 #[cfg(feature = "AppKit_NSImage")]
167 #[method(setAlternateImage:)]
168 pub unsafe fn setAlternateImage(&self, alternate_image: Option<&NSImage>);
169
170 #[method(imagePosition)]
171 pub unsafe fn imagePosition(&self) -> NSCellImagePosition;
172
173 #[method(setImagePosition:)]
174 pub unsafe fn setImagePosition(&self, image_position: NSCellImagePosition);
175
176 #[method(imageScaling)]
177 pub unsafe fn imageScaling(&self) -> NSImageScaling;
178
179 #[method(setImageScaling:)]
180 pub unsafe fn setImageScaling(&self, image_scaling: NSImageScaling);
181
182 #[cfg(feature = "Foundation_NSString")]
183 #[method_id(@__retain_semantics Other keyEquivalent)]
184 pub unsafe fn keyEquivalent(&self) -> Id<NSString>;
185
186 #[cfg(feature = "Foundation_NSString")]
187 #[method(setKeyEquivalent:)]
188 pub unsafe fn setKeyEquivalent(&self, key_equivalent: &NSString);
189
190 #[method(keyEquivalentModifierMask)]
191 pub unsafe fn keyEquivalentModifierMask(&self) -> NSEventModifierFlags;
192
193 #[method(setKeyEquivalentModifierMask:)]
194 pub unsafe fn setKeyEquivalentModifierMask(
195 &self,
196 key_equivalent_modifier_mask: NSEventModifierFlags,
197 );
198
199 #[method(isTransparent)]
200 pub unsafe fn isTransparent(&self) -> bool;
201
202 #[method(setTransparent:)]
203 pub unsafe fn setTransparent(&self, transparent: bool);
204
205 #[method(isOpaque)]
206 pub unsafe fn isOpaque(&self) -> bool;
207
208 #[method(imageDimsWhenDisabled)]
209 pub unsafe fn imageDimsWhenDisabled(&self) -> bool;
210
211 #[method(setImageDimsWhenDisabled:)]
212 pub unsafe fn setImageDimsWhenDisabled(&self, image_dims_when_disabled: bool);
213
214 #[method(showsBorderOnlyWhileMouseInside)]
215 pub unsafe fn showsBorderOnlyWhileMouseInside(&self) -> bool;
216
217 #[method(setShowsBorderOnlyWhileMouseInside:)]
218 pub unsafe fn setShowsBorderOnlyWhileMouseInside(
219 &self,
220 shows_border_only_while_mouse_inside: bool,
221 );
222
223 #[cfg(feature = "AppKit_NSSound")]
224 #[method_id(@__retain_semantics Other sound)]
225 pub unsafe fn sound(&self) -> Option<Id<NSSound>>;
226
227 #[cfg(feature = "AppKit_NSSound")]
228 #[method(setSound:)]
229 pub unsafe fn setSound(&self, sound: Option<&NSSound>);
230
231 #[cfg(feature = "AppKit_NSColor")]
232 #[method_id(@__retain_semantics Other backgroundColor)]
233 pub unsafe fn backgroundColor(&self) -> Option<Id<NSColor>>;
234
235 #[cfg(feature = "AppKit_NSColor")]
236 #[method(setBackgroundColor:)]
237 pub unsafe fn setBackgroundColor(&self, background_color: Option<&NSColor>);
238
239 #[method(setPeriodicDelay:interval:)]
240 pub unsafe fn setPeriodicDelay_interval(&self, delay: c_float, interval: c_float);
241
242 #[method(getPeriodicDelay:interval:)]
243 pub unsafe fn getPeriodicDelay_interval(
244 &self,
245 delay: NonNull<c_float>,
246 interval: NonNull<c_float>,
247 );
248
249 #[method(performClick:)]
250 pub unsafe fn performClick(&self, sender: Option<&AnyObject>);
251
252 #[cfg(feature = "AppKit_NSEvent")]
253 #[method(mouseEntered:)]
254 pub unsafe fn mouseEntered(&self, event: &NSEvent);
255
256 #[cfg(feature = "AppKit_NSEvent")]
257 #[method(mouseExited:)]
258 pub unsafe fn mouseExited(&self, event: &NSEvent);
259
260 #[cfg(feature = "AppKit_NSView")]
261 #[method(drawBezelWithFrame:inView:)]
262 pub unsafe fn drawBezelWithFrame_inView(&self, frame: NSRect, control_view: &NSView);
263
264 #[cfg(all(feature = "AppKit_NSImage", feature = "AppKit_NSView"))]
265 #[method(drawImage:withFrame:inView:)]
266 pub unsafe fn drawImage_withFrame_inView(
267 &self,
268 image: &NSImage,
269 frame: NSRect,
270 control_view: &NSView,
271 );
272
273 #[cfg(all(feature = "AppKit_NSView", feature = "Foundation_NSAttributedString"))]
274 #[method(drawTitle:withFrame:inView:)]
275 pub unsafe fn drawTitle_withFrame_inView(
276 &self,
277 title: &NSAttributedString,
278 frame: NSRect,
279 control_view: &NSView,
280 ) -> NSRect;
281 }
282);
283
284extern_methods!(
285 #[cfg(feature = "AppKit_NSButtonCell")]
287 unsafe impl NSButtonCell {
288 #[method_id(@__retain_semantics Init init)]
289 pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;
290 }
291);
292
293extern_methods!(
294 #[cfg(feature = "AppKit_NSButtonCell")]
296 unsafe impl NSButtonCell {
297 #[method_id(@__retain_semantics New new)]
298 pub unsafe fn new(mtm: MainThreadMarker) -> Id<Self>;
299 }
300);
301
302ns_enum!(
303 #[underlying(NSUInteger)]
304 #[deprecated]
305 pub enum NSGradientType {
306 NSGradientNone = 0,
307 NSGradientConcaveWeak = 1,
308 NSGradientConcaveStrong = 2,
309 NSGradientConvexWeak = 3,
310 NSGradientConvexStrong = 4,
311 }
312);
313
314extern_static!(NSMomentaryLightButton: NSButtonType = NSButtonTypeMomentaryLight);
315
316extern_static!(NSPushOnPushOffButton: NSButtonType = NSButtonTypePushOnPushOff);
317
318extern_static!(NSToggleButton: NSButtonType = NSButtonTypeToggle);
319
320extern_static!(NSSwitchButton: NSButtonType = NSButtonTypeSwitch);
321
322extern_static!(NSRadioButton: NSButtonType = NSButtonTypeRadio);
323
324extern_static!(NSMomentaryChangeButton: NSButtonType = NSButtonTypeMomentaryChange);
325
326extern_static!(NSOnOffButton: NSButtonType = NSButtonTypeOnOff);
327
328extern_static!(NSMomentaryPushInButton: NSButtonType = NSButtonTypeMomentaryPushIn);
329
330extern_static!(NSAcceleratorButton: NSButtonType = NSButtonTypeAccelerator);
331
332extern_static!(NSMultiLevelAcceleratorButton: NSButtonType = NSButtonTypeMultiLevelAccelerator);
333
334extern_static!(NSMomentaryPushButton: NSButtonType = NSButtonTypeMomentaryLight);
335
336extern_static!(NSMomentaryLight: NSButtonType = NSButtonTypeMomentaryPushIn);
337
338extern_static!(NSRoundedBezelStyle: NSBezelStyle = NSBezelStylePush);
339
340extern_static!(NSRegularSquareBezelStyle: NSBezelStyle = NSBezelStyleFlexiblePush);
341
342extern_static!(NSDisclosureBezelStyle: NSBezelStyle = NSBezelStyleDisclosure);
343
344extern_static!(NSShadowlessSquareBezelStyle: NSBezelStyle = NSBezelStyleShadowlessSquare);
345
346extern_static!(NSCircularBezelStyle: NSBezelStyle = NSBezelStyleCircular);
347
348extern_static!(NSTexturedSquareBezelStyle: NSBezelStyle = NSBezelStyleTexturedSquare);
349
350extern_static!(NSHelpButtonBezelStyle: NSBezelStyle = NSBezelStyleHelpButton);
351
352extern_static!(NSSmallSquareBezelStyle: NSBezelStyle = NSBezelStyleSmallSquare);
353
354extern_static!(NSTexturedRoundedBezelStyle: NSBezelStyle = NSBezelStyleToolbar);
355
356extern_static!(NSRoundRectBezelStyle: NSBezelStyle = NSBezelStyleAccessoryBarAction);
357
358extern_static!(NSRecessedBezelStyle: NSBezelStyle = NSBezelStyleAccessoryBar);
359
360extern_static!(NSRoundedDisclosureBezelStyle: NSBezelStyle = NSBezelStylePushDisclosure);
361
362extern_static!(NSInlineBezelStyle: NSBezelStyle = NSBezelStyleBadge);
363
364extern_static!(NSSmallIconButtonBezelStyle: NSBezelStyle = 2);
365
366extern_static!(NSThickSquareBezelStyle: NSBezelStyle = 3);
367
368extern_static!(NSThickerSquareBezelStyle: NSBezelStyle = 4);
369
370extern_methods!(
371 #[cfg(feature = "AppKit_NSButtonCell")]
373 unsafe impl NSButtonCell {
374 #[deprecated = "The gradientType property is unused, and setting it has no effect."]
375 #[method(gradientType)]
376 pub unsafe fn gradientType(&self) -> NSGradientType;
377
378 #[deprecated = "The gradientType property is unused, and setting it has no effect."]
379 #[method(setGradientType:)]
380 pub unsafe fn setGradientType(&self, gradient_type: NSGradientType);
381
382 #[cfg(feature = "Foundation_NSString")]
383 #[deprecated = "Mnemonics are not used on macOS. Set the title property directly instead."]
384 #[method(setTitleWithMnemonic:)]
385 pub unsafe fn setTitleWithMnemonic(&self, string_with_ampersand: Option<&NSString>);
386
387 #[cfg(feature = "Foundation_NSString")]
388 #[deprecated = "Mnemonics are not used on macOS. Set the alternateTitle property directly instead."]
389 #[method(setAlternateTitleWithMnemonic:)]
390 pub unsafe fn setAlternateTitleWithMnemonic(
391 &self,
392 string_with_ampersand: Option<&NSString>,
393 );
394
395 #[deprecated = "Mnemonics are not used on macOS. Calling this method has no effect."]
396 #[method(setAlternateMnemonicLocation:)]
397 pub unsafe fn setAlternateMnemonicLocation(&self, location: NSUInteger);
398
399 #[deprecated = "Mnemonics are not used on macOS. This property always returns NSNotFound."]
400 #[method(alternateMnemonicLocation)]
401 pub unsafe fn alternateMnemonicLocation(&self) -> NSUInteger;
402
403 #[cfg(feature = "Foundation_NSString")]
404 #[deprecated = "Mnemonics are not used on macOS. This property always returns an empty string."]
405 #[method_id(@__retain_semantics Other alternateMnemonic)]
406 pub unsafe fn alternateMnemonic(&self) -> Option<Id<NSString>>;
407
408 #[cfg(feature = "AppKit_NSFont")]
409 #[deprecated = "The keyEquivalentFont property is no longer used. It always returns the NSButtonCell's font, and setting it has no effect."]
410 #[method_id(@__retain_semantics Other keyEquivalentFont)]
411 pub unsafe fn keyEquivalentFont(&self) -> Option<Id<NSFont>>;
412
413 #[cfg(feature = "AppKit_NSFont")]
414 #[deprecated = "The keyEquivalentFont property is no longer used. It always returns the NSButtonCell's font, and setting it has no effect."]
415 #[method(setKeyEquivalentFont:)]
416 pub unsafe fn setKeyEquivalentFont(&self, key_equivalent_font: Option<&NSFont>);
417
418 #[cfg(feature = "Foundation_NSString")]
419 #[deprecated = "The keyEquivalentFont property is no longer used. Setting it has no effect."]
420 #[method(setKeyEquivalentFont:size:)]
421 pub unsafe fn setKeyEquivalentFont_size(&self, font_name: &NSString, font_size: CGFloat);
422 }
423);