[futurebasic] Re: [FB] Help on Pasteboard.h

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2009 : Group Archive : Group : All Groups

From: Deep <Info@...>
Date: Mon, 05 Jan 2009 10:24:20 +0000
Thanks for the replies and the assistance. I have XCode and had seen the
docs which referred to the data being "CFTypes" but this gave compiler
errors hence posting the question.

With your suggestions, it now compiles without errors after adding the "#if
ndef _DEFINEDINCARBON" part, that was the missing piece of the puzzle.

Thanks for the help, greatly appreciated!

Following now compiles:

#if ndef _DEFINEDINCARBON
#define PasteboardRef as CFTypeRef
#define PasteboardItemID as CFTypeRef
#define PasteboardFlavorFlags as UInt32
#endif

toolbox fn PasteboardCreate( CFStringRef inName, PasteboardRef
*outPasteboard ) = OSStatus
toolbox fn PasteboardClear( PasteboardRef inPasteboard ) = OSStatus
toolbox fn PasteboardPutItemFlavor( PasteboardRef inPasteboard,
PasteboardItemID inItem, CFStringRef inFlavorType, CFDataRef inData,
PasteboardFlavorFlags inFlags ) = OSStatus

_kPasteboardFlavorNoFlags = 0
_kPasteboardFlavorSenderOnly = 1 << 0
_kPasteboardFlavorSenderTranslated = 1 << 1
_kPasteboardFlavorNotSaved = 1 << 2
_kPasteboardFlavorRequestOnly = 1 << 3
_kPasteboardFlavorSystemTranslated = 1 << 8
_kPasteboardFlavorPromised = 1 << 9



local fn AddImageToPasteboardAsPDF

dim osErr as OSStatus
dim @ MyPasteBoard as PasteBoardRef
dim MyPDFData as CFDataRef

// Ignore this for now, this is not a working program yet!!!
// Eventually the MyPDFData will hold the image in PDF format
// that is to be placed on the PasteBoard.
MyPDFData = fn CFDataCreateMutable( _kCFAllocatorDefault, 0 )


osErr = fn PasteboardCreate( fn CFSTR( "com.apple.pasteboard.clipboard" ),
@MyPasteBoard )
long if ( osErr == _noErr )
osErr = fn PasteboardClear( MyPasteBoard )
long if ( osErr == _noErr )
osErr = fn PasteboardPutItemFlavor( MyPasteBoard, 1, fn CFSTR(
"com.adobe.pdf" ), MyPDFData, 0 )
end if
fn CFRelease( MyPasteBoard )
end if

fn CFRelease( MyPDFData )

end fn