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

Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone

Diagrams.Backend.Gtk

Description

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

Synopsis

Documentation

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

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

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

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.

renderToGtkSource

Arguments

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

widget to render onto

-> QDiagram Cairo R2 m

Diagram

-> IO () 

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

Typically the diagram will already have been transformed by toGtkCoords.