Package ch.bailu.gtk.gtk
Klasse StyleContext
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.type.PropertyHolder
ch.bailu.gtk.gtk.StyleContext
- Alle implementierten Schnittstellen:
PointerInterface
`GtkStyleContext` stores styling information affecting a widget.
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
[method@Gtk.StyleContext.add_provider], or to the display through
[func@Gtk.StyleContext.add_provider_for_display]. The resulting
style is a combination of all providers’ information in priority order.
For GTK widgets, any `GtkStyleContext` returned by
[method@Gtk.Widget.get_style_context] will already have a `GdkDisplay`
and RTL/LTR information set. The style context will also be updated
automatically if any of these settings change on the widget.
## 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.
# Custom styling in UI libraries and applications
If you are developing a library with custom widgets 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-4.0/gtk.css` will
still take precedence over your changes, as it uses the
%GTK_STYLE_PROVIDER_PRIORITY_USER priority.
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
[method@Gtk.StyleContext.add_provider], or to the display through
[func@Gtk.StyleContext.add_provider_for_display]. The resulting
style is a combination of all providers’ information in priority order.
For GTK widgets, any `GtkStyleContext` returned by
[method@Gtk.Widget.get_style_context] will already have a `GdkDisplay`
and RTL/LTR information set. The style context will also be updated
automatically if any of these settings change on the widget.
## 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.
# Custom styling in UI libraries and applications
If you are developing a library with custom widgets 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-4.0/gtk.css` will
still take precedence over your changes, as it uses the
%GTK_STYLE_PROVIDER_PRIORITY_USER priority.
-
Verschachtelte Klassen - Übersicht
Von Klasse geerbte verschachtelte Klassen/Schnittstellen ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Feldübersicht
Von Klasse geerbte Felder ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
Veraltet.void
Veraltet.void
addProvider
(StyleProvider provider, int priority) Veraltet.static void
addProviderForDisplay
(Display display, StyleProvider provider, int priority) Adds a global style provider to @display, which will be used
in style construction for all `GtkStyleContexts` under @display.void
Veraltet.static ClassHandler
void
Veraltet.Veraltet.static int
void
Veraltet.void
getPadding
(Border padding) Veraltet.static long
static TypeSystem.TypeSize
int
getScale()
Veraltet.int
getState()
Veraltet.static long
static TypeSystem.TypeSize
boolean
Veraltet.boolean
Veraltet.boolean
lookupColor
(Str color_name, RGBA color) Veraltet.boolean
lookupColor
(String color_name, RGBA color) Veraltet.void
removeClass
(Str class_name) Veraltet.void
removeClass
(String class_name) Veraltet.void
removeProvider
(StyleProvider provider) Veraltet.static void
removeProviderForDisplay
(Display display, StyleProvider provider) Removes @provider from the global style providers list in @display.void
restore()
Veraltet.void
save()
Veraltet.void
setDisplay
(Display display) Veraltet.void
setScale
(int scale) Veraltet.void
setState
(int flags) Veraltet.toStr
(int flags) Veraltet.Von Klasse geerbte Methoden ch.bailu.gtk.type.PropertyHolder
getBooleanProperty, getIntProperty, getObjectProperty, getStringProperty, getStrProperty, setBooleanProperty, setIntProperty, setObjectProperty, setStringProperty, setStrProperty
Von Klasse geerbte Methoden ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Von Klasse geerbte Methoden ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Von Klasse geerbte Methoden ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Von Klasse geerbte Methoden java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Von Schnittstelle geerbte Methoden ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Konstruktordetails
-
StyleContext
-
-
Methodendetails
-
getClassHandler
-
addClass
Veraltet.Adds a style class to @context, so later uses of the
style context 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
entry.search { ... }
```
While any widget defining a “search” class would be
matched by:
```css
.search { ... }
```- Parameter:
class_name
- class name to use in styling
-
addClass
Veraltet.Adds a style class to @context, so later uses of the
style context 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
entry.search { ... }
```
While any widget defining a “search” class would be
matched by:
```css
.search { ... }
```- Parameter:
class_name
- class name to use in styling
-
addProvider
Veraltet.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
[func@Gtk.StyleContext.add_provider_for_display].
Note: If both priorities are the same, a `GtkStyleProvider`
added through this function takes precedence over another added
through [func@Gtk.StyleContext.add_provider_for_display].- Parameter:
provider
- a `GtkStyleProvider`priority
- the priority of the style provider. The lower it is, the earlier it will be used in the style construction. Typically this will be in the range between %GTK_STYLE_PROVIDER_PRIORITY_FALLBACK and %GTK_STYLE_PROVIDER_PRIORITY_USER
-
getBorder
Veraltet.Gets the border for a given state as a `GtkBorder`.- Parameter:
border
- return value for the border settings
-
getColor
Veraltet.Gets the foreground color for a given state.- Parameter:
color
- return value for the foreground color
-
getDisplay
Veraltet.Returns the `GdkDisplay` to which @context is attached.- Gibt zurück:
- a `GdkDisplay`.
-
getMargin
Veraltet.Gets the margin for a given state as a `GtkBorder`.- Parameter:
margin
- return value for the margin settings
-
getPadding
Veraltet.Gets the padding for a given state as a `GtkBorder`.- Parameter:
padding
- return value for the padding settings
-
getScale
Veraltet.Returns the scale used for assets.- Gibt zurück:
- the scale
-
getState
Veraltet.Returns the state used for style matching.
This method should only be used to retrieve the `GtkStateFlags`
to pass to `GtkStyleContext` methods, like
[method@Gtk.StyleContext.get_padding].
If you need to retrieve the current state of a `GtkWidget`, use
[method@Gtk.Widget.get_state_flags].- Gibt zurück:
- the state flags
-
hasClass
Veraltet.Returns %TRUE if @context currently has defined the
given class name.- Parameter:
class_name
- a class name- Gibt zurück:
- %TRUE if @context has @class_name defined
-
hasClass
Veraltet.Returns %TRUE if @context currently has defined the
given class name.- Parameter:
class_name
- a class name- Gibt zurück:
- %TRUE if @context has @class_name defined
-
lookupColor
Veraltet.Looks up and resolves a color name in the @context color map.- Parameter:
color_name
- color name to lookupcolor
- Return location for the looked up color- Gibt zurück:
- %TRUE if @color_name was found and resolved, %FALSE otherwise
-
lookupColor
Veraltet.Looks up and resolves a color name in the @context color map.- Parameter:
color_name
- color name to lookupcolor
- Return location for the looked up color- Gibt zurück:
- %TRUE if @color_name was found and resolved, %FALSE otherwise
-
removeClass
Veraltet.Removes @class_name from @context.- Parameter:
class_name
- class name to remove
-
removeClass
Veraltet.Removes @class_name from @context.- Parameter:
class_name
- class name to remove
-
removeProvider
Veraltet.Removes @provider from the style providers list in @context.- Parameter:
provider
- a `GtkStyleProvider`
-
restore
Veraltet.Restores @context state to a previous stage.
See [method@Gtk.StyleContext.save]. -
save
Veraltet.Saves the @context state.
This allows temporary modifications done through
[method@Gtk.StyleContext.add_class],
[method@Gtk.StyleContext.remove_class],
[method@Gtk.StyleContext.set_state] to be quickly
reverted in one go through [method@Gtk.StyleContext.restore].
The matching call to [method@Gtk.StyleContext.restore]
must be done before GTK returns to the main loop. -
setDisplay
Veraltet.Attaches @context to the given display.
The display is used to add style information from “global”
style providers, such as the display's `GtkSettings` instance.
If you are using a `GtkStyleContext` returned from
[method@Gtk.Widget.get_style_context], you do not need to
call this yourself.- Parameter:
display
- a `GdkDisplay`
-
setScale
Veraltet.Sets the scale to use when getting image assets for the style.- Parameter:
scale
- scale
-
setState
Veraltet.Sets the state to be used for style matching.- Parameter:
flags
- state to represent
-
toStr
Veraltet.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.- Parameter:
flags
- Flags that determine what to print- Gibt zurück:
- a newly allocated string representing @context
-
addProviderForDisplay
public static void addProviderForDisplay(@Nonnull Display display, @Nonnull StyleProvider provider, int priority) Adds a global style provider to @display, which will be used
in style construction for all `GtkStyleContexts` under @display.
GTK uses this to make styling information from `GtkSettings`
available.
Note: If both priorities are the same, A `GtkStyleProvider`
added through [method@Gtk.StyleContext.add_provider] takes
precedence over another added through this function.- Parameter:
display
- a `GdkDisplay`provider
- a `GtkStyleProvider`priority
- the priority of the style provider. The lower it is, the earlier it will be used in the style construction. Typically this will be in the range between %GTK_STYLE_PROVIDER_PRIORITY_FALLBACK and %GTK_STYLE_PROVIDER_PRIORITY_USER
-
removeProviderForDisplay
public static void removeProviderForDisplay(@Nonnull Display display, @Nonnull StyleProvider provider) Removes @provider from the global style providers list in @display.- Parameter:
display
- a `GdkDisplay`provider
- a `GtkStyleProvider`
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-