1{-# LANGUAGE GeneralizedNewtypeDeriving #-} 2{-# OPTIONS_HADDOCK hide #-} 3----------------------------------------------------------------------------- 4-- | 5-- Module : Graphics.Rendering.Cairo.Internal 6-- Copyright : (c) Paolo Martini 2005 7-- License : BSD-style (see cairo/COPYRIGHT) 8-- 9-- Maintainer : p.martini@neuralnoise.com 10-- Stability : experimental 11-- Portability : portable 12-- 13-- Direct bindings to the cairo library. 14----------------------------------------------------------------------------- 15-- #hide 16-- 17module Graphics.Rendering.Cairo.Internal ( 18 Render(..), bracketR 19 , module Graphics.Rendering.Cairo.Types 20 , module Graphics.Rendering.Cairo.Internal.Drawing.Cairo 21 , module Graphics.Rendering.Cairo.Internal.Drawing.Paths 22 , module Graphics.Rendering.Cairo.Internal.Drawing.Patterns 23 , module Graphics.Rendering.Cairo.Internal.Drawing.Text 24 , module Graphics.Rendering.Cairo.Internal.Drawing.Transformations 25 , module Graphics.Rendering.Cairo.Internal.Fonts.FontOptions 26 , module Graphics.Rendering.Cairo.Internal.Surfaces.Image 27 , module Graphics.Rendering.Cairo.Internal.Surfaces.PDF 28 , module Graphics.Rendering.Cairo.Internal.Surfaces.PNG 29 , module Graphics.Rendering.Cairo.Internal.Surfaces.PS 30 , module Graphics.Rendering.Cairo.Internal.Surfaces.SVG 31 , module Graphics.Rendering.Cairo.Internal.Surfaces.Surface 32 , module Graphics.Rendering.Cairo.Internal.Region 33 , module Graphics.Rendering.Cairo.Internal.Utilities 34 35 ) where 36 37import Graphics.Rendering.Cairo.Types 38import Graphics.Rendering.Cairo.Internal.Drawing.Cairo 39import Graphics.Rendering.Cairo.Internal.Drawing.Paths 40import Graphics.Rendering.Cairo.Internal.Drawing.Patterns 41import Graphics.Rendering.Cairo.Internal.Drawing.Text 42import Graphics.Rendering.Cairo.Internal.Drawing.Transformations 43import Graphics.Rendering.Cairo.Internal.Fonts.FontOptions 44import Graphics.Rendering.Cairo.Internal.Surfaces.Image 45import Graphics.Rendering.Cairo.Internal.Surfaces.PDF 46import Graphics.Rendering.Cairo.Internal.Surfaces.PNG 47import Graphics.Rendering.Cairo.Internal.Surfaces.PS 48import Graphics.Rendering.Cairo.Internal.Surfaces.SVG 49import Graphics.Rendering.Cairo.Internal.Surfaces.Surface 50import Graphics.Rendering.Cairo.Internal.Region 51import Graphics.Rendering.Cairo.Internal.Utilities 52 53import Control.Monad.Reader 54import Control.Applicative 55import Control.Exception (bracket) 56 57-- | The Render monad. All drawing operations take place in a Render context. 58-- You can obtain a Render context for a 'Surface' using 'renderWith'. 59-- 60newtype Render m = Render { runRender :: ReaderT Cairo IO m } 61 deriving (Functor, Applicative, Monad, MonadIO, MonadReader Cairo) 62 63{-# INLINE bracketR #-} 64bracketR :: IO a -> (a -> IO b) -> (a -> Render c) -> Render c 65bracketR begin end action = 66 Render $ 67 ReaderT $ \r -> 68 bracket begin end 69 (\s -> runReaderT (runRender $ action s) r) 70 71