Commit dda40ca7 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor
Browse files

Use a GtkAlignment rather than a GtkDrawingArea to draw the swatch in to

2005-05-11  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkcolorbutton.c: Use a GtkAlignment rather than a GtkDrawingArea
	to draw the swatch in to avoid having an extraneous window.

	* gtk/gtkcolorsel.c (color_sample_draw_sample): Actually se tthe
	color when !has_opacity.

2005-05-10  Owen Taylor  <otaylor@redhat.com>

	* gdk/gdkcairo.[ch] gdk/gdkcolor.[ch] gdk/Makefile.am: Add source
	files for Cairo convenience functionality.

	* gdk/gdkcairo.h (gdk_cairo_rectangle, gdk_cairo_region): Add a
	convenience functions to add GdkRectangle, GdkRegion to a cairo path.

	* gdk/gdkwindow.c gdk/gdkgc.c gtk/gtkcolorsel.c gtk/gtkiconview.c
	gtk/gtkstyle.c: Use gdk_cairo_rectangle/region().

	* gdk/gdkcairo.[ch] gdk/gdkdrawable.h gdk/gdkdraw.c: Rename
	gdk_drawable_create_cairo_context() to gdk_cairo_create().

	* gdk/gdkcairo.c gdk/gdkpixbuf.h gdk/gdkpixbuf-render.c:
	Rename gdk_pixbuf_set_as_cairo_source() to
	gdk_cairo_set_source_pixbuf().

	* gdk/gdkdraw.c gdk/gdkpango.c gtk/gtkcolorsel.c gtk/gtkhruler.c
	gtk/gtkhsv.c gtk/gtkiconview.c gtk/gtkstyle.c gtk/gtkvruler.c:
	Adjust for renames.

	* gdk/gdk.symbols: Update.

	* gtk/gtkwidget.c (gtk_widget_queue_shallow_draw): Fix
	coordinate system problem that was causing the wrong portions
	to be invalidated.

	* gtk/gtkcellrenderer.c (gtk_cell_renderer_render)
	gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_render)
	gtk/gtkcellrendererprogress.c (gtk_cell_renderer_progress_render)
	gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render)
	gtk/gtkcellview.c (gtk_cell_view_expose)
	gtk/gtkdnd.c (gtk_drag_highlight_expose)
	gtk/gtkentry.c (gtk_entry_draw_text)
	gtk/gtktextview.c (text_window_invalidate_rect): Some cairoization.

	* gtk/gtkcalendar.[ch]: Beat into something roughly resembling
	GTK+ style ... use instance-private data and standard names for
	private structure, etc. Move function docs inline.

	* gtk/gtkcalendar.[ch]: Switch to drawing everything in
	expose. Switch drawing to Cairo.

	* gtk/gtkcalendar.c (gtk_calendar_freeze): Deprecate
	gtk_calendar_freeze/thaw
parent 846972ba
2005-05-11 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcolorbutton.c: Use a GtkAlignment rather than a GtkDrawingArea
to draw the swatch in to avoid having an extraneous window.
* gtk/gtkcolorsel.c (color_sample_draw_sample): Actually se tthe
color when !has_opacity.
2005-05-10 Owen Taylor <otaylor@redhat.com>
* gdk/gdkcairo.[ch] gdk/gdkcolor.[ch] gdk/Makefile.am: Add source
files for Cairo convenience functionality.
* gdk/gdkcairo.h (gdk_cairo_rectangle, gdk_cairo_region): Add a
convenience functions to add GdkRectangle, GdkRegion to a cairo path.
* gdk/gdkwindow.c gdk/gdkgc.c gtk/gtkcolorsel.c gtk/gtkiconview.c
gtk/gtkstyle.c: Use gdk_cairo_rectangle/region().
* gdk/gdkcairo.[ch] gdk/gdkdrawable.h gdk/gdkdraw.c: Rename
gdk_drawable_create_cairo_context() to gdk_cairo_create().
* gdk/gdkcairo.c gdk/gdkpixbuf.h gdk/gdkpixbuf-render.c:
Rename gdk_pixbuf_set_as_cairo_source() to
gdk_cairo_set_source_pixbuf().
* gdk/gdkdraw.c gdk/gdkpango.c gtk/gtkcolorsel.c gtk/gtkhruler.c
gtk/gtkhsv.c gtk/gtkiconview.c gtk/gtkstyle.c gtk/gtkvruler.c:
Adjust for renames.
* gdk/gdk.symbols: Update.
* gtk/gtkwidget.c (gtk_widget_queue_shallow_draw): Fix
coordinate system problem that was causing the wrong portions
to be invalidated.
* gtk/gtkcellrenderer.c (gtk_cell_renderer_render)
gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_render)
gtk/gtkcellrendererprogress.c (gtk_cell_renderer_progress_render)
gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render)
gtk/gtkcellview.c (gtk_cell_view_expose)
gtk/gtkdnd.c (gtk_drag_highlight_expose)
gtk/gtkentry.c (gtk_entry_draw_text)
gtk/gtktextview.c (text_window_invalidate_rect): Some cairoization.
* gtk/gtkcalendar.[ch]: Beat into something roughly resembling
GTK+ style ... use instance-private data and standard names for
private structure, etc. Move function docs inline.
* gtk/gtkcalendar.[ch]: Switch to drawing everything in
expose. Switch drawing to Cairo.
* gtk/gtkcalendar.c (gtk_calendar_freeze): Deprecate
gtk_calendar_freeze/thaw
2005-05-10 Tor Lillqvist <tml@novell.com> 2005-05-10 Tor Lillqvist <tml@novell.com>
* gdk/win32/gdkproperty-win32.c (gdk_screen_get_setting): Check * gdk/win32/gdkproperty-win32.c (gdk_screen_get_setting): Check
......
2005-05-11 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcolorbutton.c: Use a GtkAlignment rather than a GtkDrawingArea
to draw the swatch in to avoid having an extraneous window.
* gtk/gtkcolorsel.c (color_sample_draw_sample): Actually se tthe
color when !has_opacity.
2005-05-10 Owen Taylor <otaylor@redhat.com>
* gdk/gdkcairo.[ch] gdk/gdkcolor.[ch] gdk/Makefile.am: Add source
files for Cairo convenience functionality.
* gdk/gdkcairo.h (gdk_cairo_rectangle, gdk_cairo_region): Add a
convenience functions to add GdkRectangle, GdkRegion to a cairo path.
* gdk/gdkwindow.c gdk/gdkgc.c gtk/gtkcolorsel.c gtk/gtkiconview.c
gtk/gtkstyle.c: Use gdk_cairo_rectangle/region().
* gdk/gdkcairo.[ch] gdk/gdkdrawable.h gdk/gdkdraw.c: Rename
gdk_drawable_create_cairo_context() to gdk_cairo_create().
* gdk/gdkcairo.c gdk/gdkpixbuf.h gdk/gdkpixbuf-render.c:
Rename gdk_pixbuf_set_as_cairo_source() to
gdk_cairo_set_source_pixbuf().
* gdk/gdkdraw.c gdk/gdkpango.c gtk/gtkcolorsel.c gtk/gtkhruler.c
gtk/gtkhsv.c gtk/gtkiconview.c gtk/gtkstyle.c gtk/gtkvruler.c:
Adjust for renames.
* gdk/gdk.symbols: Update.
* gtk/gtkwidget.c (gtk_widget_queue_shallow_draw): Fix
coordinate system problem that was causing the wrong portions
to be invalidated.
* gtk/gtkcellrenderer.c (gtk_cell_renderer_render)
gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_render)
gtk/gtkcellrendererprogress.c (gtk_cell_renderer_progress_render)
gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render)
gtk/gtkcellview.c (gtk_cell_view_expose)
gtk/gtkdnd.c (gtk_drag_highlight_expose)
gtk/gtkentry.c (gtk_entry_draw_text)
gtk/gtktextview.c (text_window_invalidate_rect): Some cairoization.
* gtk/gtkcalendar.[ch]: Beat into something roughly resembling
GTK+ style ... use instance-private data and standard names for
private structure, etc. Move function docs inline.
* gtk/gtkcalendar.[ch]: Switch to drawing everything in
expose. Switch drawing to Cairo.
* gtk/gtkcalendar.c (gtk_calendar_freeze): Deprecate
gtk_calendar_freeze/thaw
2005-05-10 Tor Lillqvist <tml@novell.com> 2005-05-10 Tor Lillqvist <tml@novell.com>
* gdk/win32/gdkproperty-win32.c (gdk_screen_get_setting): Check * gdk/win32/gdkproperty-win32.c (gdk_screen_get_setting): Check
......
2005-05-11 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcolorbutton.c: Use a GtkAlignment rather than a GtkDrawingArea
to draw the swatch in to avoid having an extraneous window.
* gtk/gtkcolorsel.c (color_sample_draw_sample): Actually se tthe
color when !has_opacity.
2005-05-10 Owen Taylor <otaylor@redhat.com>
* gdk/gdkcairo.[ch] gdk/gdkcolor.[ch] gdk/Makefile.am: Add source
files for Cairo convenience functionality.
* gdk/gdkcairo.h (gdk_cairo_rectangle, gdk_cairo_region): Add a
convenience functions to add GdkRectangle, GdkRegion to a cairo path.
* gdk/gdkwindow.c gdk/gdkgc.c gtk/gtkcolorsel.c gtk/gtkiconview.c
gtk/gtkstyle.c: Use gdk_cairo_rectangle/region().
* gdk/gdkcairo.[ch] gdk/gdkdrawable.h gdk/gdkdraw.c: Rename
gdk_drawable_create_cairo_context() to gdk_cairo_create().
* gdk/gdkcairo.c gdk/gdkpixbuf.h gdk/gdkpixbuf-render.c:
Rename gdk_pixbuf_set_as_cairo_source() to
gdk_cairo_set_source_pixbuf().
* gdk/gdkdraw.c gdk/gdkpango.c gtk/gtkcolorsel.c gtk/gtkhruler.c
gtk/gtkhsv.c gtk/gtkiconview.c gtk/gtkstyle.c gtk/gtkvruler.c:
Adjust for renames.
* gdk/gdk.symbols: Update.
* gtk/gtkwidget.c (gtk_widget_queue_shallow_draw): Fix
coordinate system problem that was causing the wrong portions
to be invalidated.
* gtk/gtkcellrenderer.c (gtk_cell_renderer_render)
gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_render)
gtk/gtkcellrendererprogress.c (gtk_cell_renderer_progress_render)
gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render)
gtk/gtkcellview.c (gtk_cell_view_expose)
gtk/gtkdnd.c (gtk_drag_highlight_expose)
gtk/gtkentry.c (gtk_entry_draw_text)
gtk/gtktextview.c (text_window_invalidate_rect): Some cairoization.
* gtk/gtkcalendar.[ch]: Beat into something roughly resembling
GTK+ style ... use instance-private data and standard names for
private structure, etc. Move function docs inline.
* gtk/gtkcalendar.[ch]: Switch to drawing everything in
expose. Switch drawing to Cairo.
* gtk/gtkcalendar.c (gtk_calendar_freeze): Deprecate
gtk_calendar_freeze/thaw
2005-05-10 Tor Lillqvist <tml@novell.com> 2005-05-10 Tor Lillqvist <tml@novell.com>
* gdk/win32/gdkproperty-win32.c (gdk_screen_get_setting): Check * gdk/win32/gdkproperty-win32.c (gdk_screen_get_setting): Check
......
...@@ -27,11 +27,6 @@ gtk_calendar_set_display_options(). ...@@ -27,11 +27,6 @@ gtk_calendar_set_display_options().
The selected date can be retrieved from a #GtkCalendar using The selected date can be retrieved from a #GtkCalendar using
gtk_calendar_get_date(). gtk_calendar_get_date().
</para> </para>
<para>
If performing many 'mark' operations, the calendar can be frozen to prevent
flicker, using gtk_calendar_freeze(), and 'thawed' again using
gtk_calendar_thaw().
</para>
<!-- ##### SECTION See_Also ##### --> <!-- ##### SECTION See_Also ##### -->
<para> <para>
...@@ -165,59 +160,52 @@ These options can be used to influence the display and behaviour of a #GtkCalend ...@@ -165,59 +160,52 @@ These options can be used to influence the display and behaviour of a #GtkCalend
<!-- ##### FUNCTION gtk_calendar_new ##### --> <!-- ##### FUNCTION gtk_calendar_new ##### -->
<para> <para>
Creates a new calendar, with the current date being selected.
</para> </para>
@Returns: a #GtkCalendar. @Returns:
<!-- ##### FUNCTION gtk_calendar_select_month ##### --> <!-- ##### FUNCTION gtk_calendar_select_month ##### -->
<para> <para>
Shifts the calendar to a different month.
</para> </para>
@calendar: a #GtkCalendar. @calendar:
@month: a month number between 0 and 11. @month:
@year: the year the month is in. @year:
@Returns: %TRUE. @Returns:
<!-- ##### FUNCTION gtk_calendar_select_day ##### --> <!-- ##### FUNCTION gtk_calendar_select_day ##### -->
<para> <para>
Selects a day from the current month.
</para> </para>
@calendar: a #GtkCalendar. @calendar:
@day: the day number between 1 and 31, or 0 to unselect @day:
the currently selected day.
<!-- ##### FUNCTION gtk_calendar_mark_day ##### --> <!-- ##### FUNCTION gtk_calendar_mark_day ##### -->
<para> <para>
Places a visual marker on a particular day.
</para> </para>
@calendar: a #GtkCalendar. @calendar:
@day: the day number to mark between 1 and 31. @day:
@Returns: %TRUE. @Returns:
<!-- ##### FUNCTION gtk_calendar_unmark_day ##### --> <!-- ##### FUNCTION gtk_calendar_unmark_day ##### -->
<para> <para>
Removes the visual marker from a particular day.
</para> </para>
@calendar: a #GtkCalendar. @calendar:
@day: the day number to unmark between 1 and 31. @day:
@Returns: %TRUE. @Returns:
<!-- ##### FUNCTION gtk_calendar_clear_marks ##### --> <!-- ##### FUNCTION gtk_calendar_clear_marks ##### -->
<para> <para>
Remove all visual markers.
</para> </para>
@calendar: a #GtkCalendar. @calendar:
<!-- ##### FUNCTION gtk_calendar_get_display_options ##### --> <!-- ##### FUNCTION gtk_calendar_get_display_options ##### -->
...@@ -240,39 +228,34 @@ Remove all visual markers. ...@@ -240,39 +228,34 @@ Remove all visual markers.
<!-- ##### FUNCTION gtk_calendar_display_options ##### --> <!-- ##### FUNCTION gtk_calendar_display_options ##### -->
<para> <para>
Sets display options (whether to display the heading and the month headings).
</para> </para>
@calendar: a #GtkCalendar. @calendar:
@flags: the display options to set. @flags:
@Deprecated: Use gtk_calendar_set_display_options() instead @Deprecated:
<!-- ##### FUNCTION gtk_calendar_get_date ##### --> <!-- ##### FUNCTION gtk_calendar_get_date ##### -->
<para> <para>
Obtains the selected date from a #GtkCalendar.
</para> </para>
@calendar: a #GtkCalendar. @calendar:
@year: location to store the year number. @year:
@month: location to store the month number (between 0 and 11). @month:
@day: location to store the day number (between 1 and 31). @day:
<!-- ##### FUNCTION gtk_calendar_freeze ##### --> <!-- ##### FUNCTION gtk_calendar_freeze ##### -->
<para> <para>
Locks the display of the calendar until it is thawed with gtk_calendar_thaw().
</para> </para>
@calendar: a #GtkCalendar. @calendar:
<!-- ##### FUNCTION gtk_calendar_thaw ##### --> <!-- ##### FUNCTION gtk_calendar_thaw ##### -->
<para> <para>
Defrosts a calendar; all the changes made since the last
gtk_calendar_freeze() are displayed.
</para> </para>
@calendar: a #GtkCalendar. @calendar:
...@@ -50,6 +50,7 @@ LDADD = \ ...@@ -50,6 +50,7 @@ LDADD = \
# #
gdk_public_h_sources = \ gdk_public_h_sources = \
gdk.h \ gdk.h \
gdkcairo.h \
gdkcolor.h \ gdkcolor.h \
gdkcursor.h \ gdkcursor.h \
gdkdisplay.h \ gdkdisplay.h \
...@@ -85,6 +86,7 @@ gdk_headers = \ ...@@ -85,6 +86,7 @@ gdk_headers = \
gdk_c_sources = \ gdk_c_sources = \
gdk.c \ gdk.c \
gdkcairo.c \
gdkcolor.c \ gdkcolor.c \
gdkcursor.c \ gdkcursor.c \
gdkdisplay.c \ gdkdisplay.c \
...@@ -240,7 +242,7 @@ stamp-gdkenumtypes.h: @REBUILD@ $(gdk_public_h_sources) Makefile ...@@ -240,7 +242,7 @@ stamp-gdkenumtypes.h: @REBUILD@ $(gdk_public_h_sources) Makefile
gdkenumtypes.c: @REBUILD@ $(gdk_public_h_sources) Makefile gdkenumtypes.c: @REBUILD@ $(gdk_public_h_sources) Makefile
( cd $(srcdir) && glib-mkenums \ ( cd $(srcdir) && glib-mkenums \
--fhead "#define GDK_ENABLE_BROKEN\n#include \"gdk.h\"\n#include \"gdkalias.h\"\n" \ --fhead "#define GDK_ENABLE_BROKEN\n#include \"gdk.h\"\n#include \"gdkalias.h\"\n" \
--fprod "\n/* enumerations from \"@filename@\" */" \ --fprod "\n/* enumerations from \"@filename@\" */" \
--ftail "\n#define __GDK_ENUM_TYPES_C__\n#include \"gdkaliasdef.c\"\n" \ --ftail "\n#define __GDK_ENUM_TYPES_C__\n#include \"gdkaliasdef.c\"\n" \
--vhead "GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G@Type@Value values[] = {" \ --vhead "GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G@Type@Value values[] = {" \
--vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \ --vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#ifndef __GDK_H__ #ifndef __GDK_H__
#define __GDK_H__ #define __GDK_H__
#include <gdk/gdkcairo.h>
#include <gdk/gdkcolor.h> #include <gdk/gdkcolor.h>
#include <gdk/gdkcursor.h> #include <gdk/gdkcursor.h>
#include <gdk/gdkdisplay.h> #include <gdk/gdkdisplay.h>
......
...@@ -288,6 +288,16 @@ gdk_fontset_load_for_display ...@@ -288,6 +288,16 @@ gdk_fontset_load_for_display
#endif #endif
#endif #endif
#if IN_HEADER(__GDK_CAIRO_H__)
#if IN_FILE(__GDK_CAIRO_C__)
gdk_cairo_create
gdk_cairo_set_source_color
gdk_cairo_set_source_pixbuf
gdk_cairo_rectangle
gdk_cairo_region
#endif
#endif
#if IN_HEADER(__GDK_COLOR_H__) #if IN_HEADER(__GDK_COLOR_H__)
#if IN_FILE(__GDK_COLOR_C__) #if IN_FILE(__GDK_COLOR_C__)
#ifndef GDK_DISABLE_DEPRECATED #ifndef GDK_DISABLE_DEPRECATED
...@@ -301,7 +311,6 @@ gdk_color_equal ...@@ -301,7 +311,6 @@ gdk_color_equal
gdk_color_free gdk_color_free
gdk_color_get_type G_GNUC_CONST gdk_color_get_type G_GNUC_CONST
gdk_color_hash gdk_color_hash
gdk_cairo_set_source_color
gdk_colormap_alloc_color gdk_colormap_alloc_color
gdk_colormap_get_system gdk_colormap_get_system
gdk_colormap_get_visual gdk_colormap_get_visual
...@@ -510,7 +519,6 @@ gdk_drag_get_protocol ...@@ -510,7 +519,6 @@ gdk_drag_get_protocol
#if IN_HEADER(__GDK_DRAWABLE_H__) #if IN_HEADER(__GDK_DRAWABLE_H__)
#if IN_FILE(__GDK_DRAW_C__) #if IN_FILE(__GDK_DRAW_C__)
gdk_drawable_create_cairo_context
gdk_drawable_copy_to_image gdk_drawable_copy_to_image
gdk_drawable_get_clip_region gdk_drawable_get_clip_region
gdk_drawable_get_colormap gdk_drawable_get_colormap
...@@ -853,7 +861,6 @@ gdk_pixbuf_get_from_image ...@@ -853,7 +861,6 @@ gdk_pixbuf_get_from_image
gdk_pixbuf_render_pixmap_and_mask gdk_pixbuf_render_pixmap_and_mask
gdk_pixbuf_render_pixmap_and_mask_for_colormap gdk_pixbuf_render_pixmap_and_mask_for_colormap
gdk_pixbuf_render_threshold_alpha gdk_pixbuf_render_threshold_alpha
gdk_pixbuf_set_as_cairo_source
#ifndef GDK_DISABLE_DEPRECATED #ifndef GDK_DISABLE_DEPRECATED
gdk_pixbuf_render_to_drawable gdk_pixbuf_render_to_drawable
gdk_pixbuf_render_to_drawable_alpha gdk_pixbuf_render_to_drawable_alpha
......
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2005 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "gdkcairo.h"
#include "gdkdrawable.h"
#include "gdkinternals.h"
#include "gdkregion-generic.h"
#include "gdkalias.h"
/**
* gdk_cairo_create:
* @drawable: a #GdkDrawable
*
* Creates a Cairo context for drawing to @drawable.
*
* Return value: A newly created Cairo context. Free with
* cairo_destroy() when you are done drawing.
*
* Since: 2.10
**/
cairo_t *
gdk_cairo_create (GdkDrawable *drawable)
{
cairo_surface_t *surface;
cairo_t *cr;
g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
surface = _gdk_drawable_ref_cairo_surface (drawable);
cr = cairo_create (surface);
cairo_surface_destroy (surface);
return cr;
}
/**
* gdk_cairo_set_source_color:
* @cr: a #cairo_t
* @color: a #GdkColor
*
* Sets the specified #GdkColor as the source color of @cr.
*
* Since: 2.8
**/
void
gdk_cairo_set_source_color (cairo_t *cr,
GdkColor *color)
{
g_return_if_fail (cr != NULL);
g_return_if_fail (color != NULL);
cairo_set_source_rgb (cr,
color->red / 65535.,
color->green / 65535.,
color->blue / 65535.);
}
/**
* gdk_cairo_rectangle:
* @cr: a #cairo_t
* @rectangle: a #GdkRectangle
*
* Adds the given rectangle to the current path of @cr.
**/
void
gdk_cairo_rectangle (cairo_t *cr,
GdkRectangle *rectangle)
{
g_return_if_fail (cr != NULL);
g_return_if_fail (rectangle != NULL);
cairo_rectangle (cr,
rectangle->x, rectangle->y,
rectangle->width, rectangle->height);
}
/**
* gdk_cairo_region:
* @cr: a #cairo_t
* @region: a #GdkRegion
*
* Adds the given region to the current path of @cr.
**/
void
gdk_cairo_region (cairo_t *cr,
GdkRegion *region)
{
GdkRegionBox *boxes;
gint n_boxes, i;
g_return_if_fail (cr != NULL);
g_return_if_fail (region != NULL);
boxes = region->rects;
n_boxes = region->numRects;
for (i = 0; i < n_boxes; i++)
cairo_rectangle (cr,
boxes[i].x1,
boxes[i].y1,
boxes[i].x2 - boxes[i].x1,
boxes[i].y2 - boxes[i].y1);
}
/**
* gdk_cairo_set_source_pixbuf:
* @cr: a #Cairo context
* @pixbuf: a #GdkPixbuf
* @pixbuf_x: X coordinate of location to place upper left corner of @pixbuf
* @pixbuf_y: Y coordinate of location to place upper left corner of @pixbuf
*
* Sets the given pixbuf as the source pattern for the Cairo context.
* The pattern has an extend mode of %CAIRO_EXTEND_NONE and is aligned
* so that the origin of @pixbuf is @pixbuf_x, @pixbuf_y
**/
void
gdk_cairo_set_source_pixbuf (cairo_t *cr,
GdkPixbuf *pixbuf,
double pixbuf_x,
double pixbuf_y)
{
gint width = gdk_pixbuf_get_width (pixbuf);
gint height = gdk_pixbuf_get_height (pixbuf);
guchar *gdk_pixels = gdk_pixbuf_get_pixels (pixbuf);
int gdk_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
int n_channels = gdk_pixbuf_get_n_channels (pixbuf);
guchar *cairo_pixels;
cairo_format_t format;
cairo_surface_t *surface;
static const cairo_user_data_key_t key;
int j;
if (n_channels == 3)
format = CAIRO_FORMAT_RGB24;
else
format = CAIRO_FORMAT_ARGB32;
cairo_pixels = g_malloc (4 * width * height);
surface = cairo_image_surface_create_for_data ((unsigned char *)cairo_pixels,
format,
width