Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
- Methods
- cairoDrawFromGl
- cairoRectangle
- cairoRegion
- cairoRegionCreateFromSurface
- cairoSetSourcePixbuf
- cairoSetSourceRgba
- contentDeserializeAsync
- contentDeserializeFinish
- contentRegisterDeserializer
- contentRegisterSerializer
- contentSerializeAsync
- contentSerializeFinish
- eventsGetAngle
- eventsGetCenter
- eventsGetDistance
- internMimeType
- keyvalConvertCase
- keyvalFromName
- keyvalIsLower
- keyvalIsUpper
- keyvalName
- keyvalToLower
- keyvalToUnicode
- keyvalToUpper
- pixbufGetFromSurface
- pixbufGetFromTexture
- setAllowedBackends
- toplevelSizeGetType
- unicodeToKeyval
Synopsis
- cairoDrawFromGl :: (HasCallStack, MonadIO m, IsSurface a) => Context -> a -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> m ()
- cairoRectangle :: (HasCallStack, MonadIO m) => Context -> Rectangle -> m ()
- cairoRegion :: (HasCallStack, MonadIO m) => Context -> Region -> m ()
- cairoRegionCreateFromSurface :: (HasCallStack, MonadIO m) => Surface -> m Region
- cairoSetSourcePixbuf :: (HasCallStack, MonadIO m, IsPixbuf a) => Context -> a -> Double -> Double -> m ()
- cairoSetSourceRgba :: (HasCallStack, MonadIO m) => Context -> RGBA -> m ()
- contentDeserializeAsync :: (HasCallStack, MonadIO m, IsInputStream a, IsCancellable b) => a -> Text -> GType -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- contentDeserializeFinish :: (HasCallStack, MonadIO m, IsAsyncResult a) => a -> GValue -> m ()
- contentRegisterDeserializer :: (HasCallStack, MonadIO m) => Text -> GType -> ContentDeserializeFunc -> m ()
- contentRegisterSerializer :: (HasCallStack, MonadIO m) => GType -> Text -> ContentSerializeFunc -> m ()
- contentSerializeAsync :: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) => a -> Text -> GValue -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- contentSerializeFinish :: (HasCallStack, MonadIO m, IsAsyncResult a) => a -> m ()
- eventsGetAngle :: (HasCallStack, MonadIO m, IsEvent a, IsEvent b) => a -> b -> m (Bool, Double)
- eventsGetCenter :: (HasCallStack, MonadIO m, IsEvent a, IsEvent b) => a -> b -> m (Bool, Double, Double)
- eventsGetDistance :: (HasCallStack, MonadIO m, IsEvent a, IsEvent b) => a -> b -> m (Bool, Double)
- internMimeType :: (HasCallStack, MonadIO m) => Text -> m (Maybe Text)
- keyvalConvertCase :: (HasCallStack, MonadIO m) => Word32 -> m (Word32, Word32)
- keyvalFromName :: (HasCallStack, MonadIO m) => Text -> m Word32
- keyvalIsLower :: (HasCallStack, MonadIO m) => Word32 -> m Bool
- keyvalIsUpper :: (HasCallStack, MonadIO m) => Word32 -> m Bool
- keyvalName :: (HasCallStack, MonadIO m) => Word32 -> m (Maybe Text)
- keyvalToLower :: (HasCallStack, MonadIO m) => Word32 -> m Word32
- keyvalToUnicode :: (HasCallStack, MonadIO m) => Word32 -> m Word32
- keyvalToUpper :: (HasCallStack, MonadIO m) => Word32 -> m Word32
- pixbufGetFromSurface :: (HasCallStack, MonadIO m) => Surface -> Int32 -> Int32 -> Int32 -> Int32 -> m (Maybe Pixbuf)
- pixbufGetFromTexture :: (HasCallStack, MonadIO m, IsTexture a) => a -> m (Maybe Pixbuf)
- setAllowedBackends :: (HasCallStack, MonadIO m) => Text -> m ()
- toplevelSizeGetType :: (HasCallStack, MonadIO m) => m GType
- unicodeToKeyval :: (HasCallStack, MonadIO m) => Word32 -> m Word32
Methods
cairoDrawFromGl
:: (HasCallStack, MonadIO m, IsSurface a) | |
=> Context |
|
-> a |
|
-> Int32 |
|
-> Int32 |
|
-> Int32 |
|
-> Int32 |
|
-> Int32 |
|
-> Int32 |
|
-> Int32 |
|
-> m () |
The main way to draw GL content in GTK.
It takes a render buffer ID (sourceType
== GL_RENDERBUFFER) or a texture
id (sourceType
== GL_TEXTURE) and draws it onto cr
with an OVER operation,
respecting the current clip. The top left corner of the rectangle specified
by x
, y
, width
and height
will be drawn at the current (0,0) position of
the cairo_t
.
This will work for *all* cairo_t
, as long as surface
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 to cr
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 use GL_TEXTURE if using alpha.
Calling this may change the current GL context.
cairoRectangle
:: (HasCallStack, MonadIO m) | |
=> Context |
|
-> Rectangle |
|
-> m () |
Adds the given rectangle to the current path of cr
.
cairoRegion
:: (HasCallStack, MonadIO m) | |
=> Context |
|
-> Region |
|
-> m () |
Adds the given region to the current path of cr
.
cairoRegionCreateFromSurface
cairoRegionCreateFromSurface Source #
:: (HasCallStack, MonadIO m) | |
=> Surface |
|
-> m Region | Returns: A |
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()
.
cairoSetSourcePixbuf
:: (HasCallStack, MonadIO m, IsPixbuf a) | |
=> Context |
|
-> a |
|
-> Double |
|
-> Double |
|
-> m () |
Sets the given pixbuf as the source pattern for cr
.
The pattern has an extend mode of ExtendNone
and is aligned
so that the origin of pixbuf
is pixbufX
, pixbufY
.
cairoSetSourceRgba
:: (HasCallStack, MonadIO m) | |
=> Context |
|
-> RGBA |
|
-> m () |
Sets the specified GdkRGBA
as the source color of cr
.
contentDeserializeAsync
contentDeserializeAsync Source #
:: (HasCallStack, MonadIO m, IsInputStream a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> GType |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Read content from the given input stream and deserialize it, asynchronously.
The default I/O priority is 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 contentDeserializeFinish
to get the result of the operation.
contentDeserializeFinish
contentDeserializeFinish Source #
:: (HasCallStack, MonadIO m, IsAsyncResult a) | |
=> a |
|
-> GValue |
|
-> m () | (Can throw |
Finishes a content deserialization operation.
contentRegisterDeserializer
contentRegisterDeserializer Source #
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> GType |
|
-> ContentDeserializeFunc |
|
-> m () |
Registers a function to deserialize object of a given type.
contentRegisterSerializer
contentRegisterSerializer Source #
:: (HasCallStack, MonadIO m) | |
=> GType |
|
-> Text |
|
-> ContentSerializeFunc |
|
-> m () |
Registers a function to serialize objects of a given type.
contentSerializeAsync
contentSerializeAsync Source #
:: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> GValue |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Serialize content and write it to the given output stream, asynchronously.
The default I/O priority is 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 contentSerializeFinish
to get the result of the operation.
contentSerializeFinish
contentSerializeFinish Source #
:: (HasCallStack, MonadIO m, IsAsyncResult a) | |
=> a |
|
-> m () | (Can throw |
Finishes a content serialization operation.
eventsGetAngle
:: (HasCallStack, MonadIO m, IsEvent a, IsEvent b) | |
=> a |
|
-> b |
|
-> m (Bool, Double) | Returns: |
Returns the relative angle from event1
to event2
.
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
.
eventsGetCenter
:: (HasCallStack, MonadIO m, IsEvent a, IsEvent b) | |
=> a |
|
-> b |
|
-> m (Bool, Double, Double) | Returns: |
Returns the point halfway between the events' positions.
This assumes that both events have X/Y information.
If not, this function returns False
.
eventsGetDistance
:: (HasCallStack, MonadIO m, IsEvent a, IsEvent b) | |
=> a |
|
-> b |
|
-> m (Bool, Double) | Returns: |
Returns the distance between the event locations.
This assumes that both events have X/Y information.
If not, this function returns False
.
internMimeType
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m (Maybe Text) | Returns: An interned string for the canonicalized
mime type or |
Canonicalizes the given mime type and interns the result.
If string
is not a valid mime type, Nothing
is returned instead.
See RFC 2048 for the syntax if mime types.
keyvalConvertCase
:: (HasCallStack, MonadIO m) | |
=> Word32 |
|
-> m (Word32, Word32) |
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.
keyvalFromName
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m Word32 | Returns: the corresponding key value, or |
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_”.
keyvalIsLower
:: (HasCallStack, MonadIO m) | |
=> Word32 |
|
-> m Bool | Returns: |
Returns True
if the given key value is in lower case.
keyvalIsUpper
:: (HasCallStack, MonadIO m) | |
=> Word32 |
|
-> m Bool | Returns: |
Returns True
if the given key value is in upper case.
keyvalName
:: (HasCallStack, MonadIO m) | |
=> Word32 |
|
-> m (Maybe Text) | Returns: a string containing the name of the key |
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_”.
keyvalToLower
:: (HasCallStack, MonadIO m) | |
=> Word32 |
|
-> m Word32 | Returns: the lower case form of |
Converts a key value to lower case, if applicable.
keyvalToUnicode
:: (HasCallStack, MonadIO m) | |
=> Word32 |
|
-> m Word32 | Returns: the corresponding unicode character, or 0 if there is no corresponding character. |
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 KEY_KP_Decimal
.
keyvalToUpper
:: (HasCallStack, MonadIO m) | |
=> Word32 |
|
-> m Word32 | Returns: the upper case form of |
Converts a key value to upper case, if applicable.
pixbufGetFromSurface
:: (HasCallStack, MonadIO m) | |
=> Surface |
|
-> Int32 |
|
-> Int32 |
|
-> Int32 |
|
-> Int32 |
|
-> m (Maybe Pixbuf) | Returns: A newly-created pixbuf with a reference count of 1 |
Transfers image data from a cairo_surface_t
and converts it
to a GdkPixbuf
.
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.
pixbufGetFromTexture
:: (HasCallStack, MonadIO m, IsTexture a) | |
=> a |
|
-> m (Maybe Pixbuf) | Returns: a new |
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.
setAllowedBackends
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m () |
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:
c code
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 [funcgdk
.Display.open], gtk_init()
, or gtk_init_check()
in order to take effect.
toplevelSizeGetType
toplevelSizeGetType :: (HasCallStack, MonadIO m) => m GType Source #
No description available in the introspection data.
unicodeToKeyval
:: (HasCallStack, MonadIO m) | |
=> Word32 |
|
-> m Word32 | Returns: the corresponding GDK key symbol, if one exists. or, if there is no corresponding symbol, wc | 0x01000000 |
Convert from a Unicode character to a key symbol.