#if __GLASGOW_HASKELL__ >= 709
{-# LANGUAGE Safe #-}
#else
{-# LANGUAGE Trustworthy #-}
#endif
module Graphics.Win32.GDI.Graphics2D
where
import System.Win32.Types
import Graphics.Win32.GDI.Types
import Foreign
#include "windows_cconv.h"
moveToEx :: HDC -> Int32 -> Int32 -> IO POINT
moveToEx :: HDC -> Int32 -> Int32 -> IO POINT
moveToEx HDC
dc Int32
x Int32
y =
forall a. (Ptr POINT -> IO a) -> IO a
allocaPOINT forall a b. (a -> b) -> a -> b
$ \ Ptr POINT
p_point -> do
String -> IO Bool -> IO ()
failIfFalse_ String
"MoveToEx" forall a b. (a -> b) -> a -> b
$ HDC -> Int32 -> Int32 -> Ptr POINT -> IO Bool
c_MoveToEx HDC
dc Int32
x Int32
y Ptr POINT
p_point
Ptr POINT -> IO POINT
peekPOINT Ptr POINT
p_point
foreign import WINDOWS_CCONV unsafe "windows.h MoveToEx"
c_MoveToEx :: HDC -> Int32 -> Int32 -> Ptr POINT -> IO Bool
lineTo :: HDC -> Int32 -> Int32 -> IO ()
lineTo :: HDC -> Int32 -> Int32 -> IO ()
lineTo HDC
dc Int32
x Int32
y =
String -> IO Bool -> IO ()
failIfFalse_ String
"LineTo" forall a b. (a -> b) -> a -> b
$ HDC -> Int32 -> Int32 -> IO Bool
c_LineTo HDC
dc Int32
x Int32
y
foreign import WINDOWS_CCONV unsafe "windows.h LineTo"
c_LineTo :: HDC -> Int32 -> Int32 -> IO Bool
polyline :: HDC -> [POINT] -> IO ()
polyline :: HDC -> [POINT] -> IO ()
polyline HDC
dc [POINT]
points =
forall a. [POINT] -> (Ptr POINT -> Int -> IO a) -> IO a
withPOINTArray [POINT]
points forall a b. (a -> b) -> a -> b
$ \ Ptr POINT
pount_array Int
npoints ->
String -> IO Bool -> IO ()
failIfFalse_ String
"Polyline" forall a b. (a -> b) -> a -> b
$ HDC -> Ptr POINT -> Int -> IO Bool
c_Polyline HDC
dc Ptr POINT
pount_array Int
npoints
foreign import WINDOWS_CCONV unsafe "windows.h Polyline"
c_Polyline :: HDC -> Ptr POINT -> Int -> IO Bool
polylineTo :: HDC -> [POINT] -> IO ()
polylineTo :: HDC -> [POINT] -> IO ()
polylineTo HDC
dc [POINT]
points =
forall a. [POINT] -> (Ptr POINT -> Int -> IO a) -> IO a
withPOINTArray [POINT]
points forall a b. (a -> b) -> a -> b
$ \ Ptr POINT
pount_array Int
npoints ->
String -> IO Bool -> IO ()
failIfFalse_ String
"PolylineTo" forall a b. (a -> b) -> a -> b
$ HDC -> Ptr POINT -> Int -> IO Bool
c_PolylineTo HDC
dc Ptr POINT
pount_array Int
npoints
foreign import WINDOWS_CCONV unsafe "windows.h PolylineTo"
c_PolylineTo :: HDC -> Ptr POINT -> Int -> IO Bool
polygon :: HDC -> [POINT] -> IO ()
polygon :: HDC -> [POINT] -> IO ()
polygon HDC
dc [POINT]
points =
forall a. [POINT] -> (Ptr POINT -> Int -> IO a) -> IO a
withPOINTArray [POINT]
points forall a b. (a -> b) -> a -> b
$ \ Ptr POINT
pount_array Int
npoints ->
String -> IO Bool -> IO ()
failIfFalse_ String
"Polygon" forall a b. (a -> b) -> a -> b
$ HDC -> Ptr POINT -> Int -> IO Bool
c_Polygon HDC
dc Ptr POINT
pount_array Int
npoints
foreign import WINDOWS_CCONV unsafe "windows.h Polygon"
c_Polygon :: HDC -> Ptr POINT -> Int -> IO Bool
polyBezier :: HDC -> [POINT] -> IO ()
polyBezier :: HDC -> [POINT] -> IO ()
polyBezier HDC
dc [POINT]
points =
forall a. [POINT] -> (Ptr POINT -> Int -> IO a) -> IO a
withPOINTArray [POINT]
points forall a b. (a -> b) -> a -> b
$ \ Ptr POINT
pount_array Int
npoints ->
String -> IO Bool -> IO ()
failIfFalse_ String
"PolyBezier" forall a b. (a -> b) -> a -> b
$ HDC -> Ptr POINT -> Int -> IO Bool
c_PolyBezier HDC
dc Ptr POINT
pount_array Int
npoints
foreign import WINDOWS_CCONV unsafe "windows.h PolyBezier"
c_PolyBezier :: HDC -> Ptr POINT -> Int -> IO Bool
polyBezierTo :: HDC -> [POINT] -> IO ()
polyBezierTo :: HDC -> [POINT] -> IO ()
polyBezierTo HDC
dc [POINT]
points =
forall a. [POINT] -> (Ptr POINT -> Int -> IO a) -> IO a
withPOINTArray [POINT]
points forall a b. (a -> b) -> a -> b
$ \ Ptr POINT
pount_array Int
npoints ->
String -> IO Bool -> IO ()
failIfFalse_ String
"PolyBezierTo" forall a b. (a -> b) -> a -> b
$ HDC -> Ptr POINT -> Int -> IO Bool
c_PolyBezierTo HDC
dc Ptr POINT
pount_array Int
npoints
foreign import WINDOWS_CCONV unsafe "windows.h PolyBezierTo"
c_PolyBezierTo :: HDC -> Ptr POINT -> Int -> IO Bool
arc :: HDC -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> IO ()
arc :: HDC
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> IO ()
arc HDC
dc Int32
left Int32
top Int32
right Int32
bottom Int32
x1 Int32
y1 Int32
x2 Int32
y2 =
String -> IO Bool -> IO ()
failIfFalse_ String
"Arc" forall a b. (a -> b) -> a -> b
$ HDC
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> IO Bool
c_Arc HDC
dc Int32
left Int32
top Int32
right Int32
bottom Int32
x1 Int32
y1 Int32
x2 Int32
y2
foreign import WINDOWS_CCONV unsafe "windows.h Arc"
c_Arc :: HDC -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> IO Bool
arcTo :: HDC -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> IO ()
arcTo :: HDC
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> IO ()
arcTo HDC
dc Int32
left Int32
top Int32
right Int32
bottom Int32
x1 Int32
y1 Int32
x2 Int32
y2 =
String -> IO Bool -> IO ()
failIfFalse_ String
"ArcTo" forall a b. (a -> b) -> a -> b
$ HDC
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> IO Bool
c_ArcTo HDC
dc Int32
left Int32
top Int32
right Int32
bottom Int32
x1 Int32
y1 Int32
x2 Int32
y2
foreign import WINDOWS_CCONV unsafe "windows.h ArcTo"
c_ArcTo :: HDC -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> IO Bool
angleArc :: HDC -> Int32 -> Int32 -> WORD -> Float -> Float -> IO ()
angleArc :: HDC -> Int32 -> Int32 -> WORD -> Float -> Float -> IO ()
angleArc HDC
dc Int32
x Int32
y WORD
r Float
start Float
sweep =
String -> IO Bool -> IO ()
failIfFalse_ String
"AngleArc" forall a b. (a -> b) -> a -> b
$ HDC -> Int32 -> Int32 -> WORD -> Float -> Float -> IO Bool
c_AngleArc HDC
dc Int32
x Int32
y WORD
r Float
start Float
sweep
foreign import WINDOWS_CCONV unsafe "windows.h AngleArc"
c_AngleArc :: HDC -> Int32 -> Int32 -> WORD -> Float -> Float -> IO Bool
fillRect :: HDC -> RECT -> HBRUSH -> IO ()
fillRect :: HDC -> RECT -> HDC -> IO ()
fillRect HDC
dc RECT
rect HDC
brush =
forall a. RECT -> (Ptr RECT -> IO a) -> IO a
withRECT RECT
rect forall a b. (a -> b) -> a -> b
$ \ Ptr RECT
c_rect ->
String -> IO Bool -> IO ()
failIfFalse_ String
"FillRect" forall a b. (a -> b) -> a -> b
$ HDC -> Ptr RECT -> HDC -> IO Bool
c_FillRect HDC
dc Ptr RECT
c_rect HDC
brush
foreign import WINDOWS_CCONV unsafe "windows.h FillRect"
c_FillRect :: HDC -> Ptr RECT -> HBRUSH -> IO Bool
frameRect :: HDC -> RECT -> HBRUSH -> IO ()
frameRect :: HDC -> RECT -> HDC -> IO ()
frameRect HDC
dc RECT
rect HDC
brush =
forall a. RECT -> (Ptr RECT -> IO a) -> IO a
withRECT RECT
rect forall a b. (a -> b) -> a -> b
$ \ Ptr RECT
c_rect ->
String -> IO Bool -> IO ()
failIfFalse_ String
"FrameRect" forall a b. (a -> b) -> a -> b
$ HDC -> Ptr RECT -> HDC -> IO Bool
c_FrameRect HDC
dc Ptr RECT
c_rect HDC
brush
foreign import WINDOWS_CCONV unsafe "windows.h FrameRect"
c_FrameRect :: HDC -> Ptr RECT -> HBRUSH -> IO Bool
invertRect :: HDC -> RECT -> IO ()
invertRect :: HDC -> RECT -> IO ()
invertRect HDC
dc RECT
rect =
forall a. RECT -> (Ptr RECT -> IO a) -> IO a
withRECT RECT
rect forall a b. (a -> b) -> a -> b
$ \ Ptr RECT
c_rect ->
String -> IO Bool -> IO ()
failIfFalse_ String
"InvertRect" forall a b. (a -> b) -> a -> b
$ HDC -> Ptr RECT -> IO Bool
c_InvertRect HDC
dc Ptr RECT
c_rect
foreign import WINDOWS_CCONV unsafe "windows.h InvertRect"
c_InvertRect :: HDC -> Ptr RECT -> IO Bool
rectangle :: HDC -> Int32 -> Int32 -> Int32 -> Int32 -> IO ()
rectangle :: HDC -> Int32 -> Int32 -> Int32 -> Int32 -> IO ()
rectangle HDC
dc Int32
left Int32
top Int32
right Int32
bottom =
String -> IO Bool -> IO ()
failIfFalse_ String
"Rectangle" forall a b. (a -> b) -> a -> b
$ HDC -> Int32 -> Int32 -> Int32 -> Int32 -> IO Bool
c_Rectangle HDC
dc Int32
left Int32
top Int32
right Int32
bottom
foreign import WINDOWS_CCONV unsafe "windows.h Rectangle"
c_Rectangle :: HDC -> Int32 -> Int32 -> Int32 -> Int32 -> IO Bool
roundRect :: HDC -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> IO ()
roundRect :: HDC -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> IO ()
roundRect HDC
dc Int32
left Int32
top Int32
right Int32
bottom Int32
w Int32
h =
String -> IO Bool -> IO ()
failIfFalse_ String
"RoundRect" forall a b. (a -> b) -> a -> b
$ HDC
-> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> IO Bool
c_RoundRect HDC
dc Int32
left Int32
top Int32
right Int32
bottom Int32
w Int32
h
foreign import WINDOWS_CCONV unsafe "windows.h RoundRect"
c_RoundRect :: HDC -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> IO Bool
ellipse :: HDC -> Int32 -> Int32 -> Int32 -> Int32 -> IO ()
ellipse :: HDC -> Int32 -> Int32 -> Int32 -> Int32 -> IO ()
ellipse HDC
dc Int32
left Int32
top Int32
right Int32
bottom =
String -> IO Bool -> IO ()
failIfFalse_ String
"Ellipse" forall a b. (a -> b) -> a -> b
$ HDC -> Int32 -> Int32 -> Int32 -> Int32 -> IO Bool
c_Ellipse HDC
dc Int32
left Int32
top Int32
right Int32
bottom
foreign import WINDOWS_CCONV unsafe "windows.h Ellipse"
c_Ellipse :: HDC -> Int32 -> Int32 -> Int32 -> Int32 -> IO Bool
chord :: HDC -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> IO ()
chord :: HDC
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> IO ()
chord HDC
dc Int32
left Int32
top Int32
right Int32
bottom Int32
x1 Int32
y1 Int32
x2 Int32
y2 =
String -> IO Bool -> IO ()
failIfFalse_ String
"Chord" forall a b. (a -> b) -> a -> b
$ HDC
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> IO Bool
c_Chord HDC
dc Int32
left Int32
top Int32
right Int32
bottom Int32
x1 Int32
y1 Int32
x2 Int32
y2
foreign import WINDOWS_CCONV unsafe "windows.h Chord"
c_Chord :: HDC -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> IO Bool
pie :: HDC -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> IO ()
pie :: HDC
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> IO ()
pie HDC
dc Int32
left Int32
top Int32
right Int32
bottom Int32
x1 Int32
y1 Int32
x2 Int32
y2 =
String -> IO Bool -> IO ()
failIfFalse_ String
"Pie" forall a b. (a -> b) -> a -> b
$ HDC
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> Int32
-> IO Bool
c_Pie HDC
dc Int32
left Int32
top Int32
right Int32
bottom Int32
x1 Int32
y1 Int32
x2 Int32
y2
foreign import WINDOWS_CCONV unsafe "windows.h Pie"
c_Pie :: HDC -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> IO Bool
bitBlt :: HDC -> INT -> INT -> INT -> INT -> HDC -> INT -> INT -> RasterOp3 -> IO ()
bitBlt :: HDC
-> Int32
-> Int32
-> Int32
-> Int32
-> HDC
-> Int32
-> Int32
-> RasterOp3
-> IO ()
bitBlt HDC
dcDest Int32
xDest Int32
yDest Int32
w Int32
h HDC
dcSrc Int32
xSrc Int32
ySrc RasterOp3
rop =
String -> IO Bool -> IO ()
failIfFalse_ String
"BitBlt" forall a b. (a -> b) -> a -> b
$ HDC
-> Int32
-> Int32
-> Int32
-> Int32
-> HDC
-> Int32
-> Int32
-> RasterOp3
-> IO Bool
c_BitBlt HDC
dcDest Int32
xDest Int32
yDest Int32
w Int32
h HDC
dcSrc Int32
xSrc Int32
ySrc RasterOp3
rop
foreign import WINDOWS_CCONV unsafe "windows.h BitBlt"
c_BitBlt :: HDC -> INT -> INT -> INT -> INT -> HDC -> INT -> INT -> RasterOp3 -> IO Bool
maskBlt :: HDC -> INT -> INT -> INT -> INT -> HDC -> INT -> INT -> HBITMAP -> INT -> INT -> RasterOp4 -> IO ()
maskBlt :: HDC
-> Int32
-> Int32
-> Int32
-> Int32
-> HDC
-> Int32
-> Int32
-> HDC
-> Int32
-> Int32
-> RasterOp3
-> IO ()
maskBlt HDC
dcDest Int32
xDest Int32
yDest Int32
w Int32
h HDC
dcSrc Int32
xSrc Int32
ySrc HDC
bm Int32
xMask Int32
yMask RasterOp3
rop =
String -> IO Bool -> IO ()
failIfFalse_ String
"MaskBlt" forall a b. (a -> b) -> a -> b
$
HDC
-> Int32
-> Int32
-> Int32
-> Int32
-> HDC
-> Int32
-> Int32
-> HDC
-> Int32
-> Int32
-> RasterOp3
-> IO Bool
c_MaskBlt HDC
dcDest Int32
xDest Int32
yDest Int32
w Int32
h HDC
dcSrc Int32
xSrc Int32
ySrc HDC
bm Int32
xMask Int32
yMask RasterOp3
rop
foreign import WINDOWS_CCONV unsafe "windows.h MaskBlt"
c_MaskBlt :: HDC -> INT -> INT -> INT -> INT -> HDC -> INT -> INT -> HBITMAP -> INT -> INT -> RasterOp4 -> IO Bool
stretchBlt :: HDC -> INT -> INT -> INT -> INT -> HDC -> INT -> INT -> INT -> INT -> RasterOp3 -> IO ()
stretchBlt :: HDC
-> Int32
-> Int32
-> Int32
-> Int32
-> HDC
-> Int32
-> Int32
-> Int32
-> Int32
-> RasterOp3
-> IO ()
stretchBlt HDC
dcDest Int32
xDest Int32
yDest Int32
wDest Int32
hDest HDC
hdcSrc Int32
xSrc Int32
ySrc Int32
wSrc Int32
hSrc RasterOp3
rop =
String -> IO Bool -> IO ()
failIfFalse_ String
"StretchBlt" forall a b. (a -> b) -> a -> b
$
HDC
-> Int32
-> Int32
-> Int32
-> Int32
-> HDC
-> Int32
-> Int32
-> Int32
-> Int32
-> RasterOp3
-> IO Bool
c_StretchBlt HDC
dcDest Int32
xDest Int32
yDest Int32
wDest Int32
hDest HDC
hdcSrc Int32
xSrc Int32
ySrc Int32
wSrc Int32
hSrc RasterOp3
rop
foreign import WINDOWS_CCONV unsafe "windows.h StretchBlt"
c_StretchBlt :: HDC -> INT -> INT -> INT -> INT -> HDC -> INT -> INT -> INT -> INT -> RasterOp3 -> IO Bool
plgBlt :: HDC -> POINT -> POINT -> POINT -> HDC -> INT -> INT -> INT -> INT -> MbHBITMAP -> INT -> INT -> IO ()
plgBlt :: HDC
-> POINT
-> POINT
-> POINT
-> HDC
-> Int32
-> Int32
-> Int32
-> Int32
-> MbHBITMAP
-> Int32
-> Int32
-> IO ()
plgBlt HDC
hdDest POINT
p1 POINT
p2 POINT
p3 HDC
hdSrc Int32
x Int32
y Int32
w Int32
h MbHBITMAP
mb_bm Int32
xMask Int32
yMask =
forall a. [POINT] -> (Ptr POINT -> Int -> IO a) -> IO a
withPOINTArray [POINT
p1,POINT
p2,POINT
p3] forall a b. (a -> b) -> a -> b
$ \ Ptr POINT
vertices Int
_ ->
String -> IO Bool -> IO ()
failIfFalse_ String
"PlgBlt" forall a b. (a -> b) -> a -> b
$
HDC
-> Ptr POINT
-> HDC
-> Int32
-> Int32
-> Int32
-> Int32
-> HDC
-> Int32
-> Int32
-> IO Bool
c_PlgBlt HDC
hdDest Ptr POINT
vertices HDC
hdSrc Int32
x Int32
y Int32
w Int32
h (forall a. Maybe (Ptr a) -> Ptr a
maybePtr MbHBITMAP
mb_bm) Int32
xMask Int32
yMask
foreign import WINDOWS_CCONV unsafe "windows.h PlgBlt"
c_PlgBlt :: HDC -> Ptr POINT -> HDC -> INT -> INT -> INT -> INT -> HBITMAP -> INT -> INT -> IO Bool
textOut :: HDC -> INT -> INT -> String -> IO ()
textOut :: HDC -> Int32 -> Int32 -> String -> IO ()
textOut HDC
dc Int32
x Int32
y String
str =
forall a. String -> ((LPTSTR, Int) -> IO a) -> IO a
withTStringLen String
str forall a b. (a -> b) -> a -> b
$ \ (LPTSTR
c_str, Int
len) ->
String -> IO Bool -> IO ()
failIfFalse_ String
"TextOut" forall a b. (a -> b) -> a -> b
$ HDC -> Int32 -> Int32 -> LPTSTR -> Int -> IO Bool
c_TextOut HDC
dc Int32
x Int32
y LPTSTR
c_str Int
len
foreign import WINDOWS_CCONV unsafe "windows.h TextOutW"
c_TextOut :: HDC -> INT -> INT -> LPCTSTR -> Int -> IO Bool
getTextExtentPoint32 :: HDC -> String -> IO SIZE
getTextExtentPoint32 :: HDC -> String -> IO POINT
getTextExtentPoint32 HDC
dc String
str =
forall a. String -> ((LPTSTR, Int) -> IO a) -> IO a
withTStringLen String
str forall a b. (a -> b) -> a -> b
$ \ (LPTSTR
c_str, Int
len) ->
forall a. (Ptr POINT -> IO a) -> IO a
allocaSIZE forall a b. (a -> b) -> a -> b
$ \ Ptr POINT
p_size -> do
String -> IO Bool -> IO ()
failIfFalse_ String
"GetTextExtentPoint32" forall a b. (a -> b) -> a -> b
$
HDC -> LPTSTR -> Int -> Ptr POINT -> IO Bool
c_GetTextExtentPoint32 HDC
dc LPTSTR
c_str Int
len Ptr POINT
p_size
Ptr POINT -> IO POINT
peekSIZE Ptr POINT
p_size
foreign import WINDOWS_CCONV unsafe "windows.h GetTextExtentPoint32W"
c_GetTextExtentPoint32 :: HDC -> LPCTSTR -> Int -> Ptr SIZE -> IO Bool