[futurebasic] Re: [FB] Text Over Movie

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2016 : Group Archive : Group : All Groups

From: Bernie <bernie.fblist@...>
Date: Tue, 29 Nov 2016 21:34:50 +0000
Eugen wrote:

> 
> Thank you, Brian and Bernie,
> but I don’t understant how to use this in my example.
> I tried, but it does’n work. I never met or used an overlay window.
> Is it transparent ? What window attributes has ?
> 

Quick example.

You’re going to have to pick out the relevant bits and adjust window coordinates.

// ---------------
include "Tlbx HIView.incl"

// MacWindows.h
#if ndef _DEFINEDINCARBON
#define WindowGroupRef as WindowRef
toolbox fn GetWindowGroupOfClass( WindowClass windowClass ) = WindowGroupRef
toolbox fn SetWindowGroup(WindowRef inWindow, WindowGroupRef inNewGroup) = OSStatus
#endif

_wMain = 1
_wOverlay = 2
begin enum 1
_cStaticText
end enum

local fn MyWindowBoundsChangedHandler( nextHandler as EventHandlerCallRef, theEvent as EventRef, userData as pointer ) as OSStatus
'~'1
dim as Rect   r

fn GetEventParameter( theEvent, _kEventParamCurrentBounds, _typeQDRectangle, NULL, sizeof(r), NULL, @r )
r.top += 40 = r.bottom = r.top + 40
window _wOverlay,, @r
end fn = _noErr

void local fn BindToParent( c as ControlRef, left as Boolean, top as Boolean, right as Boolean, bottom as Boolean )
'~'1
dim as HILayoutInfo   layout

layout.version = _kHILayoutInfoVersionZero
fn HIViewGetLayoutInfo( c, @layout )
if ( top ) then layout.binding.top.kind = _kHILayoutBindTop
if ( left ) then layout.binding.left.kind = _kHILayoutBindLeft
if ( bottom ) then layout.binding.bottom.kind = _kHILayoutBindBottom
if ( right ) then layout.binding.right.kind = _kHILayoutBindRight
fn HIViewSetLayoutInfo( c, @layout )
end fn

void local fn BuildWindows
'~'1
dim as Rect                  r
dim as WindowAttributes      wa
dim as RGBColor              rgb
dim as ControlFontStyleRec   cfs
dim as EventTypeSpec         ev
dim as WindowRef             w
dim as WindowGroupRef        group

wa =  _kWindowCloseBoxAttribute
wa += _kWindowCollapseBoxAttribute
wa += _kWindowFullZoomAttribute
wa += _kWindowResizableAttribute
wa += _kWindowLiveResizeAttribute
wa += _kWindowCompositingAttribute

SetRect( r, 350, 180, 830, 540 )
appearance window -_wMain, @"Main", @r, _kDocumentWindowClass, wa
rgb.red = 0 : rgb.green = 0 : rgb.blue = 0
fn SetWindowBackground( rgb, _zTrue )
ev.eventClass = _kEventClassWindow
ev.eventKind = _kEventWindowBoundsChanged
fn InstallEventHandler( fn GetWindowEventTarget( window(_wndRef) ), @fn MyWindowBoundsChangedHandler, 1, @ev, NULL, NULL )

SetRect( r, 350, 180, 830, 260 )
appearance window -_wOverlay,, @r, _kOverlayWindowClass, _kWindowCompositingAttribute

SetRect( r, 20, 20, 460, 66 )
appearance button _cStaticText,,,,, @"Text in overlay window", @r, _kControlStaticTextProc
cfs.flags = _kControlUseSizeMask + _kControlUseJustMask + _kControlUseForecolorMask
cfs.size = 20
cfs.just = _teJustCenter
cfs.forecolor.red = 65535 : cfs.forecolor.green = 65535 : cfs.forecolor.blue = 65535
fn SetButtonFontStyle( _cStaticText, cfs )
fn BindToParent( button&(_cStaticText), _zTrue, _zTrue, _zTrue, _false )
get window _wOverlay, @w
group = fn GetWindowGroupOfClass( _kFloatingWindowClass )
fn SetWindowGroup( w, group )

window _wMain
window _wOverlay
end fn

fn BuildWindows()

RunApplicationEventLoop()