1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
|
-- -*-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#}
import Graphics.UI.Gtk.General.Enums (PositionType(..))
{# context lib="gtk" prefix="gtk" #}
--------------------
-- 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 =
{# call scale_set_digits #}
(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 $
{# call unsafe scale_get_digits #}
(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 =
{# call scale_set_draw_value #}
(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 $
{# call unsafe scale_get_draw_value #}
(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 =
{# call scale_set_value_pos #}
(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) $
{# call unsafe scale_get_value_pos #}
(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
|