Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (inaki@blueleaf.cc) |
Safe Haskell | None |
Language | Haskell2010 |
- Exported types
- Methods
- addClass
- addProvider
- addProviderForScreen
- addRegion
- cancelAnimations
- getBackgroundColor
- getBorder
- getBorderColor
- getColor
- getDirection
- getFont
- getFrameClock
- getJunctionSides
- getMargin
- getPadding
- getParent
- getPath
- getProperty
- getScale
- getScreen
- getSection
- getState
- getStyleProperty
- hasClass
- hasRegion
- invalidate
- listClasses
- listRegions
- lookupColor
- lookupIconSet
- new
- notifyStateChange
- popAnimatableRegion
- pushAnimatableRegion
- removeClass
- removeProvider
- removeProviderForScreen
- removeRegion
- resetWidgets
- restore
- save
- scrollAnimations
- setBackground
- setDirection
- setFrameClock
- setJunctionSides
- setParent
- setPath
- setScale
- setScreen
- setState
- stateIsRunning
- toString
- Properties
- Signals
StyleContext
is an object that stores styling information affecting
a widget defined by WidgetPath
.
In order to construct the final style information, StyleContext
queries information from all attached GtkStyleProviders
. Style providers
can be either attached explicitly to the context through
styleContextAddProvider
, or to the screen through
styleContextAddProviderForScreen
. The resulting style is a
combination of all providers’ information in priority order.
For GTK+ widgets, any StyleContext
returned by
widgetGetStyleContext
will already have a WidgetPath
, a
Screen
and RTL/LTR information set. The style context will also be
updated automatically if any of these settings change on the widget.
If you are using the theming layer standalone, you will need to set a
widget path and a screen yourself to the created style context through
styleContextSetPath
and possibly styleContextSetScreen
. See
the “Foreign drawing“ example in gtk3-demo.
Widgets can add style classes to their context, which can be used to associate different styles by class. The documentation for individual widgets lists which style classes it uses itself, and which style classes may be added by applications to affect their appearance.
GTK+ defines macros for a number of style classes.
Style Regions
Widgets can also add regions with flags to their context. This feature is deprecated and will be removed in a future GTK+ update. Please use style classes instead.
GTK+ defines macros for a number of style regions.
Custom styling in UI libraries and applications
If you are developing a library with custom GtkWidgets
that
render differently than standard components, you may need to add a
StyleProvider
yourself with the STYLE_PROVIDER_PRIORITY_FALLBACK
priority, either a CssProvider
or a custom object implementing the
StyleProvider
interface. This way themes may still attempt
to style your UI elements in a different way if needed so.
If you are using custom styling on an applications, you probably want then
to make your style information prevail to the theme’s, so you must use
a StyleProvider
with the STYLE_PROVIDER_PRIORITY_APPLICATION
priority, keep in mind that the user settings in
XDG_CONFIG_HOME/gtk-3.0/gtk.css
will
still take precedence over your changes, as it uses the
STYLE_PROVIDER_PRIORITY_USER
priority.
Synopsis
- newtype StyleContext = StyleContext (ManagedPtr StyleContext)
- class (GObject o, IsDescendantOf StyleContext o) => IsStyleContext o
- toStyleContext :: (MonadIO m, IsStyleContext o) => o -> m StyleContext
- noStyleContext :: Maybe StyleContext
- styleContextAddClass :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> Text -> m ()
- styleContextAddProvider :: (HasCallStack, MonadIO m, IsStyleContext a, IsStyleProvider b) => a -> b -> Word32 -> m ()
- styleContextAddProviderForScreen :: (HasCallStack, MonadIO m, IsScreen a, IsStyleProvider b) => a -> b -> Word32 -> m ()
- styleContextAddRegion :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> Text -> [RegionFlags] -> m ()
- styleContextCancelAnimations :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> Ptr () -> m ()
- styleContextGetBackgroundColor :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> [StateFlags] -> m RGBA
- styleContextGetBorder :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> [StateFlags] -> m Border
- styleContextGetBorderColor :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> [StateFlags] -> m RGBA
- styleContextGetColor :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> [StateFlags] -> m RGBA
- styleContextGetDirection :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> m TextDirection
- styleContextGetFont :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> [StateFlags] -> m FontDescription
- styleContextGetFrameClock :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> m (Maybe FrameClock)
- styleContextGetJunctionSides :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> m [JunctionSides]
- styleContextGetMargin :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> [StateFlags] -> m Border
- styleContextGetPadding :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> [StateFlags] -> m Border
- styleContextGetParent :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> m (Maybe StyleContext)
- styleContextGetPath :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> m WidgetPath
- styleContextGetProperty :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> Text -> [StateFlags] -> m GValue
- styleContextGetScale :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> m Int32
- styleContextGetScreen :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> m Screen
- styleContextGetSection :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> Text -> m (Maybe CssSection)
- styleContextGetState :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> m [StateFlags]
- styleContextGetStyleProperty :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> Text -> GValue -> m ()
- styleContextHasClass :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> Text -> m Bool
- styleContextHasRegion :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> Text -> m (Bool, [RegionFlags])
- styleContextInvalidate :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> m ()
- styleContextListClasses :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> m [Text]
- styleContextListRegions :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> m [Text]
- styleContextLookupColor :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> Text -> m (Bool, RGBA)
- styleContextLookupIconSet :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> Text -> m (Maybe IconSet)
- styleContextNew :: (HasCallStack, MonadIO m) => m StyleContext
- styleContextNotifyStateChange :: (HasCallStack, MonadIO m, IsStyleContext a, IsWindow b) => a -> b -> Ptr () -> StateType -> Bool -> m ()
- styleContextPopAnimatableRegion :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> m ()
- styleContextPushAnimatableRegion :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> Ptr () -> m ()
- styleContextRemoveClass :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> Text -> m ()
- styleContextRemoveProvider :: (HasCallStack, MonadIO m, IsStyleContext a, IsStyleProvider b) => a -> b -> m ()
- styleContextRemoveProviderForScreen :: (HasCallStack, MonadIO m, IsScreen a, IsStyleProvider b) => a -> b -> m ()
- styleContextRemoveRegion :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> Text -> m ()
- styleContextResetWidgets :: (HasCallStack, MonadIO m, IsScreen a) => a -> m ()
- styleContextRestore :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> m ()
- styleContextSave :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> m ()
- styleContextScrollAnimations :: (HasCallStack, MonadIO m, IsStyleContext a, IsWindow b) => a -> b -> Int32 -> Int32 -> m ()
- styleContextSetBackground :: (HasCallStack, MonadIO m, IsStyleContext a, IsWindow b) => a -> b -> m ()
- styleContextSetDirection :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> TextDirection -> m ()
- styleContextSetFrameClock :: (HasCallStack, MonadIO m, IsStyleContext a, IsFrameClock b) => a -> b -> m ()
- styleContextSetJunctionSides :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> [JunctionSides] -> m ()
- styleContextSetParent :: (HasCallStack, MonadIO m, IsStyleContext a, IsStyleContext b) => a -> Maybe b -> m ()
- styleContextSetPath :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> WidgetPath -> m ()
- styleContextSetScale :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> Int32 -> m ()
- styleContextSetScreen :: (HasCallStack, MonadIO m, IsStyleContext a, IsScreen b) => a -> b -> m ()
- styleContextSetState :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> [StateFlags] -> m ()
- styleContextStateIsRunning :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> StateType -> m (Bool, Double)
- styleContextToString :: (HasCallStack, MonadIO m, IsStyleContext a) => a -> [StyleContextPrintFlags] -> m Text
- constructStyleContextDirection :: IsStyleContext o => TextDirection -> IO (GValueConstruct o)
- getStyleContextDirection :: (MonadIO m, IsStyleContext o) => o -> m TextDirection
- setStyleContextDirection :: (MonadIO m, IsStyleContext o) => o -> TextDirection -> m ()
- clearStyleContextPaintClock :: (MonadIO m, IsStyleContext o) => o -> m ()
- constructStyleContextPaintClock :: (IsStyleContext o, IsFrameClock a) => a -> IO (GValueConstruct o)
- getStyleContextPaintClock :: (MonadIO m, IsStyleContext o) => o -> m (Maybe FrameClock)
- setStyleContextPaintClock :: (MonadIO m, IsStyleContext o, IsFrameClock a) => o -> a -> m ()
- clearStyleContextParent :: (MonadIO m, IsStyleContext o) => o -> m ()
- constructStyleContextParent :: (IsStyleContext o, IsStyleContext a) => a -> IO (GValueConstruct o)
- getStyleContextParent :: (MonadIO m, IsStyleContext o) => o -> m (Maybe StyleContext)
- setStyleContextParent :: (MonadIO m, IsStyleContext o, IsStyleContext a) => o -> a -> m ()
- constructStyleContextScreen :: (IsStyleContext o, IsScreen a) => a -> IO (GValueConstruct o)
- getStyleContextScreen :: (MonadIO m, IsStyleContext o) => o -> m Screen
- setStyleContextScreen :: (MonadIO m, IsStyleContext o, IsScreen a) => o -> a -> m ()
- type C_StyleContextChangedCallback = Ptr () -> Ptr () -> IO ()
- type StyleContextChangedCallback = IO ()
- afterStyleContextChanged :: (IsStyleContext a, MonadIO m) => a -> StyleContextChangedCallback -> m SignalHandlerId
- genClosure_StyleContextChanged :: MonadIO m => StyleContextChangedCallback -> m (GClosure C_StyleContextChangedCallback)
- mk_StyleContextChangedCallback :: C_StyleContextChangedCallback -> IO (FunPtr C_StyleContextChangedCallback)
- noStyleContextChangedCallback :: Maybe StyleContextChangedCallback
- onStyleContextChanged :: (IsStyleContext a, MonadIO m) => a -> StyleContextChangedCallback -> m SignalHandlerId
- wrap_StyleContextChangedCallback :: StyleContextChangedCallback -> C_StyleContextChangedCallback
Exported types
newtype StyleContext Source #
Memory-managed wrapper type.
Instances
GObject StyleContext Source # | |
Defined in GI.Gtk.Objects.StyleContext gobjectType :: IO GType # | |
HasParentTypes StyleContext Source # | |
Defined in GI.Gtk.Objects.StyleContext | |
type ParentTypes StyleContext Source # | |
Defined in GI.Gtk.Objects.StyleContext |
class (GObject o, IsDescendantOf StyleContext o) => IsStyleContext o Source #
Type class for types which can be safely cast to StyleContext
, for instance with toStyleContext
.
Instances
(GObject o, IsDescendantOf StyleContext o) => IsStyleContext o Source # | |
Defined in GI.Gtk.Objects.StyleContext |
toStyleContext :: (MonadIO m, IsStyleContext o) => o -> m StyleContext Source #
Cast to StyleContext
, for types for which this is known to be safe. For general casts, use castTo
.
noStyleContext :: Maybe StyleContext Source #
A convenience alias for Nothing
:: Maybe
StyleContext
.
Methods
addClass
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> Text |
|
-> m () |
Adds a style class to context
, so posterior calls to
gtk_style_context_get()
or any of the gtk_render_*()
functions will make use of this new class for styling.
In the CSS file format, a Entry
defining a “search”
class, would be matched by:
<!-- language="CSS" --> entry.search { ... }
While any widget defining a “search” class would be matched by: > language="CSS" -- >.search { ... }
Since: 3.0
addProvider
styleContextAddProvider Source #
:: (HasCallStack, MonadIO m, IsStyleContext a, IsStyleProvider b) | |
=> a |
|
-> b |
|
-> Word32 |
|
-> m () |
Adds a style provider to context
, to be used in style construction.
Note that a style provider added by this function only affects
the style of the widget to which context
belongs. If you want
to affect the style of all widgets, use
styleContextAddProviderForScreen
.
Note: If both priorities are the same, a StyleProvider
added through this function takes precedence over another added
through styleContextAddProviderForScreen
.
Since: 3.0
addProviderForScreen
styleContextAddProviderForScreen Source #
:: (HasCallStack, MonadIO m, IsScreen a, IsStyleProvider b) | |
=> a |
|
-> b |
|
-> Word32 |
|
-> m () |
Adds a global style provider to screen
, which will be used
in style construction for all GtkStyleContexts
under screen
.
GTK+ uses this to make styling information from Settings
available.
Note: If both priorities are the same, A StyleProvider
added through styleContextAddProvider
takes precedence
over another added through this function.
Since: 3.0
addRegion
styleContextAddRegion Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> Text |
|
-> [RegionFlags] |
|
-> m () |
Deprecated: (Since version 3.14)
Adds a region to context
, so posterior calls to
gtk_style_context_get()
or any of the gtk_render_*()
functions will make use of this new region for styling.
In the CSS file format, a TreeView
defining a “row”
region, would be matched by:
<!-- language="CSS" --> treeview row { ... }
Pseudo-classes are used for matching flags
, so the two
following rules:
> language="CSS" --
>treeview row:nth-child(even) { ... }
>treeview row:nth-child(odd) { ... }
would apply to even and odd rows, respectively.
Region names must only contain lowercase letters and “-”, starting always with a lowercase letter.
Since: 3.0
cancelAnimations
styleContextCancelAnimations Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> Ptr () |
|
-> m () |
Deprecated: (Since version 3.6)This function does nothing.
Stops all running animations for regionId
and all animatable
regions underneath.
A Nothing
regionId
will stop all ongoing animations in context
,
when dealing with a StyleContext
obtained through
widgetGetStyleContext
, this is normally done for you
in all circumstances you would expect all widget to be stopped,
so this should be only used in complex widgets with different
animatable regions.
Since: 3.0
getBackgroundColor
styleContextGetBackgroundColor Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> [StateFlags] |
|
-> m RGBA |
Deprecated: (Since version 3.16)Use renderBackground
instead.
Gets the background color for a given state.
This function is far less useful than it seems, and it should not be used in newly written code. CSS has no concept of "background color", as a background can be an image, or a gradient, or any other pattern including solid colors.
The only reason why you would call styleContextGetBackgroundColor
is
to use the returned value to draw the background with it; the correct way to
achieve this result is to use renderBackground
instead, along with CSS
style classes to modify the color to be rendered.
Since: 3.0
getBorder
styleContextGetBorder Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> [StateFlags] |
|
-> m Border |
Gets the border for a given state as a Border
.
See styleContextGetProperty
and
STYLE_PROPERTY_BORDER_WIDTH
for details.
Since: 3.0
getBorderColor
styleContextGetBorderColor Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> [StateFlags] |
|
-> m RGBA |
Deprecated: (Since version 3.16)Use renderFrame
instead.
Gets the border color for a given state.
Since: 3.0
getColor
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> [StateFlags] |
|
-> m RGBA |
Gets the foreground color for a given state.
See styleContextGetProperty
and
STYLE_PROPERTY_COLOR
for details.
Since: 3.0
getDirection
styleContextGetDirection Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> m TextDirection | Returns: the widget direction |
Deprecated: (Since version 3.8)Use styleContextGetState
and check for GTK_STATE_FLAG_DIR_LTR
and GTK_STATE_FLAG_DIR_RTL
instead.
Returns the widget direction used for rendering.
Since: 3.0
getFont
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> [StateFlags] |
|
-> m FontDescription | Returns: the |
Deprecated: (Since version 3.8)Use gtk_style_context_get()
for "font" or subproperties instead.
Returns the font description for a given state. The returned
object is const and will remain valid until the
StyleContext
::changed
signal happens.
Since: 3.0
getFrameClock
styleContextGetFrameClock Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> m (Maybe FrameClock) | Returns: a |
Returns the FrameClock
to which context
is attached.
Since: 3.8
getJunctionSides
styleContextGetJunctionSides Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> m [JunctionSides] | Returns: the junction sides |
Returns the sides where rendered elements connect visually with others.
Since: 3.0
getMargin
styleContextGetMargin Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> [StateFlags] |
|
-> m Border |
Gets the margin for a given state as a Border
.
See gtk_style_property_get()
and STYLE_PROPERTY_MARGIN
for details.
Since: 3.0
getPadding
styleContextGetPadding Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> [StateFlags] |
|
-> m Border |
Gets the padding for a given state as a Border
.
See gtk_style_context_get()
and STYLE_PROPERTY_PADDING
for details.
Since: 3.0
getParent
styleContextGetParent Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> m (Maybe StyleContext) | Returns: the parent context or |
Gets the parent context set via styleContextSetParent
.
See that function for details.
Since: 3.4
getPath
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> m WidgetPath | Returns: A |
Returns the widget path used for style matching.
Since: 3.0
getProperty
styleContextGetProperty Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> Text |
|
-> [StateFlags] |
|
-> m GValue |
Gets a style property from context
for the given state.
Note that not all CSS properties that are supported by GTK+ can be
retrieved in this way, since they may not be representable as Value
.
GTK+ defines macros for a number of properties that can be used
with this function.
Note that passing a state other than the current state of context
is not recommended unless the style context has been saved with
styleContextSave
.
When value
is no longer needed, valueUnset
must be called
to free any allocated memory.
Since: 3.0
getScale
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> m Int32 | Returns: the scale |
Returns the scale used for assets.
Since: 3.10
getScreen
styleContextGetScreen Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> m Screen | Returns: a |
Returns the Screen
to which context
is attached.
getSection
styleContextGetSection Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> Text |
|
-> m (Maybe CssSection) | Returns: |
Queries the location in the CSS where property
was defined for the
current context
. Note that the state to be queried is taken from
styleContextGetState
.
If the location is not available, Nothing
will be returned. The
location might not be available for various reasons, such as the
property being overridden, property
not naming a supported CSS
property or tracking of definitions being disabled for performance
reasons.
Shorthand CSS properties cannot be queried for a location and will
always return Nothing
.
getState
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> m [StateFlags] | Returns: the state flags |
Returns the state used for style matching.
This method should only be used to retrieve the StateFlags
to pass to StyleContext
methods, like styleContextGetPadding
.
If you need to retrieve the current state of a Widget
, use
widgetGetStateFlags
.
Since: 3.0
getStyleProperty
styleContextGetStyleProperty Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> Text |
|
-> GValue |
|
-> m () |
Gets the value for a widget style property.
When value
is no longer needed, valueUnset
must be called
to free any allocated memory.
hasClass
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> Text |
|
-> m Bool | Returns: |
Returns True
if context
currently has defined the
given class name.
Since: 3.0
hasRegion
styleContextHasRegion Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> Text |
|
-> m (Bool, [RegionFlags]) | Returns: |
invalidate
styleContextInvalidate Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> m () |
Deprecated: (Since version 3.12)Style contexts are invalidated automatically.
Invalidates context
style information, so it will be reconstructed
again. It is useful if you modify the context
and need the new
information immediately.
Since: 3.0
listClasses
styleContextListClasses Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> m [Text] | Returns: a |
Returns the list of classes currently defined in context
.
Since: 3.0
listRegions
styleContextListRegions Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> m [Text] | Returns: a |
Deprecated: (Since version 3.14)
Returns the list of regions currently defined in context
.
Since: 3.0
lookupColor
styleContextLookupColor Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> Text |
|
-> m (Bool, RGBA) | Returns: |
Looks up and resolves a color name in the context
color map.
lookupIconSet
styleContextLookupIconSet Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> Text |
|
-> m (Maybe IconSet) | Returns: The looked up |
Deprecated: (Since version 3.10)Use iconThemeLookupIcon
instead.
Looks up stockId
in the icon factories associated to context
and
the default icon factory, returning an icon set if found, otherwise
Nothing
.
new
:: (HasCallStack, MonadIO m) | |
=> m StyleContext | Returns: A newly created |
Creates a standalone StyleContext
, this style context
won’t be attached to any widget, so you may want
to call styleContextSetPath
yourself.
This function is only useful when using the theming layer
separated from GTK+, if you are using StyleContext
to
theme GtkWidgets
, use widgetGetStyleContext
in order to get a style context ready to theme the widget.
notifyStateChange
styleContextNotifyStateChange Source #
:: (HasCallStack, MonadIO m, IsStyleContext a, IsWindow b) | |
=> a |
|
-> b |
|
-> Ptr () |
|
-> StateType |
|
-> Bool |
|
-> m () |
Deprecated: (Since version 3.6)This function does nothing.
Notifies a state change on context
, so if the current style makes use
of transition animations, one will be started so all rendered elements
under regionId
are animated for state state
being set to value
stateValue
.
The window
parameter is used in order to invalidate the rendered area
as the animation runs, so make sure it is the same window that is being
rendered on by the gtk_render_*() functions.
If regionId
is Nothing
, all rendered elements using context
will be
affected by this state transition.
As a practical example, a Button
notifying a state transition on
the prelight state:
> language="C" --
>gtk_style_context_notify_state_change (context,
> gtk_widget_get_window (widget),
> NULL,
> GTK_STATE_PRELIGHT,
> button->in_button);
Can be handled in the CSS file like this: > language="CSS" -- >button { > background-color: #f00 >} > >button:hover { > background-color: #fff; > transition: 200ms linear >}
This combination will animate the button background from red to white if a pointer enters the button, and back to red if the pointer leaves the button.
Note that state
is used when finding the transition parameters, which
is why the style places the transition under the :hover pseudo-class.
Since: 3.0
popAnimatableRegion
styleContextPopAnimatableRegion Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> m () |
Deprecated: (Since version 3.6)This function does nothing.
Pops an animatable region from context
.
See styleContextPushAnimatableRegion
.
Since: 3.0
pushAnimatableRegion
styleContextPushAnimatableRegion Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> Ptr () |
|
-> m () |
Deprecated: (Since version 3.6)This function does nothing.
Pushes an animatable region, so all further gtk_render_*() calls between
this call and the following styleContextPopAnimatableRegion
will potentially show transition animations for this region if
styleContextNotifyStateChange
is called for a given state,
and the current theme/style defines transition animations for state
changes.
The regionId
used must be unique in context
so the themes
can uniquely identify rendered elements subject to a state transition.
Since: 3.0
removeClass
styleContextRemoveClass Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> Text |
|
-> m () |
Removes className
from context
.
Since: 3.0
removeProvider
styleContextRemoveProvider Source #
:: (HasCallStack, MonadIO m, IsStyleContext a, IsStyleProvider b) | |
=> a |
|
-> b |
|
-> m () |
Removes provider
from the style providers list in context
.
Since: 3.0
removeProviderForScreen
styleContextRemoveProviderForScreen Source #
:: (HasCallStack, MonadIO m, IsScreen a, IsStyleProvider b) | |
=> a |
|
-> b |
|
-> m () |
Removes provider
from the global style providers list in screen
.
Since: 3.0
removeRegion
styleContextRemoveRegion Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> Text |
|
-> m () |
Deprecated: (Since version 3.14)
Removes a region from context
.
Since: 3.0
resetWidgets
styleContextResetWidgets Source #
:: (HasCallStack, MonadIO m, IsScreen a) | |
=> a |
|
-> m () |
This function recomputes the styles for all widgets under a particular
Screen
. This is useful when some global parameter has changed that
affects the appearance of all widgets, because when a widget gets a new
style, it will both redraw and recompute any cached information about
its appearance. As an example, it is used when the color scheme changes
in the related Settings
object.
Since: 3.0
restore
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> m () |
Restores context
state to a previous stage.
See styleContextSave
.
Since: 3.0
save
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> m () |
Saves the context
state, so temporary modifications done through
styleContextAddClass
, styleContextRemoveClass
,
styleContextSetState
, etc. can quickly be reverted
in one go through styleContextRestore
.
The matching call to styleContextRestore
must be done
before GTK returns to the main loop.
Since: 3.0
scrollAnimations
styleContextScrollAnimations Source #
:: (HasCallStack, MonadIO m, IsStyleContext a, IsWindow b) | |
=> a |
|
-> b |
|
-> Int32 |
|
-> Int32 |
|
-> m () |
Deprecated: (Since version 3.6)This function does nothing.
This function is analogous to windowScroll
, and
should be called together with it so the invalidation
areas for any ongoing animation are scrolled together
with it.
Since: 3.0
setBackground
styleContextSetBackground Source #
:: (HasCallStack, MonadIO m, IsStyleContext a, IsWindow b) | |
=> a |
|
-> b |
|
-> m () |
Deprecated: (Since version 3.18)Use renderBackground
instead. Note that clients still using this function are now responsible for calling this function again whenever context
is invalidated.
Sets the background of window
to the background pattern or
color specified in context
for its current state.
Since: 3.0
setDirection
styleContextSetDirection Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> TextDirection |
|
-> m () |
Deprecated: (Since version 3.8)Use styleContextSetState
with GTK_STATE_FLAG_DIR_LTR
and GTK_STATE_FLAG_DIR_RTL
instead.
Sets the reading direction for rendering purposes.
If you are using a StyleContext
returned from
widgetGetStyleContext
, you do not need to
call this yourself.
Since: 3.0
setFrameClock
styleContextSetFrameClock Source #
:: (HasCallStack, MonadIO m, IsStyleContext a, IsFrameClock b) | |
=> a |
|
-> b |
|
-> m () |
Attaches context
to the given frame clock.
The frame clock is used for the timing of animations.
If you are using a StyleContext
returned from
widgetGetStyleContext
, you do not need to
call this yourself.
Since: 3.8
setJunctionSides
styleContextSetJunctionSides Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> [JunctionSides] |
|
-> m () |
Sets the sides where rendered elements (mostly through
renderFrame
) will visually connect with other visual elements.
This is merely a hint that may or may not be honored by themes.
Container widgets are expected to set junction hints as appropriate for their children, so it should not normally be necessary to call this function manually.
Since: 3.0
setParent
styleContextSetParent Source #
:: (HasCallStack, MonadIO m, IsStyleContext a, IsStyleContext b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Sets the parent style context for context
. The parent style
context is used to implement
inheritance
of properties.
If you are using a StyleContext
returned from
widgetGetStyleContext
, the parent will be set for you.
Since: 3.4
setPath
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> WidgetPath |
|
-> m () |
Sets the WidgetPath
used for style matching. As a
consequence, the style will be regenerated to match
the new given path.
If you are using a StyleContext
returned from
widgetGetStyleContext
, you do not need to call
this yourself.
Since: 3.0
setScale
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> Int32 |
|
-> m () |
Sets the scale to use when getting image assets for the style.
Since: 3.10
setScreen
styleContextSetScreen Source #
:: (HasCallStack, MonadIO m, IsStyleContext a, IsScreen b) | |
=> a |
|
-> b |
|
-> m () |
Attaches context
to the given screen.
The screen is used to add style information from “global” style
providers, such as the screen’s Settings
instance.
If you are using a StyleContext
returned from
widgetGetStyleContext
, you do not need to
call this yourself.
Since: 3.0
setState
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> [StateFlags] |
|
-> m () |
Sets the state to be used for style matching.
Since: 3.0
stateIsRunning
styleContextStateIsRunning Source #
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> StateType |
|
-> m (Bool, Double) | Returns: |
Deprecated: (Since version 3.6)This function always returns False
Returns True
if there is a transition animation running for the
current region (see styleContextPushAnimatableRegion
).
If progress
is not Nothing
, the animation progress will be returned
there, 0.0 means the state is closest to being unset, while 1.0 means
it’s closest to being set. This means transition animation will
run from 0 to 1 when state
is being set and from 1 to 0 when
it’s being unset.
Since: 3.0
toString
:: (HasCallStack, MonadIO m, IsStyleContext a) | |
=> a |
|
-> [StyleContextPrintFlags] |
|
-> m Text | Returns: a newly allocated string representing |
Converts the style context into a string representation.
The string representation always includes information about
the name, state, id, visibility and style classes of the CSS
node that is backing context
. Depending on the flags, more
information may be included.
This function is intended for testing and debugging of the CSS implementation in GTK+. There are no guarantees about the format of the returned string, it may change.
Since: 3.20
Properties
direction
No description available in the introspection data.
constructStyleContextDirection :: IsStyleContext o => TextDirection -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “direction
” property. This is rarely needed directly, but it is used by new
.
getStyleContextDirection :: (MonadIO m, IsStyleContext o) => o -> m TextDirection Source #
Get the value of the “direction
” property.
When overloading is enabled, this is equivalent to
get
styleContext #direction
setStyleContextDirection :: (MonadIO m, IsStyleContext o) => o -> TextDirection -> m () Source #
Set the value of the “direction
” property.
When overloading is enabled, this is equivalent to
set
styleContext [ #direction:=
value ]
paintClock
No description available in the introspection data.
clearStyleContextPaintClock :: (MonadIO m, IsStyleContext o) => o -> m () Source #
Set the value of the “paint-clock
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#paintClock
constructStyleContextPaintClock :: (IsStyleContext o, IsFrameClock a) => a -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “paint-clock
” property. This is rarely needed directly, but it is used by new
.
getStyleContextPaintClock :: (MonadIO m, IsStyleContext o) => o -> m (Maybe FrameClock) Source #
Get the value of the “paint-clock
” property.
When overloading is enabled, this is equivalent to
get
styleContext #paintClock
setStyleContextPaintClock :: (MonadIO m, IsStyleContext o, IsFrameClock a) => o -> a -> m () Source #
Set the value of the “paint-clock
” property.
When overloading is enabled, this is equivalent to
set
styleContext [ #paintClock:=
value ]
parent
Sets or gets the style context’s parent. See styleContextSetParent
for details.
Since: 3.4
clearStyleContextParent :: (MonadIO m, IsStyleContext o) => o -> m () Source #
Set the value of the “parent
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#parent
constructStyleContextParent :: (IsStyleContext o, IsStyleContext a) => a -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “parent
” property. This is rarely needed directly, but it is used by new
.
getStyleContextParent :: (MonadIO m, IsStyleContext o) => o -> m (Maybe StyleContext) Source #
Get the value of the “parent
” property.
When overloading is enabled, this is equivalent to
get
styleContext #parent
setStyleContextParent :: (MonadIO m, IsStyleContext o, IsStyleContext a) => o -> a -> m () Source #
Set the value of the “parent
” property.
When overloading is enabled, this is equivalent to
set
styleContext [ #parent:=
value ]
screen
No description available in the introspection data.
constructStyleContextScreen :: (IsStyleContext o, IsScreen a) => a -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “screen
” property. This is rarely needed directly, but it is used by new
.
getStyleContextScreen :: (MonadIO m, IsStyleContext o) => o -> m Screen Source #
Get the value of the “screen
” property.
When overloading is enabled, this is equivalent to
get
styleContext #screen
setStyleContextScreen :: (MonadIO m, IsStyleContext o, IsScreen a) => o -> a -> m () Source #
Set the value of the “screen
” property.
When overloading is enabled, this is equivalent to
set
styleContext [ #screen:=
value ]
Signals
changed
type C_StyleContextChangedCallback = Ptr () -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type StyleContextChangedCallback = IO () Source #
The ::changed signal is emitted when there is a change in the
StyleContext
.
For a StyleContext
returned by widgetGetStyleContext
, the
Widget
::style-updated
signal/vfunc might be more convenient to use.
This signal is useful when using the theming layer standalone.
Since: 3.0
afterStyleContextChanged :: (IsStyleContext a, MonadIO m) => a -> StyleContextChangedCallback -> m SignalHandlerId Source #
Connect a signal handler for the “changed
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
styleContext #changed callback
genClosure_StyleContextChanged :: MonadIO m => StyleContextChangedCallback -> m (GClosure C_StyleContextChangedCallback) Source #
Wrap the callback into a GClosure
.
mk_StyleContextChangedCallback :: C_StyleContextChangedCallback -> IO (FunPtr C_StyleContextChangedCallback) Source #
Generate a function pointer callable from C code, from a C_StyleContextChangedCallback
.
noStyleContextChangedCallback :: Maybe StyleContextChangedCallback Source #
A convenience synonym for
.Nothing
:: Maybe
StyleContextChangedCallback
onStyleContextChanged :: (IsStyleContext a, MonadIO m) => a -> StyleContextChangedCallback -> m SignalHandlerId Source #
Connect a signal handler for the “changed
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
styleContext #changed callback