uses ../GDIWindow/window


sys sxMouse,syMouse
sys wx=640,wy=480
sys fx=10,fy=20,fw=400
Window "Controls",wx,wy,2
Font fx,fy,fw,"arial"



Sub ClsColor(sys color)
sys iBrush = CreateSolidBrush color
SelectObject bHdc, iBrush
Rectangle bHdc, 0, 0, Width, Height
DeleteObject iBrush
End Sub


Sub Oval(sys x,y,ra,rb, color)
sys iBrush
iBrush = CreateSolidBrush color
SelectObject bHdc, iBrush
Ellipse bHdc,x,y,ra+x,rb+y
DeleteObject iBrush
End Sub


Sub Line(sys x,y,a,b,w, color)
sys iPen,hPen
iPen = CreatePen PS_SOLID,w,color
SelectObject bHdc, iPen
MoveToEx bHdc,x,y,Byval 0
LineTo bHdc,a,b
DeleteObject iPen
hPen = GetStockObject(DC_PEN)
SelectObject bHdc, hPen
End Sub


Sub RoundBox(sys x,y,w,h,r1,r2, color)  
sys iBrush
iBrush = CreateSolidBrush color
SelectObject bHdc, iBrush
RoundRect bHdc,x,y,w+x,h+y,r1,r2
DeleteObject iBrush
End Sub


Sub FillBox(sys x,y,w,h, color)  
sys iBrush
iBrush = CreateSolidBrush color
SelectObject bHdc, iBrush
Rectangle bHdc,x,y,w+x,h+y
DeleteObject iBrush
End Sub


Sub Text( sys x, y, string txt, sys color) 
SetTextColor bHdc, color
TextOut bHdc,x,y,txt,Len(txt)
End Sub


sub CreateImageRect(sys *dc,*bm,w,h)
bm=CreateCompatibleBitmap sys_hdc, w,h
if bm then
  dc=CreateCompatibleDC sys_hdc
  SelectObject dc,bm
end if
end sub
  '
sub DeleteImage(sys *dc,*bm)
if dc then
  DeleteObject bm
  DeleteDC dc
  bm=0 : dc=0
end if
end sub


macro CopyImageToScene(dc,x,y,w,h)
if dc
  'TransparentBlt bHdc,x,y,w,h,dc,0,0,w,h,0
  'SetStretchBltMode bHdc,sys_mode  
  StretchBlt bHdc,x,y,w,h,dc,0,0,w,h,0xCC0020
end if
end macro


macro SetPixel(dc,x,y,c)
SetPixelV dc,x,y,c
end macro


sub FlatColor(sys dc,w,h,c)
sys px,py
if not dc then exit sub
for py=0 to <h
  for px=0 to <w
  SetPixel dc,px,py,c
  next
next
end sub


Sub CopyPixelsToImage(sys dc,p,w,h)
sys x,y,q=p
for y=0 to <h
  for x=0 to <w
    SetPixel dc,x,y,*q
    q+=4
  next
next
end sub
