SameBoy/HexFiend/HFPasteboardOwner.h

52 lines
2.3 KiB
C
Raw Permalink Normal View History

//
// HFPasteboardOwner.h
// HexFiend_2
//
// Copyright 2008 ridiculous_fish. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@class HFByteArray;
extern NSString *const HFPrivateByteArrayPboardType;
@interface HFPasteboardOwner : NSObject {
@private
HFByteArray *byteArray;
NSPasteboard *pasteboard; //not retained
unsigned long long dataAmountToCopy;
NSUInteger bytesPerLine;
BOOL retainedSelfOnBehalfOfPboard;
BOOL backgroundCopyOperationFinished;
BOOL didStartModalSessionForBackgroundCopyOperation;
}
/* Creates an HFPasteboardOwner to own the given pasteboard with the given types. Note that the NSPasteboard retains its owner. */
+ (id)ownPasteboard:(NSPasteboard *)pboard forByteArray:(HFByteArray *)array withTypes:(NSArray *)types;
- (HFByteArray *)byteArray;
/* Performs a copy to pasteboard with progress reporting. This must be overridden if you support types other than the private pboard type. */
- (void)writeDataInBackgroundToPasteboard:(NSPasteboard *)pboard ofLength:(unsigned long long)length forType:(NSString *)type trackingProgress:(id)tracker;
/* NSPasteboard delegate methods, declared here to indicate that subclasses should call super */
- (void)pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type;
- (void)pasteboardChangedOwner:(NSPasteboard *)pboard;
/* Useful property that several pasteboard types want to know */
@property (nonatomic) NSUInteger bytesPerLine;
/* For efficiency, Hex Fiend writes pointers to HFByteArrays into pasteboards. In the case that the user quits and relaunches Hex Fiend, we don't want to read a pointer from the old process, so each process we generate a UUID. This is constant for the lifetime of the process. */
+ (NSString *)uuid;
/* Unpacks a byte array from a pasteboard, preferring HFPrivateByteArrayPboardType */
+ (HFByteArray *)unpackByteArrayFromPasteboard:(NSPasteboard *)pasteboard;
/* Used to handle the case where copying data will require a lot of memory and give the user a chance to confirm. */
- (unsigned long long)amountToCopyForDataLength:(unsigned long long)numBytes stringLength:(unsigned long long)stringLength;
/* Must be overridden to return the length of a string containing this number of bytes. */
- (unsigned long long)stringLengthForDataLength:(unsigned long long)dataLength;
@end