Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: DrawingAreaResizeCallback

[290:7] extends: object

Generated low-level callback wrapper for GIR callback resize.

Members

  • callbackObj
  • userFn
  • userData
  • hasUserData

Methods

  • DrawingAreaResizeCallback (callback Fn, UserData = null)

    Creates one native callback wrapper. The wrapper owns a trampoline that converts native pointers into generated wrapper objects before invoking Fn.

    • @p Fn is the Aussom callback implementation.
    • @p UserData is retained and passed through to Fn on each invocation when provided.
  • trampoline (nativeSelf, width, height, nativeUserData)

    Internal trampoline. Converts native pointer arguments into generated wrapper instances, then invokes the user's callback.

  • callback ()

    Returns the wrapped NativeCallback.

  • handle ()

    Returns the callback as a NativeHandle.

  • close ()

    Closes the underlying NativeCallback.

  • isClosed ()

    Returns true when the callback has been closed.

class: DrawingArea

[45:7] extends: object

Allows drawing with cairo. An example GtkDrawingArea It’s essentially a blank widget; you can draw on it. After creating a drawing area, the application may want to connect to: - The [signal@Gtk.Widget::realize] signal to take any necessary actions when the widget is instantiated on a particular display. (Create GDK resources in response to this signal.) - The [signal@Gtk.DrawingArea::resize] signal to take any necessary actions when the widget changes size. - Call [method@Gtk.DrawingArea.set_draw_func] to handle redrawing the contents of the widget. The following code portion demonstrates using a drawing area to display a circle in the normal widget foreground color. ## Simple GtkDrawingArea usage c static void draw_function (GtkDrawingArea *area, cairo_t *cr, int width, int height, gpointer data) { GdkRGBA color; cairo_arc (cr, width / 2.0, height / 2.0, MIN (width, height) / 2.0, 0, 2 * G_PI); gtk_widget_get_color (GTK_WIDGET (area), &color); gdk_cairo_set_source_rgba (cr, &color); cairo_fill (cr); } int main (int argc, char **argv) { gtk_init (); GtkWidget *area = gtk_drawing_area_new (); gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (area), 100); gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (area), 100); gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (area), draw_function, NULL, NULL); return 0; } The draw function is normally called when a drawing area first comes onscreen, or when it’s covered by another window and then uncovered. You can also force a redraw by adding to the “damage region” of the drawing area’s window using [method@Gtk.Widget.queue_draw]. This will cause the drawing area to call the draw function again. The available routines for drawing are documented in the Cairo documentation; GDK offers additional API to integrate with Cairo, like [func@Gdk.cairo_set_source_rgba] or [func@Gdk.cairo_set_source_pixbuf]. To receive mouse events on a drawing area, you will need to use event controllers. To receive keyboard events, you will need to set the “can-focus” property on the drawing area, and you should probably draw some user-visible indication that the drawing area is focused. If you need more complex control over your widget, you should consider creating your own GtkWidget subclass.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • DrawingArea ()

    Creates a new drawing area.

  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • asWidget ()

    Wraps this handle as Widget.

    • @r A Widget object.
  • asAccessible ()

    Wraps this handle as Accessible.

    • @r A Accessible object.
  • asBuildable ()

    Wraps this handle as Buildable.

    • @r A Buildable object.
  • asConstraintTarget ()

    Wraps this handle as ConstraintTarget.

    • @r A ConstraintTarget object.
  • connectSignal (string Name, CallbackObj)

    Connects one generated callback wrapper to a named signal.

    • @p Name is the signal name.
    • @p CallbackObj is the generated callback wrapper to connect.
    • @r The connected handler id.
  • disconnectSignalHandler (int HandlerId)

    Disconnects one retained signal handler id.

    • @p HandlerId is the signal handler id to disconnect.
    • @r None.
  • setOnResize (callback Fn, UserData = null)

    Emitted once when the widget is realized, and then each time the widget is changed while realized. This is useful in order to keep state up to date with the widget size, like for instance a backing surface.

    • @p Fn is the Aussom callback.
    • @p Fn is called with (DrawingArea Self, int Width, int Height).
    • @p UserData is retained and passed through to the generated callback wrapper when provided.
    • @r The connected handler id.
  • getProperty (string Name)

    Reads one generated property by name.

  • setProperty (string Name, Value)

    Writes one generated property by name.

  • setContentheight (int Value)

    The content height.

    • @p Value is the new property value.
    • @r None.
  • setContentwidth (int Value)

    The content width.

    • @p Value is the new property value.
    • @r None.
  • get_content_height ()

    Retrieves the content height of the GtkDrawingArea.

  • get_content_width ()

    Retrieves the content width of the GtkDrawingArea.

  • set_content_height (int height)

    Sets the desired height of the contents of the drawing area. Note that because widgets may be allocated larger sizes than they requested, it is possible that the actual height passed to your draw function is larger than the height set here. You can use [method@Gtk.Widget.set_valign] to avoid that. If the height is set to 0 (the default), the drawing area may disappear.

    • @p height is the height of contents.
    • @r None.
  • set_content_width (int width)

    Sets the desired width of the contents of the drawing area. Note that because widgets may be allocated larger sizes than they requested, it is possible that the actual width passed to your draw function is larger than the width set here. You can use [method@Gtk.Widget.set_halign] to avoid that. If the width is set to 0 (the default), the drawing area may disappear.

    • @p width is the width of contents.
    • @r None.

class: DrawingAreaMeta

[360:14] static extends: object

Generated metadata helpers for DrawingArea class surfaces.

Methods

  • properties ()

    Returns property metadata for DrawingArea.

    • @r A list.
  • signals ()

    Returns signal metadata for DrawingArea.

    • @r A list.