-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathGtkView.hs
31 lines (26 loc) · 1010 Bytes
/
GtkView.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
-- | Implements the generic view class for the Gtk GUI manager.
--
-- Copyright : (C) Keera Studios Ltd, 2013
-- License : BSD3
-- Maintainer : support@keera.co.uk
module Hails.MVC.View.GtkView where
import Graphics.UI.Gtk
import Hails.MVC.View
-- | A GtkGUI is a collection of elements that may be initialised We use this
-- class to make the Instantiation of View simpler.
class GtkGUI a where
initialise :: IO a
-- | A GtkView simply encapsulates a GtkGUI.
data GtkGUI a => GtkView a = GtkView a
-- | Extracts the GUI from a GtkView
getGUI :: GtkGUI a => GtkView a -> a
getGUI (GtkView x) = x
-- | Instantiates the generic View for Gtk views using the default GtkGUI
-- initialiser and the default Gtk counterparts of the View class functions.
instance GtkGUI a => View (GtkView a) where
initView _ = initGUI >> return ()
createView = initialise >>= (return . GtkView)
startView _ = mainGUI
onViewSync _ = postGUISync
onViewAsync _ = postGUIAsync
destroyView _ = mainQuit