[futurebasic] Re: [FB] How to create pdf with specified rectangle under program control

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

From: Deep <Info@...>
Date: Tue, 26 May 2009 21:42:56 +0100
Anyone know why FB4.4.3 cannot see toolbox functions declared in the source
code?

Domokos is right, the error message appears in FB4.4.3 saying missing
toolbox functions. This means that although the toolbox functions are
defined in the source code, the FB4 compiler does not see the API which is
strange as they should appear in 10.5 even under Rosetta.

Anyone know what is happening here? Or should this be a hint to Domokos to
move to FB5/FBtoC development?


> From: Domokos Vekas <domika@...>
> Reply-To: <futurebasic@...>
> Date: Tue, 26 May 2009 19:42:43 +0200
> To: <futurebasic@...>
> Subject: Re: [FB] How to create pdf with specified rectangle under program
> control
> 
> Deep,
> 
> I am using an Intel iMac running Leopard (10.5.6).
> On this computer, your code is fine with FB5/FBtoC.
> I modified it slightly for use with FB4.4.3 without FBtoC (changing
> the syntax of fn CGRectMake or using FSSpec for example), but then it
> produces the strange message (toolbox items not available) when I try
> to run it, on the same iMac.
> 
> I include below the modified demo, hoping that the problem, not easy
> for me, could be detected with your help.
> 
> Domokos
> 
> // Begin Sample Code -
> // slightly modified, intended to run in FB4 (without FBtoC)
> 
> include "Rntm Appearance.incl"
> include "Tlbx CoreGraphics.incl"'d
> include "Tlbx HIView.incl"
> 
> toolbox fn CGPDFContextCreateWithURL( CFURLRef url, const CGRect
> *mediaBox, CFDictionaryRef auxiliaryInfo ) = CGContextRef
> toolbox CGPDFContextBeginPage( CGContextRef context, CFDictionaryRef pageInfo
> )
> toolbox CGPDFContextEndPage( CGContextRef context )
> 
> /* this fn is from RP's example file:
> Given an FSSpec, create the equivalent CFURL
> */
> local mode
> local fn CreateCFURLFromFSSpec( fs as ^FSSpec ) as CFURLRef
> '~'1
> dim as FSRef folderFSRef
> dim as FSSpec folderFSSpec
> dim as CFURLRef baseCFURL, theCFURL
> dim as CFStringRef fileName
> dim as OSErr err
> 
> theCFURL = 0
> err = fn FSMakeFSSpec( fs.vRefNum, fs.parID, "", @folderFSSpec )
> long if ( err == _noErr )
> err = fn FSpMakeFSRef( folderFSSpec, @folderFSRef )
> long if ( err == _noErr )
> baseCFURL = fn CFURLCreateFromFSRef( 0, folderFSRef )
> long if ( baseCFURL )
> fileName = fn CFStringCreateWithPascalString( ¬
>  0, fs.name, _kCFStringEncodingMacRoman )
> theCFURL = fn CFURLCreateCopyAppendingPathComponent( ¬
>  0, baseCFURL, fileName, _false )
> CFRelease( fileName )
> CFRelease( baseCFURL )
> end if
> end if
> end if
> end fn = theCFURL
> 
> local fn MakeMyPDF
> dim @ myCFURL as CFURLRef
> dim as FSSpec fs'domi
> dim myRect as CGRect
> dim myContext as CGContextRef
> dim myX as double
> dim myY as double
> dim myH as double
> dim myW as double
> 
> dim wndwidth as long
> dim wndheight as long
> 
> myCFURL = 0
> 
> wndwidth = 500
> wndheight = 300
> 
> myX = 0.0
> myY = 0.0
> myW = wndwidth
> myH = wndheight
> 'myRect = fn CGRectMake( myX, myY, myW, myH )
> fn CGRectMake( myRect, myX, myY, myW, myH )'d
> 
> 'long if ( files$( _CFURLRefSave, "Save PDF File As?", "My Sample
> PDFFile.pdf", myCFURL ) )
> 'long if ( myCFURL )
> long if ( files$( _FSSpecSave, "Save pdf as...", "untitled.pdf", fs ) != "" )
> long if ( fs )
> myCFURL = FN CreateCFURLFromFSSpec( fs )
> myContext = fn CGPDFContextCreateWithURL( myCFURL, @myRect, 0 )
> 
> fn CGPDFContextBeginPage( myContext, 0 )
> 
> // Draw using CG Quartz here:
> 
> // Set line colour to black
> fn CGContextSetRGBStrokeColor( myContext, 0, 0, 1, 1 )
> 
> // Draw Rectangle border
> fn CGContextStrokeRectWithWidth( myContext, myRect, 10 )
> 
> // Draw curve
> fn CGContextSetLineWidth( myContext, 5 )
> fn CGContextSetRGBStrokeColor( myContext, 1, 0, 1, 1 )
> fn CGContextMoveToPoint( myContext, 250, 50 )
> fn CGContextAddArcToPoint( myContext, 250, 250, 300, 250, 50 )
> fn CGContextStrokePath( myContext )
> 
> // Draw circle
> fn CGContextSetLineWidth( myContext, 5.0 )
> fn CGContextSetRGBStrokeColor( myContext, 1, 0, 0, 1 )
> // Draw counterclockwise with start at 0 and end at 2*Pi
> fn CGContextAddArc( myContext, 300, 150, 30 , 0, 8.0 * ATN(1.0), 0 )
> fn CGContextStrokePath( myContext )
> 
> // Draw rectangle with transparency
> fn CGContextSetRGBFillColor( myContext, 0.1, 0.8, 0.3, 0.5 )
> 'myRect = fn CGRectMake( 200, 150, 150, 150 )
> fn CGRectMake( myRect, 200, 150, 150, 150 )
> 
> fn CGContextFillRect( myContext, myRect )
> 
> 
> fn CGPDFContextEndPage( myContext )
> 
> fn CGContextRelease( myContext )
> 
> CFRelease( myCFURL )
> 
> end if
> 
> end if
> 
> end fn
> 
> 
> fn MakeMyPDF
> 
> do
> handleevents
> until gFBquit
> 
> // End Sample Code
> 
> 
> 
> 
> 2009/5/25 Deep <Info@...>:
>> 
>> Domokos,
>> 
>> Your application should check you are running 10.4 or later before reaching
>> the CGPDF... functions in your source code as they are only available in
>> 10.4 or later.
>> 
>> Are you using 10.3 or earlier?
>> 
>> Deep
>> 
>> 
>> 
>>> From: Domokos Vekas <domika@...>
>>> Reply-To: <futurebasic@...>
>>> Date: Mon, 25 May 2009 23:38:59 +0200
>>> To: <futurebasic@...>
>>> Subject: Re: [FB] How to create pdf with specified rectangle under program
>>> control
>>> 
>>> Deep, thank you for the FB5/FBtoC demo (and many thanks to Steve Van
>>> Voorst who sent me offlist a similar example file). It's exactly what
>>> I need, but it only works in FB5.
>>> 
>>> My only problem is FB4 compatibility, my major project (about 50,000
>>> lines) is still in FB4 (after a several months long conversion from
>>> FB2).
>>> 
>>> I changed some lines in order to avoid the error messages when in FB4,
>>> but I got this last message:
>>> The following toolbox items are not available on this computer. This
>>> program may crash if you continue.
>>> CGPDFContextBeginPage
>>> CGPDFContextCreateWithURL
>>> CGPDFContextEndPage.
>>> 
>>> I would need some suggestions on this. Thank you for any help.
>>> Domokos
>>> 
>>> 2009/5/25 Deep <Info@...>:
>>>> 
>>>> Following works in 10.4 onwards:
>>>> 
>>>> 
>>>> // Begin Sample Code - Requires FB5 with FBtoC
>>>> 
>>> 
>>> --
>>> To unsubscribe, send ANY message to: futurebasic-unsubscribe@...
>> 
>> --
>> To unsubscribe, send ANY message to: futurebasic-unsubscribe@...
>> 
>> 
> 
> --
> To unsubscribe, send ANY message to: futurebasic-unsubscribe@...
>