DrawContextProtocol
public protocol DrawContextProtocol : ObjectProtocol
The DrawContextProtocol
protocol exposes the methods and properties of an underlying GdkDrawContext
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 DrawContext
.
Alternatively, use DrawContextRef
as a lighweight, unowned
reference if you already have an instance you just want to use.
Base class for objects implementing different rendering methods.
GdkDrawContext
is the base object used by contexts implementing different
rendering methods, such as [classGdk.CairoContext
] or [classGdk.GLContext
].
It provides shared functionality between those contexts.
You will always interact with one of those subclasses.
A GdkDrawContext
is always associated with a single toplevel surface.
-
Untyped pointer to the underlying
GdkDrawContext
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
draw_context_ptr
Default implementationTyped pointer to the underlying
GdkDrawContext
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GdkDrawContext
instance.Declaration
Swift
var draw_context_ptr: UnsafeMutablePointer<GdkDrawContext>! { get }
-
Required Initialiser for types conforming to
DrawContextProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
DrawContextPropertyName
source property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: DrawContextPropertyName, 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 DrawContext property
Declaration
Swift
@inlinable func get(property: DrawContextPropertyName) -> 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 DrawContext property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: DrawContextPropertyName, value v: GLibObject.Value)
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
beginFrame(region:
Extension method) Indicates that you are beginning the process of redrawing
region
on thecontext
‘s surface.Calling this function begins a drawing operation using
context
on the surface thatcontext
was created from. The actual requirements and guarantees for the drawing operation vary for different implementations of drawing, so a [classGdk.CairoContext
] and a [classGdk.GLContext
] need to be treated differently.A call to this function is a requirement for drawing and must be followed by a call to [method
Gdk.DrawContext.end_frame
], which will complete the drawing operation and ensure the contents become visible on screen.Note that the
region
passed to this function is the minimum region that needs to be drawn and depending on implementation, windowing system and hardware in use, it might be necessary to draw a larger region. Drawing implementation must use [methodGdk.DrawContext.get_frame_region
()
to query the region that must be drawn.When using GTK, the widget system automatically places calls to
gdk_draw_context_begin_frame()
andgdk_draw_context_end_frame()
via the use of [classGsk.Renderer
]s, so application code does not need to call these functions explicitly.Declaration
Swift
@inlinable func beginFrame<RegionT>(region: RegionT) where RegionT : RegionProtocol
-
endFrame()
Extension methodEnds a drawing operation started with
gdk_draw_context_begin_frame()
.This makes the drawing available on screen. See [method
Gdk.DrawContext.begin_frame
] for more details about drawing.When using a [class
Gdk.GLContext
], this function may callglFlush()
implicitly before returning; it is not recommended to callglFlush()
explicitly before calling this function.Declaration
Swift
@inlinable func endFrame()
-
getDisplay()
Extension methodRetrieves the
GdkDisplay
thecontext
is created forDeclaration
Swift
@inlinable func getDisplay() -> DisplayRef!
-
getFrameRegion()
Extension methodRetrieves the region that is currently being repainted.
After a call to [method
Gdk.DrawContext.begin_frame
] this function will return a union of the region passed to that function and the area of the surface that thecontext
determined needs to be repainted.If
context
is not in between calls to [methodGdk.DrawContext.begin_frame
] and [methodGdk.DrawContext.end_frame
],nil
will be returned.Declaration
Swift
@inlinable func getFrameRegion() -> Cairo.RegionRef!
-
getSurface()
Extension methodRetrieves the surface that
context
is bound to.Declaration
Swift
@inlinable func getSurface() -> SurfaceRef!
-
display
Extension methodThe
GdkDisplay
used to create theGdkDrawContext
.Declaration
Swift
@inlinable var display: DisplayRef! { get }
-
frameRegion
Extension methodRetrieves the region that is currently being repainted.
After a call to [method
Gdk.DrawContext.begin_frame
] this function will return a union of the region passed to that function and the area of the surface that thecontext
determined needs to be repainted.If
context
is not in between calls to [methodGdk.DrawContext.begin_frame
] and [methodGdk.DrawContext.end_frame
],nil
will be returned.Declaration
Swift
@inlinable var frameRegion: Cairo.RegionRef! { get }
-
isInFrame
Extension methodReturns
true
ifcontext
is in the process of drawing to its surface.This is the case between calls to [method
Gdk.DrawContext.begin_frame
] and [methodGdk.DrawContext.end_frame
]. In this situation, drawing commands may be effecting the contents of thecontext
‘s surface.Declaration
Swift
@inlinable var isInFrame: Bool { get }
-
surface
Extension methodThe
GdkSurface
the context is bound to.Declaration
Swift
@inlinable var surface: SurfaceRef! { get }