StyleContextProtocol
public protocol StyleContextProtocol : ObjectProtocol
GtkStyleContext
is an object that stores styling information affecting
a widget defined by GtkWidgetPath
.
In order to construct the final style information, GtkStyleContext
queries information from all attached GtkStyleProviders
. Style providers
can be either attached explicitly to the context through
gtk_style_context_add_provider()
, or to the screen through
gtk_style_context_add_provider_for_screen()
. The resulting style is a
combination of all providers’ information in priority order.
For GTK+ widgets, any GtkStyleContext
returned by
gtk_widget_get_style_context()
will already have a GtkWidgetPath
, a
GdkScreen
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
gtk_style_context_set_path()
and possibly gtk_style_context_set_screen()
. See
the “Foreign drawing“ example in gtk3-demo.
Style Classes #
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
GtkStyleProvider
yourself with the GTK_STYLE_PROVIDER_PRIORITY_FALLBACK
priority, either a GtkCssProvider
or a custom object implementing the
GtkStyleProvider
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 GtkStyleProvider
with the GTK_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
GTK_STYLE_PROVIDER_PRIORITY_USER
priority.
The StyleContextProtocol
protocol exposes the methods and properties of an underlying GtkStyleContext
instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see StyleContext
.
Alternatively, use StyleContextRef
as a lighweight, unowned
reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkStyleContext
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
style_context_ptr
Default implementationTyped pointer to the underlying
GtkStyleContext
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkStyleContext
instance.Declaration
Swift
var style_context_ptr: UnsafeMutablePointer<GtkStyleContext>! { get }
-
Required Initialiser for types conforming to
StyleContextProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
StyleContextPropertyName
source property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: StyleContextPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol
Parameters
source_property
the source property to bind
target
the target object to bind to
target_property
the target property to bind to
flags
the flags to pass to the
Binding
transform_from
ValueTransformer
to use for forward transformationtransform_to
ValueTransformer
to use for backwards transformationReturn Value
binding reference or
nil
in case of an error -
get(property:
Extension method) Get the value of a StyleContext property
Declaration
Swift
@inlinable func get(property: StyleContextPropertyName) -> GLibObject.Value
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
set(property:
Extension methodvalue: ) Set the value of a StyleContext property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: StyleContextPropertyName, value v: GLibObject.Value)
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
connect(signal:
Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
StyleContextSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: StyleContextSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
handler
The Swift signal handler (function or callback) to invoke on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
connect(signal:
Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
StyleContextSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: StyleContextSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
signalHandler
The C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
onChanged(flags:
Extension methodhandler: ) The
changed
signal is emitted when there is a change in theGtkStyleContext
.For a
GtkStyleContext
returned bygtk_widget_get_style_context()
, theGtkWidget::style-updated
signal/vfunc might be more convenient to use.This signal is useful when using the theming layer standalone.
Note
This represents the underlyingchanged
signalDeclaration
Swift
@discardableResult @inlinable func onChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: StyleContextRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
handler
The signal handler to call Run the given callback whenever the
changed
signal is emitted -
changedSignal
Extension methodTyped
changed
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var changedSignal: StyleContextSignalName { get }
-
onNotifyDirection(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::direction
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyDirection(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: StyleContextRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyDirection
signal is emitted -
notifyDirectionSignal
Extension methodTyped
notify::direction
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyDirectionSignal: StyleContextSignalName { get }
-
onNotifyPaintClock(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::paint-clock
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyPaintClock(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: StyleContextRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyPaintClock
signal is emitted -
notifyPaintClockSignal
Extension methodTyped
notify::paint-clock
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyPaintClockSignal: StyleContextSignalName { get }
-
onNotifyParent(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::parent
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyParent(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: StyleContextRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyParent
signal is emitted -
notifyParentSignal
Extension methodTyped
notify::parent
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyParentSignal: StyleContextSignalName { get }
-
onNotifyScreen(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::screen
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyScreen(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: StyleContextRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyScreen
signal is emitted -
notifyScreenSignal
Extension methodTyped
notify::screen
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyScreenSignal: StyleContextSignalName { get }
-
addClass(className:
Extension method) Adds a style class to
context
, so posterior calls togtk_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
GtkEntry
defining a “search” class, would be matched by:(CSS Language Example):
entry.search { ... }
While any widget defining a “search” class would be matched by: (CSS Language Example):
.search { ... }
Declaration
Swift
@inlinable func addClass(className: UnsafePointer<gchar>!)
-
add(provider:
Extension methodpriority: ) 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 whichcontext
belongs. If you want to affect the style of all widgets, usegtk_style_context_add_provider_for_screen()
.Note: If both priorities are the same, a
GtkStyleProvider
added through this function takes precedence over another added throughgtk_style_context_add_provider_for_screen()
.Declaration
Swift
@inlinable func add<StyleProviderT>(provider: StyleProviderT, priority: Int) where StyleProviderT : StyleProviderProtocol
-
addRegion(regionName:
Extension methodflags: ) Adds a region to
context
, so posterior calls togtk_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
GtkTreeView
defining a “row” region, would be matched by:(CSS Language Example):
treeview row { ... }
Pseudo-classes are used for matching
flags
, so the two following rules: (CSS Language Example):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.
add_region is deprecated: This method is deprecated.
Declaration
Swift
@available(*, deprecated) @inlinable func addRegion(regionName: UnsafePointer<gchar>!, flags: RegionFlags)
-
cancelAnimations(regionID:
Extension method) Stops all running animations for
region_id
and all animatable regions underneath.A
nil
region_id
will stop all ongoing animations incontext
, when dealing with aGtkStyleContext
obtained throughgtk_widget_get_style_context()
, 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.cancel_animations is deprecated: This function does nothing.
Declaration
Swift
@available(*, deprecated) @inlinable func cancelAnimations(regionID: gpointer! = nil)
-
getBackgroundColor(state:
Extension methodcolor: ) 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
gtk_style_context_get_background_color()
is to use the returned value to draw the background with it; the correct way to achieve this result is to usegtk_render_background()
instead, along with CSS style classes to modify the color to be rendered.get_background_color is deprecated: Use gtk_render_background() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func getBackgroundColor<RGBAT>(state: StateFlags, color: RGBAT) where RGBAT : RGBAProtocol
-
getBorder(state:
Extension methodborder: ) Gets the border for a given state as a
GtkBorder
.See
gtk_style_context_get_property()
andGTK_STYLE_PROPERTY_BORDER_WIDTH
for details.Declaration
Swift
@inlinable func getBorder<BorderT>(state: StateFlags, border: BorderT) where BorderT : BorderProtocol
-
getBorderColor(state:
Extension methodcolor: ) Gets the border color for a given state.
get_border_color is deprecated: Use gtk_render_frame() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func getBorderColor<RGBAT>(state: StateFlags, color: RGBAT) where RGBAT : RGBAProtocol
-
getColor(state:
Extension methodcolor: ) Gets the foreground color for a given state.
See
gtk_style_context_get_property()
andGTK_STYLE_PROPERTY_COLOR
for details.Declaration
Swift
@inlinable func getColor<RGBAT>(state: StateFlags, color: RGBAT) where RGBAT : RGBAProtocol
-
getDirection()
Extension methodReturns the widget direction used for rendering.
get_direction is deprecated: Use gtk_style_context_get_state() and check for #GTK_STATE_FLAG_DIR_LTR and #GTK_STATE_FLAG_DIR_RTL instead.
Declaration
Swift
@available(*, deprecated) @inlinable func getDirection() -> GtkTextDirection
-
getFont(state:
Extension method) Returns the font description for a given state. The returned object is const and will remain valid until the
GtkStyleContext::changed
signal happens.get_font is deprecated: Use gtk_style_context_get() for “font” or subproperties instead.
Declaration
Swift
@available(*, deprecated) @inlinable func getFont(state: StateFlags) -> Pango.FontDescriptionRef!
-
getFrameClock()
Extension methodReturns the
GdkFrameClock
to whichcontext
is attached.Declaration
Swift
@inlinable func getFrameClock() -> Gdk.FrameClockRef!
-
getJunctionSides()
Extension methodReturns the sides where rendered elements connect visually with others.
Declaration
Swift
@inlinable func getJunctionSides() -> JunctionSides
-
getMargin(state:
Extension methodmargin: ) Gets the margin for a given state as a
GtkBorder
. Seegtk_style_property_get()
andGTK_STYLE_PROPERTY_MARGIN
for details.Declaration
Swift
@inlinable func getMargin<BorderT>(state: StateFlags, margin: BorderT) where BorderT : BorderProtocol
-
getPadding(state:
Extension methodpadding: ) Gets the padding for a given state as a
GtkBorder
. Seegtk_style_context_get()
andGTK_STYLE_PROPERTY_PADDING
for details.Declaration
Swift
@inlinable func getPadding<BorderT>(state: StateFlags, padding: BorderT) where BorderT : BorderProtocol
-
getParent()
Extension methodGets the parent context set via
gtk_style_context_set_parent()
. See that function for details.Declaration
Swift
@inlinable func getParent() -> StyleContextRef!
-
getPath()
Extension methodReturns the widget path used for style matching.
Declaration
Swift
@inlinable func getPath() -> WidgetPathRef!
-
get(property:
Extension methodstate: value: ) 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
GValue
. 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 withgtk_style_context_save()
.When
value
is no longer needed,g_value_unset()
must be called to free any allocated memory.Declaration
Swift
@inlinable func get<ValueT>(property: UnsafePointer<gchar>!, state: StateFlags, value: ValueT) where ValueT : ValueProtocol
-
getScale()
Extension methodReturns the scale used for assets.
Declaration
Swift
@inlinable func getScale() -> Int
-
getScreen()
Extension methodReturns the
GdkScreen
to whichcontext
is attached.Declaration
Swift
@inlinable func getScreen() -> Gdk.ScreenRef!
-
getSection(property:
Extension method) Queries the location in the CSS where
property
was defined for the currentcontext
. Note that the state to be queried is taken fromgtk_style_context_get_state()
.If the location is not available,
nil
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
nil
.Declaration
Swift
@inlinable func getSection(property: UnsafePointer<gchar>!) -> CssSectionRef!
-
getState()
Extension methodReturns the state used for style matching.
This method should only be used to retrieve the
GtkStateFlags
to pass toGtkStyleContext
methods, likegtk_style_context_get_padding()
. If you need to retrieve the current state of aGtkWidget
, usegtk_widget_get_state_flags()
.Declaration
Swift
@inlinable func getState() -> StateFlags
-
getStyleProperty(propertyName:
Extension methodvalue: ) Gets the value for a widget style property.
When
value
is no longer needed,g_value_unset()
must be called to free any allocated memory.Declaration
Swift
@inlinable func getStyleProperty<ValueT>(propertyName: UnsafePointer<gchar>!, value: ValueT) where ValueT : ValueProtocol
-
getStyleValist(args:
Extension method) Retrieves several widget style properties from
context
according to the current style.Declaration
Swift
@inlinable func getStyleValist(args: CVaListPointer)
-
getValist(state:
Extension methodargs: ) Retrieves several style property values from
context
for a given state.See
gtk_style_context_get_property()
for details.Declaration
Swift
@inlinable func getValist(state: StateFlags, args: CVaListPointer)
-
hasClass(className:
Extension method) Returns
true
ifcontext
currently has defined the given class name.Declaration
Swift
@inlinable func hasClass(className: UnsafePointer<gchar>!) -> Bool
-
hasRegion(regionName:
Extension methodflagsReturn: ) Returns
true
ifcontext
has the region defined. Ifflags_return
is notnil
, it is set to the flags affecting the region.has_region is deprecated: This method is deprecated.
Declaration
Swift
@available(*, deprecated) @inlinable func hasRegion(regionName: UnsafePointer<gchar>!, flagsReturn: UnsafeMutablePointer<GtkRegionFlags>! = nil) -> Bool
-
invalidate()
Extension methodInvalidates
context
style information, so it will be reconstructed again. It is useful if you modify thecontext
and need the new information immediately.invalidate is deprecated: Style contexts are invalidated automatically.
Declaration
Swift
@available(*, deprecated) @inlinable func invalidate()
-
listClasses()
Extension methodReturns the list of classes currently defined in
context
.Declaration
Swift
@inlinable func listClasses() -> GLib.ListRef!
-
listRegions()
Extension methodReturns the list of regions currently defined in
context
.list_regions is deprecated: This method is deprecated.
Declaration
Swift
@available(*, deprecated) @inlinable func listRegions() -> GLib.ListRef!
-
lookupColor(colorName:
Extension methodcolor: ) Looks up and resolves a color name in the
context
color map.Declaration
Swift
@inlinable func lookupColor<RGBAT>(colorName: UnsafePointer<gchar>!, color: RGBAT) -> Bool where RGBAT : RGBAProtocol
-
lookupIconSet(stockID:
Extension method) Looks up
stock_id
in the icon factories associated tocontext
and the default icon factory, returning an icon set if found, otherwisenil
.lookup_icon_set is deprecated: Use gtk_icon_theme_lookup_icon() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func lookupIconSet(stockID: UnsafePointer<gchar>!) -> IconSetRef!
-
notifyStateChange(window:
Extension methodregionID: state: stateValue: ) Notifies a state change on
context
, so if the current style makes use of transition animations, one will be started so all rendered elements underregion_id
are animated for statestate
being set to valuestate_value
.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
region_id
isnil
, all rendered elements usingcontext
will be affected by this state transition.As a practical example, a
GtkButton
notifying a state transition on the prelight state: (C Language Example):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: (CSS Language Example):
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.notify_state_change is deprecated: This function does nothing.
Declaration
Swift
@available(*, deprecated) @inlinable func notifyStateChange<WindowT>(window: WindowT, regionID: gpointer! = nil, state: GtkStateType, stateValue: Bool) where WindowT : WindowProtocol
-
popAnimatableRegion()
Extension methodPops an animatable region from
context
. Seegtk_style_context_push_animatable_region()
.pop_animatable_region is deprecated: This function does nothing.
Declaration
Swift
@available(*, deprecated) @inlinable func popAnimatableRegion()
-
pushAnimatableRegion(regionID:
Extension method) Pushes an animatable region, so all further gtk_render_*() calls between this call and the following
gtk_style_context_pop_animatable_region()
will potentially show transition animations for this region ifgtk_style_context_notify_state_change()
is called for a given state, and the current theme/style defines transition animations for state changes.The
region_id
used must be unique incontext
so the themes can uniquely identify rendered elements subject to a state transition.push_animatable_region is deprecated: This function does nothing.
Declaration
Swift
@available(*, deprecated) @inlinable func pushAnimatableRegion(regionID: gpointer! = nil)
-
removeClass(className:
Extension method) Removes
class_name
fromcontext
.Declaration
Swift
@inlinable func removeClass(className: UnsafePointer<gchar>!)
-
remove(provider:
Extension method) Removes
provider
from the style providers list incontext
.Declaration
Swift
@inlinable func remove<StyleProviderT>(provider: StyleProviderT) where StyleProviderT : StyleProviderProtocol
-
removeRegion(regionName:
Extension method) Removes a region from
context
.remove_region is deprecated: This method is deprecated.
Declaration
Swift
@available(*, deprecated) @inlinable func removeRegion(regionName: UnsafePointer<gchar>!)
-
restore()
Extension methodRestores
context
state to a previous stage. Seegtk_style_context_save()
.Declaration
Swift
@inlinable func restore()
-
save()
Extension methodSaves the
context
state, so temporary modifications done throughgtk_style_context_add_class()
,gtk_style_context_remove_class()
,gtk_style_context_set_state()
, etc. can quickly be reverted in one go throughgtk_style_context_restore()
.The matching call to
gtk_style_context_restore()
must be done before GTK returns to the main loop.Declaration
Swift
@inlinable func save()
-
scrollAnimations(window:
Extension methoddx: dy: ) This function is analogous to
gdk_window_scroll()
, and should be called together with it so the invalidation areas for any ongoing animation are scrolled together with it.scroll_animations is deprecated: This function does nothing.
Declaration
Swift
@available(*, deprecated) @inlinable func scrollAnimations<WindowT>(window: WindowT, dx: Int, dy: Int) where WindowT : WindowProtocol
-
setBackground(window:
Extension method) Sets the background of
window
to the background pattern or color specified incontext
for its current state.set_background is deprecated: Use gtk_render_background() instead. Note that clients still using this function are now responsible for calling this function again whenever @context is invalidated.
Declaration
Swift
@available(*, deprecated) @inlinable func setBackground<WindowT>(window: WindowT) where WindowT : WindowProtocol
-
set(direction:
Extension method) Sets the reading direction for rendering purposes.
If you are using a
GtkStyleContext
returned fromgtk_widget_get_style_context()
, you do not need to call this yourself.set_direction is deprecated: Use gtk_style_context_set_state() with #GTK_STATE_FLAG_DIR_LTR and #GTK_STATE_FLAG_DIR_RTL instead.
Declaration
Swift
@available(*, deprecated) @inlinable func set(direction: GtkTextDirection)
-
set(frameClock:
Extension method) Attaches
context
to the given frame clock.The frame clock is used for the timing of animations.
If you are using a
GtkStyleContext
returned fromgtk_widget_get_style_context()
, you do not need to call this yourself.Declaration
Swift
@inlinable func set<FrameClockT>(frameClock: FrameClockT) where FrameClockT : FrameClockProtocol
-
setJunction(sides:
Extension method) Sets the sides where rendered elements (mostly through
gtk_render_frame()
) 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.
Declaration
Swift
@inlinable func setJunction(sides: JunctionSides)
-
set(parent:
Extension method) Sets the parent style context for
context
. The parent style context is used to implement inheritance of properties.If you are using a
GtkStyleContext
returned fromgtk_widget_get_style_context()
, the parent will be set for you.Declaration
Swift
@inlinable func set(parent: StyleContextRef? = nil)
-
set(parent:
Extension method) Sets the parent style context for
context
. The parent style context is used to implement inheritance of properties.If you are using a
GtkStyleContext
returned fromgtk_widget_get_style_context()
, the parent will be set for you.Declaration
Swift
@inlinable func set<StyleContextT>(parent: StyleContextT?) where StyleContextT : StyleContextProtocol
-
set(path:
Extension method) Sets the
GtkWidgetPath
used for style matching. As a consequence, the style will be regenerated to match the new given path.If you are using a
GtkStyleContext
returned fromgtk_widget_get_style_context()
, you do not need to call this yourself.Declaration
Swift
@inlinable func set<WidgetPathT>(path: WidgetPathT) where WidgetPathT : WidgetPathProtocol
-
set(scale:
Extension method) Sets the scale to use when getting image assets for the style.
Declaration
Swift
@inlinable func set(scale: Int)
-
set(screen:
Extension method) Attaches
context
to the given screen.The screen is used to add style information from “global” style providers, such as the screen’s
GtkSettings
instance.If you are using a
GtkStyleContext
returned fromgtk_widget_get_style_context()
, you do not need to call this yourself.Declaration
Swift
@inlinable func set<ScreenT>(screen: ScreenT) where ScreenT : ScreenProtocol
-
setState(flags:
Extension method) Sets the state to be used for style matching.
Declaration
Swift
@inlinable func setState(flags: StateFlags)
-
stateIsRunning(state:
Extension methodprogress: ) Returns
true
if there is a transition animation running for the current region (seegtk_style_context_push_animatable_region()
).If
progress
is notnil
, 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 whenstate
is being set and from 1 to 0 when it’s being unset.state_is_running is deprecated: This function always returns %FALSE
Declaration
Swift
@available(*, deprecated) @inlinable func stateIsRunning(state: GtkStateType, progress: UnsafeMutablePointer<gdouble>!) -> Bool
-
toString(flags:
Extension method) 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.
Declaration
Swift
@inlinable func toString(flags: StyleContextPrintFlags) -> String!
-
renderActivity(cr:
Extension methodx: y: width: height: ) Renders an activity indicator (such as in
GtkSpinner
). The stateGTK_STATE_FLAG_CHECKED
determines whether there is activity going on.Declaration
Swift
@inlinable func renderActivity<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double) where ContextT : ContextProtocol
-
renderArrow(cr:
Extension methodangle: x: y: size: ) Renders an arrow pointing to
angle
.Typical arrow rendering at 0, 1⁄2 π;, π; and 3⁄2 π:
Declaration
Swift
@inlinable func renderArrow<ContextT>(cr: ContextT, angle: Double, x: Double, y: Double, size: Double) where ContextT : ContextProtocol
-
renderBackground(cr:
Extension methodx: y: width: height: ) Renders the background of an element.
Typical background rendering, showing the effect of
background-image
,border-width
andborder-radius
:Declaration
Swift
@inlinable func renderBackground<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double) where ContextT : ContextProtocol
-
renderBackgroundGetClip(x:
Extension methody: width: height: outClip: ) Returns the area that will be affected (i.e. drawn to) when calling
gtk_render_background()
for the givencontext
and rectangle.Declaration
Swift
@inlinable func renderBackgroundGetClip<RectangleT>(x: Double, y: Double, width: Double, height: Double, outClip: RectangleT) where RectangleT : RectangleProtocol
-
renderCheck(cr:
Extension methodx: y: width: height: ) Renders a checkmark (as in a
GtkCheckButton
).The
GTK_STATE_FLAG_CHECKED
state determines whether the check is on or off, andGTK_STATE_FLAG_INCONSISTENT
determines whether it should be marked as undefined.Typical checkmark rendering:
Declaration
Swift
@inlinable func renderCheck<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double) where ContextT : ContextProtocol
-
renderExpander(cr:
Extension methodx: y: width: height: ) Renders an expander (as used in
GtkTreeView
andGtkExpander
) in the area defined byx
,y
,width
,height
. The stateGTK_STATE_FLAG_CHECKED
determines whether the expander is collapsed or expanded.Typical expander rendering:
Declaration
Swift
@inlinable func renderExpander<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double) where ContextT : ContextProtocol
-
renderExtension(cr:
Extension methodx: y: width: height: gapSide: ) Renders a extension (as in a
GtkNotebook
tab) in the rectangle defined byx
,y
,width
,height
. The side where the extension connects to is defined bygap_side
.Typical extension rendering:
Declaration
Swift
@inlinable func renderExtension<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double, gapSide: GtkPositionType) where ContextT : ContextProtocol
-
renderFocus(cr:
Extension methodx: y: width: height: ) Renders a focus indicator on the rectangle determined by
x
,y
,width
,height
.Typical focus rendering:
Declaration
Swift
@inlinable func renderFocus<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double) where ContextT : ContextProtocol
-
renderFrame(cr:
Extension methodx: y: width: height: ) Renders a frame around the rectangle defined by
x
,y
,width
,height
.Examples of frame rendering, showing the effect of
border-image
,border-color
,border-width
,border-radius
and junctions:Declaration
Swift
@inlinable func renderFrame<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double) where ContextT : ContextProtocol
-
renderFrameGap(cr:
Extension methodx: y: width: height: gapSide: xy0Gap: xy1Gap: ) Renders a frame around the rectangle defined by (
x
,y
,width
,height
), leaving a gap on one side.xy0_gap
andxy1_gap
will mean X coordinates forGTK_POS_TOP
andGTK_POS_BOTTOM
gap sides, and Y coordinates forGTK_POS_LEFT
andGTK_POS_RIGHT
.Typical rendering of a frame with a gap:
render_frame_gap is deprecated: Use gtk_render_frame() instead. Themes can create gaps by omitting borders via CSS.
Declaration
Swift
@available(*, deprecated) @inlinable func renderFrameGap<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double, gapSide: GtkPositionType, xy0Gap: Double, xy1Gap: Double) where ContextT : ContextProtocol
-
renderHandle(cr:
Extension methodx: y: width: height: ) Renders a handle (as in
GtkHandleBox
,GtkPaned
andGtkWindow
’s resize grip), in the rectangle determined byx
,y
,width
,height
.Handles rendered for the paned and grip classes:
Declaration
Swift
@inlinable func renderHandle<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double) where ContextT : ContextProtocol
-
renderIcon(cr:
Extension methodpixbuf: x: y: ) Renders the icon in
pixbuf
at the specifiedx
andy
coordinates.This function will render the icon in
pixbuf
at exactly its size, regardless of scaling factors, which may not be appropriate when drawing on displays with high pixel densities.You probably want to use
gtk_render_icon_surface()
instead, if you already have a Cairo surface.Declaration
Swift
@inlinable func renderIcon<ContextT, PixbufT>(cr: ContextT, pixbuf: PixbufT, x: Double, y: Double) where ContextT : ContextProtocol, PixbufT : PixbufProtocol
-
renderIconPixbuf(source:
Extension methodsize: ) Renders the icon specified by
source
at the givensize
, returning the result in a pixbuf.render_icon_pixbuf is deprecated: Use gtk_icon_theme_load_icon() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func renderIconPixbuf<IconSourceT>(source: IconSourceT, size: GtkIconSize) -> PixbufRef! where IconSourceT : IconSourceProtocol
-
renderIconSurface(cr:
Extension methodsurface: x: y: ) Renders the icon in
surface
at the specifiedx
andy
coordinates.Declaration
Swift
@inlinable func renderIconSurface<ContextT, SurfaceT>(cr: ContextT, surface: SurfaceT, x: Double, y: Double) where ContextT : ContextProtocol, SurfaceT : SurfaceProtocol
-
renderInsertionCursor(cr:
Extension methodx: y: layout: index: direction: ) Draws a text caret on
cr
at the specified index oflayout
.Declaration
Swift
@inlinable func renderInsertionCursor<ContextT, LayoutT>(cr: ContextT, x: Double, y: Double, layout: LayoutT, index: Int, direction: PangoDirection) where ContextT : ContextProtocol, LayoutT : LayoutProtocol
-
renderLayout(cr:
Extension methodx: y: layout: ) Renders
layout
on the coordinatesx
,y
Declaration
Swift
@inlinable func renderLayout<ContextT, LayoutT>(cr: ContextT, x: Double, y: Double, layout: LayoutT) where ContextT : ContextProtocol, LayoutT : LayoutProtocol
-
renderLine(cr:
Extension methodx0: y0: x1: y1: ) Renders a line from (x0, y0) to (x1, y1).
Declaration
Swift
@inlinable func renderLine<ContextT>(cr: ContextT, x0: Double, y0: Double, x1: Double, y1: Double) where ContextT : ContextProtocol
-
renderOption(cr:
Extension methodx: y: width: height: ) Renders an option mark (as in a
GtkRadioButton
), theGTK_STATE_FLAG_CHECKED
state will determine whether the option is on or off, andGTK_STATE_FLAG_INCONSISTENT
whether it should be marked as undefined.Typical option mark rendering:
Declaration
Swift
@inlinable func renderOption<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double) where ContextT : ContextProtocol
-
renderSlider(cr:
Extension methodx: y: width: height: orientation: ) Renders a slider (as in
GtkScale
) in the rectangle defined byx
,y
,width
,height
.orientation
defines whether the slider is vertical or horizontal.Typical slider rendering:
Declaration
Swift
@inlinable func renderSlider<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double, orientation: GtkOrientation) where ContextT : ContextProtocol
-
direction
Extension methodUndocumented
Declaration
Swift
@inlinable var direction: GtkTextDirection { get nonmutating set }
-
frameClock
Extension methodReturns the
GdkFrameClock
to whichcontext
is attached.Declaration
Swift
@inlinable var frameClock: Gdk.FrameClockRef! { get nonmutating set }
-
junctionSides
Extension methodReturns the sides where rendered elements connect visually with others.
Declaration
Swift
@inlinable var junctionSides: JunctionSides { get nonmutating set }
-
parent
Extension methodSets or gets the style context’s parent. See
gtk_style_context_set_parent()
for details.Declaration
Swift
@inlinable var parent: StyleContextRef! { get nonmutating set }
-
path
Extension methodReturns the widget path used for style matching.
Declaration
Swift
@inlinable var path: WidgetPathRef! { get nonmutating set }
-
scale
Extension methodReturns the scale used for assets.
Declaration
Swift
@inlinable var scale: Int { get nonmutating set }
-
screen
Extension methodUndocumented
Declaration
Swift
@inlinable var screen: Gdk.ScreenRef! { get nonmutating set }
-
state
Extension methodReturns the state used for style matching.
This method should only be used to retrieve the
GtkStateFlags
to pass toGtkStyleContext
methods, likegtk_style_context_get_padding()
. If you need to retrieve the current state of aGtkWidget
, usegtk_widget_get_state_flags()
.Declaration
Swift
@inlinable var state: StateFlags { get nonmutating set }
-
parentObject
Extension methodUndocumented
Declaration
Swift
@inlinable var parentObject: GObject { get }