package ocgtk

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Wrappers.Style_context

type t = [ `style_context | `object_ ] Gobject.obj
val to_string : t -> Gtk_enums.stylecontextprintflags -> string

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.

val set_state : t -> Gtk_enums.stateflags -> unit

Sets the state to be used for style matching.

val set_scale : t -> int -> unit

Sets the scale to use when getting image assets for the style.

val set_display : t -> Ocgtk_gdk.Gdk.Wrappers.Display.t -> unit

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.

val save : t -> unit

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.

val restore : t -> unit

Restores @context state to a previous stage.

See method@Gtk.StyleContext.save.

val remove_provider : t -> [ `style_provider ] Gobject.obj -> unit

Removes @provider from the style providers list in @context.

val remove_class : t -> string -> unit

Removes @class_name from @context.

val lookup_color : t -> string -> bool * Ocgtk_gdk.Gdk.Wrappers.Rgb_a.t

Looks up and resolves a color name in the @context color map.

val has_class : t -> string -> bool

Returns %TRUE if @context currently has defined the given class name.

val get_state : t -> Gtk_enums.stateflags

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.

val get_scale : t -> int

Returns the scale used for assets.

val get_padding : t -> [ `border ] Gobject.obj

Gets the padding for a given state as a `GtkBorder`.

val get_margin : t -> [ `border ] Gobject.obj

Gets the margin for a given state as a `GtkBorder`.

val get_display : t -> Ocgtk_gdk.Gdk.Wrappers.Display.t

Returns the `GdkDisplay` to which @context is attached.

Gets the foreground color for a given state.

val get_border : t -> [ `border ] Gobject.obj

Gets the border for a given state as a `GtkBorder`.

val add_provider : t -> [ `style_provider ] Gobject.obj -> int -> unit

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.

val add_class : t -> string -> unit

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 ... ```