I want to draw into part of a window in Haskell+Gtk2Hs+Gtk3. It's an app to change images from one cartographic projection to another, for doing things with all the maps you find across the internet, like Wikipedia. First the user has to mark out some lines of latitude and longitude on the image
So I've created a window with glade with a DrawingArea in it called "area"
import Graphics.UI.Gtk
import Graphics.UI.Gtk.Abstract.Widget
import Graphics.UI.Gtk.Misc.DrawingArea
main = do
initGUI
builder <- builderNew
builderAddFromFile builder "Atlas.glade"
window <- builderGetObject builder castToWindow "window"
area <- builderGetObject builder castToDrawingArea "area"
on area exposeEvent (drawGrid area)
--on window destroyEvent $ \e -> do
widgetShow window
mainGUI
lamaziOfSph (psi, theta) = (2 * cos (psi / 2), -theta)
sphOfLamazi (r, theta) = (2 * acos (r / 2), -theta)
cartOfPol s (r, theta) = (r * s * sin theta + s, r * s * cos theta + s)
drawGrid area = do
let t = cartOfPol 100 . lamaziOfSph
d <- eventArea
drawWindow <- drawingAreaGetDrawWindow area
--sequence $ concat $ crossWith (\x y -> drawLine d gc (t (x, y)) (t (x + 10, y))) [-180,-170..180] [-90,-80..90]
--sequence $ concat $ crossWith (\x y -> drawLine d gc (t (x, y)) (t (x, y + 10))) [-180,-170..180] [-90,-80..90]
return
But I get the error message:
ghci> :re
[5 of 5] Compiling Map ( Atlas.hs, interpreted )
Atlas.hs:268:14: error: [GHC-88464]
Variable not in scope:
drawingAreaGetDrawWindow
:: transformers-0.6.1.0:Control.Monad.Trans.Reader.ReaderT
(GHC.Ptr.Ptr EExpose) IO a0
|
268 | window <- drawingAreaGetDrawWindow
| ^^^^^^^^^^^^^^^^^^^^^^^^
Failed, four modules loaded.
EDIT: gtk3-0.15.9/Graphics/UI/Gtk/Abstract/Widget.chs contains this:
module Graphics.UI.Gtk.Abstract.Widget (
#if GTK_MAJOR_VERSION < 3
widgetGetDrawWindow,
#endif
The drawingAreaGetDrawWindow
and related functions have been removed in GTK 3. I'd suggest looking at the Gtk2Hs carsim demo to see how to do custom rendering: