Bernie wrote:
> Messing about with HITextViews, I stumbled on an Apple demo which
> creates a transparent window.
> FB translation: <http://homepage.ntlworld.com/bernie.w/
> TransparentWindow.zip>
A stunning demo of modern programming, with a nice scrolling text box
thrown in for good measure.
> Although I have no intention of ever using one of these things,
> I'm curious if it's possible to eliminate the horrible dirty text
> shadow.
You can eliminate the fixed shadows deriving from the initial text by
letting the window draw before you put text into it. (A window
calculates its shadow from all of its opaque parts when first asked
to draw). Split off a separate function TxtViewLoadText from your
original BuildUI, and call it after the window is drawn:
local fn TxtViewLoadText( txtView as HIViewRef )
'~'1
dim as CFURLRef url
dim as TXNObject @ txnObj
dim as OSStatus ignore
url = fn CFBundleCopyResourceURL( fn CFBundleGetMainBundle(), fn CFSTR
("dummy.rtf"), 0, 0 )
long if (url )
txnObj = fn HITextViewGetTXNObject( txtView )
ignore = fn TXNReadFromCFURL( txnObj, _kTXNStartOffset,
_kTXNEndOffset, 0, url, #0 )
CFRelease( url )
end if
end fn
local fn BuildUI
'~'1
dim as IBNibRef @ nib
dim as WindowRef @ w
dim as HIViewRef @ txtView
long if ( fn CreateNibReference( fn CFSTR( "main" ), @nib ) == _noErr )
call SetMenuBarFromNib( nib, fn CFSTR( "MenuBar" ) )
call CreateWindowFromNib( nib, fn CFSTR( "Window" ), @w )
fn InstallTransparentWindowHandlers( w )
long if ( fn HIViewFindByID( fn HIViewGetRoot( w ), 0, 1, @txtView )
== _noErr )
fn TxtViewSetAlpha( txtView, 0.25 )
fn TxtViewSetMargins( txtView, 5, 0, 0, 0 )
end if
ShowWindow( w )
DisposeNibReference( nib )
end if
end fn = txtView
dim as HIViewRef txtView
txtView = fn BuildUI()
HandleEvents // allow window to draw
fn TxtViewLoadText( txtView ) // then load the text
RunApplicationEventLoop()
There's a different way to combat the shadow. In Interface Builder:
Robert P.
Attachments: