_wndW = 600 _wndH = 600 _window = 1 begin enum 1 _sliderBtn _sliderValue _cWell _pixelView _quitBtn end enum void local fn ViewDrawRect CGRect viewRect, dotRect CGContextRef ctx = fn GraphicsContextCurrentCGContext viewRect = fn ViewBounds( _pixelView ) long sliderValue = fn ControlIntegerValue( _sliderBtn ) CGContextSaveGState( ctx ) CGContextSetLineWidth(ctx, 1.0) CGContextSetRGBStrokeColor( ctx, 0.0, 0.0, 0.0, 1.0 ) CGContextStrokeRect( ctx, viewRect ) dotRect.origin.x = viewRect.size.width/2 - sliderValue dotRect.origin.y = viewRect.size.height/2 - sliderValue dotRect.size.width = 2 * sliderValue dotRect.size.height = 2 * sliderValue ColorRef col = fn ColorWellColor(_cWell) CGColorRef myColor = fn ColorCGColor( col ) CGContextSetStrokeColorWithColor( ctx, myColor ) CGContextStrokeEllipseInRect( ctx, dotRect ) CGContextRestoreGState( ctx ) end fn void local fn BuildWindow window 1, @"DotView", ( 0, 0, _wndW, _wndH ) view subclass _pixelView, ( 0, 0, _wndH, _wndW) ColorRef myColor = fn ColorWithRGB( 1.0, 0.0, 0.0, 1.0 ) colorwell _cWell,, myColor, ( 30, 30, 50, 30 ) ViewAddSubview( _pixelView, _cWell ) slider _sliderBtn,, 75, ( 170, 30, 250, 20 ), 1, 240 ControlSetContinuous( _sliderBtn, YES ) ViewAddSubview( _pixelView, _sliderBtn ) textlabel _sliderValue, @"75", ( 430, 35, 36, 17 ) ControlSetAlignment( _sliderValue, NSTextAlignmentCenter ) ViewAddSubview( _pixelView, _sliderValue ) button _quitBtn, , , @"Q", (_wndW - 50, 10, 40, 40),, NSBezelStyleCircular ControlSetAction( _quitBtn, @"terminate:" ) end fn void local fn DoDialog( ev as long, tag as long ) select ( ev ) case _btnClick select (tag) case _cWell : ViewSetNeedsDisplay( _pixelView ) case _sliderBtn ControlTakeIntegerValueFrom( _sliderValue, _sliderBtn ) ViewSetNeedsDisplay( _pixelView ) end select case _viewDrawRect select ( tag ) case _pixelView : fn ViewDrawRect end select end select end fn on dialog fn DoDialog fn BuildWindow HandleEvents