[futurebasic] Re: [FB] Metal Sheet window

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 2005 : Group Archive : Group : All Groups

From: Robert Purves <robert.purves@...>
Date: Thu, 21 Jul 2005 23:23:25 +1200
Bernie wrote:

> Brian S wrote:
>
>> The Apple guidelines say using a metal sheet is not necessary just  
>> because the main window is metal. However, I've seen several  
>> applications that use metal sheets with metal main windows. Does  
>> anyone have the combination of constants to create a metal sheet  
>> window?
>>
> I wonder if HIThemeApplyBackground() or HIThemeDrawBackground()  
> along with _kThemeBackgroundMetal will do it? Unfortunately, they  
> use those CGContextRef thingies and I wouldn't know how to go about  
> it... but I'll bet I know a man who would  :-)
>

Pretty ugly, but the sheet does get metallized eventually.

Robert P.

'----------------
include "Tlbx HIView.incl"
include "Tlbx CoreGraphics.incl"

_kThemeBackgroundMetal = 6

begin record HIThemeBackgroundDrawInfo
dim as UInt32               version // always 0
dim as ThemeDrawState       state // always _kThemeStateActive
dim as ThemeBackgroundKind  kind
end record

#define HIThemeOrientation as UInt32
_kHIThemeOrientationNormal   = 0
_kHIThemeOrientationInverted = 1

toolbox fn HIThemeDrawBackground( const HIRect *inBounds, const  
HIThemeBackgroundDrawInfo *inDrawInfo, CGContextRef inContext,  
HIThemeOrientation inOrientation ) = OSStatus //  
AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER

begin enum 1
_myMainWindow
_mySheetWindow
end enum

local fn DoDialog
'~'1
dim as long           evt
dim as OSStatus       err
dim as HIRect         bounds
dim as CGContextRef @ ctx
dim as HIThemeBackgroundDrawInfo info
dim as WindowRef @ parentW, sheetW

evt = dialog( 0 )

select evt
case _btnClick
select window( _activeWnd )

case _myMainWindow
get window _myMainWindow, parentW
get window _mySheetWindow, sheetW
err = fn ShowSheetWindow( sheetW, parentW ) // show the sheet

window output _mySheetWindow

info.version = 0
info.state  = _kThemeStateActive
info.kind   = _kThemeBackgroundMetal
bounds.origin.x = 0
bounds.origin.y = 0
bounds.size.width  = 400
bounds.size.height = 150

err = fn QDBeginCGContext( window( _wndPort ), @ctx )
err = fn HIThemeDrawBackground( bounds, info, ctx,  
_kHIThemeOrientationInverted )
err = fn QDEndCGContext( window( _wndPort ), @ctx )

case _mySheetWindow
get window _mySheetWindow, sheetW
err = fn HideSheetWindow( sheetW )
window output _myMainWindow
end select

end select
end fn

long if ( system( _sysVers ) < 1030 )
shutdown "HIThemeDrawBackground requires OS X 10.3 or higher"
end if
// Make the sheet window, invisibly
appearance window -_mySheetWindow ,"", (0,0)-(400,150),  
_kSheetWindowClass, _kWindowNoAttributes
button 1, 1, "OK",  (20,110)-(380,130)
// Make the main window
appearance window _myMainWindow,, (150,100)-(450,600),  
_kDocumentWindowClass, _kWindowStandardDocumentAttributes
button 1, 1, "Oops!", (100,270)-(200,485)

on dialog fn DoDialog
do
HandleEvents
until 0
'----------------