{-# LINE 2 "./Graphics/UI/Gtk/Abstract/Scale.chs" #-}
-- -*-haskell-*-
-- GIMP Toolkit (GTK) Widget Scale
--
-- Author : Axel Simon
--
-- Created: 23 May 2001
--
-- Copyright (C) 1999-2005 Axel Simon
--
-- 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 'HScale' and 'VScale'
--
module Graphics.UI.Gtk.Abstract.Scale (
-- * Detail
--
-- | A 'Scale' is a slider control used to select a numeric value. To use it,
-- you'll probably want to investigate the methods on its base class, 'Range',
-- in addition to the methods for 'Scale' itself. To set the value of a scale,
-- you would normally use 'Graphics.UI.Gtk.Abstract.Range.rangeSetValue'.
-- To detect changes to the value, you would normally use the
-- 'Graphics.UI.Gtk.Abstract.Range.onRangeValueChanged' signal.
--
-- The 'Scale' widget is an abstract class, used only for deriving the
-- subclasses 'HScale' and 'VScale'. To create a scale widget, call
-- 'Graphics.UI.Gtk.Entry.HScale.hScaleNewWithRange' or
-- 'Graphics.UI.Gtk.Entry.VScale.vScaleNewWithRange'.
--

-- * Class Hierarchy
-- |
-- @
-- | 'GObject'
-- | +----'Object'
-- | +----'Widget'
-- | +----'Range'
-- | +----Scale
-- | +----'HScale'
-- | +----'VScale'
-- @

-- * Types
  Scale,
  ScaleClass,
  castToScale, gTypeScale,
  toScale,

-- * Methods
  scaleSetDigits,
  scaleGetDigits,
  scaleSetDrawValue,
  scaleGetDrawValue,
  PositionType(..),
  scaleSetValuePos,
  scaleGetValuePos,

-- * Attributes
  scaleDigits,
  scaleDrawValue,
  scaleValuePos,
  ) where

import Control.Monad (liftM)

import System.Glib.FFI
import System.Glib.Attributes
import Graphics.UI.Gtk.Types
{-# LINE 82 "./Graphics/UI/Gtk/Abstract/Scale.chs" #-}
import Graphics.UI.Gtk.General.Enums (PositionType(..))


{-# LINE 85 "./Graphics/UI/Gtk/Abstract/Scale.chs" #-}

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

-- | Sets the number of decimal places that are displayed in the value. Also
-- causes the value of the adjustment to be rounded off to this number of
-- digits, so the retrieved value matches the value the user saw.
--
scaleSetDigits :: ScaleClass self => self
 -> Int -- ^ @digits@ - the number of decimal places to display, e.g. use 1
          -- to display 1.0, 2 to display 1.00 etc.
 -> IO ()
scaleSetDigits :: forall self. ScaleClass self => self -> Int -> IO ()
scaleSetDigits self
self Int
digits =
  (\(Scale ForeignPtr Scale
arg1) CInt
arg2 -> ForeignPtr Scale -> (Ptr Scale -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Scale
arg1 ((Ptr Scale -> IO ()) -> IO ()) -> (Ptr Scale -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Scale
argPtr1 ->Ptr Scale -> CInt -> IO ()
gtk_scale_set_digits Ptr Scale
argPtr1 CInt
arg2)
{-# LINE 99 "./Graphics/UI/Gtk/Abstract/Scale.chs" #-}
    (toScale self)
    (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
digits)

-- | Gets the number of decimal places that are displayed in the value.
--
scaleGetDigits :: ScaleClass self => self
 -> IO Int -- ^ returns the number of decimal places that are displayed.
scaleGetDigits :: forall self. ScaleClass self => self -> IO Int
scaleGetDigits self
self =
  (CInt -> Int) -> IO CInt -> IO Int
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (IO CInt -> IO Int) -> IO CInt -> IO Int
forall a b. (a -> b) -> a -> b
$
  (\(Scale ForeignPtr Scale
arg1) -> ForeignPtr Scale -> (Ptr Scale -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Scale
arg1 ((Ptr Scale -> IO CInt) -> IO CInt)
-> (Ptr Scale -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Scale
argPtr1 ->Ptr Scale -> IO CInt
gtk_scale_get_digits Ptr Scale
argPtr1)
{-# LINE 109 "./Graphics/UI/Gtk/Abstract/Scale.chs" #-}
    (toScale self)

-- | Specifies whether the current value is displayed as a string next to the
-- slider.
--
scaleSetDrawValue :: ScaleClass self => self
 -> Bool -- ^ @drawValue@ - a boolean.
 -> IO ()
scaleSetDrawValue :: forall self. ScaleClass self => self -> Bool -> IO ()
scaleSetDrawValue self
self Bool
drawValue =
  (\(Scale ForeignPtr Scale
arg1) CInt
arg2 -> ForeignPtr Scale -> (Ptr Scale -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Scale
arg1 ((Ptr Scale -> IO ()) -> IO ()) -> (Ptr Scale -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Scale
argPtr1 ->Ptr Scale -> CInt -> IO ()
gtk_scale_set_draw_value Ptr Scale
argPtr1 CInt
arg2)
{-# LINE 119 "./Graphics/UI/Gtk/Abstract/Scale.chs" #-}
    (toScale self)
    (Bool -> CInt
forall a. Num a => Bool -> a
fromBool Bool
drawValue)

-- | Returns whether the current value is displayed as a string next to the
-- slider.
--
scaleGetDrawValue :: ScaleClass self => self
 -> IO Bool -- ^ returns whether the current value is displayed as a string.
scaleGetDrawValue :: forall self. ScaleClass self => self -> IO Bool
scaleGetDrawValue self
self =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
  (\(Scale ForeignPtr Scale
arg1) -> ForeignPtr Scale -> (Ptr Scale -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Scale
arg1 ((Ptr Scale -> IO CInt) -> IO CInt)
-> (Ptr Scale -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Scale
argPtr1 ->Ptr Scale -> IO CInt
gtk_scale_get_draw_value Ptr Scale
argPtr1)
{-# LINE 130 "./Graphics/UI/Gtk/Abstract/Scale.chs" #-}
    (toScale self)

-- | Sets the position in which the current value is displayed.
--
scaleSetValuePos :: ScaleClass self => self
 -> PositionType -- ^ @pos@ - the position in which the current value is
                 -- displayed.
 -> IO ()
scaleSetValuePos :: forall self. ScaleClass self => self -> PositionType -> IO ()
scaleSetValuePos self
self PositionType
pos =
  (\(Scale ForeignPtr Scale
arg1) CInt
arg2 -> ForeignPtr Scale -> (Ptr Scale -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Scale
arg1 ((Ptr Scale -> IO ()) -> IO ()) -> (Ptr Scale -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Scale
argPtr1 ->Ptr Scale -> CInt -> IO ()
gtk_scale_set_value_pos Ptr Scale
argPtr1 CInt
arg2)
{-# LINE 140 "./Graphics/UI/Gtk/Abstract/Scale.chs" #-}
    (toScale self)
    ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (PositionType -> Int) -> PositionType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PositionType -> Int
forall a. Enum a => a -> Int
fromEnum) PositionType
pos)

-- | Gets the position in which the current value is displayed.
--
scaleGetValuePos :: ScaleClass self => self
 -> IO PositionType -- ^ returns the position in which the current value is
                    -- displayed.
scaleGetValuePos :: forall self. ScaleClass self => self -> IO PositionType
scaleGetValuePos self
self =
  (CInt -> PositionType) -> IO CInt -> IO PositionType
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Int -> PositionType
forall a. Enum a => Int -> a
toEnum (Int -> PositionType) -> (CInt -> Int) -> CInt -> PositionType
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) (IO CInt -> IO PositionType) -> IO CInt -> IO PositionType
forall a b. (a -> b) -> a -> b
$
  (\(Scale ForeignPtr Scale
arg1) -> ForeignPtr Scale -> (Ptr Scale -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Scale
arg1 ((Ptr Scale -> IO CInt) -> IO CInt)
-> (Ptr Scale -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Scale
argPtr1 ->Ptr Scale -> IO CInt
gtk_scale_get_value_pos Ptr Scale
argPtr1)
{-# LINE 151 "./Graphics/UI/Gtk/Abstract/Scale.chs" #-}
    (toScale self)

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

-- | The number of decimal places that are displayed in the value.
--
-- Allowed values: [-1,64]
--
-- Default value: 1
--
scaleDigits :: ScaleClass self => Attr self Int
scaleDigits :: forall self. ScaleClass self => Attr self Int
scaleDigits = (self -> IO Int)
-> (self -> Int -> IO ()) -> ReadWriteAttr self Int Int
forall o a b.
(o -> IO a) -> (o -> b -> IO ()) -> ReadWriteAttr o a b
newAttr
  self -> IO Int
forall self. ScaleClass self => self -> IO Int
scaleGetDigits
  self -> Int -> IO ()
forall self. ScaleClass self => self -> Int -> IO ()
scaleSetDigits

-- | Whether the current value is displayed as a string next to the slider.
--
-- Default value: @True@
--
scaleDrawValue :: ScaleClass self => Attr self Bool
scaleDrawValue :: forall self. ScaleClass self => Attr self Bool
scaleDrawValue = (self -> IO Bool)
-> (self -> Bool -> IO ()) -> ReadWriteAttr self Bool Bool
forall o a b.
(o -> IO a) -> (o -> b -> IO ()) -> ReadWriteAttr o a b
newAttr
  self -> IO Bool
forall self. ScaleClass self => self -> IO Bool
scaleGetDrawValue
  self -> Bool -> IO ()
forall self. ScaleClass self => self -> Bool -> IO ()
scaleSetDrawValue

-- | The position in which the current value is displayed.
--
-- Default value: 'PosTop'
--
scaleValuePos :: ScaleClass self => Attr self PositionType
scaleValuePos :: forall self. ScaleClass self => Attr self PositionType
scaleValuePos = (self -> IO PositionType)
-> (self -> PositionType -> IO ())
-> ReadWriteAttr self PositionType PositionType
forall o a b.
(o -> IO a) -> (o -> b -> IO ()) -> ReadWriteAttr o a b
newAttr
  self -> IO PositionType
forall self. ScaleClass self => self -> IO PositionType
scaleGetValuePos
  self -> PositionType -> IO ()
forall self. ScaleClass self => self -> PositionType -> IO ()
scaleSetValuePos

foreign import ccall safe "gtk_scale_set_digits"
  gtk_scale_set_digits :: ((Ptr Scale) -> (CInt -> (IO ())))

foreign import ccall unsafe "gtk_scale_get_digits"
  gtk_scale_get_digits :: ((Ptr Scale) -> (IO CInt))

foreign import ccall safe "gtk_scale_set_draw_value"
  gtk_scale_set_draw_value :: ((Ptr Scale) -> (CInt -> (IO ())))

foreign import ccall unsafe "gtk_scale_get_draw_value"
  gtk_scale_get_draw_value :: ((Ptr Scale) -> (IO CInt))

foreign import ccall safe "gtk_scale_set_value_pos"
  gtk_scale_set_value_pos :: ((Ptr Scale) -> (CInt -> (IO ())))

foreign import ccall unsafe "gtk_scale_get_value_pos"
  gtk_scale_get_value_pos :: ((Ptr Scale) -> (IO CInt))