class Cairo::XlibSurface

Overview

The Xlib surface is used to render cairo graphics to X Window System windows and pixmaps using the XLib library.

NOTE that the XLib surface automatically takes advantage of X render extension if it is available.

Defined in:

cairo/xlib_surface.cr

Constructors

Instance Method Summary

Instance methods inherited from class Cairo::Surface

content : Content content, copy_page copy_page, create_for_rectangle(x : Float64, y : Float64, width : Float64, height : Float64) : Surface create_for_rectangle, create_observer(mode : SurfaceObserverMode) : Surface create_observer, create_similar(content : Content, width : Int32, height : Int32) : Surface create_similar, create_similar_image(format : Format, width : Int32, height : Int32) : Surface create_similar_image, data : Pointer(UInt8) data, device : Device device, device_offset : Point device_offset, device_offset=(offset : Point) device_offset=, device_scale : Point device_scale, device_scale=(scale : Point) device_scale=, extents : NamedTuple(extents: Rectangle, bounded: Bool) extents, fallback_resolution : Point fallback_resolution, fallback_resolution=(res : Point) fallback_resolution=, finalize finalize, finish finish, flush flush, font_options : FontOptions font_options, format : Format format, has_show_text_glyphs? : Bool has_show_text_glyphs?, height : Int32 height, ink_extents : Rectangle ink_extents, map_to_image(extents : RectangleInt | Nil) : Surface map_to_image, mark_dirty mark_dirty, mark_dirty_rectangle(x : Int32, y : Int32, width : Int32, height : Int32) mark_dirty_rectangle, mime_data(mime_type : String) : Bytes mime_data, observer_add_fill_callback(func : LibCairo::SurfaceObserverCallbackT, data : Pointer(Void)) : Status observer_add_fill_callback, observer_add_finish_callback(func : LibCairo::SurfaceObserverCallbackT, data : Pointer(Void)) : Status observer_add_finish_callback, observer_add_flush_callback(func : LibCairo::SurfaceObserverCallbackT, data : Pointer(Void)) : Status observer_add_flush_callback, observer_add_glyphs_callback(func : LibCairo::SurfaceObserverCallbackT, data : Pointer(Void)) : Status observer_add_glyphs_callback, observer_add_mask_callback(func : LibCairo::SurfaceObserverCallbackT, data : Pointer(Void)) : Status observer_add_mask_callback, observer_add_paint_callback(func : LibCairo::SurfaceObserverCallbackT, data : Pointer(Void)) : Status observer_add_paint_callback, observer_add_stroke_callback(func : LibCairo::SurfaceObserverCallbackT, data : Pointer(Void)) : Status observer_add_stroke_callback, observer_elapsed : Float64 observer_elapsed, observer_print(write_func : LibCairo::WriteFuncT, closure : Pointer(Void)) : Status observer_print, reference : Surface reference, reference_count : UInt32 reference_count, set_device_offset(x_offset : Float64, y_offset : Float64) set_device_offset, set_device_scale(x_scale : Float64, y_scale : Float64) set_device_scale, set_fallback_resolution(x_pixels_per_inch : Float64, y_pixels_per_inch : Float64) set_fallback_resolution, set_mime_data(mime_type : String, data : Bytes, destroy : LibCairo::DestroyFuncT, closure : Pointer(Void)) : Status set_mime_data, set_user_data(key : UserDataKey, user_data : Pointer(Void), destroy : LibCairo::DestroyFuncT) : Status set_user_data, status : Status status, stride : Int32 stride, supports_mime_type?(mime_type : String) : Bool supports_mime_type?, surface_show_page surface_show_page, to_unsafe : LibCairo::PSurfaceT to_unsafe, type : SurfaceType type, unmap_image(image : Surface) unmap_image, user_data(key : UserDataKey) : Pointer(Void) user_data, width : Int32 width, write_to_png(filename : String) : Status write_to_png, write_to_png_stream(write_func : LibCairo::WriteFuncT, closure : Pointer(Void)) : Status write_to_png_stream

Constructor methods inherited from class Cairo::Surface

new(data : Bytes, format : Format, width : Int32, height : Int32, stride : Int32)
new(format : Format, width : Int32, height : Int32)
new(read_func : LibCairo::ReadFuncT, closure : Pointer(Void))
new(content : Content, extents : Rectangle | Nil)
new(surface : LibCairo::PSurfaceT)
new(filename : String)
new

Constructor Detail

def self.new(dpy : Display, drawable : Drawable, visual : Visual, width : Int32, height : Int32) #

Creates an Xlib surface that draws to the given drawable. The way that colors are represented in the drawable is specified by the provided visual.

NOTE If drawable is a Window, then the function XlibSurface#set_size must be called whenever the size of the window changes.

When drawable is a Window containing child windows then drawing to the created surface will be clipped by those child windows. When the created surface is used as a source, the contents of the children will be included.

###Parameters

  • dpy an X Display
  • drawable an X Drawable, (a Pixmap or a Window)
  • visual the visual to use for drawing to drawable. The depth of the visual must match the depth of the drawable. Currently, only TrueColor visuals are fully supported.
  • width the current width of drawable.
  • height the current height of drawable.

###Returns The newly created surface.


[View source]
def self.new(dpy : Display, bitmap : Pixmap, screen : Screen, width : Int32, height : Int32) #

Creates an Xlib surface that draws to the given bitmap. This will be drawn to as a Format::A1 object.

###Parameters

  • dpy an X Display
  • bitmap an X Drawable, (a depth-1 Pixmap)
  • screen the X Screen associated with bitmap
  • width the current width of bitmap.
  • height the current height of bitmap.

###Returns The newly created surface.


[View source]

Instance Method Detail

def depth : Int32 #

Get the number of bits used to represent each pixel value.

###Returns The depth of the surface in bits.


[View source]
def display : Display #

Get the X Display for the underlying X Drawable.

###Returns The display.


[View source]
def drawable : Drawable #

Get the underlying X Drawable used for the surface.

###Returns The drawable.


[View source]
def height : Int32 #

Get the height of the X Drawable underlying the surface in pixels.

###Returns The height of the surface in pixels.


[View source]
def screen : Screen #

Get the X Screen for the underlying X Drawable.

###Returns The screen.


[View source]
def set_drawable(drawable : Drawable, width : Int32, height : Int32) #

Informs cairo of a new X Drawable underlying the surface. The drawable must match the display, screen and format of the existing drawable or the application will get X protocol errors and will probably terminate. No checks are done by this function to ensure this compatibility.

###Parameters

  • drawable the new drawable for the surface
  • width the width of the new drawable
  • height the height of the new drawable

[View source]
def set_size(width : Int32, height : Int32) #

Informs cairo of the new size of the X Drawable underlying the surface. For a surface created for a Window (rather than a Pixmap), this function must be called each time the size of the window changes. (For a subwindow, you are normally resizing the window yourself, but for a toplevel window, it is necessary to listen for ConfigureNotify events.)

A Pixmap can never change size, so it is never necessary to call this function on a surface created for a Pixmap.

###Parameters

  • width the new width of the surface
  • height the new height of the surface

[View source]
def visual : Visual #

Gets the X Visual associated with surface, suitable for use with the underlying X Drawable. If surface was created by XlibSurface#initialize, the return value is the Visual passed to that constructor.

###Returns The Visual or nil if there is no appropriate Visual for surface.


[View source]
def width : Int32 #

Get the width of the X Drawable underlying the surface in pixels.

###Returns The width of the surface in pixels.


[View source]