comparison foosdk/sdk/foobar2000/helpers-mac/NSView+ppsubviews.m @ 1:20d02a178406 default tip

*: check in everything else yay
author Paper <paper@tflc.us>
date Mon, 05 Jan 2026 02:15:46 -0500
parents
children
comparison
equal deleted inserted replaced
0:e9bb126753e7 1:20d02a178406
1 #import "NSView+ppsubviews.h"
2
3 #if 0
4 @implementation NSView (ppsubviews)
5
6 - (NSView*) recurFindSubViewOfClass: (Class) cls identifier: (NSString*) identifier {
7 return NSViewFindSubViewRecursive ( self, cls, identifier );
8 }
9
10 - (NSView*) findSubViewOfClass: (Class) cls identifier: (NSString*) identifier {
11 return NSViewFindSubView( self, cls, identifier );
12 }
13 - (NSView *)findSubViewOfClass:(Class)cls {
14 return NSViewFindSubView( self, cls, nil );
15 }
16 - (NSButton *)findButton {
17 return (NSButton*) [self findSubViewOfClass: [NSButton class]];
18 }
19 - (NSTextView *)findTextView {
20 return (NSTextView*) [self findSubViewOfClass: [NSTextView class]];
21 }
22 - (NSTextField *) findTextField {
23 return (NSTextField*) [self findSubViewOfClass: [NSTextField class]];
24 }
25 - (NSImageView*) findImageView {
26 return (NSImageView*) [self findSubViewOfClass: [NSImageView class]];
27 }
28 @end
29 #endif
30
31 __kindof NSView * NSViewFindSubView( NSView * parent, Class cls, NSUserInterfaceItemIdentifier identifier ) {
32 for (__kindof NSView * v in parent.subviews) {
33 if ( (cls == nil || [v isKindOfClass: cls]) && ( identifier == nil || [ v.identifier isEqualToString: identifier ] ) ) {
34 return v;
35 }
36 }
37 return nil;
38 }
39
40 __kindof NSView * NSViewFindSubViewRecursive( NSView * parent, Class cls, NSUserInterfaceItemIdentifier identifier ) {
41 @autoreleasepool {
42 NSMutableArray<__kindof NSView*> * arrAll = [NSMutableArray arrayWithArray: parent.subviews];
43
44 for ( NSUInteger w = 0; w < arrAll.count; ++ w ) {
45 __kindof NSView * thisView = arrAll[w];
46
47 if ( (cls == nil || [thisView isKindOfClass: cls]) && ( identifier == nil || [thisView.identifier isEqualToString: identifier] ) ) {
48 return thisView;
49 }
50 [arrAll addObjectsFromArray: thisView.subviews];
51
52 if ( w >= 200 ) {
53 [arrAll removeObjectsInRange: NSMakeRange(0, w) ];
54 w = 0;
55 }
56 }
57 return nil;
58 }
59 }