[futurebasic] Re: [FB] About Box

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 2007 : Group Archive : Group : All Groups

From: Brian Stevens <bstevens33@...>
Date: Tue, 17 Apr 2007 21:49:09 -0700
On Apr 17, 2007, at 9:22 PM, Brian Heibert wrote:

> Hi,
>
> I want to use the OS X standard about box
> How do I  implement a about box in FB that either is the standard  
> one or looks like it?
>
> My problem with the one included with FB in the Scripts is that it  
> has a edit field with a list of credits and I don't want that I  
> want the small os x dialog box
>
> I am using menu resources, otherwise I'd just leave the one alone  
> that FB  provides
> but I can't because I got a apple menu resource
>
> Brian
>
> --
> To unsubscribe, send ANY message to: futurebasic- 
> unsubscribe@...
>

Use HIAboutBox(). By default HIAboutBox uses plst entries to fill in  
the information - which is easy and works. Alternatively, it is  
possible to override all entries dynamically at runtime by getting a  
pointer to the dictionary key callbacks, CFSTRing your strings into a  
CSStringRef array, and feeding the array to CFDicionaryCreate. The  
second example was taken directly from an example by either Herbie,  
RP or Bernie ( I don't remember, sorry guys).

This version uses the values in the plst:

toolbox fn HIAboutBox( CFDictionaryRef inOptions ) = OSStatus
dim as OSStatus ignore
ignore = fn HIAboutBox(0)

========================

This version used the values supplied:

toolbox fn HIAboutBox( CFDictionaryRef inOptions ) = OSStatus
toolbox fn CFDictionaryCreate( CFAllocatorRef allocator, ¬
                                ptr keys, ptr values, ¬
                                CFIndex numValues, ¬
                                ptr keyCallBacks, ¬
                                ptr valueCallBacks) = CFDictionaryRef

toolbox CFDictionaryGetKeysAndValues( CFDictionaryRef dict, ptr keys,  
ptr values)
toolbox fn CFBundleGetDataPointerForName( CFBundleRef bundle, ¬
                          CFStringRef symbolName ) = pointer



local fn DoAboutMenu
'~'1
dim as CFStringRef        keys(3), values(3)
dim as CFDictionaryRef    dict
dim as OSStatus           ignore
dim as pointer            keyCallBacks
begin globals
dim as CFBundleRef        sCoreFoundBndl
end globals

long if ( sCoreFoundBndl == 0 )
sCoreFoundBndl = fn CreateBundleForFramework 
( "CoreFoundation.framework" )
end if
// data pointer from bundle and name of extern const
keyCallBacks = fn CFBundleGetDataPointerForName( sCoreFoundBndl, ¬
   fn CFSTR( "kCFCopyStringDictionaryKeyCallBacks" ) )

select menu(_menuID)
case _appleMenu

keys(0)   = fn CFSTR( "HIAboutBoxName" )
values(0) = fn CFSTR( "MGP - My Great Program" )

keys(1)   = fn CFSTR( "HIAboutBoxVersion" )
values(1) = fn CFSTR( "version 1.0 - © 2007" )

keys(2)   = fn CFSTR( "HIAboutBoxDescription" )
values(2) = fn CFSTR( "web page: www.myWebPage" )

keys(3)   = fn CFSTR( "HIAboutBoxCopyright" )
values(3) = fn CFSTR( "Icon courtesy someone with talent" )

dict = fn CFDictionaryCreate( 0, @keys(0), @values(0), 4,  
keyCallBacks, 0 )
ignore = fn HIAboutBox( dict )
CFRelease( dict )
end select
end fn