  | Implements the generic view class for the Gtk GUI manager .
--
  Copyright    : ( C ) Keera Studios Ltd , 2013
-- License     : BSD3
  Maintainer   : 
module Hails.MVC.View.GtkView where

import Graphics.UI.Gtk
import Hails.MVC.View

  | A  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  .
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 
  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


 License     : BSD3
  | Implements the generic view class for the Gtk GUI manager .
  Copyright    : ( C ) Keera Studios Ltd , 2013
  Maintainer   : 
module Hails.MVC.View.GtkView where

import Graphics.UI.Gtk
import Hails.MVC.View

  | A  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  .
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 
  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
