From: <kr_...@us...> - 2003-07-13 09:09:22
|
Update of /cvsroot/htoolkit/port/src/Port In directory sc8-pr-cvs1:/tmp/cvs-serv29827/src/Port Modified Files: Types.hs Log Message: withCPointResult Index: Types.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/Types.hs,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Types.hs 12 Jul 2003 19:50:04 -0000 1.23 --- Types.hs 13 Jul 2003 09:09:10 -0000 1.24 *************** *** 88,97 **** , withCBitmap, fromCBitmap ! ! , withCFont, fromCFont , withCFontDef, withCFontDefResult, fromCFontDef, fromCStyle, fromCWeight , withCFontMetricsResult, fromCFontMetrics ! , withCPoint, fromCPoint , withCSize, withCSizeResult, fromCSize , withCRect, withCRectResult, fromCRect --- 88,97 ---- , withCBitmap, fromCBitmap ! ! , withCFont, fromCFont , withCFontDef, withCFontDefResult, fromCFontDef, fromCStyle, fromCWeight , withCFontMetricsResult, fromCFontMetrics ! , withCPoint, withCPointResult, fromCPoint , withCSize, withCSizeResult, fromCSize , withCRect, withCRectResult, fromCRect *************** *** 173,177 **** pointMove (Size w h) (Point x y) = Point (x + w) (y + h) ! pointAdd :: Point -> Point -> Point pointAdd (Point x1 y1) (Point x2 y2) = Point (x1+x2) (y1+y2) --- 173,177 ---- pointMove (Size w h) (Point x y) = Point (x + w) (y + h) ! pointAdd :: Point -> Point -> Point pointAdd (Point x1 y1) (Point x2 y2) = Point (x1+x2) (y1+y2) *************** *** 182,186 **** pointScale v (Point x y) = Point (v*x) (v*y) ! -- marshalling withCPoint :: Point -> (CInt -> CInt -> IO a) -> IO a --- 182,186 ---- pointScale v (Point x y) = Point (v*x) (v*y) ! -- marshalling withCPoint :: Point -> (CInt -> CInt -> IO a) -> IO a *************** *** 188,191 **** --- 188,198 ---- = f (toCInt x) (toCInt y) + withCPointResult :: (Ptr CInt -> IO ()) -> IO Point + withCPointResult f + = allocaArray 2 $ \cpoint -> + do f cpoint + [x,y] <- peekArray 2 cpoint + return (fromCPoint x y) + fromCPoint :: CInt -> CInt -> Point fromCPoint x y *************** *** 196,200 **** -----------------------------------------------------------------------------------------} -- | A @Size@ has a width and height. ! data Size = Size { sw :: !Int -- ^ the width of a size , sh :: !Int -- ^ the height of a size --- 203,207 ---- -----------------------------------------------------------------------------------------} -- | A @Size@ has a width and height. ! data Size = Size { sw :: !Int -- ^ the width of a size , sh :: !Int -- ^ the height of a size *************** *** 220,224 **** sizeDistance :: Point -> Point -> Size ! sizeDistance (Point x1 y1) (Point x2 y2) = Size (if x1 < x2 then x2-x1 else x1-x2) (if y1 < y2 then y2-y1 else y1-y2) --- 227,231 ---- sizeDistance :: Point -> Point -> Size ! sizeDistance (Point x1 y1) (Point x2 y2) = Size (if x1 < x2 then x2-x1 else x1-x2) (if y1 < y2 then y2-y1 else y1-y2) *************** *** 234,238 **** [w,h] <- peekArray 2 csize return (fromCSize w h) ! fromCSize :: CInt -> CInt -> Size fromCSize w h --- 241,245 ---- [w,h] <- peekArray 2 csize return (fromCSize w h) ! fromCSize :: CInt -> CInt -> Size fromCSize w h *************** *** 247,251 **** -- (and not a single pixel). The pixel width of a rectangle is therefore simply the difference -- between the right and left, or bottom and top coordinate. ! data Rect = Rect { left :: !Int , top :: !Int --- 254,258 ---- -- (and not a single pixel). The pixel width of a rectangle is therefore simply the difference -- between the right and left, or bottom and top coordinate. ! data Rect = Rect { left :: !Int , top :: !Int |