{-# 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 self digits = (\(Scale arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_scale_set_digits argPtr1 arg2) {-# LINE 99 "./Graphics/UI/Gtk/Abstract/Scale.chs" #-} (toScale self) (fromIntegral 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 self = liftM fromIntegral $ (\(Scale arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_scale_get_digits 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 self drawValue = (\(Scale arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_scale_set_draw_value argPtr1 arg2) {-# LINE 119 "./Graphics/UI/Gtk/Abstract/Scale.chs" #-} (toScale self) (fromBool 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 self = liftM toBool $ (\(Scale arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_scale_get_draw_value 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 self pos = (\(Scale arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_scale_set_value_pos argPtr1 arg2) {-# LINE 140 "./Graphics/UI/Gtk/Abstract/Scale.chs" #-} (toScale self) ((fromIntegral . fromEnum) 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 self = liftM (toEnum . fromIntegral) $ (\(Scale arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_scale_get_value_pos 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 = newAttr scaleGetDigits scaleSetDigits -- | Whether the current value is displayed as a string next to the slider. -- -- Default value: @True@ -- scaleDrawValue :: ScaleClass self => Attr self Bool scaleDrawValue = newAttr scaleGetDrawValue scaleSetDrawValue -- | The position in which the current value is displayed. -- -- Default value: 'PosTop' -- scaleValuePos :: ScaleClass self => Attr self PositionType scaleValuePos = newAttr scaleGetValuePos 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))