Robert, I will take a look at this below. Sorry I have been ill and spent the last day in the hospital. regards Steve On Jul 8, 2011, at 4:35 PM, Robert Purves wrote: > > Bernie wrote: > >>> we want these notifications to show temporary alerts, like those shown when you adjust the speaker volume (or when the mouse gets disconnected). >>> >>> The window should be a gray translucent rounded rectangle, containing opaque white text. How can that appearance best be obtained? >> >> This Cocoa version is far from perfect but maybe someone here could improve on it/get it to work in FB: >> http://freegroups.net/groups/fbcocoa/www/Cocoa/Dialogs%20and%20Windows/TempAlert.zip > > Thanks, Bernie. Interesting but, er, complicated. > > In the meantime Steve VV sent some improvements to my original attempt, the most surprising of which makes the window a naked drawer (for its rounded corners). A few more tweaks gave the handsome result below. > > The original request from my collaborator was for "...a cool state-of-the art transparent window, like the volume control functions...". Perhaps he will let us know if the problem is sufficiently well solved: similar in spirit to the system mouse 'Connection Loss' alert, but commendably free of slavish imitation. > > Robert P. > > '------------ > #if compilerversion < 167 > toolbox fn SetWindowAlpha( WindowRef inWindow, CGFloat inAlpha ) = OSStatus > toolbox fn GetWindowAlpha( WindowRef inWindow, CGFloat * outAlpha ) = OSStatus > #endif > > begin record TempAlertRec > dim as WindowRef w > dim as ProcessSerialNumber frontPSN > end record > > _taWndNum = 135762 // arbitrary unique value > _taHeight = 140 : _taWidth = 250 > _taBottomMargin = 60 > > > local fn TemporaryAlertHandler( theTimer as EventLoopTimerRef, userData as pointer ) > '~'1 > dim as ^TempAlertRec info : info = userData > dim as CGFloat alpha > > fn GetWindowAlpha( info.w, @alpha ) > long if ( alpha < 0.1 ) > fn RemoveEventLoopTimer( theTimer ) > window close _taWndNum > fn SetFrontProcess( info.frontPSN ) // restore original process > free( info ) > xelse > fn SetWindowAlpha( info.w, alpha - 0.025 ) // fade > end if > end fn > > > local fn TemporaryAlert( msg as Str255, explanation as Str255 ) > '~'1 > dim as ^TempAlertRec info > dim as long height, wdth > dim as Rect r > dim as ProcessSerialNumber ourPSN > dim as ControlFontStyleRec cfs > dim as RGBColor fore, back > > info = fn malloc( sizeof( TempAlertRec ) ) > fn GetFrontProcess( @info.frontPSN ) // save original process > height = system( _scrnHeight ) : wdth = system( _scrnWidth ) > SetRect( @r, (wdth - _taWidth)/2, height - _taHeight - _taBottomMargin, (wdth + _taWidth)/2, height - _taBottomMargin ) > appearance window _taWndNum,, @r, _kDrawerWindowClass, _kWindowNoShadowAttribute > get window _taWndNum, info.w > fn SetWindowAlpha( info.w, 0.93 ) > SetRect( @r, 0, 0, _taWidth, _taHeight/2 ) > appearance button 1,,,,,,@r, _kControlStaticTextProc > fore.red = -1 : fore.green = -1 : fore.blue = -1 // white > back.red = 28000 : back.green = 28000 : back.blue = 28000 // gray > cfs.flags = _kControlUseFaceMask _kControlUseSizeMask _kControlUseJustMask _kControlUseForeColorMask _kControlUseBackColorMask > cfs.size = 17 : cfs.style = _boldBit% : cfs.just = _teCenter : cfs.foreColor = fore : cfs.backColor = back > fn SetButtonFontStyle( 1, cfs ) > fn SetButtonTextString( 1, chr$( 13 ) + msg ) > SetRect( @r, 0, _taHeight/2, _taWidth, _taHeight ) > appearance button 2,,,,,,@r, _kControlStaticTextProc > cfs.style = 0 > fn SetButtonFontStyle( 2, cfs ) > fn SetButtonTextString( 2, explanation ) > fn InstallEventLoopTimer( fn GetMainEventLoop(), 3.0, 0.02, @fn TemporaryAlertHandler, #info, 0 ) > ourPSN.lowLongOfPSN = _kCurrentProcess : ourPSN.highLongOfPSN = 0 > fn SetFrontProcess( @ourPSN ) // ensure we are front > end fn > > > fn TemporaryAlert( "Alas!", "Something happened" ) > HandleEvents > '------------ > > > -- > To unsubscribe, send ANY message to: futurebasic-unsubscribe@... > To access the list archives, go to: http://freegroups.net/groups/futurebasic/ >