packages feed

gtkimageview-0.11.1: Graphics/UI/Gtk/ImageView/Zooms.chs

{-# LANGUAGE CPP #-}
-- -*-haskell-*-
--  GIMP Toolkit (GTK) Widget Zooms
--
--  Author : Andy Stewart
--
--  Created: 19 Aug 2010
--
--  Copyright (C) 2010 Andy Stewart
--
--  This library is free software; you can redistribute it and/or
--  modify it under the terms of the GNU Lesser General Public
--  License as published by the Free Software Foundation; either
--  version 2.1 of the License, or (at your option) any later version.
--
--  This library is distributed in the hope that it will be useful,
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
--  Lesser General Public License for more details.
--
-- |
-- Maintainer  : gtk2hs-users@lists.sourceforge.net
-- Stability   : provisional
-- Portability : portable (depends on GHC)
--
module Graphics.UI.Gtk.ImageView.Zooms (
-- * Details
-- | 'ImageView' uses a discrete amount of zoom factors for determining which zoom to set. Using these
-- functions, it is possible to retrieve information and manipulate a zoom factor.

-- * Methods  
   zoomsGetZoomIn,
   zoomsGetZoomOut,
   zoomsGetMinZoom,
   zoomsGetMaxZoom,
   zoomsClampZoom,
) where

import Control.Monad	(liftM)

import System.Glib.Attributes
import System.Glib.FFI
import System.Glib.UTFString

{# context lib="gtk" prefix="gtk" #}

-- | Returns the zoom factor that is one step larger than the supplied zoom factor.
zoomsGetZoomIn :: Double -- ^ @zoom@    A zoom factor.                                              
               -> IO Double -- ^ returns a zoom factor that is one step larger than the supplied one 
zoomsGetZoomIn zoom = 
  liftM realToFrac $
  {#call gtk_zooms_get_zoom_in #}
    (realToFrac zoom)

-- | Returns the zoom factor that is one step smaller than the supplied zoom factor.
zoomsGetZoomOut :: Double  -- ^ @zoom@    a zoom factor                                                 
                -> IO Double  -- ^ returns a zoom factor that is one step smaller than the supplied one. 
zoomsGetZoomOut zoom =
  liftM realToFrac $
  {#call gtk_zooms_get_zoom_out #}
    (realToFrac zoom)

-- | Returns the minimum allowed zoom factor.
zoomsGetMinZoom :: IO Double  -- ^ returns The minimal zoom factor. 
zoomsGetMinZoom =
  liftM realToFrac $
  {#call gtk_zooms_get_min_zoom #}

-- | Returns the maximum allowed zoom factor.
zoomsGetMaxZoom :: IO Double  -- ^ returns The maximal zoom factor. 
zoomsGetMaxZoom =
  liftM realToFrac $
  {#call gtk_zooms_get_max_zoom #}

-- | Returns the zoom factor clamped to the minumum and maximum allowed value.
zoomsClampZoom :: Double -- ^ @zoom@    A zoom factor                                       
               -> IO Double  -- ^ returns The zoom factor clamped to the interval [min, max]. 
zoomsClampZoom zoom =
  liftM realToFrac $
  {#call gtk_zooms_clamp_zoom #}
    (realToFrac zoom)