* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
+#include <config.h>
#include "gdkdrawable.h"
#include "gdkinternals.h"
#include "gdkwindow.h"
* Gets the #GdkScreen associated with a #GdkDrawable.
*
* Return value: the #GdkScreen associated with @drawable
+ *
+ * Since: 2.2
**/
GdkScreen*
gdk_drawable_get_screen(GdkDrawable *drawable)
* Gets the #GdkDisplay associated with a #GdkDrawable.
*
* Return value: the #GdkDisplay associated with @drawable
+ *
+ * Since: 2.2
**/
GdkDisplay*
gdk_drawable_get_display (GdkDrawable *drawable)
* gdk_draw_line:
* @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
* @gc: a #GdkGC.
- * @x1: the x coordinate of the start point.
- * @y1: the y coordinate of the start point.
- * @x2: the x coordinate of the end point.
- * @y2: the y coordinate of the end point.
+ * @x1_: the x coordinate of the start point.
+ * @y1_: the y coordinate of the start point.
+ * @x2_: the x coordinate of the end point.
+ * @y2_: the y coordinate of the end point.
*
* Draws a line, using the foreground color and other attributes of
* the #GdkGC.
* @string: the string of characters to draw.
*
* Draws a string of characters in the given font or fontset.
+ *
+ * Deprecated: Use gdk_draw_layout() instead.
**/
void
gdk_draw_string (GdkDrawable *drawable,
* @text_length: the number of characters of @text to draw.
*
* Draws a number of characters in the given font or fontset.
+ *
+ * Deprecated: Use gdk_draw_layout() instead.
**/
void
gdk_draw_text (GdkDrawable *drawable,
* Draws a number of wide characters using the given font of fontset.
* If the font is a 1-byte font, the string is converted into 1-byte
* characters (discarding the high bytes) before output.
+ *
+ * Deprecated: Use gdk_draw_layout() instead.
**/
void
gdk_draw_text_wc (GdkDrawable *drawable,
* @dest_y: Destination Y coordinate within drawable.
* @width: Width of region to render, in pixels, or -1 to use pixbuf width.
* @height: Height of region to render, in pixels, or -1 to use pixbuf height.
- * @dither: Dithering mode for GdkRGB.
+ * @dither: Dithering mode for #GdkRGB.
* @x_dither: X offset for dither.
* @y_dither: Y offset for dither.
*
* Renders a rectangular portion of a pixbuf to a drawable. The destination
* drawable must have a colormap. All windows have a colormap, however, pixmaps
- * only have colormap by default if they were created with a non-NULL window argument.
- * Otherwise a colormap must be set on them with gdk_drawable_set_colormap.
+ * only have colormap by default if they were created with a non-%NULL window
+ * argument. Otherwise a colormap must be set on them with
+ * gdk_drawable_set_colormap().
*
- * On older X servers, rendering pixbufs with an alpha channel involves round trips
- * to the X server, and may be somewhat slow.
+ * On older X servers, rendering pixbufs with an alpha channel involves round
+ * trips to the X server, and may be somewhat slow.
+ *
+ * The clip mask of @gc is ignored, but clip rectangles and clip regions work
+ * fine.
+ *
+ * Since: 2.2
**/
void
gdk_draw_pixbuf (GdkDrawable *drawable,
/**
- * _gdk_drawable_copy_to_image:
+ * gdk_drawable_copy_to_image:
* @drawable: a #GdkDrawable
* @image: a #GdkDrawable, or %NULL if a new @image should be created.
* @src_x: x coordinate on @drawable
* and copies into that. See gdk_drawable_get_image() for further details.
*
* Return value: @image, or a new a #GdkImage containing the contents
- of @drawable
+ * of @drawable
+ *
+ * Since: 2.4
**/
GdkImage*
-_gdk_drawable_copy_to_image (GdkDrawable *drawable,
- GdkImage *image,
- gint src_x,
- gint src_y,
- gint dest_x,
- gint dest_y,
- gint width,
- gint height)
+gdk_drawable_copy_to_image (GdkDrawable *drawable,
+ GdkImage *image,
+ gint src_x,
+ gint src_y,
+ gint dest_x,
+ gint dest_y,
+ gint width,
+ gint height)
{
GdkDrawable *composite;
gint composite_x_offset = 0;
gint width,
gint height)
{
- return _gdk_drawable_copy_to_image (drawable, NULL, x, y, 0, 0, width, height);
+ return gdk_drawable_copy_to_image (drawable, NULL, x, y, 0, 0, width, height);
}
static GdkDrawable*
gint x_dither,
gint y_dither)
{
- gboolean free_gc = FALSE;
GdkPixbuf *composited = NULL;
gint dwidth, dheight;
GdkRegion *clip;
return;
/* Actually draw */
-
if (!gc)
- {
- gc = gdk_gc_new (drawable);
- free_gc = TRUE;
- }
+ gc = _gdk_drawable_get_scratch_gc (drawable, FALSE);
if (pixbuf->has_alpha)
{
width1, height1,
gdk_drawable_get_depth (drawable), &xs0, &ys0);
- _gdk_drawable_copy_to_image (drawable, image,
- dest_x + x0, dest_y + y0,
- xs0, ys0,
- width1, height1);
+ gdk_drawable_copy_to_image (drawable, image,
+ dest_x + x0, dest_y + y0,
+ xs0, ys0,
+ width1, height1);
(*composite_func) (pixbuf->pixels + (src_y + y0) * pixbuf->rowstride + (src_x + x0) * 4,
pixbuf->rowstride,
(guchar*)image->mem + ys0 * image->bpl + xs0 * image->bpp,
out:
if (composited)
g_object_unref (composited);
+}
+
+/**
+ * _gdk_drawable_get_scratch_gc:
+ * @drawable: A #GdkDrawable
+ * @graphics_exposures: Whether the reutrned #GdkGC should generate graphics exposures
+ *
+ * Returns a #GdkGC suitable for drawing on @drawable. The #GdkGC has
+ * the standard values for @drawable, except for the graphics_exposures
+ * field which is determined by the @graphics_exposures parameter.
+ *
+ * The foreground color of the returned #GdkGC is undefined. The #GdkGC
+ * must not be altered in any way, except to change its foreground color.
+ *
+ * Return value: A #GdkGC suitable for drawing on @drawable
+ *
+ * Since: 2.4
+ **/
+GdkGC *
+_gdk_drawable_get_scratch_gc (GdkDrawable *drawable,
+ gboolean graphics_exposures)
+{
+ GdkScreen *screen;
+ gint depth;
+
+ g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
+
+ screen = gdk_drawable_get_screen (drawable);
+
+ g_return_val_if_fail (!screen->closed, NULL);
+
+ depth = gdk_drawable_get_depth (drawable);
+
+ if (graphics_exposures)
+ {
+ if (!screen->exposure_gcs[depth])
+ {
+ GdkGCValues values;
+ GdkGCValuesMask mask;
+
+ values.graphics_exposures = TRUE;
+ mask = GDK_GC_EXPOSURES;
+ screen->exposure_gcs[depth] =
+ gdk_gc_new_with_values (drawable, &values, mask);
+ }
- if (free_gc)
- g_object_unref (gc);
+ return screen->exposure_gcs[depth];
+ }
+ else
+ {
+ if (!screen->normal_gcs[depth])
+ {
+ screen->normal_gcs[depth] =
+ gdk_gc_new (drawable);
+ }
+
+ return screen->normal_gcs[depth];
+ }
}