61 lines
1.7 KiB
Plaintext
61 lines
1.7 KiB
Plaintext
_window = 1
|
|
begin enum 1
|
|
_circularView
|
|
_ovalView
|
|
end enum
|
|
|
|
void local fn BuildWindow
|
|
CGRect r = fn CGRectMake( 0, 0, 400, 400 )
|
|
|
|
window _window, @"Death Star", r, NSWindowStyleMaskTitled + NSWindowStyleMaskClosable + NSWindowStyleMaskMiniaturizable
|
|
WindowSetBackgroundColor( _window, fn ColorBlack )
|
|
|
|
r = fn CGRectMake( 20, 20, 360, 360 )
|
|
subclass view _circularView, r
|
|
|
|
r = fn CGRectMake( 0, 120, 200, 200 )
|
|
subclass view _ovalView, r
|
|
end fn
|
|
|
|
local fn OvalView( tag as NSInteger )
|
|
CGRect r = fn ViewBounds( tag )
|
|
r.size.height *= 0.5
|
|
CFArrayRef cols = @[fn ColorWithWhite(0.8,1),fn ColorBlack]
|
|
BezierPathRef path = fn BezierPathWithOvalInRect( r )
|
|
GradientRef grad = fn GradientWithColors( cols )
|
|
GraphicsContextSaveGraphicsState
|
|
AffineTransformRef tx = fn AffineTransformInit
|
|
NSPoint center = fn CGPointMake( fn CGRectGetMidX(r), fn CGRectGetMidY(r))
|
|
center.x -= 25
|
|
AffineTransformTranslate( tx, center.x, center.y )
|
|
AffineTransformRotateByDegrees( tx, 52 )
|
|
AffineTransformConcat( tx )
|
|
GradientDrawInBezierPath( grad, path, 0.0 )
|
|
GraphicsContextRestoreGraphicsState
|
|
end fn
|
|
|
|
local fn CircularView( tag as NSinteger )
|
|
CGRect r = fn ViewBounds( tag )
|
|
CFArrayRef cols = @[fn ColorWithWhite(0.1,1),fn ColorWhite]
|
|
BezierPathRef path = fn BezierPathWithOvalInRect( r )
|
|
GradientRef grad = fn GradientWithColors( cols )
|
|
GradientDrawInBezierPath( grad, path, 0.0 )
|
|
end fn
|
|
|
|
void local fn DoDialog( ev as long, tag as long )
|
|
select ( ev )
|
|
case _viewDrawRect
|
|
select ( tag )
|
|
case _circularView : fn CircularView( tag )
|
|
case _ovalView : fn OvalView( tag)
|
|
end select
|
|
case _windowWillClose : end
|
|
end select
|
|
end fn
|
|
|
|
on dialog fn DoDialog
|
|
|
|
fn BuildWindow
|
|
|
|
HandleEvents
|