module Graphics.Win32.GDI.Types
where
import System.Win32.Types
import Control.Monad( zipWithM_ )
import Foreign
type POINT =
( LONG
, LONG
)
sizeofPOINT :: Int
sizeofPOINT = (8)
allocaPOINT :: (Ptr POINT -> IO a) -> IO a
allocaPOINT =
allocaBytes sizeofPOINT
peekPOINT :: Ptr POINT -> IO POINT
peekPOINT p = do
x <- (\hsc_ptr -> peekByteOff hsc_ptr 0) p
y <- (\hsc_ptr -> peekByteOff hsc_ptr 4) p
return (x,y)
pokePOINT :: Ptr POINT -> POINT -> IO ()
pokePOINT p (x,y) = do
(\hsc_ptr -> pokeByteOff hsc_ptr 0) p x
(\hsc_ptr -> pokeByteOff hsc_ptr 4) p y
withPOINT :: POINT -> (Ptr POINT -> IO a) -> IO a
withPOINT p f =
allocaPOINT $ \ ptr -> do
pokePOINT ptr p
f ptr
type RECT =
( LONG
, LONG
, LONG
, LONG
)
allocaRECT :: (Ptr RECT -> IO a) -> IO a
allocaRECT =
allocaBytes ((16))
peekRECT :: Ptr RECT -> IO RECT
peekRECT p = do
left <- (\hsc_ptr -> peekByteOff hsc_ptr 0) p
top <- (\hsc_ptr -> peekByteOff hsc_ptr 4) p
right <- (\hsc_ptr -> peekByteOff hsc_ptr 8) p
bottom <- (\hsc_ptr -> peekByteOff hsc_ptr 12) p
return (left, top, right, bottom)
pokeRECT :: Ptr RECT -> RECT -> IO ()
pokeRECT p (left, top, right, bottom) = do
(\hsc_ptr -> pokeByteOff hsc_ptr 0) p left
(\hsc_ptr -> pokeByteOff hsc_ptr 4) p top
(\hsc_ptr -> pokeByteOff hsc_ptr 8) p right
(\hsc_ptr -> pokeByteOff hsc_ptr 12) p bottom
type SIZE =
( LONG
, LONG
)
allocaSIZE :: (Ptr SIZE -> IO a) -> IO a
allocaSIZE =
allocaBytes ((8))
peekSIZE :: Ptr SIZE -> IO SIZE
peekSIZE p = do
cx <- (\hsc_ptr -> peekByteOff hsc_ptr 0) p
cy <- (\hsc_ptr -> peekByteOff hsc_ptr 4) p
return (cx,cy)
pokeSIZE :: Ptr SIZE -> SIZE -> IO ()
pokeSIZE p (cx,cy) = do
(\hsc_ptr -> pokeByteOff hsc_ptr 0) p cx
(\hsc_ptr -> pokeByteOff hsc_ptr 4) p cy
withPOINTArray :: [POINT] -> (Ptr POINT -> Int -> IO a) -> IO a
withPOINTArray xs f = allocaBytes (sizeofPOINT * len) $ \ ptr -> do
pokePOINTArray ptr xs
f ptr len
where
len = length xs
pokePOINTArray :: Ptr POINT -> [POINT] -> IO ()
pokePOINTArray ptr xs = zipWithM_ (setPOINT ptr) [0..] xs
setPOINT :: Ptr POINT -> Int -> POINT -> IO ()
setPOINT ptr off = pokePOINT (ptr `plusPtr` (off*sizeofPOINT))
type LPRECT = Ptr RECT
type MbLPRECT = Maybe LPRECT
withRECT :: RECT -> (Ptr RECT -> IO a) -> IO a
withRECT r f =
allocaRECT $ \ ptr -> do
pokeRECT ptr r
f ptr
getRECT :: LPRECT -> IO RECT
getRECT = peekRECT
type HBITMAP = HANDLE
type MbHBITMAP = Maybe HBITMAP
type HFONT = HANDLE
type MbHFONT = Maybe HFONT
type HCURSOR = HICON
type MbHCURSOR = Maybe HCURSOR
type HICON = HANDLE
type MbHICON = Maybe HICON
type HRGN = ForeignHANDLE
type PRGN = HANDLE
type MbHRGN = Maybe HRGN
type HPALETTE = HANDLE
type MbHPALETTE = Maybe HPALETTE
type HBRUSH = HANDLE
type MbHBRUSH = Maybe HBRUSH
type HPEN = HANDLE
type MbHPEN = Maybe HPEN
type HACCEL = HANDLE
type HDC = HANDLE
type MbHDC = Maybe HDC
type HDWP = HANDLE
type MbHDWP = Maybe HDWP
type HWND = HANDLE
type MbHWND = Maybe HWND
hWND_BOTTOM :: HWND
hWND_BOTTOM = castUINTPtrToPtr 1
hWND_NOTOPMOST :: HWND
hWND_NOTOPMOST = castUINTPtrToPtr 4294967294
hWND_TOP :: HWND
hWND_TOP = castUINTPtrToPtr 0
hWND_TOPMOST :: HWND
hWND_TOPMOST = castUINTPtrToPtr 4294967295
type HMENU = HANDLE
type MbHMENU = Maybe HMENU
type COLORREF = Word32
foreign import ccall unsafe "HsGDI.h"
rgb :: BYTE -> BYTE -> BYTE -> COLORREF
foreign import ccall unsafe "HsGDI.h"
getRValue :: COLORREF -> BYTE
foreign import ccall unsafe "HsGDI.h"
getGValue :: COLORREF -> BYTE
foreign import ccall unsafe "HsGDI.h"
getBValue :: COLORREF -> BYTE
foreign import ccall unsafe "HsGDI.h"
pALETTERGB :: BYTE -> BYTE -> BYTE -> COLORREF
foreign import ccall unsafe "HsGDI.h"
pALETTEINDEX :: WORD -> COLORREF
type RasterOp3 = Word32
type RasterOp4 = Word32
foreign import ccall unsafe "HsGDI.h"
mAKEROP4 :: RasterOp3 -> RasterOp3 -> RasterOp4
type PolyFillMode = INT
aLTERNATE :: PolyFillMode
aLTERNATE = 1
wINDING :: PolyFillMode
wINDING = 2
type ArcDirection = INT
type MbArcDirection = Maybe ArcDirection
aD_COUNTERCLOCKWISE :: ArcDirection
aD_COUNTERCLOCKWISE = 1
aD_CLOCKWISE :: ArcDirection
aD_CLOCKWISE = 2
type GraphicsMode = DWORD
type MbGraphicsMode = Maybe GraphicsMode
gM_COMPATIBLE :: GraphicsMode
gM_COMPATIBLE = 1
gM_ADVANCED :: GraphicsMode
gM_ADVANCED = 2
type BackgroundMode = INT
tRANSPARENT :: BackgroundMode
tRANSPARENT = 1
oPAQUE :: BackgroundMode
oPAQUE = 2
type HatchStyle = INT
hS_HORIZONTAL :: HatchStyle
hS_HORIZONTAL = 0
hS_VERTICAL :: HatchStyle
hS_VERTICAL = 1
hS_FDIAGONAL :: HatchStyle
hS_FDIAGONAL = 2
hS_BDIAGONAL :: HatchStyle
hS_BDIAGONAL = 3
hS_CROSS :: HatchStyle
hS_CROSS = 4
hS_DIAGCROSS :: HatchStyle
hS_DIAGCROSS = 5
type StretchBltMode = INT
bLACKONWHITE :: StretchBltMode
bLACKONWHITE = 1
wHITEONBLACK :: StretchBltMode
wHITEONBLACK = 2
cOLORONCOLOR :: StretchBltMode
cOLORONCOLOR = 3
hALFTONE :: StretchBltMode
hALFTONE = 4
sTRETCH_ANDSCANS :: StretchBltMode
sTRETCH_ANDSCANS = 1
sTRETCH_ORSCANS :: StretchBltMode
sTRETCH_ORSCANS = 2
sTRETCH_DELETESCANS :: StretchBltMode
sTRETCH_DELETESCANS = 3
type TextAlignment = UINT
tA_NOUPDATECP :: TextAlignment
tA_NOUPDATECP = 0
tA_UPDATECP :: TextAlignment
tA_UPDATECP = 1
tA_LEFT :: TextAlignment
tA_LEFT = 0
tA_RIGHT :: TextAlignment
tA_RIGHT = 2
tA_CENTER :: TextAlignment
tA_CENTER = 6
tA_TOP :: TextAlignment
tA_TOP = 0
tA_BOTTOM :: TextAlignment
tA_BOTTOM = 8
tA_BASELINE :: TextAlignment
tA_BASELINE = 24
type ClippingMode = INT
rGN_AND :: ClippingMode
rGN_AND = 1
rGN_OR :: ClippingMode
rGN_OR = 2
rGN_XOR :: ClippingMode
rGN_XOR = 3
rGN_DIFF :: ClippingMode
rGN_DIFF = 4
rGN_COPY :: ClippingMode
rGN_COPY = 5
type RegionType = INT
eRROR :: RegionType
eRROR = 0
nULLREGION :: RegionType
nULLREGION = 1
sIMPLEREGION :: RegionType
sIMPLEREGION = 2
cOMPLEXREGION :: RegionType
cOMPLEXREGION = 3
gDI_ERROR :: Num a => a
gDI_ERROR = 4294967295
cLR_INVALID :: COLORREF
cLR_INVALID = 4294967295
oBJ_PEN :: UINT
oBJ_PEN = 1
oBJ_BRUSH :: UINT
oBJ_BRUSH = 2
oBJ_DC :: UINT
oBJ_DC = 3
oBJ_METADC :: UINT
oBJ_METADC = 4
oBJ_PAL :: UINT
oBJ_PAL = 5
oBJ_FONT :: UINT
oBJ_FONT = 6
oBJ_BITMAP :: UINT
oBJ_BITMAP = 7
oBJ_REGION :: UINT
oBJ_REGION = 8
oBJ_METAFILE :: UINT
oBJ_METAFILE = 9
oBJ_MEMDC :: UINT
oBJ_MEMDC = 10
oBJ_EXTPEN :: UINT
oBJ_EXTPEN = 11
oBJ_ENHMETADC :: UINT
oBJ_ENHMETADC = 12
oBJ_ENHMETAFILE :: UINT
oBJ_ENHMETAFILE = 13
foreign import ccall unsafe "HsGDI.h"
prim_ChildWindowFromPoint :: HWND -> Ptr POINT -> IO HWND
foreign import ccall unsafe "HsGDI.h"
prim_ChildWindowFromPointEx :: HWND -> Ptr POINT -> DWORD -> IO HWND
foreign import ccall unsafe "HsGDI.h"
prim_MenuItemFromPoint :: HWND -> HMENU -> Ptr POINT -> IO UINT