Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
A GtkScale 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 GtkScale itself.
To set the value of a scale, you would normally use rangeSetValue
.
To detect changes to the value, you would normally use the
Range::valueChanged signal.
Note that using the same upper and lower bounds for the Scale
(through
the Range
methods) will hide the slider itself. This is useful for
applications that want to show an undeterminate value on the scale, without
changing the layout of the application (such as movie or music players).
GtkScale as GtkBuildable
GtkScale supports a custom <marks>
element, which can contain multiple
<mark>
elements. The “value” and “position” attributes have the same
meaning as scaleAddMark
parameters of the same name. If the
element is not empty, its content is taken as the markup to show at
the mark. It can be translated with the usual ”translatable” and
“context” attributes.
CSS nodes
plain code
scale[.fine-tune][.marks-before][.marks-after] ├── marks.top │ ├── mark │ ┊ ├── [label] │ ┊ ╰── indicator ┊ ┊ │ ╰── mark ├── [value] ├── contents │ ╰── trough │ ├── slider │ ├── [highlight] │ ╰── [fill] ╰── marks.bottom ├── mark ┊ ├── indicator ┊ ╰── [label] ╰── mark
GtkScale has a main CSS node with name scale and a subnode for its contents, with subnodes named trough and slider.
The main node gets the style class .fine-tune added when the scale is in 'fine-tuning' mode.
If the scale has an origin (see scaleSetHasOrigin
), there is a
subnode with name highlight below the trough node that is used for rendering
the highlighted part of the trough.
If the scale is showing a fill level (see rangeSetShowFillLevel
),
there is a subnode with name fill below the trough node that is used for
rendering the filled in part of the trough.
If marks are present, there is a marks subnode before or after the contents node, below which each mark gets a node with name mark. The marks nodes get either the .top or .bottom style class.
The mark node has a subnode named indicator. If the mark has text, it also has a subnode named label. When the mark is either above or left of the scale, the label subnode is the first when present. Otherwise, the indicator subnode is the first.
The main CSS node gets the 'marks-before' and/or 'marks-after' style classes added depending on what marks are present.
If the scale is displaying the value (see Scale:drawValue), there is subnode with name value.
Synopsis
- newtype Scale = Scale (ManagedPtr Scale)
- class (GObject o, IsDescendantOf Scale o) => IsScale o
- toScale :: (MonadIO m, IsScale o) => o -> m Scale
- scaleAddMark :: (HasCallStack, MonadIO m, IsScale a) => a -> Double -> PositionType -> Maybe Text -> m ()
- scaleClearMarks :: (HasCallStack, MonadIO m, IsScale a) => a -> m ()
- scaleGetDigits :: (HasCallStack, MonadIO m, IsScale a) => a -> m Int32
- scaleGetDrawValue :: (HasCallStack, MonadIO m, IsScale a) => a -> m Bool
- scaleGetHasOrigin :: (HasCallStack, MonadIO m, IsScale a) => a -> m Bool
- scaleGetLayout :: (HasCallStack, MonadIO m, IsScale a) => a -> m (Maybe Layout)
- scaleGetLayoutOffsets :: (HasCallStack, MonadIO m, IsScale a) => a -> m (Int32, Int32)
- scaleGetValuePos :: (HasCallStack, MonadIO m, IsScale a) => a -> m PositionType
- scaleNew :: (HasCallStack, MonadIO m, IsAdjustment a) => Orientation -> Maybe a -> m Scale
- scaleNewWithRange :: (HasCallStack, MonadIO m) => Orientation -> Double -> Double -> Double -> m Scale
- scaleSetDigits :: (HasCallStack, MonadIO m, IsScale a) => a -> Int32 -> m ()
- scaleSetDrawValue :: (HasCallStack, MonadIO m, IsScale a) => a -> Bool -> m ()
- scaleSetHasOrigin :: (HasCallStack, MonadIO m, IsScale a) => a -> Bool -> m ()
- scaleSetValuePos :: (HasCallStack, MonadIO m, IsScale a) => a -> PositionType -> m ()
- constructScaleDigits :: (IsScale o, MonadIO m) => Int32 -> m (GValueConstruct o)
- getScaleDigits :: (MonadIO m, IsScale o) => o -> m Int32
- setScaleDigits :: (MonadIO m, IsScale o) => o -> Int32 -> m ()
- constructScaleDrawValue :: (IsScale o, MonadIO m) => Bool -> m (GValueConstruct o)
- getScaleDrawValue :: (MonadIO m, IsScale o) => o -> m Bool
- setScaleDrawValue :: (MonadIO m, IsScale o) => o -> Bool -> m ()
- constructScaleHasOrigin :: (IsScale o, MonadIO m) => Bool -> m (GValueConstruct o)
- getScaleHasOrigin :: (MonadIO m, IsScale o) => o -> m Bool
- setScaleHasOrigin :: (MonadIO m, IsScale o) => o -> Bool -> m ()
- constructScaleValuePos :: (IsScale o, MonadIO m) => PositionType -> m (GValueConstruct o)
- getScaleValuePos :: (MonadIO m, IsScale o) => o -> m PositionType
- setScaleValuePos :: (MonadIO m, IsScale o) => o -> PositionType -> m ()
- type ScaleFormatValueCallback = Double -> IO Text
- afterScaleFormatValue :: (IsScale a, MonadIO m) => a -> ((?self :: a) => ScaleFormatValueCallback) -> m SignalHandlerId
- onScaleFormatValue :: (IsScale a, MonadIO m) => a -> ((?self :: a) => ScaleFormatValueCallback) -> m SignalHandlerId
Exported types
Memory-managed wrapper type.
Instances
Eq Scale Source # | |
GObject Scale Source # | |
Defined in GI.Gtk.Objects.Scale | |
ManagedPtrNewtype Scale Source # | |
Defined in GI.Gtk.Objects.Scale toManagedPtr :: Scale -> ManagedPtr Scale | |
TypedObject Scale Source # | |
Defined in GI.Gtk.Objects.Scale | |
HasParentTypes Scale Source # | |
Defined in GI.Gtk.Objects.Scale | |
IsGValue (Maybe Scale) Source # | Convert |
Defined in GI.Gtk.Objects.Scale gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe Scale -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe Scale) | |
type ParentTypes Scale Source # | |
Defined in GI.Gtk.Objects.Scale |
class (GObject o, IsDescendantOf Scale o) => IsScale o Source #
Instances
(GObject o, IsDescendantOf Scale o) => IsScale o Source # | |
Defined in GI.Gtk.Objects.Scale |
Methods
Click to display all available methods, including inherited ones
Methods
activate, addAccelerator, addChild, addDeviceEvents, addEvents, addMark, addMnemonicLabel, addTickCallback, bindProperty, bindPropertyFull, canActivateAccel, childFocus, childNotify, classPath, clearMarks, computeExpand, constructChild, createPangoContext, createPangoLayout, customFinished, customTagEnd, customTagStart, destroy, destroyed, deviceIsShadowed, dragBegin, dragBeginWithCoordinates, dragCheckThreshold, dragDestAddImageTargets, dragDestAddTextTargets, dragDestAddUriTargets, dragDestFindTarget, dragDestGetTargetList, dragDestGetTrackMotion, dragDestSet, dragDestSetProxy, dragDestSetTargetList, dragDestSetTrackMotion, dragDestUnset, dragGetData, dragHighlight, dragSourceAddImageTargets, dragSourceAddTextTargets, dragSourceAddUriTargets, dragSourceGetTargetList, dragSourceSet, dragSourceSetIconGicon, dragSourceSetIconName, dragSourceSetIconPixbuf, dragSourceSetIconStock, dragSourceSetTargetList, dragSourceUnset, dragUnhighlight, draw, ensureStyle, errorBell, event, forceFloating, freezeChildNotify, freezeNotify, getv, grabAdd, grabDefault, grabFocus, grabRemove, hasDefault, hasFocus, hasGrab, hasRcStyle, hasScreen, hasVisibleFocus, hide, hideOnDelete, inDestruction, initTemplate, inputShapeCombineRegion, insertActionGroup, intersect, isAncestor, isComposited, isDrawable, isFloating, isFocus, isSensitive, isToplevel, isVisible, keynavFailed, listAccelClosures, listActionPrefixes, listMnemonicLabels, map, mnemonicActivate, modifyBase, modifyBg, modifyCursor, modifyFg, modifyFont, modifyStyle, modifyText, notify, notifyByPspec, overrideBackgroundColor, overrideColor, overrideCursor, overrideFont, overrideSymbolicColor, parserFinished, path, queueAllocate, queueComputeExpand, queueDraw, queueDrawArea, queueDrawRegion, queueResize, queueResizeNoRedraw, realize, ref, refSink, regionIntersect, registerWindow, removeAccelerator, removeMnemonicLabel, removeTickCallback, renderIcon, renderIconPixbuf, reparent, resetRcStyles, resetStyle, runDispose, sendExpose, sendFocusChange, shapeCombineRegion, show, showAll, showNow, sizeAllocate, sizeAllocateWithBaseline, sizeRequest, stealData, stealQdata, styleAttach, styleGetProperty, thawChildNotify, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unregisterWindow, unsetStateFlags, watchClosure.
Getters
getAccessible, getActionGroup, getAdjustment, getAllocatedBaseline, getAllocatedHeight, getAllocatedSize, getAllocatedWidth, getAllocation, getAncestor, getAppPaintable, getCanDefault, getCanFocus, getChildRequisition, getChildVisible, getClip, getClipboard, getCompositeName, getData, getDeviceEnabled, getDeviceEvents, getDigits, getDirection, getDisplay, getDoubleBuffered, getDrawValue, getEvents, getFillLevel, getFlippable, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasOrigin, getHasTooltip, getHasWindow, getHexpand, getHexpandSet, getInternalChild, getInverted, getLayout, getLayoutOffsets, getLowerStepperSensitivity, getMapped, getMarginBottom, getMarginEnd, getMarginLeft, getMarginRight, getMarginStart, getMarginTop, getMinSliderSize, getModifierMask, getModifierStyle, getName, getNoShowAll, getOpacity, getOrientation, getPangoContext, getParent, getParentWindow, getPath, getPointer, getPreferredHeight, getPreferredHeightAndBaselineForWidth, getPreferredHeightForWidth, getPreferredSize, getPreferredWidth, getPreferredWidthForHeight, getProperty, getQdata, getRangeRect, getRealized, getReceivesDefault, getRequestMode, getRequisition, getRestrictToFillLevel, getRootWindow, getRoundDigits, getScaleFactor, getScreen, getSensitive, getSettings, getShowFillLevel, getSizeRequest, getSliderRange, getSliderSizeFixed, getState, getStateFlags, getStyle, getStyleContext, getSupportMultidevice, getTemplateChild, getTooltipMarkup, getTooltipText, getTooltipWindow, getToplevel, getUpperStepperSensitivity, getValign, getValignWithBaseline, getValue, getValuePos, getVexpand, getVexpandSet, getVisible, getVisual, getWindow.
Setters
setAccelPath, setAdjustment, setAllocation, setAppPaintable, setBuildableProperty, setCanDefault, setCanFocus, setChildVisible, setClip, setCompositeName, setData, setDataFull, setDeviceEnabled, setDeviceEvents, setDigits, setDirection, setDoubleBuffered, setDrawValue, setEvents, setFillLevel, setFlippable, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasOrigin, setHasTooltip, setHasWindow, setHexpand, setHexpandSet, setIncrements, setInverted, setLowerStepperSensitivity, setMapped, setMarginBottom, setMarginEnd, setMarginLeft, setMarginRight, setMarginStart, setMarginTop, setMinSliderSize, setName, setNoShowAll, setOpacity, setOrientation, setParent, setParentWindow, setProperty, setRange, setRealized, setReceivesDefault, setRedrawOnAllocate, setRestrictToFillLevel, setRoundDigits, setSensitive, setShowFillLevel, setSizeRequest, setSliderSizeFixed, setState, setStateFlags, setStyle, setSupportMultidevice, setTooltipMarkup, setTooltipText, setTooltipWindow, setUpperStepperSensitivity, setValign, setValue, setValuePos, setVexpand, setVexpandSet, setVisible, setVisual, setWindow.
addMark
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> Double |
|
-> PositionType |
|
-> Maybe Text |
|
-> m () |
Adds a mark at value
.
A mark is indicated visually by drawing a tick mark next to the scale, and GTK+ makes it easy for the user to position the scale exactly at the marks value.
If markup
is not Nothing
, text is shown next to the tick mark.
To remove marks from a scale, use scaleClearMarks
.
Since: 2.16
clearMarks
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> m () |
Removes any marks that have been added with scaleAddMark
.
Since: 2.16
getDigits
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> m Int32 | Returns: the number of decimal places that are displayed |
Gets the number of decimal places that are displayed in the value.
getDrawValue
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> m Bool | Returns: whether the current value is displayed as a string |
Returns whether the current value is displayed as a string next to the slider.
getHasOrigin
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> m Bool | Returns: |
Returns whether the scale has an origin.
Since: 3.4
getLayout
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> m (Maybe Layout) | Returns: the |
Gets the Layout
used to display the scale. The returned
object is owned by the scale so does not need to be freed by
the caller.
Since: 2.4
getLayoutOffsets
scaleGetLayoutOffsets Source #
Obtains the coordinates where the scale will draw the
Layout
representing the text in the scale. Remember
when using the Layout
function you need to convert to
and from pixels using PANGO_PIXELS()
or SCALE
.
If the Scale:drawValue property is False
, the return
values are undefined.
Since: 2.4
getValuePos
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> m PositionType | Returns: the position in which the current value is displayed |
Gets the position in which the current value is displayed.
new
:: (HasCallStack, MonadIO m, IsAdjustment a) | |
=> Orientation |
|
-> Maybe a |
|
-> m Scale | Returns: a new |
Creates a new Scale
.
Since: 3.0
newWithRange
:: (HasCallStack, MonadIO m) | |
=> Orientation |
|
-> Double |
|
-> Double |
|
-> Double |
|
-> m Scale | Returns: a new |
Creates a new scale widget with the given orientation that lets the
user input a number between min
and max
(including min
and max
)
with the increment step
. step
must be nonzero; it’s the distance
the slider moves when using the arrow keys to adjust the scale
value.
Note that the way in which the precision is derived works best if step
is a power of ten. If the resulting precision is not suitable for your
needs, use scaleSetDigits
to correct it.
Since: 3.0
setDigits
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> Int32 |
|
-> m () |
Sets the number of decimal places that are displayed in the value. Also
causes the value of the adjustment to be rounded to this number of digits,
so the retrieved value matches the displayed one, if Scale:drawValue is
True
when the value changes. If you want to enforce rounding the value when
Scale:drawValue is False
, you can set Range:roundDigits instead.
Note that rounding to a small number of digits can interfere with
the smooth autoscrolling that is built into Scale
. As an alternative,
you can use the Scale::formatValue signal to format the displayed
value yourself.
setDrawValue
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> Bool |
|
-> m () |
Specifies whether the current value is displayed as a string next to the slider.
setHasOrigin
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> Bool |
|
-> m () |
If Scale:hasOrigin is set to True
(the default), the scale will
highlight the part of the trough between the origin (bottom or left side)
and the current value.
Since: 3.4
setValuePos
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> PositionType |
|
-> m () |
Sets the position in which the current value is displayed.
Properties
digits
No description available in the introspection data.
constructScaleDigits :: (IsScale o, MonadIO m) => Int32 -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “digits
” property. This is rarely needed directly, but it is used by new
.
getScaleDigits :: (MonadIO m, IsScale o) => o -> m Int32 Source #
Get the value of the “digits
” property.
When overloading is enabled, this is equivalent to
get
scale #digits
setScaleDigits :: (MonadIO m, IsScale o) => o -> Int32 -> m () Source #
Set the value of the “digits
” property.
When overloading is enabled, this is equivalent to
set
scale [ #digits:=
value ]
drawValue
No description available in the introspection data.
constructScaleDrawValue :: (IsScale o, MonadIO m) => Bool -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “draw-value
” property. This is rarely needed directly, but it is used by new
.
getScaleDrawValue :: (MonadIO m, IsScale o) => o -> m Bool Source #
Get the value of the “draw-value
” property.
When overloading is enabled, this is equivalent to
get
scale #drawValue
setScaleDrawValue :: (MonadIO m, IsScale o) => o -> Bool -> m () Source #
Set the value of the “draw-value
” property.
When overloading is enabled, this is equivalent to
set
scale [ #drawValue:=
value ]
hasOrigin
No description available in the introspection data.
constructScaleHasOrigin :: (IsScale o, MonadIO m) => Bool -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “has-origin
” property. This is rarely needed directly, but it is used by new
.
getScaleHasOrigin :: (MonadIO m, IsScale o) => o -> m Bool Source #
Get the value of the “has-origin
” property.
When overloading is enabled, this is equivalent to
get
scale #hasOrigin
setScaleHasOrigin :: (MonadIO m, IsScale o) => o -> Bool -> m () Source #
Set the value of the “has-origin
” property.
When overloading is enabled, this is equivalent to
set
scale [ #hasOrigin:=
value ]
valuePos
No description available in the introspection data.
constructScaleValuePos :: (IsScale o, MonadIO m) => PositionType -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “value-pos
” property. This is rarely needed directly, but it is used by new
.
getScaleValuePos :: (MonadIO m, IsScale o) => o -> m PositionType Source #
Get the value of the “value-pos
” property.
When overloading is enabled, this is equivalent to
get
scale #valuePos
setScaleValuePos :: (MonadIO m, IsScale o) => o -> PositionType -> m () Source #
Set the value of the “value-pos
” property.
When overloading is enabled, this is equivalent to
set
scale [ #valuePos:=
value ]
Signals
formatValue
type ScaleFormatValueCallback Source #
Signal which allows you to change how the scale value is displayed.
Connect a signal handler which returns an allocated string representing
value
. That string will then be used to display the scale's value.
If no user-provided handlers are installed, the value will be displayed on its own, rounded according to the value of the Scale:digits property.
Here's an example signal handler which displays a value 1.0 as with "-->1.0<--".
C code
static gchar* format_value_callback (GtkScale *scale, gdouble value) { return g_strdup_printf ("-->\%0.*g<--", gtk_scale_get_digits (scale), value); }
afterScaleFormatValue :: (IsScale a, MonadIO m) => a -> ((?self :: a) => ScaleFormatValueCallback) -> m SignalHandlerId Source #
Connect a signal handler for the formatValue signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
scale #formatValue callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onScaleFormatValue :: (IsScale a, MonadIO m) => a -> ((?self :: a) => ScaleFormatValueCallback) -> m SignalHandlerId Source #
Connect a signal handler for the formatValue signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
scale #formatValue callback