{-# LINE 2 "./Graphics/UI/Gtk/Display/LevelBar.chs" #-}
-- -*-haskell-*-
-- GIMP Toolkit (GTK) Widget LevelBar
--
-- Author : Vincent Hanquez
--
-- Copyright (C) 2014 Vincent Hanquez
-- 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)
--
-- A widget which indicates progress visually
--
module Graphics.UI.Gtk.Display.LevelBar (
-- * Detail
--
-- | The 'LevelBar' is typically used to display level indicator

-- * Class Hierarchy
-- |
-- @
-- | 'GObject'
-- | +----'Object'
-- | +----'Widget'
-- | +----LevelBar
-- @

-- * Types

  LevelBar,
  LevelBarClass,
  castToLevelBar, gTypeLevelBar,
  toLevelBar,

-- * Constructors
  levelBarNew,

-- * Methods
  levelBarSetMode,
  levelBarGetMode,
  levelBarAddOffsetValue,
  levelBarRemoveOffsetValue,
  levelBarGetOffsetValue,

-- * Attributes

  levelBarInverted,

  levelBarMaxValue,
  levelBarMinValue,
  levelBarValue,
  levelBarMode

  ) where


import Control.Monad (liftM)

import System.Glib.FFI
import System.Glib.UTFString
import System.Glib.Attributes
import System.Glib.Properties
import Graphics.UI.Gtk.Abstract.Object (makeNewObject)
import Graphics.UI.Gtk.Types
{-# LINE 78 "./Graphics/UI/Gtk/Display/LevelBar.chs" #-}
import Graphics.UI.Gtk.General.Enums (LevelBarMode(..))


{-# LINE 81 "./Graphics/UI/Gtk/Display/LevelBar.chs" #-}

--------------------
-- Constructors

-- | Creates a new 'LevelBar'.
--
levelBarNew :: IO LevelBar
levelBarNew =
  makeNewObject mkLevelBar $
  liftM (castPtr :: Ptr Widget -> Ptr LevelBar) $
  gtk_level_bar_new
{-# LINE 92 "./Graphics/UI/Gtk/Display/LevelBar.chs" #-}

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

-- | Sets the value of the "mode" property.
--
levelBarSetMode :: LevelBarClass self => self -> LevelBarMode -> IO ()
levelBarSetMode self mode =
  (\(LevelBar arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_level_bar_set_mode argPtr1 arg2) (toLevelBar self) ((fromIntegral . fromEnum) mode)

-- | Returns the value of the "mode" property.
levelBarGetMode :: LevelBarClass self => self -> IO LevelBarMode
levelBarGetMode self =
  liftM (toEnum . fromIntegral) $
  (\(LevelBar arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_level_bar_get_mode argPtr1)
{-# LINE 107 "./Graphics/UI/Gtk/Display/LevelBar.chs" #-}
    (toLevelBar self)

-- | Add a new offset marker at the position specified by @value
--
levelBarAddOffsetValue :: (LevelBarClass self, GlibString string) => self
 -> string -- ^ @name@ - Offset name
 -> Double -- ^ @value@ - Offset position
 -> IO ()
levelBarAddOffsetValue self name value =
  withUTFString name $ \namePtr ->
  (\(LevelBar arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gtk_level_bar_add_offset_value argPtr1 arg2 arg3)
{-# LINE 118 "./Graphics/UI/Gtk/Display/LevelBar.chs" #-}
    (toLevelBar self)
    namePtr
    (realToFrac value)

-- | Add a new offset marker at the position specified by @value
--
levelBarRemoveOffsetValue :: (LevelBarClass self, GlibString string) => self
 -> string
 -> IO ()
levelBarRemoveOffsetValue self name =
  withUTFString name $ \namePtr ->
  (\(LevelBar arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_level_bar_remove_offset_value argPtr1 arg2)
{-# LINE 130 "./Graphics/UI/Gtk/Display/LevelBar.chs" #-}
    (toLevelBar self)
    namePtr

-- | Returns the current fraction of the task that's been completed.
--
levelBarGetOffsetValue :: (LevelBarClass self, GlibString string) => self
 -> string
 -> IO Double -- ^ returns the value of the offset
levelBarGetOffsetValue self name =
  alloca $ \dPtr ->
  withUTFString name $ \namePtr -> do
    (\(LevelBar arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gtk_level_bar_get_offset_value argPtr1 arg2 arg3)
{-# LINE 142 "./Graphics/UI/Gtk/Display/LevelBar.chs" #-}
      (toLevelBar self) namePtr dPtr
    liftM realToFrac $ peek dPtr

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


-- | Level bars normally grow from top to bottom or left to right. Inverted level bars grow in the opposite direction.
--
-- Default value: (0)
--
-- Since 3.8
levelBarInverted :: LevelBarClass self => Attr self Bool
levelBarInverted = newAttrFromBoolProperty "inverted"


-- | The "value" property determines the currently filled value of the level bar.
--
-- Allowed values: >= 0
--
-- Default value: 0
--
levelBarValue :: LevelBarClass self => Attr self Double
levelBarValue = newAttrFromDoubleProperty "value"

-- | The "min-value" property determines the minimum value of the interval that can be displayed by the bar.
--
-- Allowed values: >= 0
--
-- Default value: 0
--
levelBarMinValue :: LevelBarClass self => Attr self Double
levelBarMinValue = newAttrFromDoubleProperty "min-value"

-- | The "max-value" property determaxes the maximum value of the interval that can be displayed by the bar.
--
-- Allowed values: >= 0
--
-- Default value: 1
levelBarMaxValue :: LevelBarClass self => Attr self Double
levelBarMaxValue = newAttrFromDoubleProperty "max-value"

-- | The "bar-mode" property determines the way LevelBar interprets the
-- value properties to draw the level fill area. Specifically, when the value is
-- LevelBarModeContinous, LevelBar will draw a single block
-- representing the current value in that area; when the value is
-- LevelBarModeDiscrete, the widget will draw a succession of separate
-- blocks filling the draw area, with the number of blocks being equal to the
-- units separating the integral roundings of "min-value" and "max-value".
--
-- Default value: LevelBarModeContinuous
levelBarMode :: LevelBarClass self => Attr self LevelBarMode
levelBarMode = newAttr levelBarGetMode levelBarSetMode

foreign import ccall unsafe "gtk_level_bar_new"
  gtk_level_bar_new :: (IO (Ptr Widget))

foreign import ccall safe "gtk_level_bar_set_mode"
  gtk_level_bar_set_mode :: ((Ptr LevelBar) -> (CInt -> (IO ())))

foreign import ccall safe "gtk_level_bar_get_mode"
  gtk_level_bar_get_mode :: ((Ptr LevelBar) -> (IO CInt))

foreign import ccall unsafe "gtk_level_bar_add_offset_value"
  gtk_level_bar_add_offset_value :: ((Ptr LevelBar) -> ((Ptr CChar) -> (CDouble -> (IO ()))))

foreign import ccall unsafe "gtk_level_bar_remove_offset_value"
  gtk_level_bar_remove_offset_value :: ((Ptr LevelBar) -> ((Ptr CChar) -> (IO ())))

foreign import ccall unsafe "gtk_level_bar_get_offset_value"
  gtk_level_bar_get_offset_value :: ((Ptr LevelBar) -> ((Ptr CChar) -> ((Ptr CDouble) -> (IO CInt))))