Implement NSUserInterfaceItemIdentification

This commit is contained in:
Ariel Abreu 2023-10-13 10:08:54 -04:00
parent 6f9958fd46
commit 1efc3b97de
No known key found for this signature in database
GPG Key ID: 5B88AAAF4280706F
19 changed files with 86 additions and 23 deletions

View File

@ -449,6 +449,7 @@ set(AppKit_sources
NSSwitch.m
NSTextFinder.m
NSScrubber.m
NSUserInterfaceItemIdentification.m
)
set_source_files_properties(${AppKit_sources} LANGUAGE C)

View File

@ -38,6 +38,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
@implementation NSCell
@synthesize identifier = _identifier;
#pragma mark -
#pragma mark Class Methods
@ -265,6 +267,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
[_image release];
[_formatter release];
[_representedObject release];
[_identifier release];
[super dealloc];
}

View File

@ -37,6 +37,8 @@ NSString *const _NSWindowsMenuName = @"Window";
@implementation NSMenu
@synthesize identifier = _identifier;
+ (void) popUpContextMenu: (NSMenu *) menu
withEvent: (NSEvent *) event
forView: (NSView *) view
@ -167,6 +169,7 @@ NSString *const _NSWindowsMenuName = @"Window";
[_itemArray makeObjectsPerformSelector: @selector(_setMenu:)
withObject: nil];
[_itemArray release];
[_identifier release];
[super dealloc];
}

View File

@ -30,6 +30,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
@implementation NSMenuItem
@synthesize identifier = _identifier;
+ (NSMenuItem *) separatorItem {
return [[[self alloc] initWithTitle: nil action: NULL
keyEquivalent: nil] autorelease];
@ -110,6 +112,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
[_mixedStateImage release];
[_offStateImage release];
[_representedObject release];
[_identifier release];
[super dealloc];
}

View File

@ -32,6 +32,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
@implementation NSTableColumn
@synthesize identifier = _identifier;
- (void) encodeWithCoder: (NSCoder *) coder {
NSUnimplementedMethod();
}
@ -60,7 +62,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
// NSOutlineView needs to programmatically instantiated as IB/WOF4 doesn't have
// an editor for it.. also theoretically -dealloc could've crashed as the cell
// prototypes weren't initialized at all...
- initWithIdentifier: identifier {
- (instancetype) initWithIdentifier: (NSUserInterfaceItemIdentifier) identifier {
_identifier = [identifier retain];
_width = 100.0;
_minWidth = 10.0;
@ -91,10 +93,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
_width, _minWidth, _maxWidth];
}
- (id) identifier {
return _identifier;
}
- (NSTableView *) tableView {
return _tableView;
}
@ -135,12 +133,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
return _resizingMask;
}
- (void) setIdentifier: (id) identifier {
identifier = [identifier retain];
[_identifier release];
_identifier = identifier;
}
- (void) setTableView: (NSTableView *) tableView {
_tableView = tableView;
}

View File

@ -0,0 +1,18 @@
#import <AppKit/NSUserInterfaceItemIdentification.h>
@implementation NSObject (NSUserInterfaceItemIdentification)
- (NSUserInterfaceItemIdentifier) userInterfaceItemIdentifier {
if ([self respondsToSelector: @selector(identifier)]) {
return [self identifier];
}
return nil;
}
- (void) setUserInterfaceItemIdentifier: (NSUserInterfaceItemIdentifier) userInterfaceItemIdentifier {
if ([self respondsToSelector: @selector(setIdentifier:)]) {
[self setIdentifier: userInterfaceItemIdentifier];
}
}
@end

View File

@ -69,6 +69,8 @@ const NSViewFullScreenModeOptionKey NSFullScreenModeApplicationPresentationOptio
@implementation NSView
@synthesize identifier = _identifier;
static BOOL NSViewLayersEnabled = YES;
static BOOL NSShowAllViews = NO;
@ -408,6 +410,8 @@ typedef struct __VFlags {
[_layerContext invalidate];
[_layerContext release];
[_identifier release];
[super dealloc];
}

View File

@ -5,6 +5,8 @@
@implementation NSViewController
@synthesize identifier = _identifier;
- initWithNibName: (NSString *) name bundle: (NSBundle *) bundle {
_nibName = [name copy];
_nibBundle = [bundle retain];
@ -24,6 +26,12 @@
return self;
}
- (void) dealloc {
[_identifier release];
[super dealloc];
}
- (NSString *) nibName {
return _nibName;
}

View File

@ -206,6 +206,8 @@ NSInteger NSBitsPerPixelFromDepth(NSWindowDepth depth) {
@implementation NSWindow
@synthesize identifier = _identifier;
static BOOL _allowsAutomaticWindowTabbing;
+ (NSWindowDepth) defaultDepthLimit {
@ -416,6 +418,7 @@ static BOOL _allowsAutomaticWindowTabbing;
_platformWindow = nil;
[_threadToContext release];
[_undoManager release];
[_identifier release];
[super dealloc];
}

View File

@ -20,6 +20,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <AppKit/NSGraphics.h>
#import <AppKit/NSParagraphStyle.h>
#import <AppKit/NSText.h>
#import <AppKit/NSUserInterfaceItemIdentification.h>
@class NSFont, NSImage, NSView;
@ -95,7 +96,7 @@ enum {
NSCellHitTrackableArea = 0x04,
};
@interface NSCell : NSObject <NSCopying, NSCoding> {
@interface NSCell : NSObject <NSCopying, NSCoding, NSUserInterfaceItemIdentification> {
NSControlStateValue _state;
NSFont *_font;
NSInteger _entryType;
@ -112,6 +113,7 @@ enum {
NSLineBreakMode _lineBreakMode;
NSBackgroundStyle _backgroundStyle;
NSUInteger _cFlags; // required for Xcode
NSUserInterfaceItemIdentifier _identifier;
BOOL _isEnabled;
BOOL _isEditable;

View File

@ -19,6 +19,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <AppKit/AppKitExport.h>
#import <Foundation/Foundation.h>
#import <AppKit/NSUserInterfaceItemIdentification.h>
@class NSScreen, NSMenu, NSMenuItem, NSWindow, NSEvent, NSView;
@ -27,13 +28,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
APPKIT_EXPORT const NSNotificationName NSMenuDidBeginTrackingNotification;
APPKIT_EXPORT const NSNotificationName NSMenuDidEndTrackingNotification;
@interface NSMenu : NSObject <NSCopying> {
@interface NSMenu : NSObject <NSCopying, NSUserInterfaceItemIdentification> {
NSMenu *_supermenu;
NSString *_title;
NSString *_name;
NSMutableArray *_itemArray;
BOOL _autoenablesItems;
id<NSMenuDelegate> _delegate;
NSUserInterfaceItemIdentifier _identifier;
}
+ (void) popUpContextMenu: (NSMenu *) menu

View File

@ -20,10 +20,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <AppKit/NSCell.h>
#import <AppKit/NSUserInterfaceValidation.h>
#import <Foundation/NSObject.h>
#import <AppKit/NSUserInterfaceItemIdentification.h>
@class NSMenu, NSImage, NSAttributedString;
@interface NSMenuItem : NSObject <NSCopying, NSValidatedUserInterfaceItem> {
@interface NSMenuItem : NSObject <NSCopying, NSValidatedUserInterfaceItem, NSUserInterfaceItemIdentification> {
NSMenu *_menu;
NSString *_title;
NSAttributedString *_atitle;
@ -44,6 +45,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
NSImage *_onStateImage;
NSImage *_offStateImage;
NSImage *_mixedStateImage;
NSUserInterfaceItemIdentifier _identifier;
}
+ (NSMenuItem *) separatorItem;

View File

@ -18,6 +18,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <Foundation/Foundation.h>
#import <AppKit/NSUserInterfaceItemIdentification.h>
@class NSTableView, NSCell;
@ -27,8 +28,8 @@ enum {
NSTableColumnUserResizingMask = 0x02,
};
@interface NSTableColumn : NSObject {
id _identifier;
@interface NSTableColumn : NSObject <NSUserInterfaceItemIdentification> {
NSUserInterfaceItemIdentifier _identifier;
NSTableView *_tableView;
NSCell *_headerCell;
NSCell *_dataCell;
@ -42,9 +43,8 @@ enum {
NSSortDescriptor *_sortDescriptorPrototype;
}
- initWithIdentifier: identifier;
- (instancetype) initWithIdentifier: (NSUserInterfaceItemIdentifier) identifier;
- identifier;
- (NSTableView *) tableView;
- (id) headerCell;
- (id) dataCell;
@ -57,7 +57,6 @@ enum {
- (BOOL) isEditable;
- (NSUInteger) resizingMask;
- (void) setIdentifier: identifier;
- (void) setTableView: (NSTableView *) tableView;
- (void) setHeaderCell: (NSCell *) cell;
- (void) setDataCell: (NSCell *) cell;

View File

@ -1,3 +1,15 @@
#import <Foundation/NSString.h>
typedef NSString* NSUserInterfaceItemIdentifier;
@protocol NSUserInterfaceItemIdentification
@property(copy) NSUserInterfaceItemIdentifier identifier;
@end
@interface NSObject (NSUserInterfaceItemIdentification)
@property(copy) NSUserInterfaceItemIdentifier userInterfaceItemIdentifier;
@end

View File

@ -25,6 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <AppKit/NSGraphics.h>
#import <AppKit/NSResponder.h>
#import <ApplicationServices/ApplicationServices.h>
#import <AppKit/NSUserInterfaceItemIdentification.h>
@class NSWindow, NSMenu, NSMenuItem, NSCursor, NSClipView, NSPasteboard,
NSTextInputContext, NSImage, NSBitmapImageRep, NSScrollView,
@ -82,7 +83,7 @@ APPKIT_EXPORT const NSNotificationName NSViewGlobalFrameDidChangeNotification;
APPKIT_EXPORT const NSViewFullScreenModeOptionKey NSFullScreenModeApplicationPresentationOptions;
@interface NSView : NSResponder <NSAnimatablePropertyContainer> {
@interface NSView : NSResponder <NSAnimatablePropertyContainer, NSUserInterfaceItemIdentification> {
NSRect _frame;
NSRect _bounds;
NSWindow *_window;
@ -127,6 +128,7 @@ APPKIT_EXPORT const NSViewFullScreenModeOptionKey NSFullScreenModeApplicationPre
CALayerContext *_layerContext;
id __remove;
NSUserInterfaceItemIdentifier _identifier;
}
+ (NSView *) focusView;

View File

@ -1,13 +1,15 @@
#import <AppKit/NSResponder.h>
#import <AppKit/NSUserInterfaceItemIdentification.h>
@class NSView;
@interface NSViewController : NSResponder {
@interface NSViewController : NSResponder <NSUserInterfaceItemIdentification> {
NSString *_nibName;
NSBundle *_nibBundle;
id _representedObject;
NSString *_title;
NSView *_view;
NSUserInterfaceItemIdentifier _identifier;
}
- initWithNibName: (NSString *) name bundle: (NSBundle *) bundle;

View File

@ -25,6 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <AppKit/NSView.h>
#import <ApplicationServices/ApplicationServices.h>
#import <CoreGraphics/CGSubWindow.h>
#import <AppKit/NSUserInterfaceItemIdentification.h>
@class NSView, NSEvent, NSColor, NSColorSpace, NSCursor, NSImage, NSScreen,
NSText, NSTextView, CGWindow, NSPasteboard, NSSheetContext,
@ -145,7 +146,7 @@ APPKIT_EXPORT const NSNotificationName NSWindowWillEnterFullScreenNotification;
APPKIT_EXPORT const NSNotificationName NSWindowWillExitFullScreenNotification;
APPKIT_EXPORT const NSNotificationName NSWindowDidExposeNotification;
@interface NSWindow : NSResponder {
@interface NSWindow : NSResponder <NSUserInterfaceItemIdentification> {
NSRect _frame;
NSWindowStyleMask _styleMask;
NSBackingStoreType _backingType;
@ -241,6 +242,8 @@ APPKIT_EXPORT const NSNotificationName NSWindowDidExposeNotification;
NSRect _savedFrame;
NSPoint _mouseDownLocationInWindow;
NSUserInterfaceItemIdentifier _identifier;
}
@property(class) BOOL allowsAutomaticWindowTabbing;

View File

@ -38,6 +38,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
NSString *_windowTitle;
NSView *windowView;
NSString *_windowAutosave;
NSUserInterfaceItemIdentifier _identifier;
}
@end

View File

@ -29,7 +29,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
@implementation NSWindowTemplate
- initWithCoder: (NSCoder *) coder {
@synthesize identifier = _identifier;
- (instancetype) initWithCoder: (NSCoder *) coder {
if ([coder allowsKeyedCoding]) {
NSKeyedUnarchiver *keyed = (NSKeyedUnarchiver *) coder;
@ -69,6 +71,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
[_windowTitle release];
[windowView release];
[_windowAutosave release];
[_identifier release];
[super dealloc];
}