Functions
The following functions are available globally.
-
The main way to draw GL content in GTK.
It takes a render buffer ID (
source_type
==GL_RENDERBUFFER
) or a texture id (source_type
==GL_TEXTURE
) and draws it ontocr
with an OVER operation, respecting the current clip. The top left corner of the rectangle specified byx
,y
,width
andheight
will be drawn at the current (0,0) position of thecairo_t
.This will work for all
cairo_t
, as long assurface
is realized, but the fallback implementation that reads back the pixels from the buffer may be used in the general case. In the case of direct drawing to a surface with no special effects applied tocr
it will however use a more efficient approach.For
GL_RENDERBUFFER
the code will always fall back to software for buffers with alpha components, so make sure you useGL_TEXTURE
if using alpha.Calling this may change the current GL context.
Declaration
Swift
@inlinable public func cairoDrawFromGl<ContextT, SurfaceT>(cr: ContextT, surface: SurfaceT, source: Int, sourceType: Int, bufferScale: Int, x: Int, y: Int, width: Int, height: Int) where ContextT : ContextProtocol, SurfaceT : SurfaceProtocol
-
Adds the given rectangle to the current path of
cr
.Declaration
Swift
@inlinable public func cairoRectangle<ContextT, RectangleT>(cr: ContextT, rectangle: RectangleT) where ContextT : ContextProtocol, RectangleT : RectangleProtocol
-
Adds the given region to the current path of
cr
.Declaration
Swift
@inlinable public func cairoRegion<ContextT, RegionT>(cr: ContextT, region: RegionT) where ContextT : ContextProtocol, RegionT : RegionProtocol
-
Creates region that covers the area where the given
surface
is more than 50% opaque.This function takes into account device offsets that might be set with
cairo_surface_set_device_offset()
.Declaration
Swift
@inlinable public func cairoRegionCreateFrom<SurfaceT>(surface: SurfaceT) -> Cairo.RegionRef! where SurfaceT : SurfaceProtocol
-
Sets the given pixbuf as the source pattern for
cr
.The pattern has an extend mode of
CAIRO_EXTEND_NONE
and is aligned so that the origin ofpixbuf
ispixbuf_x
,pixbuf_y
.Declaration
Swift
@inlinable public func cairoSetSourcePixbuf<ContextT, PixbufT>(cr: ContextT, pixbuf: PixbufT, pixbufX: CDouble, pixbufY: CDouble) where ContextT : ContextProtocol, PixbufT : PixbufProtocol
-
Sets the specified
GdkRGBA
as the source color ofcr
.Declaration
Swift
@inlinable public func cairoSetSourceRgba<ContextT, RGBAT>(cr: ContextT, rgba: RGBAT) where ContextT : ContextProtocol, RGBAT : RGBAProtocol
-
Read content from the given input stream and deserialize it, asynchronously.
The default I/O priority is
G_PRIORITY_DEFAULT
(i.e. 0), and lower numbers indicate a higher priority.When the operation is finished,
callback
will be called. You must then call [funccontent_deserialize_finish
] to get the result of the operation.Declaration
Swift
@inlinable public func contentDeserializeAsync<InputStreamT>(stream: InputStreamT, mimeType: UnsafePointer<CChar>!, type: GType, ioPriority: Int, cancellable: GIO.CancellableRef? = nil, callback: GAsyncReadyCallback? = nil, userData: gpointer! = nil) where InputStreamT : InputStreamProtocol
-
Read content from the given input stream and deserialize it, asynchronously.
The default I/O priority is
G_PRIORITY_DEFAULT
(i.e. 0), and lower numbers indicate a higher priority.When the operation is finished,
callback
will be called. You must then call [funccontent_deserialize_finish
] to get the result of the operation.Declaration
Swift
@inlinable public func contentDeserializeAsync<CancellableT, InputStreamT>(stream: InputStreamT, mimeType: UnsafePointer<CChar>!, type: GType, ioPriority: Int, cancellable: CancellableT?, callback: GAsyncReadyCallback? = nil, userData: gpointer! = nil) where CancellableT : CancellableProtocol, InputStreamT : InputStreamProtocol
-
Finishes a content deserialization operation.
Declaration
Swift
@inlinable public func contentDeserializeFinish<AsyncResultT, ValueT>(result: AsyncResultT, value: ValueT) throws -> Bool where AsyncResultT : AsyncResultProtocol, ValueT : ValueProtocol
-
Registers a function to deserialize object of a given type.
Declaration
Swift
@inlinable public func contentRegisterDeserializer(mimeType: UnsafePointer<CChar>!, type: GType, deserialize: GdkContentDeserializeFunc?, data: gpointer! = nil, notify: GDestroyNotify?)
-
Registers a function to serialize objects of a given type.
Declaration
Swift
@inlinable public func contentRegisterSerializer(type: GType, mimeType: UnsafePointer<CChar>!, serialize: GdkContentSerializeFunc?, data: gpointer! = nil, notify: GDestroyNotify?)
-
Serialize content and write it to the given output stream, asynchronously.
The default I/O priority is
G_PRIORITY_DEFAULT
(i.e. 0), and lower numbers indicate a higher priority.When the operation is finished,
callback
will be called. You must then call [funccontent_serialize_finish
] to get the result of the operation.Declaration
Swift
@inlinable public func contentSerializeAsync<OutputStreamT, ValueT>(stream: OutputStreamT, mimeType: UnsafePointer<CChar>!, value: ValueT, ioPriority: Int, cancellable: GIO.CancellableRef? = nil, callback: GAsyncReadyCallback? = nil, userData: gpointer! = nil) where OutputStreamT : OutputStreamProtocol, ValueT : ValueProtocol
-
Serialize content and write it to the given output stream, asynchronously.
The default I/O priority is
G_PRIORITY_DEFAULT
(i.e. 0), and lower numbers indicate a higher priority.When the operation is finished,
callback
will be called. You must then call [funccontent_serialize_finish
] to get the result of the operation.Declaration
Swift
@inlinable public func contentSerializeAsync<CancellableT, OutputStreamT, ValueT>(stream: OutputStreamT, mimeType: UnsafePointer<CChar>!, value: ValueT, ioPriority: Int, cancellable: CancellableT?, callback: GAsyncReadyCallback? = nil, userData: gpointer! = nil) where CancellableT : CancellableProtocol, OutputStreamT : OutputStreamProtocol, ValueT : ValueProtocol
-
Finishes a content serialization operation.
Declaration
Swift
@inlinable public func contentSerializeFinish<AsyncResultT>(result: AsyncResultT) throws -> Bool where AsyncResultT : AsyncResultProtocol
-
Checks if
action
represents a single action or includes multiple actions.When
action
is 0 - ie no action was given,true
is returned.Declaration
Swift
@inlinable public func dragActionIsUnique(action: DragAction) -> Bool
-
Returns the relative angle from
event1
toevent2
.The relative angle is the angle between the X axis and the line through both events’ positions. The rotation direction for positive angles is from the positive X axis towards the positive Y axis.
This assumes that both events have X/Y information. If not, this function returns
false
.Declaration
Swift
@inlinable public func eventsGetAngle<EventT>(event1: EventT, event2: EventT, angle: UnsafeMutablePointer<CDouble>!) -> Bool where EventT : EventProtocol
-
Returns the point halfway between the events’ positions.
This assumes that both events have X/Y information. If not, this function returns
false
.Declaration
Swift
@inlinable public func eventsGetCenter<EventT>(event1: EventT, event2: EventT, x: UnsafeMutablePointer<CDouble>!, y: UnsafeMutablePointer<CDouble>!) -> Bool where EventT : EventProtocol
-
Returns the distance between the event locations.
This assumes that both events have X/Y information. If not, this function returns
false
.Declaration
Swift
@inlinable public func eventsGetDistance<EventT>(event1: EventT, event2: EventT, distance: UnsafeMutablePointer<CDouble>!) -> Bool where EventT : EventProtocol
-
Undocumented
Declaration
Swift
@inlinable public func glErrorQuark() -> GQuark
-
Canonicalizes the given mime type and interns the result.
If
string
is not a valid mime type,nil
is returned instead. See RFC 2048 for the syntax if mime types.Declaration
Swift
@inlinable public func internMimeType(string: UnsafePointer<CChar>!) -> String!
-
Obtains the upper- and lower-case versions of the keyval
symbol
.Examples of keyvals are
GDK_KEY_a
,GDK_KEY_Enter
,GDK_KEY_F1
, etc.Declaration
Swift
@inlinable public func keyvalConvertCase(symbol: Int, lower: UnsafeMutablePointer<guint>!, upper: UnsafeMutablePointer<guint>!)
-
Converts a key name to a key value.
The names are the same as those in the
gdk/gdkkeysyms.h
header file but without the leading “GDK_KEY_”.Declaration
Swift
@inlinable public func keyvalFromName(keyvalName: UnsafePointer<CChar>!) -> Int
-
Returns
true
if the given key value is in lower case.Declaration
Swift
@inlinable public func keyvalIsLower(keyval: Int) -> Bool
-
Returns
true
if the given key value is in upper case.Declaration
Swift
@inlinable public func keyvalIsUpper(keyval: Int) -> Bool
-
Converts a key value into a symbolic name.
The names are the same as those in the
gdk/gdkkeysyms.h
header file but without the leading “GDK_KEY_”.Declaration
Swift
@inlinable public func keyvalName(keyval: Int) -> String!
-
Converts a key value to lower case, if applicable.
Declaration
Swift
@inlinable public func keyvalToLower(keyval: Int) -> Int
-
Convert from a GDK key symbol to the corresponding Unicode character.
Note that the conversion does not take the current locale into consideration, which might be expected for particular keyvals, such as
GDK_KEY_KP_Decimal
.Declaration
Swift
@inlinable public func keyvalToUnicode(keyval: Int) -> guint32
-
Converts a key value to upper case, if applicable.
Declaration
Swift
@inlinable public func keyvalToUpper(keyval: Int) -> Int
-
Returns a paintable that has the given intrinsic size and draws nothing.
This is often useful for implementing the
GdkPaintableInterface.get_current_image
()
virtual function when the paintable is in an incomplete state (like a [classGtk.MediaStream
] before receiving the first frame).Declaration
Swift
@inlinable public func paintableNewEmpty(intrinsicWidth: Int, intrinsicHeight: Int) -> PaintableRef!
-
Obtains a clip region which contains the areas where the given ranges of text would be drawn.
x_origin
andy_origin
are the top left point to center the layout.index_ranges
should contain ranges of bytes in the layout’s text.Note that the regions returned correspond to logical extents of the text ranges, not ink extents. So the drawn layout may in fact touch areas out of the clip region. The clip region is mainly useful for highlightling parts of text, such as when text is selected.
Declaration
Swift
@inlinable public func pangoLayoutGetClipRegion<LayoutT>(layout: LayoutT, xOrigin: Int, yOrigin: Int, indexRanges: UnsafePointer<gint>!, nRanges: Int) -> Cairo.RegionRef! where LayoutT : LayoutProtocol
-
Obtains a clip region which contains the areas where the given ranges of text would be drawn.
x_origin
andy_origin
are the top left position of the layout.index_ranges
should contain ranges of bytes in the layout’s text. The clip region will include space to the left or right of the line (to the layout bounding box) if you have indexes above or below the indexes contained inside the line. This is to draw the selection all the way to the side of the layout. However, the clip region is in line coordinates, not layout coordinates.Note that the regions returned correspond to logical extents of the text ranges, not ink extents. So the drawn line may in fact touch areas out of the clip region. The clip region is mainly useful for highlightling parts of text, such as when text is selected.
Declaration
Swift
@inlinable public func pangoLayoutLineGetClipRegion<LayoutLineT>(line: LayoutLineT, xOrigin: Int, yOrigin: Int, indexRanges: UnsafePointer<CInt>!, nRanges: Int) -> Cairo.RegionRef! where LayoutLineT : LayoutLineProtocol
-
Transfers image data from a
cairo_surface_t
and converts it to aGdkPixbuf
.This allows you to efficiently read individual pixels from cairo surfaces.
This function will create an RGB pixbuf with 8 bits per channel. The pixbuf will contain an alpha channel if the
surface
contains one.Declaration
Swift
@inlinable public func pixbufGetFrom<SurfaceT>(surface: SurfaceT, srcX: Int, srcY: Int, width: Int, height: Int) -> PixbufRef! where SurfaceT : SurfaceProtocol
-
Creates a new pixbuf from
texture
.This should generally not be used in newly written code as later stages will almost certainly convert the pixbuf back into a texture to draw it on screen.
Declaration
Swift
@inlinable public func pixbufGetFrom<TextureT>(texture: TextureT) -> PixbufRef! where TextureT : TextureProtocol
-
Sets a list of backends that GDK should try to use.
This can be useful if your application does not work with certain GDK backends.
By default, GDK tries all included backends.
For example:
gdk_set_allowed_backends ("wayland,macos,*");
instructs GDK to try the Wayland backend first, followed by the MacOs backend, and then all others.
If the
GDK_BACKEND
environment variable is set, it determines what backends are tried in what order, while still respecting the set of allowed backends that are specified by this function.The possible backend names are:
broadway
macos
wayland
.win32
x11
You can also include a
*
in the list to try all remaining backends.This call must happen prior to functions that open a display, such as [func
Gdk.Display.open
],gtk_init()
, orgtk_init_check()
in order to take effect.Declaration
Swift
@inlinable public func setAllowed(backends: UnsafePointer<CChar>!)
-
Undocumented
Declaration
Swift
@inlinable public func toplevelSizeGetType() -> GType
-
Convert from a Unicode character to a key symbol.
Declaration
Swift
@inlinable public func unicodeToKeyval(wc: guint32) -> Int
-
Undocumented
Declaration
Swift
@inlinable public func vulkanErrorQuark() -> GQuark