2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = cairo-cairo-surface-t.html
28 * strct = cairo_surface_t
50 module cairoLib
.Surface
;
52 private import cairoLib
.cairoLibtypes
;
54 private import lib
.cairoLib
;
56 private import glib
.Str
;
64 /** the main Gtk struct */
65 protected cairo_surface_t
* cairo_surface
;
68 public cairo_surface_t
* getSurfaceStruct()
74 /** the main Gtk struct as a void* */
75 protected void* getStruct()
77 return cast(void*)cairo_surface
;
81 * Sets our main struct and passes it to the parent class
83 public this (cairo_surface_t
* cairo_surface
)
85 this.cairo_surface
= cairo_surface
;
90 * Image surfaces provide the ability to render to memory buffers
91 * either allocated by cairo or by the calling code. The supported
92 * image formats are those defined in cairo_format_t.
101 * Create a new surface that is as compatible as possible with an
102 * existing surface. For example the new surface will have the same
103 * fallback resolution and font options as other. Generally, the new
104 * surface will also use the same backend as other, unless that is
105 * not possible for some reason. The type of the returned surface may
106 * be examined with cairo_surface_get_type().
107 * Initially the surface contents are all 0 (transparent if contents
108 * have transparency, black otherwise.)
110 * an existing surface used to select the backend of the new surface
112 * the content for the new surface
114 * width of the new surface, (in device-space units)
116 * height of the new surface (in device-space units)
118 * a pointer to the newly allocated surface. The caller
119 * owns the surface and should call cairo_surface_destroy when done
121 * This function always returns a valid pointer, but it will return a
122 * pointer to a "nil" surface if other is already in an error state
123 * or any other error occurs.
125 public cairo_surface_t
* createSimilar(cairo_content_t content
, int width
, int height
)
127 // cairo_surface_t* cairo_surface_create_similar (cairo_surface_t *other, cairo_content_t content, int width, int height);
128 return cairo_surface_create_similar(cairo_surface
, content
, width
, height
);
132 * Decreases the reference count on surface by one. If the result is
133 * zero, then surface and all associated resources are freed. See
134 * cairo_surface_reference().
138 public void destroy()
140 // void cairo_surface_destroy (cairo_surface_t *surface);
141 cairo_surface_destroy(cairo_surface
);
145 * This function finishes the surface and drops all references to
146 * external resources. For example, for the Xlib backend it means
147 * that cairo will no longer access the drawable, which can be freed.
148 * After calling cairo_surface_finish() the only valid operations on a
149 * surface are getting and setting user data and referencing and
150 * destroying it. Further drawing to the surface will not affect the
151 * surface but will instead trigger a CAIRO_STATUS_SURFACE_FINISHED
153 * When the last call to cairo_surface_destroy() decreases the
154 * reference count to zero, cairo will call cairo_surface_finish() if
155 * it hasn't been called already, before freeing the resources
156 * associated with the surface.
158 * the cairo_surface_t to finish
162 // void cairo_surface_finish (cairo_surface_t *surface);
163 cairo_surface_finish(cairo_surface
);
167 * Do any pending drawing for the surface and also restore any
168 * temporary modification's cairo has made to the surface's
169 * state. This function must be called before switching from
170 * drawing on the surface with cairo to drawing on it directly
171 * with native APIs. If the surface doesn't support direct access,
172 * then this function does nothing.
178 // void cairo_surface_flush (cairo_surface_t *surface);
179 cairo_surface_flush(cairo_surface
);
183 * Retrieves the default font rendering options for the surface.
184 * This allows display surfaces to report the correct subpixel order
185 * for rendering on them, print surfaces to disable hinting of
186 * metrics and so forth. The result can then be used with
187 * cairo_scaled_font_create().
191 * a cairo_font_options_t object into which to store
192 * the retrieved options. All existing values are overwritten
194 public void getFontOptions(cairo_font_options_t
* options
)
196 // void cairo_surface_get_font_options (cairo_surface_t *surface, cairo_font_options_t *options);
197 cairo_surface_get_font_options(cairo_surface
, options
);
204 * The content type of surface which indicates whether
205 * the surface contains color and/or alpha information. See
209 public cairo_content_t
getContent()
211 // cairo_content_t cairo_surface_get_content (cairo_surface_t *surface);
212 return cairo_surface_get_content(cairo_surface
);
216 * Attach user data to surface. To remove user data from a surface,
217 * call this function with the key that was used to set it and NULL
222 * the address of a cairo_user_data_key_t to attach the user data to
224 * the user data to attach to the surface
226 * a cairo_destroy_func_t which will be called when the
227 * surface is destroyed or when new user data is attached using the
230 * CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY if a
231 * slot could not be allocated for the user data.
233 public cairo_status_t
setUserData(cairo_user_data_key_t
* key
, void* userData
, cairo_destroy_func_t destroy
)
235 // cairo_status_t cairo_surface_set_user_data (cairo_surface_t *surface, const cairo_user_data_key_t *key, void *user_data, cairo_destroy_func_t destroy);
236 return cairo_surface_set_user_data(cairo_surface
, key
, userData
, destroy
);
240 * Return user data previously attached to surface using the specified
241 * key. If no user data has been attached with the given key this
242 * function returns NULL.
246 * the address of the cairo_user_data_key_t the user data was
249 * the user data previously attached or NULL.
251 public void* getUserData(cairo_user_data_key_t
* key
)
253 // void* cairo_surface_get_user_data (cairo_surface_t *surface, const cairo_user_data_key_t *key);
254 return cairo_surface_get_user_data(cairo_surface
, key
);
258 * Tells cairo that drawing has been done to surface using means other
259 * than cairo, and that cairo should reread any cached areas. Note
260 * that you must call cairo_surface_flush() before doing such drawing.
264 public void markDirty()
266 // void cairo_surface_mark_dirty (cairo_surface_t *surface);
267 cairo_surface_mark_dirty(cairo_surface
);
271 * Like cairo_surface_mark_dirty(), but drawing has been done only to
272 * the specified rectangle, so that cairo can retain cached contents
273 * for other parts of the surface.
274 * Any cached clip set on the surface will be reset by this function,
275 * to make sure that future cairo calls have the clip set that they
280 * X coordinate of dirty rectangle
282 * Y coordinate of dirty rectangle
284 * width of dirty rectangle
286 * height of dirty rectangle
288 public void markDirtyRectangle(int x
, int y
, int width
, int height
)
290 // void cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface, int x, int y, int width, int height);
291 cairo_surface_mark_dirty_rectangle(cairo_surface
, x
, y
, width
, height
);
295 * Increases the reference count on surface by one. This prevents
296 * surface from being destroyed until a matching call to
297 * cairo_surface_destroy() is made.
301 * the referenced cairo_surface_t.
303 public cairo_surface_t
* reference()
305 // cairo_surface_t* cairo_surface_reference (cairo_surface_t *surface);
306 return cairo_surface_reference(cairo_surface
);
310 * Sets an offset that is added to the device coordinates determined
311 * by the CTM when drawing to surface. One use case for this function
312 * is when we want to create a cairo_surface_t that redirects drawing
313 * for a portion of an onscreen surface to an offscreen surface in a
314 * way that is completely invisible to the user of the cairo
315 * API. Setting a transformation via cairo_translate() isn't
316 * sufficient to do this, since functions like
317 * cairo_device_to_user() will expose the hidden offset.
318 * Note that the offset affects drawing to the surface as well as
319 * using the surface in a source pattern.
323 * the offset in the X direction, in device units
325 * the offset in the Y direction, in device units
327 public void setDeviceOffset(double xOffset
, double yOffset
)
329 // void cairo_surface_set_device_offset (cairo_surface_t *surface, double x_offset, double y_offset);
330 cairo_surface_set_device_offset(cairo_surface
, xOffset
, yOffset
);
334 * This function returns the previous device offset set by
335 * cairo_surface_set_device_offset().
339 * the offset in the X direction, in device units
341 * the offset in the Y direction, in device units
344 public void getDeviceOffset(double* xOffset
, double* yOffset
)
346 // void cairo_surface_get_device_offset (cairo_surface_t *surface, double *x_offset, double *y_offset);
347 cairo_surface_get_device_offset(cairo_surface
, xOffset
, yOffset
);
351 * Set the horizontal and vertical resolution for image fallbacks.
352 * When certain operations aren't supported natively by a backend,
353 * cairo will fallback by rendering operations to an image and then
354 * overlaying that image onto the output. For backends that are
355 * natively vector-oriented, this function can be used to set the
356 * resolution used for these image fallbacks, (larger values will
357 * result in more detailed images, but also larger file sizes).
358 * Some examples of natively vector-oriented backends are the ps, pdf,
360 * For backends that are natively raster-oriented, image fallbacks are
361 * still possible, but they are always performed at the native
362 * device resolution. So this function has no effect on those
364 * NOTE: The fallback resolution only takes effect at the time of
365 * completing a page (with cairo_show_page() or cairo_copy_page()) so
366 * there is currently no way to have more than one fallback resolution
367 * in effect on a single page.
371 * horizontal setting for pixels per inch
373 * vertical setting for pixels per inch
376 public void setFallbackResolution(double xPixelsPerInch
, double yPixelsPerInch
)
378 // void cairo_surface_set_fallback_resolution (cairo_surface_t *surface, double x_pixels_per_inch, double y_pixels_per_inch);
379 cairo_surface_set_fallback_resolution(cairo_surface
, xPixelsPerInch
, yPixelsPerInch
);
383 * Checks whether an error has previously occurred for this
388 * CAIRO_STATUS_SUCCESS, CAIRO_STATUS_NULL_POINTER,
389 * CAIRO_STATUS_NO_MEMORY, CAIRO_STATUS_READ_ERROR,
390 * CAIRO_STATUS_INVALID_CONTENT, CAIRO_STATUS_INVALUE_FORMAT, or
391 * CAIRO_STATUS_INVALID_VISUAL.
393 public cairo_status_t
status()
395 // cairo_status_t cairo_surface_status (cairo_surface_t *surface);
396 return cairo_surface_status(cairo_surface
);
401 * This function returns the type of the backend used to create
402 * a surface. See cairo_surface_type_t for available types.
406 * The type of surface.
409 public cairo_surface_type_t
getType()
411 // cairo_surface_type_t cairo_surface_get_type (cairo_surface_t *surface);
412 return cairo_surface_get_type(cairo_surface
);
417 * Creates an image surface of the specified format and
418 * dimensions. Initially the surface contents are all
419 * 0. (Specifically, within each pixel, each color or alpha channel
420 * belonging to format will be 0. The contents of bits within a pixel,
421 * but not belonging to the given format are undefined).
423 * format of pixels in the surface to create
425 * width of the surface, in pixels
427 * height of the surface, in pixels
429 * a pointer to the newly created surface. The caller
430 * owns the surface and should call cairo_surface_destroy when done
432 * This function always returns a valid pointer, but it will return a
433 * pointer to a "nil" surface if an error such as out of memory
434 * occurs. You can use cairo_surface_status() to check for this.
436 public static cairo_surface_t
* imageSurfaceCreate(cairo_format_t format
, int width
, int height
)
438 // cairo_surface_t* cairo_image_surface_create (cairo_format_t format, int width, int height);
439 return cairo_image_surface_create(format
, width
, height
);
443 * Creates an image surface for the provided pixel data. The output
444 * buffer must be kept around until the cairo_surface_t is destroyed
445 * or cairo_surface_finish() is called on the surface. The initial
446 * contents of buffer will be used as the inital image contents; you
447 * must explicitely clear the buffer, using, for example,
448 * cairo_rectangle() and cairo_fill() if you want it cleared.
450 * a pointer to a buffer supplied by the application
451 * in which to write contents.
453 * the format of pixels in the buffer
455 * the width of the image to be stored in the buffer
457 * the height of the image to be stored in the buffer
459 * the number of bytes between the start of rows
460 * in the buffer. Having this be specified separate from width
461 * allows for padding at the end of rows, or for writing
462 * to a subportion of a larger image.
464 * a pointer to the newly created surface. The caller
465 * owns the surface and should call cairo_surface_destroy when done
467 * This function always returns a valid pointer, but it will return a
468 * pointer to a "nil" surface if an error such as out of memory
469 * occurs. You can use cairo_surface_status() to check for this.
470 * See cairo_surface_set_user_data() for a means of attaching a
471 * destroy-notification fallback to the surface if necessary.
473 public static cairo_surface_t
* imageSurfaceCreateForData(ubyte* data
, cairo_format_t format
, int width
, int height
, int stride
)
475 // cairo_surface_t* cairo_image_surface_create_for_data (unsigned char *data, cairo_format_t format, int width, int height, int stride);
476 return cairo_image_surface_create_for_data(data
, format
, width
, height
, stride
);
480 * Get a pointer to the data of the image surface, for direct
481 * inspection or modification.
483 * a cairo_image_surface_t
485 * a pointer to the image data of this surface or NULL
486 * if surface is not an image surface.
489 public ubyte* imageSurfaceGetData()
491 // unsigned char* cairo_image_surface_get_data (cairo_surface_t *surface);
492 return cairo_image_surface_get_data(cairo_surface
);
496 * Get the format of the surface.
498 * a cairo_image_surface_t
500 * the format of the surface
503 public cairo_format_t
imageSurfaceGetFormat()
505 // cairo_format_t cairo_image_surface_get_format (cairo_surface_t *surface);
506 return cairo_image_surface_get_format(cairo_surface
);
510 * Get the width of the image surface in pixels.
512 * a cairo_image_surface_t
514 * the width of the surface in pixels.
516 public int imageSurfaceGetWidth()
518 // int cairo_image_surface_get_width (cairo_surface_t *surface);
519 return cairo_image_surface_get_width(cairo_surface
);
523 * Get the height of the image surface in pixels.
525 * a cairo_image_surface_t
527 * the height of the surface in pixels.
529 public int imageSurfaceGetHeight()
531 // int cairo_image_surface_get_height (cairo_surface_t *surface);
532 return cairo_image_surface_get_height(cairo_surface
);
536 * Get the stride of the image surface in bytes
538 * a cairo_image_surface_t
540 * the stride of the image surface in bytes (or 0 if
541 * surface is not an image surface). The stride is the distance in
542 * bytes from the beginning of one row of the image data to the
543 * beginning of the next row.
546 public int imageSurfaceGetStride()
548 // int cairo_image_surface_get_stride (cairo_surface_t *surface);
549 return cairo_image_surface_get_stride(cairo_surface
);