[futurebasic] Re: [FB] X metal window

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2003 : Group Archive : Group : All Groups

From: Robert Purves <robert.purves@...>
Date: Sat, 1 Feb 2003 21:57:12 +1300
Ted Spencer wrote:

> While mucking about with one of Dr. P's metal windows, it seems that a 
> CLS erases (to white) the metal except for the dragable strip (and 
> title bar) all around it. Restoring that metal finish eludes me.
> Must it be so?

A simple request, but non-trivial to answer. In the demo, 
DoDrawWindowFrame sends the window a 
{_kEventClassWindow,_kEventWindowDrawFrame} Carbon event, thus causing 
the window to repaint its metal region.

Note that the workaround definition (#if CompilerVersion... ...#endif) 
will not be needed in R8.

'-------------------
'~'A
'                       Runtime : Rntm Appearance.Incl
'                           CPU : Carbon
'                    CALL Req'd : Off
'~'B

/*
How to refill the OS X 10.2 metal window
Robert P.  1 Feb 2003
*/
_kWindowMetalAttribute = 1 << 8

include "Tlbx CarbonEvents.Incl"

#if CompilerVersion <= 0x07000000
// CreateEvent wrongly defined as MacCreateEvent
toolbox fn CreateEvent( CFAllocatorRef inAllocator,  ¬
   UInt32 inClassID, UInt32 kind, EventTime when, ¬
   EventAttributes flags, EventRef * outEvent ) = OSStatus
#endif

local fn DoDrawWindowFrame( wndNum as long )
'~'1
dim as EventRef   @ evt
dim as WindowRef  @ wRef
dim as OSErr        err

Get Window wndNum, wRef
long if wRef
err = fn CreateEvent( 0, _kEventClassWindow, ¬
        _kEventWindowDrawFrame, 0.0, 0, @evt)
long if ( err == _noErr )
err = fn SendEventToEventTarget( evt, fn GetWindowEventTarget( wRef ) )
ReleaseEvent( evt )
end if
end if
end fn

// main program
'~'1
long if ( system( _sysVers ) < 1020 )
stop "Requires OS X 10.2 or higher" : end
end if

appearance window 1, "Metal 1", (10, 60)-(300, 300), ¬
   _kDocumentWindowClass, _kWindowMetalAttribute
cls // make a great white hole

appearance window 2, "Metal 2", (310, 60)-(600, 300), ¬
   _kDocumentWindowClass, _kWindowMetalAttribute
cls // make a great white hole

fn DoDrawWindowFrame( 1 ) // refill window 1 with metal paint

do
HandleEvents
until 0
'-------------------

Robert P.