{-# LINE 2 "./Graphics/UI/Gtk/Special/Ruler.chs" #-}
-- -*-haskell-*-
-- GIMP Toolkit (GTK) Widget Ruler
--
-- Author : Andy Stewart
--
-- Created: 28 Mar 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)
--
-- Base class for horizontal or vertical rulers
--
module Graphics.UI.Gtk.Special.Ruler (

-- * Detail
--
-- | The 'Ruler' widget is a base class for horizontal and vertical rulers.
-- Rulers are used to show the mouse pointer's location in a window. The ruler
-- can either be horizontal or vertical on the window. Within the ruler a small
-- triangle indicates the location of the mouse relative to the horizontal or
-- vertical ruler. See 'HRuler' to learn how to create a new horizontal ruler.
-- See 'VRuler' to learn how to create a new vertical ruler.
--
-- * Rulers are removed in Gtk3 and thus this module is blank. There is no
-- replacement

-- * Class Hierarchy
--
-- |
-- @
-- | 'GObject'
-- | +----'Object'
-- | +----'Widget'
-- | +----Ruler
-- | +----'HRuler'
-- | +----'VRuler'
-- @

-- * Types
  Ruler,
  RulerClass,
  castToRuler,
  toRuler,

-- * Enums
  MetricType (..),

-- * Attributes
  rulerRange,
  rulerLower,
  rulerUpper,
  rulerPosition,
  rulerMaxSize,

  rulerMetric,


  ) where

import System.Glib.FFI
import System.Glib.Attributes
import System.Glib.Properties
import Graphics.UI.Gtk.General.Enums
import Graphics.UI.Gtk.Types
{-# LINE 80 "./Graphics/UI/Gtk/Special/Ruler.chs" #-}


{-# LINE 82 "./Graphics/UI/Gtk/Special/Ruler.chs" #-}

--------------------
-- Methods

-- | This sets the range of the ruler.
--
rulerSetRange :: RulerClass self => self
 -> (Double
   ,Double
   ,Double
   ,Double)
      -- ^ @lower@ - the lower limit of the ruler
      -- ^ @upper@ - the upper limit of the ruler
      -- ^ @position@ - the mark on the ruler
      -- ^ @maxSize@ - the maximum size of the ruler used when calculating the space to leave for the text
 -> IO ()
rulerSetRange :: forall self.
RulerClass self =>
self -> (Double, Double, Double, Double) -> IO ()
rulerSetRange self
self (Double
lower, Double
upper, Double
position, Double
maxSize) =
  (\(Ruler ForeignPtr Ruler
arg1) CDouble
arg2 CDouble
arg3 CDouble
arg4 CDouble
arg5 -> ForeignPtr Ruler -> (Ptr Ruler -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Ruler
arg1 ((Ptr Ruler -> IO ()) -> IO ()) -> (Ptr Ruler -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Ruler
argPtr1 ->Ptr Ruler -> CDouble -> CDouble -> CDouble -> CDouble -> IO ()
gtk_ruler_set_range Ptr Ruler
argPtr1 CDouble
arg2 CDouble
arg3 CDouble
arg4 CDouble
arg5)
{-# LINE 100 "./Graphics/UI/Gtk/Special/Ruler.chs" #-}
    (toRuler self)
    (Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
lower)
    (Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
upper)
    (Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
position)
    (Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
maxSize)

-- | Retrieves values indicating the range and current position of a 'Ruler'.
-- See 'rulerSetRange'.
--
rulerGetRange :: RulerClass self => self
 -> IO (Double, Double, Double, Double)
rulerGetRange :: forall self.
RulerClass self =>
self -> IO (Double, Double, Double, Double)
rulerGetRange self
self =
  (Ptr CDouble -> IO (Double, Double, Double, Double))
-> IO (Double, Double, Double, Double)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CDouble -> IO (Double, Double, Double, Double))
 -> IO (Double, Double, Double, Double))
-> (Ptr CDouble -> IO (Double, Double, Double, Double))
-> IO (Double, Double, Double, Double)
forall a b. (a -> b) -> a -> b
$ \Ptr CDouble
lowerPtr ->
  (Ptr CDouble -> IO (Double, Double, Double, Double))
-> IO (Double, Double, Double, Double)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CDouble -> IO (Double, Double, Double, Double))
 -> IO (Double, Double, Double, Double))
-> (Ptr CDouble -> IO (Double, Double, Double, Double))
-> IO (Double, Double, Double, Double)
forall a b. (a -> b) -> a -> b
$ \Ptr CDouble
upperPtr ->
  (Ptr CDouble -> IO (Double, Double, Double, Double))
-> IO (Double, Double, Double, Double)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CDouble -> IO (Double, Double, Double, Double))
 -> IO (Double, Double, Double, Double))
-> (Ptr CDouble -> IO (Double, Double, Double, Double))
-> IO (Double, Double, Double, Double)
forall a b. (a -> b) -> a -> b
$ \Ptr CDouble
positionPtr ->
  (Ptr CDouble -> IO (Double, Double, Double, Double))
-> IO (Double, Double, Double, Double)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CDouble -> IO (Double, Double, Double, Double))
 -> IO (Double, Double, Double, Double))
-> (Ptr CDouble -> IO (Double, Double, Double, Double))
-> IO (Double, Double, Double, Double)
forall a b. (a -> b) -> a -> b
$ \Ptr CDouble
maxSizePtr -> do
  (\(Ruler ForeignPtr Ruler
arg1) Ptr CDouble
arg2 Ptr CDouble
arg3 Ptr CDouble
arg4 Ptr CDouble
arg5 -> ForeignPtr Ruler -> (Ptr Ruler -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Ruler
arg1 ((Ptr Ruler -> IO ()) -> IO ()) -> (Ptr Ruler -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Ruler
argPtr1 ->Ptr Ruler
-> Ptr CDouble
-> Ptr CDouble
-> Ptr CDouble
-> Ptr CDouble
-> IO ()
gtk_ruler_get_range Ptr Ruler
argPtr1 Ptr CDouble
arg2 Ptr CDouble
arg3 Ptr CDouble
arg4 Ptr CDouble
arg5)
{-# LINE 117 "./Graphics/UI/Gtk/Special/Ruler.chs" #-}
    (toRuler self)
    Ptr CDouble
lowerPtr
    Ptr CDouble
upperPtr
    Ptr CDouble
positionPtr
    Ptr CDouble
maxSizePtr
  CDouble
lower <- Ptr CDouble -> IO CDouble
forall a. Storable a => Ptr a -> IO a
peek Ptr CDouble
lowerPtr
  CDouble
upper <- Ptr CDouble -> IO CDouble
forall a. Storable a => Ptr a -> IO a
peek Ptr CDouble
upperPtr
  CDouble
position <- Ptr CDouble -> IO CDouble
forall a. Storable a => Ptr a -> IO a
peek Ptr CDouble
positionPtr
  CDouble
maxSize <- Ptr CDouble -> IO CDouble
forall a. Storable a => Ptr a -> IO a
peek Ptr CDouble
maxSizePtr
  (Double, Double, Double, Double)
-> IO (Double, Double, Double, Double)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
lower, CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
upper, CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
position, CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
maxSize)

--------------------
-- Attributes

-- | Range of ruler
--
rulerRange :: RulerClass self => Attr self (Double, Double, Double, Double)
rulerRange :: forall self.
RulerClass self =>
Attr self (Double, Double, Double, Double)
rulerRange = (self -> IO (Double, Double, Double, Double))
-> (self -> (Double, Double, Double, Double) -> IO ())
-> ReadWriteAttr
     self
     (Double, Double, Double, Double)
     (Double, Double, Double, Double)
forall o a b.
(o -> IO a) -> (o -> b -> IO ()) -> ReadWriteAttr o a b
newAttr
  self -> IO (Double, Double, Double, Double)
forall self.
RulerClass self =>
self -> IO (Double, Double, Double, Double)
rulerGetRange
  self -> (Double, Double, Double, Double) -> IO ()
forall self.
RulerClass self =>
self -> (Double, Double, Double, Double) -> IO ()
rulerSetRange

-- | Lower limit of ruler.
--
-- Default value: 0
--
rulerLower :: RulerClass self => Attr self Double
rulerLower :: forall self. RulerClass self => Attr self Double
rulerLower = String -> Attr self Double
forall gobj. GObjectClass gobj => String -> Attr gobj Double
newAttrFromDoubleProperty String
"lower"

-- | Upper limit of ruler.
--
-- Default value: 0
--
rulerUpper :: RulerClass self => Attr self Double
rulerUpper :: forall self. RulerClass self => Attr self Double
rulerUpper = String -> Attr self Double
forall gobj. GObjectClass gobj => String -> Attr gobj Double
newAttrFromDoubleProperty String
"upper"

-- | Position of mark on the ruler.
--
-- Default value: 0
--
rulerPosition :: RulerClass self => Attr self Double
rulerPosition :: forall self. RulerClass self => Attr self Double
rulerPosition = String -> Attr self Double
forall gobj. GObjectClass gobj => String -> Attr gobj Double
newAttrFromDoubleProperty String
"position"

-- | Maximum size of the ruler.
--
-- Default value: 0
--
rulerMaxSize :: RulerClass self => Attr self Double
rulerMaxSize :: forall self. RulerClass self => Attr self Double
rulerMaxSize = String -> Attr self Double
forall gobj. GObjectClass gobj => String -> Attr gobj Double
newAttrFromDoubleProperty String
"max-size"


-- | The metric used for the ruler.
--
-- Default value: ''Pixels''
--
-- Since 2.8
--
rulerMetric :: RulerClass self => Attr self MetricType
rulerMetric :: forall self. RulerClass self => Attr self MetricType
rulerMetric = String -> GType -> Attr self MetricType
forall gobj enum.
(GObjectClass gobj, Enum enum) =>
String -> GType -> Attr gobj enum
newAttrFromEnumProperty String
"metric"
                GType
gtk_metric_type_get_type
{-# LINE 176 "./Graphics/UI/Gtk/Special/Ruler.chs" #-}

foreign import ccall safe "gtk_ruler_set_range"
  gtk_ruler_set_range :: ((Ptr Ruler) -> (CDouble -> (CDouble -> (CDouble -> (CDouble -> (IO ()))))))

foreign import ccall safe "gtk_ruler_get_range"
  gtk_ruler_get_range :: ((Ptr Ruler) -> ((Ptr CDouble) -> ((Ptr CDouble) -> ((Ptr CDouble) -> ((Ptr CDouble) -> (IO ()))))))

foreign import ccall unsafe "gtk_metric_type_get_type"
  gtk_metric_type_get_type :: CULong