diagrams-gtk-0.6.0.1/0000755000000000000000000000000012176524215012421 5ustar0000000000000000diagrams-gtk-0.6.0.1/Setup.hs0000644000000000000000000000005612176524215014056 0ustar0000000000000000import Distribution.Simple main = defaultMain diagrams-gtk-0.6.0.1/README.markdown0000644000000000000000000000041512176524215015122 0ustar0000000000000000[![Build Status](https://secure.travis-ci.org/diagrams/diagrams-gtk.png)](http://travis-ci.org/diagrams/diagrams-gtk) A rendering backend for drawing [diagrams](http://projects.haskell.org/diagrams) directly to GTK windows, built on top of the diagrams-cairo backend. diagrams-gtk-0.6.0.1/LICENSE0000644000000000000000000000275412176524215013436 0ustar0000000000000000Copyright (c) 2012, John Lato All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of John Lato nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diagrams-gtk-0.6.0.1/diagrams-gtk.cabal0000644000000000000000000000213512176524215015760 0ustar0000000000000000name: diagrams-gtk version: 0.6.0.1 synopsis: Backend for rendering diagrams directly to GTK windows description: An optional add-on to the diagrams-cairo package which allows rendering diagrams directly to GTK windows. homepage: http://projects.haskell.org/diagrams/ license: BSD3 license-file: LICENSE author: John Lato maintainer: diagrams-discuss@googlegroups.com copyright: John Lato category: Graphics build-type: Simple cabal-version: >=1.10 tested-with: GHC == 7.2.1, GHC == 7.4.2 extra-source-files: CHANGES.markdown, README.markdown source-repository head type: git location: http://github.com/diagrams/diagrams-gtk.git library exposed-modules: Diagrams.Backend.Gtk build-depends: base >= 4.2 && < 4.8, diagrams-lib >= 0.6 && < 0.8, diagrams-cairo >= 0.6 && < 0.8, gtk >= 0.12.0 && < 0.13 hs-source-dirs: src default-language: Haskell2010diagrams-gtk-0.6.0.1/CHANGES.markdown0000644000000000000000000000035112176524215015234 0ustar00000000000000000.6.0.1: 1 August 2013 ---------------------- * Allow `base-4.7`, `diagrams-lib-0.7`, and `diagrams-cairo-0.7` 0.6: 11 December 2012 --------------------- Initial release. Split out into a separate package from `diagrams-cairo`. diagrams-gtk-0.6.0.1/src/0000755000000000000000000000000012176524215013210 5ustar0000000000000000diagrams-gtk-0.6.0.1/src/Diagrams/0000755000000000000000000000000012176524215014737 5ustar0000000000000000diagrams-gtk-0.6.0.1/src/Diagrams/Backend/0000755000000000000000000000000012176524215016266 5ustar0000000000000000diagrams-gtk-0.6.0.1/src/Diagrams/Backend/Gtk.hs0000644000000000000000000000561312176524215017354 0ustar0000000000000000{-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- -- | -- Module : Diagrams.Backend.Gtk -- Copyright : (c) 2011 Diagrams-cairo team (see LICENSE) -- License : BSD-style (see LICENSE) -- Maintainer : diagrams-discuss@googlegroups.com -- -- Convenient interface to rendering diagrams directly -- on Gtk widgets using the Cairo backend. -- ----------------------------------------------------------------------------- module Diagrams.Backend.Gtk ( defaultRender , toGtkCoords , renderToGtk ) where import Diagrams.Prelude hiding (width, height) import Diagrams.Backend.Cairo as Cairo -- Below hack is needed because GHC 7.0.x has a bug regarding export -- of data family constructors; see comments in Diagrams.Backend.Cairo #if __GLASGOW_HASKELL__ < 702 || __GLASGOW_HASKELL__ >= 704 import Diagrams.Backend.Cairo.Internal #endif import Graphics.UI.Gtk import qualified Graphics.UI.Gtk.Cairo as CG -- | Convert a Diagram to the backend coordinates. -- -- Provided to Query the diagram with coordinates from a mouse click -- event. -- -- > widget `on` buttonPressEvent $ tryEvent $ do -- > click <- eventClick -- > (x,y) <- eventCoordinates -- > let result = runQuery (query $ toGtkCoords myDiagram) (P (x,y)) -- > do_something_with result -- -- `toGtkCoords` does no rescaling of the diagram, however it is centered in -- the window. toGtkCoords :: Monoid' m => QDiagram Cairo R2 m -> QDiagram Cairo R2 m toGtkCoords d = snd $ adjustDia Cairo (CairoOptions "" Absolute RenderOnly False) d -- | Render a diagram to a DrawingArea, rescaling to fit the full area. defaultRender :: Monoid' m => DrawingArea -> QDiagram Cairo R2 m -> IO () defaultRender da d = do (w,h) <- widgetGetSize da dw <- widgetGetDrawWindow da let r = snd $ renderDia Cairo (CairoOptions { cairoFileName = "" , cairoSizeSpec = Dims (fromIntegral w) (fromIntegral h) , cairoOutputType = RenderOnly , cairoBypassAdjust = False } ) d CG.renderWithDrawable dw r -- | Render a diagram to a 'DrawableClass'. No rescaling or -- transformations will be performed. -- -- Typically the diagram will already have been transformed by -- 'toGtkCoords'. renderToGtk :: (DrawableClass dc, Monoid' m) => dc -- ^ widget to render onto -> QDiagram Cairo R2 m -- ^ Diagram -> IO () renderToGtk dc d = do let r = snd $ renderDia Cairo (CairoOptions { cairoFileName = "" , cairoSizeSpec = Absolute , cairoOutputType = RenderOnly , cairoBypassAdjust = True } ) d CG.renderWithDrawable dc r