ComponentProtocol
public protocol ComponentProtocol
AtkComponent
should be implemented by most if not all UI elements
with an actual on-screen presence, i.e. components which can be
said to have a screen-coordinate bounding box. Virtually all
widgets will need to have AtkComponent
implementations provided
for their corresponding AtkObject
class. In short, only UI
elements which are not GUI elements will omit this ATK interface.
A possible exception might be textual information with a
transparent background, in which case text glyph bounding box
information is provided by AtkText
.
The ComponentProtocol
protocol exposes the methods and properties of an underlying AtkComponent
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 Component
.
Alternatively, use ComponentRef
as a lighweight, unowned
reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
AtkComponent
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
component_ptr
Default implementationTyped pointer to the underlying
AtkComponent
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
AtkComponent
instance.Declaration
Swift
var component_ptr: UnsafeMutablePointer<AtkComponent>! { get }
-
Required Initialiser for types conforming to
ComponentProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
connect(signal:
Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
ComponentSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: ComponentSignalName, 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
ComponentSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: ComponentSignalName, 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)
-
onBoundsChanged(flags:
Extension methodhandler: ) The ‘bounds-changed" signal is emitted when the bposition or size of the component changes.
Note
This represents the underlyingbounds-changed
signalDeclaration
Swift
@discardableResult @inlinable func onBoundsChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ComponentRef, _ arg1: RectangleRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
arg1
The AtkRectangle giving the new position and size.
handler
The signal handler to call Run the given callback whenever the
boundsChanged
signal is emitted -
boundsChangedSignal
Extension methodTyped
bounds-changed
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var boundsChangedSignal: ComponentSignalName { get }
-
addFocus(handler:
Extension method) Add the specified handler to the set of functions to be called when this object receives focus events (in or out). If the handler is already added it is not added again
add_focus_handler is deprecated: If you need to track when an object gains or lose the focus, use the #AtkObject::state-change “focused” notification instead.
Declaration
Swift
@available(*, deprecated) @inlinable func addFocus(handler: AtkFocusHandler?) -> Int
-
contains(x:
Extension methody: coordType: ) Checks whether the specified point is within the extent of the
component
.Toolkit implementor note: ATK provides a default implementation for this virtual method. In general there are little reason to re-implement it.
Declaration
Swift
@inlinable func contains(x: Int, y: Int, coordType: AtkCoordType) -> Bool
-
getAlpha()
Extension methodReturns the alpha value (i.e. the opacity) for this
component
, on a scale from 0 (fully transparent) to 1.0 (fully opaque).Declaration
Swift
@inlinable func getAlpha() -> Double
-
getExtents(x:
Extension methody: width: height: coordType: ) Gets the rectangle which gives the extent of the
component
.If the extent can not be obtained (e.g. a non-embedded plug or missing support), all of x, y, width, height are set to -1.
Declaration
Swift
@inlinable func getExtents(x: UnsafeMutablePointer<gint>! = nil, y: UnsafeMutablePointer<gint>! = nil, width: UnsafeMutablePointer<gint>! = nil, height: UnsafeMutablePointer<gint>! = nil, coordType: AtkCoordType)
-
getLayer()
Extension methodGets the layer of the component.
Declaration
Swift
@inlinable func getLayer() -> AtkLayer
-
getMdiZorder()
Extension methodGets the zorder of the component. The value G_MININT will be returned if the layer of the component is not ATK_LAYER_MDI or ATK_LAYER_WINDOW.
Declaration
Swift
@inlinable func getMdiZorder() -> Int
-
getPosition(x:
Extension methody: coordType: ) Gets the position of
component
in the form of a point specifyingcomponent
‘s top-left corner.If the position can not be obtained (e.g. a non-embedded plug or missing support), x and y are set to -1.
get_position is deprecated: Since 2.12. Use atk_component_get_extents() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func getPosition(x: UnsafeMutablePointer<gint>! = nil, y: UnsafeMutablePointer<gint>! = nil, coordType: AtkCoordType)
-
getSize(width:
Extension methodheight: ) Gets the size of the
component
in terms of width and height.If the size can not be obtained (e.g. a non-embedded plug or missing support), width and height are set to -1.
get_size is deprecated: Since 2.12. Use atk_component_get_extents() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func getSize(width: UnsafeMutablePointer<gint>! = nil, height: UnsafeMutablePointer<gint>! = nil)
-
grabFocus()
Extension methodGrabs focus for this
component
.Declaration
Swift
@inlinable func grabFocus() -> Bool
-
refAccessibleAtPoint(x:
Extension methody: coordType: ) Gets a reference to the accessible child, if one exists, at the coordinate point specified by
x
andy
.Declaration
Swift
@inlinable func refAccessibleAtPoint(x: Int, y: Int, coordType: AtkCoordType) -> Atk.ObjectRef!
-
removeFocusHandler(handlerId:
Extension method) Remove the handler specified by
handler_id
from the list of functions to be executed when this object receives focus events (in or out).remove_focus_handler is deprecated: If you need to track when an object gains or lose the focus, use the #AtkObject::state-change “focused” notification instead.
Declaration
Swift
@available(*, deprecated) @inlinable func removeFocusHandler(handlerId: Int)
-
scrollTo(type:
Extension method) Makes
component
visible on the screen by scrolling all necessary parents.Contrary to atk_component_set_position, this does not actually move
component
in its parent, this only makes the parents scroll so that the object shows up on the screen, given its current position within the parents.Declaration
Swift
@inlinable func scrollTo(type: AtkScrollType) -> Bool
-
scrollToPoint(coords:
Extension methodx: y: ) Move the top-left of
component
to a given position of the screen by scrolling all necessary parents.Declaration
Swift
@inlinable func scrollToPoint(coords: AtkCoordType, x: Int, y: Int) -> Bool
-
setExtents(x:
Extension methody: width: height: coordType: ) Sets the extents of
component
.Declaration
Swift
@inlinable func setExtents(x: Int, y: Int, width: Int, height: Int, coordType: AtkCoordType) -> Bool
-
setPosition(x:
Extension methody: coordType: ) Sets the position of
component
.Contrary to atk_component_scroll_to, this does not trigger any scrolling, this just moves
component
in its parent.Declaration
Swift
@inlinable func setPosition(x: Int, y: Int, coordType: AtkCoordType) -> Bool
-
setSize(width:
Extension methodheight: ) Set the size of the
component
in terms of width and height.Declaration
Swift
@inlinable func setSize(width: Int, height: Int) -> Bool
-
alpha
Extension methodReturns the alpha value (i.e. the opacity) for this
component
, on a scale from 0 (fully transparent) to 1.0 (fully opaque).Declaration
Swift
@inlinable var alpha: Double { get }
-
layer
Extension methodGets the layer of the component.
Declaration
Swift
@inlinable var layer: AtkLayer { get }
-
mdiZorder
Extension methodGets the zorder of the component. The value G_MININT will be returned if the layer of the component is not ATK_LAYER_MDI or ATK_LAYER_WINDOW.
Declaration
Swift
@inlinable var mdiZorder: Int { get }