diagrams-gtk- Backend for rendering diagrams directly to GTK windows

Copyright(c) 2011 Diagrams-cairo team (see LICENSE)
LicenseBSD-style (see LICENSE)
Safe HaskellNone



Convenient interface to rendering diagrams directly on Gtk widgets using the Cairo backend.



defaultRender :: Monoid' m => DrawingArea -> QDiagram Cairo R2 m -> IO () Source

Render a diagram to a DrawingArea with double buffering, rescaling to fit the full area.

toGtkCoords :: Monoid' m => QDiagram Cairo R2 m -> QDiagram Cairo R2 m Source

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.

renderToGtk Source


:: (DrawableClass dc, Monoid' m) 
=> dc

widget to render onto

-> QDiagram Cairo R2 m


-> IO () 

Render a diagram to a DrawableClass with double buffering. No rescaling or transformations will be performed.

Typically the diagram will already have been transformed by toGtkCoords.